Commit 00ab730f authored by Steven Jones's avatar Steven Jones

Major rejector of the DNS service to autoload.

parent e503ab94
......@@ -2,7 +2,7 @@
// simple wrapper class for PDO based db services
class provisionService_db_pdo extends provisionService_db {
class Provision_Service_db_pdo extends Provision_Service_db {
public $conn;
protected $creds;
private $dsn;
......
<?php
/**
* Base config class for all dns config files.
*/
class Provision_Config_Dns extends Provision_Config {
public $mode = 0777;
function write() {
parent::write();
$this->data['server']->sync($this->filename());
}
function unlink() {
parent::unlink();
$this->data['server']->sync($this->filename());
}
}
<?php
class Provision_Config_Dns_Host extends Provision_Config_Dns {
public $template = 'host.tpl.php';
public $description = 'Host-wide DNS configuration';
function filename() {
return "{$this->data['server']->dns_hostd_path}/{$this->uri}.hosts";
}
}
<?php
/**
* Base config class for the server level config.
*/
class Provision_Config_Dns_Server extends Provision_Config_Dns {
public $template = 'server.tpl.php';
public $description = 'Server-wide DNS configuration';
public $data_store_class = 'Provision_Config_Dns_Server_Store';
function filename() {
if (isset($this->data['application_name'])) {
$file = $this->data['application_name'] . '.conf';
return $this->data['server']->config_path . '/' . $file;
}
else {
return FALSE;
}
}
function write() {
// lock the store until we are done generating our config.
$this->store->lock();
parent::write();
$this->store->write();
$this->store->close();
if (isset($this->data['application_name'])) {
$file = $this->data['application_name'] . '.conf';
// We link the app_name.conf file on the remote server to the right version.
$cmd = sprintf('ln -sf %s %s',
escapeshellarg($this->data['server']->config_path . '/' . $file),
escapeshellarg($this->data['server']->aegir_root . '/config/' . $file)
);
if ($this->data['server']->shell_exec($cmd)) {
drush_log(dt("Created symlink for %file on %server", array(
'%file' => $file,
'%server' => $this->data['server']->remote_host,
)));
};
}
}
}
<?php
// The data store for the server configuration
// contains a list of zones we manage.
class Provision_Config_Dns_Server_Store extends Provision_Config_Data_Store {
function filename() {
return $this->data['server']->dns_data_path . '/zones.master.inc';
}
}
<?php
/**
* Base config class for all dns config files.
*/
class provisionConfig_dns extends Provision_Config {
public $mode = 0777;
function write() {
parent::write();
$this->data['server']->sync($this->filename());
}
function unlink() {
parent::unlink();
$this->data['server']->sync($this->filename());
}
}
// The data store for the server configuration
// contains a list of zones we manage.
class provisionConfig_dns_server_store extends Provision_Config_Data_Store {
function filename() {
return $this->data['server']->dns_data_path . '/zones.master.inc';
}
}
/**
* Base config class for the server level config.
*/
class provisionConfig_dns_server extends provisionConfig_dns {
public $template = 'server.tpl.php';
public $description = 'Server-wide DNS configuration';
public $data_store_class = 'provisionConfig_dns_server_store';
function filename() {
if (isset($this->data['application_name'])) {
$file = $this->data['application_name'] . '.conf';
return $this->data['server']->config_path . '/' . $file;
}
else {
return FALSE;
}
}
function write() {
// lock the store until we are done generating our config.
$this->store->lock();
parent::write();
$this->store->write();
$this->store->close();
if (isset($this->data['application_name'])) {
$file = $this->data['application_name'] . '.conf';
// We link the app_name.conf file on the remote server to the right version.
$cmd = sprintf('ln -sf %s %s',
escapeshellarg($this->data['server']->config_path . '/' . $file),
escapeshellarg($this->data['server']->aegir_root . '/config/' . $file)
);
if ($this->data['server']->shell_exec($cmd)) {
drush_log(dt("Created symlink for %file on %server", array(
'%file' => $file,
'%server' => $this->data['server']->remote_host,
)));
};
}
}
}
class provisionConfig_dns_zone_store extends Provision_Config_Data_Store {
function filename() {
return "{$this->data['server']->dns_data_path}/{$this->data['name']}.zone.inc";
}
}
/**
* Representation of a DNS zonefile
*
* This is the internal representation of a zonefile. It can be
* extended by other subclasses to implement various engines, but it
* has its own internal storage (through
* provisionConfig_dns_zone_store).
* Provision_Config_Dns_Zone_Store).
*
* It assumes a certain structure in the records of the store.
*
......@@ -113,13 +35,13 @@ class provisionConfig_dns_zone_store extends Provision_Config_Data_Store {
*
* @see drush_dns_provision_zone()
* @see increment_serial()
* @see provisionConfig_dns_zone_store
* @see Provision_Config_Dns_Zone_Store
*/
class provisionConfig_dns_zone extends provisionConfig_dns {
class Provision_Config_Dns_Zone extends Provision_Config_Dns {
public $template = 'zone.tpl.php';
public $description = 'Zone-wide DNS configuration';
public $data_store_class = 'provisionConfig_dns_zone_store';
public $data_store_class = 'Provision_Config_Dns_Zone_Store';
function filename() {
return "{$this->data['server']->dns_zoned_path}/{$this->data['name']}.zone";
......@@ -133,7 +55,7 @@ class provisionConfig_dns_zone extends provisionConfig_dns {
// increment the serial.
$serial = (isset($records['@']['SOA']['serial']) ? $records['@']['SOA']['serial'] : NULL);
$this->store->records['@']['SOA']['serial'] = $records['serial'] = provisionService_dns::increment_serial($serial);
$this->store->records['@']['SOA']['serial'] = $records['serial'] = Provision_Service_dns::increment_serial($serial);
$this->data['records'] = $records;
}
......@@ -194,15 +116,3 @@ class provisionConfig_dns_zone extends provisionConfig_dns {
}
}
class provisionConfig_dns_host extends provisionConfig_dns {
public $template = 'host.tpl.php';
public $description = 'Host-wide DNS configuration';
function filename() {
return "{$this->data['server']->dns_hostd_path}/{$this->uri}.hosts";
}
}
<?php
class Provision_Config_Dns_Zone_Store extends Provision_Config_Data_Store {
function filename() {
return "{$this->data['server']->dns_data_path}/{$this->data['name']}.zone.inc";
}
}
<?php
class Provision_Config_Dnsmasq_Host extends Provision_Config_Dns_Host {
}
<?php
class Provision_Config_Dnsmasq_Server extends Provision_Config_Dns_Server {
}
<?php
class Provision_Config_Dnsmasq_Zone extends Provision_Config_Dns_Zone {
}
<?php
class Provision_Config_Bind_Server extends Provision_Config_Dns_Server {
/**
* pre-render the slave servers IP addresses
*
* This is done so we can configure the allow-transfer ACL.
*/
function process() {
parent::process();
$slaves = array();
if (!is_array($this->server->slave_servers)) {
$this->server->slave_servers = array($this->server->slave_servers);
}
foreach ($this->server->slave_servers as $slave) {
$slaves = array_merge($slaves, d($slave)->ip_addresses);
}
$this->data['server']->slave_servers_ips = $slaves;
}
}
<?php
class Provision_Config_Bind_slave extends provisionConfig_dns_server {
public $template = 'slave.tpl.php';
function process() {
parent::process();
if ($this->context->type == 'server') {
$ips = $this->context->ip_addresses;
}
else {
$ips = $this->context->server->ip_addresses;
}
$this->data['master_ip_list'] = implode(';', $ips);
}
}
<?php
class Provision_Config_Bind_Zone extends Provision_Config_Dns_Zone {
/**
* this renders the slave servers names (as their alias is stored)
*/
function process() {
parent::process();
$slaves = array();
if (!is_array($this->server->slave_servers)) {
$this->server->slave_servers = array($this->server->slave_servers);
}
foreach ($this->server->slave_servers as $slave) {
$slaves[] = d($slave)->remote_host;
}
$this->data['server']->slave_servers_names = $slaves;
}
}
This diff is collapsed.
<?php
/**
* Implementation of the DNS service through BIND9
*
* A lot of this is inspired by the Apache implementation of the HTTP service.
*/
class Provision_Service_dns_bind extends Provision_Service_dns {
protected $application_name = 'bind';
protected $has_restart_cmd = TRUE;
private $zone_cache = array();
static function bind_default_restart_cmd() {
return "rndc reload";
}
function default_restart_cmd() {
return Provision_Service_dns_bind::bind_default_restart_cmd();
}
function init_server() {
parent::init_server();
$this->configs['server'][] = 'Provision_Config_Bind_Server';
$this->configs['zone'][] = 'Provision_Config_Bind_Zone';
}
function parse_configs() {
$status = $this->restart();
return $status && parent::parse_configs();
}
}
......@@ -6,18 +6,18 @@
* A lot of this is inspired by the BIND implementation of the DNS service and
* the cluster HTTP service.
*/
class provisionService_dns_bind_slave extends provisionService_dns {
class Provision_Service_dns_bind_slave extends Provision_Service_dns {
protected $application_name = 'bind';
protected $has_restart_cmd = TRUE;
function default_restart_cmd() {
return provisionService_dns_bind::bind_default_restart_cmd();
return Provision_Service_dns_bind::bind_default_restart_cmd();
}
function init_server() {
parent::init_server();
$this->configs['server'][] = 'provisionConfig_bind_slave';
$this->configs['server'][] = 'Provision_Config_Bind_slave';
}
function parse_configs() {
......@@ -49,7 +49,7 @@ class provisionService_dns_bind_slave extends provisionService_dns {
*
* @arg $zone string the zonefile name to create
*
* @see provisionService_dns::create_zone()
* @see Provision_Service_dns::create_zone()
*/
function create_zone($zone = null) {
if (is_null($zone) && ($this->context->type == 'site')) {
......@@ -74,18 +74,3 @@ class provisionService_dns_bind_slave extends provisionService_dns {
return $this->config('server')->record_del($zone, $zone)->write();
}
}
class provisionConfig_bind_slave extends provisionConfig_dns_server {
public $template = 'slave.tpl.php';
function process() {
parent::process();
if ($this->context->type == 'server') {
$ips = $this->context->ip_addresses;
}
else {
$ips = $this->context->server->ip_addresses;
}
$this->data['master_ip_list'] = implode(';', $ips);
}
}
<?php
class Provision_Service_dns_dnsmasq extends Provision_Service_dns {
protected $application_name = 'dnsmasq';
protected $has_restart_cmd = TRUE;
function default_restart_cmd() {
return 'sudo /etc/init.d/dnsmasq restart';
}
function init_server() {
parent::init_server();
$this->configs['server'][] = 'Provision_Config_Dnsmasq_Server';
$this->configs['zone'][] = 'Provision_Config_Dnsmasq_Zone';
$this->configs['host'][] = 'Provision_Config_Dnsmasq_Host';
}
function parse_configs() {
$this->restart();
}
function create_host($host = NULL) {
parent::create_host($host);
$this->create_config('host');
}
}
<?php
/**
* Implementation of the DNS service through BIND9
*
* A lot of this is inspired by the Apache implementation of the HTTP service.
*/
class provisionService_dns_bind extends provisionService_dns {
protected $application_name = 'bind';
protected $has_restart_cmd = TRUE;
private $zone_cache = array();
static function bind_default_restart_cmd() {
return "rndc reload";
}
function default_restart_cmd() {
return provisionService_dns_bind::bind_default_restart_cmd();
}
function init_server() {
parent::init_server();
$this->configs['server'][] = 'provisionConfig_bind_server';
$this->configs['zone'][] = 'provisionConfig_bind_zone';
}
function parse_configs() {
$status = $this->restart();
return $status && parent::parse_configs();
}
}
class provisionConfig_bind_zone extends provisionConfig_dns_zone {
/**
* this renders the slave servers names (as their alias is stored)
*/
function process() {
parent::process();
$slaves = array();
if (!is_array($this->server->slave_servers)) {
$this->server->slave_servers = array($this->server->slave_servers);
}
foreach ($this->server->slave_servers as $slave) {
$slaves[] = d($slave)->remote_host;
}
$this->data['server']->slave_servers_names = $slaves;
}
}
class provisionConfig_bind_server extends provisionConfig_dns_server {
/**
* pre-render the slave servers IP addresses
*
* This is done so we can configure the allow-transfer ACL.
*/
function process() {
parent::process();
$slaves = array();
if (!is_array($this->server->slave_servers)) {
$this->server->slave_servers = array($this->server->slave_servers);
}
foreach ($this->server->slave_servers as $slave) {
$slaves = array_merge($slaves, d($slave)->ip_addresses);
}
$this->data['server']->slave_servers_ips = $slaves;
}
}
This diff is collapsed.
<?php
class provisionService_dns_dnsmasq extends provisionService_dns {
protected $application_name = 'dnsmasq';
protected $has_restart_cmd = TRUE;
function default_restart_cmd() {
return 'sudo /etc/init.d/dnsmasq restart';
}
function init_server() {
parent::init_server();
$this->configs['server'][] = 'provisionConfig_dnsmasq_server';
$this->configs['zone'][] = 'provisionConfig_dnsmasq_zone';
$this->configs['host'][] = 'provisionConfig_dnsmasq_host';
}
function parse_configs() {
$this->restart();
}
function create_host($host = NULL) {
parent::create_host($host);
$this->create_config('host');
}
}
class provisionConfig_dnsmasq_server extends provisionConfig_dns_server {
}
class provisionConfig_dnsmasq_zone extends provisionConfig_dns_zone {
}
class provisionConfig_dnsmasq_host extends provisionConfig_dns_host {
}
// Todo: ditch this file.
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