You are here

function hosting_get_db_server in Hostmaster (Aegir) 6

Find the database server.

File

modules/hosting/db_server/hosting_db_server.module, line 30
Allow Hostmaster to configure database servers.

Code

function hosting_get_db_server($hostname) {
  if (_hosting_valid_ip($hostname)) {
    $ip = $hostname;
    $hostname = gethostbyaddr($hostname);
  }
  else {
    $ip = gethostbyname($hostname);
  }
  $result = db_result(db_query("SELECT nid FROM {node} WHERE title in ('%s', '%s') and type='server'", $ip, $hostname));
  if ($result) {
    return node_load($result);
  }
  return false;
}