本文整理汇总了PHP中OpenCloud\Rackspace::imageService方法的典型用法代码示例。如果您正苦于以下问题:PHP Rackspace::imageService方法的具体用法?PHP Rackspace::imageService怎么用?PHP Rackspace::imageService使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OpenCloud\Rackspace
的用法示例。
在下文中一共展示了Rackspace::imageService方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: list_nodes
public function list_nodes($availability_zone_name, $availability_zone_friendly_name)
{
$output = new Symfony\Component\Console\Output\ConsoleOutput();
$success = false;
$integration = Integration::find($this->db_integration_id);
$nodes = [];
// We need to measure how often this actually matters. I wonder if UK_IDENTITY_ENDPOINT is only
// for UK-based companies, or if it's needed to connect to Hong Kong.
try {
$client = new Rackspace(Rackspace::US_IDENTITY_ENDPOINT, array('username' => $integration->authorization_field_1, 'apiKey' => $integration->authorization_field_2));
} catch (Exception $e) {
$client = new Rackspace(Rackspace::UK_IDENTITY_ENDPOINT, array('username' => $integration->authorization_field_1, 'apiKey' => $integration->authorization_field_2));
}
$computeService = $client->computeService(null, $availability_zone_name, 'publicURL');
$serverList = $computeService->serverList();
foreach ($serverList as $server) {
$server_ips = [];
$private_dns = "";
$public_dns = "";
$server_status = "";
if (strtolower($server->status) == "active") {
foreach ($server->addresses->public as $ip) {
array_push($server_ips, $ip->addr);
}
foreach ($server->addresses->private as $ip) {
array_push($server_ips, $ip->addr);
}
$public_dns = null;
foreach ($server->addresses->public as $pubdns) {
if (strlen($pubdns->addr) < 16) {
$public_dns = $pubdns->addr;
}
}
$private_dns = null;
foreach ($server->addresses->private as $pdns) {
if (strlen($pubdns->addr) < 16) {
$private_dns = $pdns->addr;
}
}
$server_status = 'running';
} else {
switch (strtolower($server->status)) {
case "active":
$server_status = 'running';
break;
case "build":
$server_status = 'starting';
break;
default:
continue;
}
}
// Get image info so we can get platform info
$imageService = $client->imageService("cloudImages", $availability_zone_name);
$imageInfo = $imageService->getImage($server->image->id);
$platform = $imageInfo['os_type'];
array_push($nodes, array('service_provider_status' => $server_status, 'service_provider_base_image_id' => $server->image->id, 'service_provider_id' => $server->id, 'private_dns_name' => $private_dns, 'public_dns_name' => $public_dns, 'network_interfaces' => [], 'service_provider_cluster_id' => null, 'service_provider_ip_addresses' => $server_ips, 'availability_zone_friendly' => $availability_zone_friendly_name, 'availability_zone_name' => $availability_zone_name, 'platform' => ucfirst($platform)));
}
// If nodes is empty, make attempt to list them through the legacy api.
if (empty($nodes)) {
$output->writeln("robby's account");
}
return $nodes;
}