简体   繁体   English

serverList()只返回100个结果

[英]serverList() only returns 100 results

I'm trying to write a bit of code to inventory our OpenStack deployment, and I've run into an issue where serverList() only ever returns 100 results instead of the 600+ I'm expecting. 我正在尝试编写一些代码来清点我们的OpenStack部署,并且我遇到了一个问题,其中serverList()只返回100个结果而不是600+我期待的结果。 I've reviewed the documentation and a bit of the source, and as far as I can tell there's no reason that this should be happening as the PaginatedIterator should be doing its pagination transparently. 我已经回顾了文档和一些来源,据我所知,没有理由认为这应该发生,因为PaginatedIterator应该透明地进行分页。

There are no errors or warning either generated in my code, or logged on my controller [that I can find]. 我的代码中没有生成错误或警告,或者我的控制器[我可以找到]登录。 I am using php-opencloud v1.12 via composer. 我通过composer使用php-opencloud v1.12。

use OpenCloud\OpenStack;
$client = new OpenStack('http://1.2.3.4:5000/v2.0/', array(
    'username'  => 'admin',
    'password'  => 'hunter2',
    'tenantName'=> 'admin',
));
$service = $client->computeService('nova', 'RegionOne');

$stmt = $dbh->prepare('INSERT INTO servers VALUES (?,?)');
/* foreach($service->serverList() as $server) {
    $stmt->execute([$server->id, $server->name]);
} // neither method works */
$list = $service->serverList();
while( $list->valid() ) {
    $server = $list->current();
    $stmt->execute([$server->id, $server->name]);
    $list->next();
}
echo "\n";
var_dump($dbh->query('SELECT * FROM servers')->fetchAll(PDO::FETCH_ASSOC));

分页的默认限制为100.可以使用更高的限制覆盖此限制,如下所示:

$list = $service->serverList(null, array('limit' => 700));

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM