Skip to content

Instantly share code, notes, and snippets.

@ktbartholomew
Last active February 19, 2016 17:59
Show Gist options
  • Save ktbartholomew/b9bea97a81a881ce5017 to your computer and use it in GitHub Desktop.
Save ktbartholomew/b9bea97a81a881ce5017 to your computer and use it in GitHub Desktop.
List servers (with details) with PHP-opencloud
<?php
require('./vendor/autoload.php');
use OpenCloud\Rackspace;
header('Content-Type: text/plain');
$client = new Rackspace(Rackspace::US_IDENTITY_ENDPOINT, array(
'username' => getenv('RACKSPACE_USERNAME'),
'apiKey' => getenv('RACKSPACE_APIKEY')
));
$compute = $client->computeService(null, 'IAD');
// If this is false, only basic information like name and ID will be returned.
$show_server_details = true;
$servers = $compute->serverList($show_server_details);
foreach ($servers as $server) {
echo $server->name . PHP_EOL;
echo $server->ip(4) . PHP_EOL;
echo $server->status . PHP_EOL;
echo $server->created . PHP_EOL;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment