Summary
\OpenCloud\Common\Collection\PaginatedIterator::constructNextUrl() sets the wrong marker for Loadbalancers.
Problem
I'm working with the \OpenCloud\LoadBalancer\Service class to retrieve a list of loadbalancers. The data that is returned is limited to 100 entries at once, so I'll have to set up processing to retrieve each new set.
Here's some initial code that I wrote to do this:
$rax->setDatacenter('ord');
$client = $rax->getClientByDatacenter();
$lbservice = $client->loadBalancerService(null, $rax->getDatacenter());
$loadbalancer = $lbservice->loadBalancerList(true, array('limit' => 5));
echo "Found " . $loadbalancer->count() . " results" . PHP_EOL;
// Cycle through the loadbalancers
while ($loadbalancer->valid()) {
echo "ID: " . $loadbalancer->currentElement()->id;
echo " Name: " . $loadbalancer->currentElement()->name . PHP_EOL;
$loadbalancer->next();
}
// Load the next set of Loadbalancers
$next_url = $loadbalancer->constructNextUrl();
echo "URL: " . $next_url . PHP_EOL;
$loadbalancer = $lbservice->resourceList('LoadBalancer', $next_url);
The constructNextUrl() method should be setting up the marker query argument to facilitate retrieving the next "page" of results. However, it seems that for loadbalancers the marker is set to the loadbalancer name when it should be the loadbalancer ID.
Here's the sample output from the above section of code (replacing IDs with ######):
Datacenter set to ORD
Found 5 results
ID: ###### Name: lbmaster-10004
ID: ###### Name: lbmaster-10004-ssl
ID: ###### Name: lbmaster-10006
ID: ###### Name: lbmaster-10006-ssl
ID: ###### Name: lbmaster-112
Getting new results ...
URL: https://ord.loadbalancers.api.rackspacecloud.com/v1.0/######/loadbalancers?limit=5&marker=lbmaster-112
Found 0 results
To test, I built the URL manually, and used that instead:
$next_url->setQuery(array('limit' => 5, 'marker' => $loadbalancer->getElement(5-1)->id));
$loadbalancer = $lbservice->resourceList('LoadBalancer', $next_url);
With that change, I get the following output (again with IDs replaced by ######):
Datacenter set to ORD
Found 5 results
ID: ###### Name: lbmaster-10004
ID: ###### Name: lbmaster-10004-ssl
ID: ###### Name: lbmaster-10006
ID: ###### Name: lbmaster-10006-ssl
ID: ###### Name: lbmaster-112
Getting new results ...
URL: https://ord.loadbalancers.api.rackspacecloud.com/v1.0/######/loadbalancers?limit=5&marker=######
Found 5 results
ID: ###### Name: lbmaster-112
ID: ###### Name: lbmaster-112-ssl
ID: ###### Name: lbmaster-116
ID: ###### Name: lbmaster-116-ssl
ID: ###### Name: lbmaster-117
Suggested solution
The code should be updated to utilize the loadbalancer ID instead of the loadbalancer name when generating the marker.
Summary
\OpenCloud\Common\Collection\PaginatedIterator::constructNextUrl()sets the wrong marker for Loadbalancers.Problem
I'm working with the
\OpenCloud\LoadBalancer\Serviceclass to retrieve a list of loadbalancers. The data that is returned is limited to 100 entries at once, so I'll have to set up processing to retrieve each new set.Here's some initial code that I wrote to do this:
The
constructNextUrl()method should be setting up themarkerquery argument to facilitate retrieving the next "page" of results. However, it seems that for loadbalancers the marker is set to the loadbalancer name when it should be the loadbalancer ID.Here's the sample output from the above section of code (replacing IDs with ######):
To test, I built the URL manually, and used that instead:
With that change, I get the following output (again with IDs replaced by ######):
Suggested solution
The code should be updated to utilize the loadbalancer ID instead of the loadbalancer name when generating the marker.