You are here

function hosting_nodeapi_server_presave in Hostmaster (Aegir) 6

Implementation of hook_presave()

We resolve the server name to IP addresses if none has been given by the operator. we also fire up the regular services hooks.

File

modules/hosting/server/hosting_server.module, line 275

Code

function hosting_nodeapi_server_presave(&$node) {
  if (empty($node->ip_addresses)) {

    // this returns an array or FALSE
    $ips = gethostbynamel($node->title);
    if ($ips) {
      drupal_set_message(t('Initialized the IP to %ip based on hostname %name. If an HTTP service is enabled, this will be used to create database grants so make sure it is the right address, as seen from the database server.', array(
        '%ip' => join(',', $ips),
        '%name' => $node->title,
      )), 'message');
      $node->ip_addresses = $ips;
    }
    else {
      drupal_set_message(t("Could not resolve IP address of server %name, not automatically setting IP address. DNS may fail.", array(
        '%name' => $node->title,
      )));
    }
  }
  hosting_server_services_from_post($node);
}