本文整理汇总了PHP中Scalr_Environment::cloudstack方法的典型用法代码示例。如果您正苦于以下问题:PHP Scalr_Environment::cloudstack方法的具体用法?PHP Scalr_Environment::cloudstack怎么用?PHP Scalr_Environment::cloudstack使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Scalr_Environment
的用法示例。
在下文中一共展示了Scalr_Environment::cloudstack方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getInstanceTypes
/**
* {@inheritdoc}
* @see \Scalr\Modules\PlatformModuleInterface::getInstanceTypes()
*/
public function getInstanceTypes(\Scalr_Environment $env = null, $cloudLocation = null, $details = false)
{
if (!$env instanceof \Scalr_Environment) {
throw new \InvalidArgumentException(sprintf("Method %s requires environment to be specified.", __METHOD__));
}
$ret = array();
$cs = $env->cloudstack($this->platform);
$products = $cs->listAvailableProductTypes();
if (count($products) > 0) {
foreach ($products as $product) {
$ret[(string) $product->serviceofferingid] = (string) $product->serviceofferingdesc;
}
}
return $ret;
}
示例2: GetServersList
public function GetServersList(\Scalr_Environment $environment, $region, $skipCache = false)
{
if (!$region) {
return array();
}
if (!$this->instancesListCache[$environment->id][$region] || $skipCache) {
$cs = $environment->cloudstack($this->platform);
try {
$results = $cs->instance->describe(array('zoneid' => $region));
} catch (\Exception $e) {
throw new \Exception(sprintf("Cannot get list of servers for platform {$this->platform}: %s", $e->getMessage()));
}
if (count($results) > 0) {
foreach ($results as $item) {
$this->instancesListCache[$environment->id][$region][$item->id] = $item->state;
}
}
}
return $this->instancesListCache[$environment->id][$region];
}
示例3: getImageInfo
/**
* {@inheritdoc}
* @see PlatformModuleInterface::getImageInfo()
*/
public function getImageInfo(\Scalr_Environment $environment, $cloudLocation, $imageId)
{
$snap = $environment->cloudstack($this->platform)->template->describe(["templatefilter" => "executable", "id" => $imageId, "zoneid" => $cloudLocation]);
return $snap && isset($snap[0]) ? ["name" => $snap[0]->name, "size" => ceil($snap[0]->size / pow(1024, 3))] : [];
}
示例4: getInstanceTypes
/**
* {@inheritdoc}
* @see \Scalr\Modules\PlatformModuleInterface::getInstanceTypes()
*/
public function getInstanceTypes(\Scalr_Environment $env = null, $cloudLocation = null, $details = false)
{
if (!$env instanceof \Scalr_Environment) {
throw new \InvalidArgumentException(sprintf("Method %s requires environment to be specified.", __METHOD__));
}
$ret = [];
$detailed = [];
//Trying to retrieve instance types from the cache
$url = $env->cloudCredentials($this->platform)->properties[Entity\CloudCredentialsProperty::CLOUDSTACK_API_URL];
$collection = $this->getCachedInstanceTypes($this->platform, $url, $cloudLocation ?: '');
if ($collection === false || $collection->count() == 0) {
//No cache. Fetching data from the cloud
$client = $env->cloudstack($this->platform);
foreach ($client->listServiceOfferings() as $offering) {
$detailed[(string) $offering->id] = array('name' => (string) $offering->name, 'ram' => (string) $offering->memory, 'vcpus' => (string) $offering->cpunumber, 'disk' => "", 'type' => strtoupper((string) $offering->storagetype));
if (!$details) {
$ret[(string) $offering->id] = (string) $offering->name;
} else {
$ret[(string) $offering->id] = $detailed[(string) $offering->id];
}
}
//Refreshes/creates a cache
CloudLocation::updateInstanceTypes($this->platform, $url, $cloudLocation ?: '', $detailed);
} else {
//Takes data from cache
foreach ($collection as $cloudInstanceType) {
/* @var $cloudInstanceType \Scalr\Model\Entity\CloudInstanceType */
if (!$details) {
$ret[$cloudInstanceType->instanceTypeId] = $cloudInstanceType->name;
} else {
$ret[$cloudInstanceType->instanceTypeId] = $cloudInstanceType->getProperties();
}
}
}
return $ret;
}
示例5: getInstanceTypes
/**
* {@inheritdoc}
* @see \Scalr\Modules\PlatformModuleInterface::getInstanceTypes()
*/
public function getInstanceTypes(\Scalr_Environment $env = null, $cloudLocation = null, $details = false)
{
if (!$env instanceof \Scalr_Environment) {
throw new \InvalidArgumentException(sprintf("Method %s requires environment to be specified.", __METHOD__));
}
$ret = array();
$client = $env->cloudstack($this->platform);
foreach ($client->listServiceOfferings() as $offering) {
if (!$details) {
$ret[(string) $offering->id] = (string) $offering->name;
} else {
$ret[(string) $offering->id] = array('name' => (string) $offering->name, 'ram' => (string) $offering->memory, 'vcpus' => (string) $offering->cpunumber, 'disk' => "", 'type' => strtoupper((string) $offering->storagetype));
}
}
return $ret;
}