Last active
February 19, 2016 17:59
-
-
Save ktbartholomew/b9bea97a81a881ce5017 to your computer and use it in GitHub Desktop.
List servers (with details) with PHP-opencloud
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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