/** * Return the domain associated with this host * * @return OpenStackNovaDomain */ function getDomain() { global $wgAuth; if (!$this->domainCache) { $this->domainCache = OpenStackNovaDomain::getDomainByHostIP($this->ip); if (!$this->domainCache) { $wgAuth->printDebug("Looked up domain for ip {$this->ip} but domainCache is still empty.", NONSENSITIVE); } } return $this->domainCache; }
/** * Get a host by ip address and an OpenStackNovaDomain. Returns null if * the entry does not exist. * * @static * @param $ip * @return null|OpenStackNovaHost */ static function getHostByIP( $ip ) { global $wgAuth; global $wgOpenStackManagerLDAPInstanceBaseDN; $domain = OpenStackNovaDomain::getDomainByHostIP( $ip ); if ( ! $domain ) { return null; } $result = LdapAuthenticationPlugin::ldap_search( $wgAuth->ldapconn, $wgOpenStackManagerLDAPInstanceBaseDN, '(arecord=' . $ip . ')' ); $hostInfo = LdapAuthenticationPlugin::ldap_get_entries( $wgAuth->ldapconn, $result ); if ( $hostInfo["count"] == "0" ) { return null; } else { array_shift( $hostInfo ); $hostname = $hostInfo[0]['dc'][0]; $host = OpenStackNovaHost::getHostByName( $hostname, $domain ); return $host; } }