/** * @return bool */ function deleteKey() { global $wgOpenStackManagerNovaKeypairStorage; $this->setHeaders(); $this->getOutput()->setPagetitle(wfMsg('openstackmanager-deletekey')); $keyInfo = array(); $hash = ''; $keypairs = array(); if ($wgOpenStackManagerNovaKeypairStorage == 'nova') { $keyname = $this->getRequest()->getVal('keyname'); $project = $this->getRequest()->getVal('project'); if ($project && !$this->userLDAP->inProject($project)) { $this->notInProject(); return true; } $keyInfo['keyname'] = array('type' => 'hidden', 'default' => $project, 'name' => 'keyname'); $keyInfo['project'] = array('type' => 'hidden', 'default' => $keyname, 'name' => 'project'); } elseif ($wgOpenStackManagerNovaKeypairStorage == 'ldap') { $hash = $this->getRequest()->getVal('hash'); $keypairs = $this->userLDAP->getKeypairs(); if (!$this->getRequest()->wasPosted()) { $this->getOutput()->addHTML(Html::element('pre', array(), $keypairs[$hash])); $this->getOutput()->addWikiMsg('openstackmanager-deletekeyconfirm'); } $keyInfo['hash'] = array('type' => 'hidden', 'default' => $hash, 'name' => 'hash'); } $keyInfo['key'] = array('type' => 'hidden', 'default' => $keypairs[$hash], 'name' => 'key'); $keyInfo['action'] = array('type' => 'hidden', 'default' => 'delete', 'name' => 'action'); $keyForm = new SpecialNovaKeyForm($keyInfo, 'openstackmanager-novakey'); $keyForm->setTitle(SpecialPage::getTitleFor('NovaKey')); $keyForm->setSubmitID('novakey-form-deletekeysubmit'); $keyForm->setSubmitCallback(array($this, 'tryDeleteSubmit')); $keyForm->show(); return true; }
function execute( $par ) { global $wgOpenStackManagerNovaAdminKeys; if ( !$this->getUser()->isLoggedIn() ) { $this->notLoggedIn(); return; } $this->userLDAP = new OpenStackNovaUser(); if ( !$this->userLDAP->exists() ) { $this->noCredentials(); return; } $project = $this->getRequest()->getVal( 'project' ); $userCredentials = $this->userLDAP->getCredentials(); $this->userNova = new OpenStackNovaController( $userCredentials, $project ); $adminCredentials = $wgOpenStackManagerNovaAdminKeys; $this->adminNova = new OpenStackNovaController( $adminCredentials ); $action = $this->getRequest()->getVal( 'action' ); if ( $action == "create" ) { if ( ! $this->userLDAP->inProject( $project ) ) { $this->notInProject(); return; } $this->createVolume(); } elseif ( $action == "delete" ) { if ( ! $this->userLDAP->inProject( $project ) ) { $this->notInProject(); return; } $this->deleteVolume(); } elseif ( $action == "attach" ) { if ( ! $this->userLDAP->inProject( $project ) ) { $this->notInProject(); return; } $this->attachVolume(); } elseif ( $action == "detach" ) { if ( ! $this->userLDAP->inProject( $project ) ) { $this->notInProject(); return; } $this->detachVolume(); } else { $this->listVolumes(); } }
function execute($par) { if (!$this->getUser()->isLoggedIn()) { $this->notLoggedIn(); return; } $this->userLDAP = new OpenStackNovaUser(); if (!$this->userLDAP->exists()) { $this->noCredentials(); return; } $this->checkTwoFactor(); $project = $this->getRequest()->getVal('project'); $region = $this->getRequest()->getVal('region'); $this->userNova = OpenStackNovaController::newFromUser($this->userLDAP); $this->userNova->setProject($project); $this->userNova->setRegion($region); $action = $this->getRequest()->getVal('action'); if ($action === "create") { if (!$this->userLDAP->inProject($project)) { $this->notInProject($project); return; } $this->createVolume(); } elseif ($action === "delete") { if (!$this->userLDAP->inProject($project)) { $this->notInProject($project); return; } $this->deleteVolume(); } elseif ($action === "attach") { if (!$this->userLDAP->inProject($project)) { $this->notInProject($project); return; } $this->attachVolume(); } elseif ($action === "detach") { if (!$this->userLDAP->inProject($project)) { $this->notInProject($project); return; } $this->detachVolume(); } else { $this->listVolumes(); } }
function execute($par) { if (!$this->getUser()->isLoggedIn()) { $this->notLoggedIn(); return; } $this->userLDAP = new OpenStackNovaUser(); if (!$this->userLDAP->exists()) { $this->noCredentials(); return; } $this->checkTwoFactor(); $project = $this->getRequest()->getVal('project'); $region = $this->getRequest()->getVal('region'); $this->userNova = OpenStackNovaController::newFromUser($this->userLDAP); $this->userNova->setProject($project); $this->userNova->setRegion($region); # ?action= $action = $this->getRequest()->getVal('action'); if ($action === "create") { if (!$this->userLDAP->inProject($project)) { $this->notInProject($project); return; } $this->createInstance(); } elseif ($action === "delete") { if (!$this->userLDAP->inProject($project)) { $this->notInProject($project); return; } $this->deleteInstance(); } elseif ($action === "configure") { if (!$this->userLDAP->inProject($project)) { $this->notInProject($project); return; } $this->configureInstance(); } elseif ($action === "reboot") { if (!$this->userLDAP->inProject($project)) { $this->notInProject($project); return; } $this->rebootInstance(); } elseif ($action === "consoleoutput") { if (!$this->userLDAP->inProject($project)) { $this->notInProject($project); return; } $this->getConsoleOutput(); } else { # Fall back to listing all instances $this->listInstances(); } }