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");
}