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


PHP Scalr_Environment::openstack方法代码示例

本文整理汇总了PHP中Scalr_Environment::openstack方法的典型用法代码示例。如果您正苦于以下问题:PHP Scalr_Environment::openstack方法的具体用法?PHP Scalr_Environment::openstack怎么用?PHP Scalr_Environment::openstack使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Scalr_Environment的用法示例。


在下文中一共展示了Scalr_Environment::openstack方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getLocations

 /**
  * {@inheritdoc}
  * @see \Scalr\Modules\PlatformModuleInterface::getLocations()
  */
 public function getLocations(\Scalr_Environment $environment = null)
 {
     if ($environment === null || !$environment->isPlatformEnabled($this->platform)) {
         return array();
     }
     try {
         $client = $environment->openstack($this->platform, "fakeRegion");
         foreach ($client->listZones() as $zone) {
             $retval[$zone->name] = ucfirst($this->platform) . " / {$zone->name}";
         }
     } catch (\Exception $e) {
         return array();
     }
     return $retval;
 }
开发者ID:sacredwebsite,项目名称:scalr,代码行数:19,代码来源:OpenstackPlatformModule.php

示例2: getLocations

 /**
  * {@inheritdoc}
  * @see \Scalr\Modules\Platforms\Openstack\OpenstackPlatformModule::getLocations()
  */
 public function getLocations(\Scalr_Environment $environment = null)
 {
     if (!$environment) {
         return array('ORD' => 'Rackspace US / ORD', 'DFW' => 'Rackspace US / DFW', 'IAD' => 'Rackspace US / IAD', 'SYD' => 'Rackspace US / SYD');
     } else {
         try {
             $client = $environment->openstack($this->platform, "fakeRegion");
             $zones = $client->listZones();
             $endpoints = $client->getConfig()->getAuthToken()->getRegionEndpoints();
             foreach ($zones as $zone) {
                 if (isset($endpoints['compute'][$zone->name])) {
                     $retval[$zone->name] = "Rackspace US / {$zone->name}";
                 }
             }
         } catch (\Exception $e) {
             return array();
         }
         return $retval;
     }
 }
开发者ID:mheydt,项目名称:scalr,代码行数:24,代码来源:RackspaceNgUsPlatformModule.php

示例3: getInstanceTypes

 /**
  * {@inheritdoc}
  * @see \Scalr\Modules\PlatformModuleInterface::getInstanceTypes()
  */
 public function getInstanceTypes(\Scalr_Environment $env = null, $cloudLocation = null, $details = false)
 {
     if (!$env instanceof \Scalr_Environment || empty($cloudLocation)) {
         throw new \InvalidArgumentException(sprintf("Method %s requires both environment object and cloudLocation to be specified.", __METHOD__));
     }
     $ret = array();
     $client = $env->openstack($this->platform, $cloudLocation);
     foreach ($client->servers->listFlavors() as $flavor) {
         if (!$details) {
             $ret[(string) $flavor->id] = (string) $flavor->name;
         } else {
             $ret[(string) $flavor->id] = array('name' => (string) $flavor->name, 'ram' => (string) $flavor->ram, 'vcpus' => (string) $flavor->vcpus, 'disk' => (string) $flavor->disk, 'type' => 'HDD');
         }
     }
     return $ret;
 }
开发者ID:rickb838,项目名称:scalr,代码行数:20,代码来源:OpenstackPlatformModule.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 || empty($cloudLocation)) {
         throw new \InvalidArgumentException(sprintf("Method %s requires both environment object and cloudLocation to be specified.", __METHOD__));
     }
     $ret = [];
     $detailed = [];
     //Trying to retrieve instance types from the cache
     $url = $env->cloudCredentials($this->platform)->properties[Entity\CloudCredentialsProperty::OPENSTACK_KEYSTONE_URL];
     $collection = $this->getCachedInstanceTypes($this->platform, $url, $cloudLocation);
     if ($collection === false || $collection->count() == 0) {
         //No cache. Fetching data from the cloud
         $client = $env->openstack($this->platform, $cloudLocation);
         foreach ($client->servers->listFlavors() as $flavor) {
             $detailed[(string) $flavor->id] = array('name' => (string) $flavor->name, 'ram' => (string) $flavor->ram, 'vcpus' => (string) $flavor->vcpus, 'disk' => (string) $flavor->disk, 'type' => 'HDD');
             if (!$details) {
                 $ret[(string) $flavor->id] = (string) $flavor->name;
             } else {
                 $ret[(string) $flavor->id] = $detailed[(string) $flavor->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,代码来源:OpenstackPlatformModule.php

示例5: getOsClient

 /**
  * @return \Scalr\Service\OpenStack\OpenStack
  */
 public function getOsClient(Scalr_Environment $environment, $cloudLocation)
 {
     return $environment->openstack($this->platform, $cloudLocation);
 }
开发者ID:recipe,项目名称:scalr,代码行数:7,代码来源:Openstack.php

示例6: getImageInfo

 /**
  * {@inheritdoc}
  * @see PlatformModuleInterface::getImageInfo()
  */
 public function getImageInfo(\Scalr_Environment $environment, $cloudLocation, $imageId)
 {
     $snap = $environment->openstack($this->platform, $cloudLocation)->servers->getImage($imageId);
     return $snap ? ["name" => $snap->name, "size" => $snap->metadata->instance_type_root_gb] : [];
 }
开发者ID:mheydt,项目名称:scalr,代码行数:9,代码来源:AbstractOpenstackPlatformModule.php


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