/** * Adds or edits an article for this instance * * @return void */ function editArticle() { global $wgOpenStackManagerNovaAdminKeys; if (!OpenStackNovaArticle::canCreatePages()) { return; } $format = <<<RESOURCEINFO {{Nova Resource |Resource Type=instance |Instance Name=%s |Reservation Id=%s |Instance Id=%s |Private IP=%s |Public IP=%s |Instance State=%s |Instance Host=%s |Instance Type=%s |RAM Size=%s |Number of CPUs=%s |Amount of Storage=%s |Image Id=%s |Project=%s |Availability Zone=%s |Region=%s |Security Group=%s |Launch Time=%s |FQDN=%s |Puppet Class=%s |Puppet Var=%s}} RESOURCEINFO; $host = $this->getHost(); $puppetinfo = $host->getPuppetConfiguration(); if ($puppetinfo['puppetclass']) { $puppetclasses = implode(',', $puppetinfo['puppetclass']); } else { $puppetclasses = ''; } $puppetvars = ''; if ($puppetinfo['puppetvar']) { foreach ($puppetinfo['puppetvar'] as $key => $val) { # Let's not leak user's email addresses; we know this # will be set, since we are setting it. if ($key == 'instancecreator_email') { continue; } $puppetvars .= $key . '=' . $val . ','; } } $adminNova = new OpenStackNovaController($wgOpenStackManagerNovaAdminKeys); $instanceType = $adminNova->getInstanceType($this->getInstanceType()); $text = sprintf($format, $this->getInstanceName(), $this->getReservationId(), $this->getInstanceId(), $this->getInstancePrivateIP(), $this->getInstancePublicIP(), $this->getInstanceState(), $this->getInstanceHost(), $this->getInstanceType(), $instanceType->getMemorySize(), $instanceType->getNumberOfCPUs(), $instanceType->getStorageSize(), $this->getImageId(), $this->getOwner(), $this->getAvailabilityZone(), $this->getRegion(), implode(',', $this->getSecurityGroups()), $this->getLaunchTime(), $host->getFullyQualifiedHostName(), $puppetclasses, $puppetvars); OpenStackNovaArticle::editArticle($this->getInstanceId(), $text); }