compared with
Key
This line was removed.
This word was removed. This word was added.
This line was added.

Changes (2)

View Page History
||UC2-01||

Create a new server instance. Metadata ($metadata) and files ($files) are optional parameters.

{code:php}
{code}

||UC2-02||

Get a server, specifing the ID of the server.

{code:php}
$user= 'xxx';
$key= 'yyy';

$rackspace= new Zend\Service\Rackspace\Servers($user,$key);

$server= $rackspace->getServer('20056589');

if ($server!==false) {
printf("Name: %s\n",$server->getName());
printf("Id: %s\n",$server->getId());
printf("Flavor Id: %s\n",$server->getFlavorId());
} else {
printf ("Error code: %s\n",$rackspace->getErrorCode());
printf ("Error msg: %s\n",$rackspace->getErrorMsg());
}


{code}

||UC2-03||

Get all the servers. The parameter of listServers() is a boolean flag to get a list of server with detailed information (true) or not (false).

{code:php}
$user= 'xxx';
$key= 'yyy';

$rackspace= new Zend\Service\Rackspace\Servers($user,$key);

$servers= $rackspace->listServers(true);

if ($servers!==false) {
foreach ($servers as $srv) {
printf("Name: %s\n",$srv->getName());
printf("Id: %s\n",$srv->getId());
printf("Flavor Id: %s\n",$srv->getFlavorId());
printf("Image Id: %s\n",$srv->getImageId());
printf("Status: %s\n\n",$srv->getStatus());
}
} else {
printf ("Error code: %s\n",$rackspace->getErrorCode());
printf ("Error msg: %s\n",$rackspace->getErrorMsg());
}
{code}

{zone-data}