当前位置: 首页>>代码示例>>PHP>>正文


PHP Scalr_Environment::cloudstack方法代码示例

本文整理汇总了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;
 }
开发者ID:rickb838,项目名称:scalr,代码行数:19,代码来源:UCloudPlatformModule.php

示例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];
 }
开发者ID:sacredwebsite,项目名称:scalr,代码行数:20,代码来源:CloudstackPlatformModule.php

示例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))] : [];
 }
开发者ID:mheydt,项目名称:scalr,代码行数:9,代码来源:AbstractCloudstackPlatformModule.php

示例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;
 }
开发者ID:mheydt,项目名称:scalr,代码行数:40,代码来源:CloudstackPlatformModule.php

示例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;
 }
开发者ID:rickb838,项目名称:scalr,代码行数:20,代码来源:CloudstackPlatformModule.php


注:本文中的Scalr_Environment::cloudstack方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。