/** * @param $formData * @param string $entryPoint * @return bool */ function tryAddHostSubmit( $formData, $entryPoint = 'internal' ) { $ip = $formData['ip']; $project = $formData['project']; $address = $this->adminNova->getAddress( $ip ); $outputPage = $this->getOutput(); if ( ! $address ) { $outputPage->addWikiMsg( 'openstackmanager-invalidaddress', $ip ); return true; } if ( $address->getProject() != $project ) { $outputPage->addWikiMsg( 'openstackmanager-invalidaddressforproject', $ip ); return true; } $hostname = $formData['hostname']; $domain = $formData['domain']; $domain = OpenStackNovaDomain::getDomainByName( $domain ); $hostbyname = OpenStackNovaHost::getHostByName( $hostname, $domain ); $hostbyip = OpenStackNovaHost::getHostByIP( $ip ); if ( $hostbyname ) { # We need to add an arecord, if the arecord doesn't already exist $success = $hostbyname->addARecord( $ip ); if ( $success ) { $outputPage->addWikiMsg( 'openstackmanager-addedhost', $hostname, $ip ); } else { $outputPage->addWikiMsg( 'openstackmanager-addhostfailed', $hostname, $ip ); } } elseif ( $hostbyip ) { # We need to add an associateddomain, if the associateddomain doesn't already exist $success = $hostbyip->addAssociatedDomain( $hostname . '.' . $domain->getFullyQualifiedDomainName() ); if ( $success ) { $outputPage->addWikiMsg( 'openstackmanager-addedhost', $hostname, $ip ); } else { $outputPage->addWikiMsg( 'openstackmanager-addhostfailed', $hostname, $ip ); } } else { # This is a new host entry $host = OpenStackNovaHost::addPublicHost( $hostname, $ip, $domain ); if ( $host ) { $outputPage->addWikiMsg( 'openstackmanager-addedhost', $hostname, $ip ); } else { $outputPage->addWikiMsg( 'openstackmanager-addhostfailed', $hostname, $ip ); } } $this->getOutput(); $out = '<br />'; $out .= Linker::link( $this->getTitle(), wfMsgHtml( 'openstackmanager-backaddresslist' ) ); $outputPage->addHTML( $out ); return true; }
function addHost($hostName, $domain, $ip) { $domain = OpenStackNovaDomain::getDomainByName($domain); $hostbyip = OpenStackNovaHost::getHostByPublicIP($ip); $fqdn = $hostName . '.' . $domain->getFullyQualifiedDomainName(); if ($hostbyip) { # We need to add an associateddomain, if the associateddomain doesn't already exist $success = $hostbyip->addAssociatedDomain($fqdn); if (!$success) { return false; } } else { # This is a new host entry $host = OpenStackNovaHost::addPublicHost($hostName, $ip, $domain); if (!$host) { return false; } } return true; }
/** * @param $formData * @param string $entryPoint * @return bool */ function tryAddHostSubmit($formData, $entryPoint = 'internal') { $id = $formData['id']; $address = $this->userNova->getAddress($id); $ip = $address->getPublicIp(); $outputPage = $this->getOutput(); if (!$address) { $outputPage->addWikiMsg('openstackmanager-invalidaddress', $ip); return true; } $hostname = $formData['hostname']; $domain = $formData['domain']; $domain = OpenStackNovaDomain::getDomainByName($domain); $hostbyip = OpenStackNovaHost::getHostByPublicIP($ip); if ($hostbyip) { # We need to add an associateddomain, if the associateddomain doesn't already exist $success = $hostbyip->addAssociatedDomain($hostname . '.' . $domain->getFullyQualifiedDomainName()); if ($success) { $outputPage->addWikiMsg('openstackmanager-addedhost', $hostname, $ip); } else { $outputPage->addWikiMsg('openstackmanager-addhostfailed', $hostname, $ip); } } else { # This is a new host entry $host = OpenStackNovaHost::addPublicHost($hostname, $ip, $domain); if ($host) { $outputPage->addWikiMsg('openstackmanager-addedhost', $hostname, $ip); } else { $outputPage->addWikiMsg('openstackmanager-addhostfailed', $hostname, $ip); } } $this->getOutput(); $out = '<br />'; $out .= Linker::link($this->getPageTitle(), $this->msg('openstackmanager-backaddresslist')->escaped()); $outputPage->addHTML($out); return true; }