/usr/share/doc/php-opencloud/examples/compute/overlimit.php is in php-opencloud 1.6.0+dfsg-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | <?php
// (c)2012 Rackspace Hosting
// See COPYING for licensing information
require_once "php-opencloud.php";
define('AUTHURL', RACKSPACE_US);
define('USERNAME', $_ENV['OS_USERNAME']);
define('TENANT', $_ENV['OS_TENANT_NAME']);
define('APIKEY', $_ENV['NOVA_API_KEY']);
// establish our credentials
$connection = new \OpenCloud\Rackspace(AUTHURL,
array( 'username' => USERNAME,
'apiKey' => APIKEY ));
// now, connect to the compute service
$compute = $connection->Compute('cloudServersOpenStack', 'DFW');
// display our limits
print("Rate limits:\n");
$lim = $compute->Limits();
foreach($lim->rate as $limit) {
printf("Limit url=%s regex=%s:\n",
isset($limit->url) ? $limit->url : 'N/A', $limit->regex);
foreach($limit->limit as $item) {
printf("\tVerb: %s Unit: %s Remaining: %d Value: %d\n",
$item->verb, $item->unit, $item->remaining, $item->value);
$next = 'next-available';
printf("\tNext available: %s\n", $item->$next);
}
}
/**
* Now, we're going to try to hit the rate limits
*/
/* uncomment if you really want to do this
print("Trying to hit the rate limits\n");
$serverlist = $compute->ServerList();
$server = $serverlist->Next(); // we just need one server
$met = $server->metadata('foo');
$met->foo = 'bar';
$met->foo = 'baz';
$met->Create();
for($count=1; $count<=1000; $count++) {
print(".");
$met = $server->metadata();
$met->Update();
if (($count % 50) == 0)
print(" $count\n");
}
*/
print("\nDone\n");
|