Scalr_Environment::cloudstack PHP Method

cloudstack() public method

This method ensures that cloudstack instance is always from the current environment scope
public cloudstack ( string $platform = 'cloudstack', string $apiUrl = null, string $apiKey = null, string $secretKey = null ) : CloudStack
$platform string Platform name
$apiUrl string The endpoint name url
$apiKey string Api key
$secretKey string Secret key
return Scalr\Service\CloudStack\CloudStack Returns cloudstack instance from DI container
    public function cloudstack($platform = 'cloudstack', $apiUrl = null, $apiKey = null, $secretKey = null)
    {
        $arguments = func_get_args();
        if (count($arguments) <= 1) {
            $arguments[0] = isset($arguments[0]) ? $arguments[0] : null;
            //Adds Scalr_Environment as second parameter
            $arguments[1] = $this;
        }
        //Retrieves an instance from the DI container
        return $this->__call('cloudstack', $arguments);
    }

Usage Example

コード例 #1
0
 /**
  * {@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;
 }
All Usage Examples Of Scalr_Environment::cloudstack