Commit 466f4d88 authored by Steven Jones's avatar Steven Jones

Fix code style of dns.php

parent e1b9b441
<?php
/**
* @file
* The base Provision DNS service.
*/
class Provision_Service_dns extends Provision_Service {
public $service = 'dns';
public $slave = null;
public $slave = NULL;
/**
* Helper function to increment a zone's serial number.
*
* @param $serial
* A serial in YYYYMMDDnn format. If null, a new serial based on
* A serial in YYYYMMDDnn format. If NULL, a new serial based on
* the date will be generated.
*
* @return
* The serial, incremented based on current date and index
*/
static public function increment_serial($serial = null) {
static public function increment_serial($serial = NULL) {
$today = date('Ymd');
if (is_null($serial)) {
return $today . '00';
......@@ -23,11 +26,13 @@ class Provision_Service_dns extends Provision_Service {
$date = substr($serial, 0, 8); # Get the YYYYMMDD part
if ($date != $today) {
return $today . '00';
} else {
}
else {
$index = substr($serial, 8, 2); # Get the index part
if ($index >= 99) {
drush_set_error("serial number overflow");
} else {
}
else {
$index++;
}
return $date . sprintf('%02d', $index);
......@@ -52,7 +57,7 @@ class Provision_Service_dns extends Provision_Service {
}
$this->server->setProperty('slave_servers', array());
$this->server->setProperty('dns_default_mx', null); # XXX: until we get full zone management
$this->server->setProperty('dns_default_mx', NULL); # XXX: until we get full zone management
$this->server->setProperty('dns_ttl', 86400); # 24h
$this->server->setProperty('dns_refresh', 21600); # 6h
$this->server->setProperty('dns_retry', 3600); # 1h
......@@ -63,7 +68,7 @@ class Provision_Service_dns extends Provision_Service {
function init_site() {
parent::init_site();
$this->context->setProperty('dns_zone', null);
$this->context->setProperty('dns_zone', NULL);
if (is_null($this->context->dns_zone)) {
$this->context->dns_zone = $this->guess_zone($this->context->uri);
}
......@@ -82,7 +87,7 @@ class Provision_Service_dns extends Provision_Service {
* need to be merged, but then the cluster_web_server parameter need to be
* renamed...
*
* @see Provision_Service_http_cluster::_each_server()
* @see Provision_Service_http_cluster::_each_server().
*/
function _each_server($method, $args = array()) {
// Return True by default.
......@@ -102,7 +107,7 @@ class Provision_Service_dns extends Provision_Service {
provision_file()->create_dir($this->server->dns_zoned_path, dt("DNS zone configuration"), 0755);
$this->sync($this->server->dns_zoned_path, array(
'exclude' => $this->server->dns_zoned_path . '/*', // Make sure remote directory is created
));
));
provision_file()->create_dir($this->server->dns_hostd_path , dt("DNS host configuration"), 0755);
$this->sync($this->server->dns_hostd_path, array(
......@@ -112,11 +117,11 @@ class Provision_Service_dns extends Provision_Service {
# TODO: create a slave zone path too.
$this->create_config('server');
}
}
}
function config_data($config = null, $class = null) {
function config_data($config = NULL, $class = NULL) {
$data = parent::config_data($config, $class);
if (!is_null($this->application_name)) {
$data['dns_data_path'] = $this->server->dns_zoned_path;
......@@ -161,7 +166,7 @@ class Provision_Service_dns extends Provision_Service {
$subdomain[] = $scrap;
drush_log("zone $tld not found, ditching $scrap, count: " . count($parts));
$found = FALSE;
}
}
}
// this is necessary if we hit the limit of two subdomains
......@@ -192,7 +197,7 @@ class Provision_Service_dns extends Provision_Service {
/**
* This creates a zone, which mostly consists of adding the SOA record.
*/
function create_zone($zone = null) {
function create_zone($zone = NULL) {
if (is_null($zone) && ($this->context->type == 'site')) {
$host = $this->context->uri;
$zone = $this->context->dns_zone;
......@@ -231,22 +236,22 @@ class Provision_Service_dns extends Provision_Service {
return $status;
}
/**
/**
* Create a host in DNS.
*
* This can do a lot of things, create a zonefile, add a record to a
* zonefile, it's going to make its best guess doing the Right
* Thing.
*
* @arg $host string the hostname to create. If null, we look in the
* @arg $host string the hostname to create. If NULL, we look in the
* current context (should be a site) for a URI.
*/
function create_host($host = null) {
function create_host($host = NULL) {
if (!is_null($host)) {
$zone = $this->guess_zone($host);
$sub = $this->guess_zone($host, 'subdomain');
$aliases = array();
}
}
elseif ($this->context->type == 'site') {
$host = $this->context->uri;
$zone = $this->context->dns_zone;
......@@ -276,7 +281,7 @@ class Provision_Service_dns extends Provision_Service {
array('CNAME' => array($zone . '.')));
}
}
$this->create_zone($zone);
}
......@@ -286,15 +291,15 @@ class Provision_Service_dns extends Provision_Service {
*
* Similar to create host, this will seek and destroy that host throughout zonefiles.
*
* @arg $host string the hostname to create. If null, we look in the
* @arg $host string the hostname to create. If NULL, we look in the
* current context (should be a site) for a URI.
*/
function delete_host($host = null) {
function delete_host($host = NULL) {
if (!is_null($host)) {
$zone = $this->guess_zone($host);
$sub = $this->guess_zone($host, 'subdomain');
$aliases = array();
}
}
elseif ($this->context->type == 'site') {
$host = $this->context->uri;
$zone = $this->context->dns_zone;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment