/**
  * Default action
  * @return void
  */
 function listInstances()
 {
     $this->setHeaders();
     $this->getOutput()->addModules('ext.openstack.Instance');
     $projects = OpenStackNovaProject::getProjectsByName($this->userLDAP->getProjects());
     $instanceOut = '';
     $ownedProjects = array();
     $instanceCount = 0;
     foreach ($projects as $project) {
         $projectName = $project->getProjectName();
         $instancesInProject = 0;
         if ($this->userLDAP->inRole('projectadmin', $projectName)) {
             $ownedProjects[] = $projectName;
         }
         $projectactions = array('projectadmin' => array());
         $regions = '';
         $this->userNova->setProject($projectName);
         foreach ($this->userNova->getRegions('compute') as $region) {
             $regionactions = array();
             $thisCount = 0;
             $instances = $this->getInstances($projectName, $region, $thisCount);
             $instancesInProject += $thisCount;
             if ($thisCount > 0) {
                 $regions .= $this->createRegionSection($region, $projectName, $regionactions, $instances);
             }
         }
         if ($instancesInProject) {
             $instanceOut .= $this->createProjectSection($projectName, $projectactions, $regions);
             $instanceCount += $instancesInProject;
         } else {
         }
     }
     $out = '';
     if ($ownedProjects) {
         $this->getOutput()->setPagetitle($this->msg('openstackmanager-ownedprojects', count($ownedProjects)));
         foreach ($ownedProjects as $ownedProject) {
             $projectNameOut = $this->createResourceLink($ownedProject);
             $out .= $projectNameOut . " ";
         }
     } else {
         $this->getOutput()->setPagetitle($this->msg('openstackmanager-noownedprojects'));
     }
     if ($instanceCount) {
         $out .= Html::rawElement('h1', array(), $this->msg('openstackmanager-ownedinstances', $instanceCount)->text());
         $out .= $instanceOut;
     } else {
         $out .= Html::rawElement('h1', array(), $this->msg('openstackmanager-noownedinstances')->text());
     }
     $this->getOutput()->addHTML($out);
 }
 /**
  * @return void
  */
 function listProjects()
 {
     $this->setHeaders();
     $this->getOutput()->setPageTitle($this->msg('openstackmanager-projectlist'));
     $this->getOutput()->addModuleStyles('ext.openstack');
     if ($this->getUser()->isAllowed('listall')) {
         $projects = OpenStackNovaProject::getAllProjects();
         $this->showCreateProject();
     } else {
         $projects = OpenStackNovaProject::getProjectsByName($this->userLDAP->getProjects());
     }
     $this->showProjectFilter($projects);
     $projectfilter = $this->getProjectFilter();
     if (!$projectfilter) {
         $this->getOutput()->addWikiMsg('openstackmanager-setprojectfilter');
         return null;
     }
     $out = '';
     foreach ($projects as $project) {
         $projectName = $project->getProjectName();
         if (!in_array($projectName, $projectfilter)) {
             continue;
         }
         $actions = array();
         $out .= $this->createProjectSection($projectName, $actions, $this->getProject($project));
     }
     $this->getOutput()->addHTML($out);
 }
 /**
  * @return bool
  */
 function listSecurityGroups()
 {
     $this->setHeaders();
     $this->getOutput()->addModuleStyles('ext.openstack');
     $this->getOutput()->setPagetitle($this->msg('openstackmanager-securitygrouplist'));
     if ($this->userCanExecute($this->getUser())) {
         $projects = OpenStackNovaProject::getAllProjects();
     } else {
         $projects = OpenStackNovaProject::getProjectsByName($this->userLDAP->getProjects());
     }
     $this->showProjectFilter($projects);
     $projectfilter = $this->getProjectFilter();
     if (!$projectfilter) {
         $this->getOutput()->addWikiMsg('openstackmanager-setprojectfilter');
         return null;
     }
     $out = '';
     foreach ($projects as $project) {
         $projectName = $project->getProjectName();
         if (!in_array($projectName, $projectfilter)) {
             continue;
         }
         $projectactions = array('projectadmin' => array());
         $regions = '';
         $this->userNova->setProject($projectName);
         foreach ($this->userNova->getRegions('compute') as $region) {
             $this->userNova->setRegion($region);
             $regionactions = array('projectadmin' => array($this->createActionLink('openstackmanager-createnewsecuritygroup', array('action' => 'create', 'project' => $projectName, 'region' => $region))));
             $securityGroups = $this->getSecurityGroups($projectName, $region);
             $regions .= $this->createRegionSection($region, $projectName, $regionactions, $securityGroups);
         }
         $out .= $this->createProjectSection($projectName, $projectactions, $regions);
     }
     $this->getOutput()->addHTML($out);
     return true;
 }
 /**
  * Default action
  * @return void
  */
 function listInstances()
 {
     global $wgOpenStackManagerReadOnlyRegions;
     $this->setHeaders();
     $this->getOutput()->addModules('ext.openstack.Instance');
     $this->getOutput()->setPagetitle($this->msg('openstackmanager-instancelist'));
     if ($this->getUser()->isAllowed('listall')) {
         $projects = OpenStackNovaProject::getAllProjects();
     } else {
         $projects = OpenStackNovaProject::getProjectsByName($this->userLDAP->getProjects());
     }
     $this->showProjectFilter($projects);
     $projectfilter = $this->getProjectFilter();
     if (!$projectfilter) {
         $this->getOutput()->addWikiMsg('openstackmanager-setprojectfilter');
         return null;
     }
     $out = '';
     foreach ($projects as $project) {
         $projectName = $project->getProjectName();
         if (!in_array($projectName, $projectfilter)) {
             continue;
         }
         $projectactions = array('projectadmin' => array());
         $regions = '';
         $this->userNova->setProject($projectName);
         foreach ($this->userNova->getRegions('compute') as $region) {
             if (in_array($region, $wgOpenStackManagerReadOnlyRegions)) {
                 $regionactions = array('projectadmin' => array($this->msg('openstackmanager-creationdisabled')));
             } else {
                 $regionactions = array('projectadmin' => array($this->createActionLink('openstackmanager-createinstance', array('action' => 'create', 'project' => $projectName, 'region' => $region))));
             }
             $instances = $this->getInstances($projectName, $region);
             $regions .= $this->createRegionSection($region, $projectName, $regionactions, $instances);
         }
         $out .= $this->createProjectSection($projectName, $projectactions, $regions);
     }
     $this->getOutput()->addHTML($out);
 }
 /**
  * @return void
  */
 function listPuppetGroups()
 {
     $this->setHeaders();
     $this->getOutput()->setPagetitle($this->msg('openstackmanager-puppetgrouplist'));
     $this->getOutput()->addModuleStyles('ext.openstack');
     if ($this->getUser()->isAllowed('listall')) {
         $projects = OpenStackNovaProject::getAllProjects();
     } else {
         $projects = OpenStackNovaProject::getProjectsByName($this->userLDAP->getProjects());
     }
     $this->showProjectFilter($projects);
     $projectfilter = $this->getProjectFilter();
     if (!$projectfilter) {
         $this->getOutput()->addWikiMsg('openstackmanager-setprojectfilter');
         return null;
     }
     $out = '';
     foreach ($projects as $project) {
         $projectName = $project->getProjectName();
         if ($projectfilter && !in_array($projectName, $projectfilter)) {
             continue;
         }
         $actions = array('projectadmin' => array());
         $actions['projectadmin'][] = $this->createActionLink('openstackmanager-createpuppetgroup', array('action' => 'create', 'project' => $projectName));
         $out .= $this->createProjectSection($projectName, $actions, $this->getPuppetGroupOutput(OpenStackNovaPuppetGroup::getGroupList($projectName)));
     }
     $action = '';
     $showlinks = $this->userCanExecute($this->getUser());
     if ($showlinks) {
         $action = $this->createActionLink('openstackmanager-createpuppetgroup', array('action' => 'create'));
         $action = Html::rawElement('span', array('id' => 'novaaction'), "[{$action}]");
     }
     $allProjectsMsg = Html::rawElement('span', array('class' => 'mw-customtoggle-allprojects', 'id' => 'novaproject'), $this->msg('openstackmanager-puppetallprojects')->escaped());
     $out .= Html::rawElement('h2', array(), "{$allProjectsMsg} {$action}");
     $groupsOut = $this->getPuppetGroupOutput(OpenStackNovaPuppetGroup::getGroupList(), $showlinks);
     $out .= Html::rawElement('div', array('class' => 'mw-collapsible', 'id' => 'mw-customcollapsible-allprojects'), $groupsOut);
     $this->getOutput()->addHTML($out);
 }