function drush_dns_provision_zone

7.x-3.x dns.drush.inc drush_dns_provision_zone($action, $zone, $name = null, $type = null, $destination = null)

File

dns/dns.drush.inc, line 44
DNS provisioning module.

Code

function drush_dns_provision_zone($action, $zone, $name = null, $type = null, $destination = null) {
  switch ($action) {
    case 'create-host':
      $status = d()->service('dns')->create_host($zone);
      break;
    case 'delete-host':
      $status = d()->service('dns')->delete_host($zone);
      break;
    case 'verify':
    case 'create':
      $status = d()->service('dns')->create_zone($zone);
      break;
    case 'delete':
      $status = d()->service('dns')->delete_zone($zone);
      break;
    case 'rr-add':
      $record = d()->service('dns')->config('zone', $zone)->record_get($name);
      if (!is_array($record[$type])) {
        $record[$type] = array();
      }
      $record[$type] = array_merge($record[$type], array($destination));
      $status = d()->service('dns')->config('zone', $zone)->record_set($name, $record)->write();
      break;
    case 'rr-modify':
      $status = d()->service('dns')->config('zone', $zone)->record_set($name, array($type => array($destination)))->write();
      break;
    case 'rr-delete':
      if ($type) {
        $status = d()->service('dns')->config('zone', $zone)->record_set($name, array($type => NULL))->write();
      }
      else {
        $status = d()->service('dns')->config('zone', $zone)->record_set($name, NULL)->write();
      }
      break;
    default:
      $status = drush_set_error('DRUSH_WRONG_ARGUMENT', dt("wrong argument provided to provision-zone"));
      break;
  }
  // XXX: we shouldn't reload zones unless we have actually done changes, but return values of the above functions are always FALSE
  d()->service('dns')->parse_configs();

  return $status;
}