function getInstances($projectName, $region, &$instanceCount) { global $wgMemc; $this->userNova->setRegion($region); $headers = array('openstackmanager-instancename', 'openstackmanager-instanceid', 'openstackmanager-instancestate', 'openstackmanager-instanceip', 'openstackmanager-projectname', 'openstackmanager-launchtime', 'openstackmanager-instancecreator'); $instances = $this->userNova->getInstances(); $instanceRows = array(); $instanceCount = 0; /** * @var $instance OpenStackNovaInstance */ foreach ($instances as $instance) { # Only display instances created by the current user. if ($instance->getInstanceCreator() != $this->userLDAP->getUid()) { continue; } $instanceRow = array(); $this->pushResourceColumn($instanceRow, $instance->getInstanceName(), array('class' => 'novainstancename')); $host = $instance->getHost(); if ($host) { $this->pushRawResourceColumn($instanceRow, $this->createResourceLink($host->getFullyQualifiedHostName()), array('class' => 'novainstanceid')); } else { $this->pushResourceColumn($instanceRow, $instance->getInstanceId(), array('class' => 'novainstanceid')); } $state = $instance->getInstanceState(); $taskState = $instance->getInstanceTaskState(); if ($taskState) { $stateDisplay = "{$state} ({$taskState})"; } else { $stateDisplay = $state; } $this->pushResourceColumn($instanceRow, $stateDisplay, array('class' => 'novainstancestate')); $this->pushRawResourceColumn($instanceRow, $this->createResourceList($instance->getInstancePrivateIPs())); $this->pushResourceColumn($instanceRow, $projectName); $this->pushResourceColumn($instanceRow, $instance->getLaunchTime()); $this->pushResourceColumn($instanceRow, $instance->getInstanceCreator()); $actions = array(); $instanceDataAttributes = array('data-osid' => $instance->getInstanceOSId(), 'data-id' => $instance->getInstanceId(), 'data-name' => $instance->getInstanceName(), 'data-project' => $projectName, 'data-region' => $region, 'class' => 'novainstanceaction'); $instanceRows[] = $instanceRow; $instanceCount += 1; } if ($instanceRows) { return $this->createResourceTable($headers, $instanceRows); } return ''; }
/** * @param $user User * @param $preferences array * @return bool True */ public static function novaUserPreferences(User $user, array &$preferences) { $link = Linker::link(SpecialPage::getTitleFor('NovaKey'), wfMessage('novakey')->escaped(), array(), array('returnto' => SpecialPage::getTitleFor('Preferences')->getPrefixedText())); $novaUser = new OpenStackNovaUser($user->getName()); $preferences['shellusername'] = array('type' => 'info', 'label-message' => 'openstackmanager-shellaccountname-pref', 'default' => $novaUser->getUid(), 'section' => 'personal/info'); $preferences['openstack-sshkeylist'] = array('type' => 'info', 'raw' => true, 'default' => self::getKeyList($novaUser), 'label-message' => 'openstackmanager-prefs-novapublickey', 'section' => 'openstack/openstack-keys'); return true; }