Scalr\Modules\PlatformFactory::isOpenstack PHP Method

isOpenstack() public static method

Checks wheter specified cloud is OpenStack based
public static isOpenstack ( string $platform, boolean $canonical = false ) : boolean
$platform string A platform name
$canonical boolean optional Only canonical OpenStack platforms
return boolean Returns true if specified cloud is OpenStack based or false otherwise
    public static function isOpenstack($platform, $canonical = false)
    {
        return in_array($platform, $canonical ? static::getCanonicalOpenstackPlatforms() : self::getOpenstackBasedPlatforms());
    }

Usage Example

Beispiel #1
0
 public function deleteAction()
 {
     $this->request->defineParams(array('sshKeyId' => array('type' => 'int')));
     $sshKey = Scalr_SshKey::init()->loadById($this->getParam('sshKeyId'));
     $this->user->getPermissions()->validate($sshKey);
     if ($sshKey->type == Scalr_SshKey::TYPE_GLOBAL) {
         if ($sshKey->platform == SERVER_PLATFORMS::EC2) {
             $aws = $this->getEnvironment()->aws($sshKey->cloudLocation);
             $aws->ec2->keyPair->delete($sshKey->cloudKeyName);
             $sshKey->delete();
             $this->response->success();
         } elseif (PlatformFactory::isOpenstack($sshKey->platform)) {
             $os = $this->getEnvironment()->openstack($sshKey->platform, $sshKey->cloudLocation);
             try {
                 $os->servers->keypairs->delete($sshKey->cloudKeyName);
             } catch (Exception $e) {
             }
             $sshKey->delete();
             $this->response->success();
         } else {
             $sshKey->delete();
         }
     } else {
         //TODO:
     }
     $this->response->success("SSH key successfully removed");
 }
All Usage Examples Of Scalr\Modules\PlatformFactory::isOpenstack