Commit 29731cee authored by Adrian Rossouw's avatar Adrian Rossouw

Remove a bunch of non configurable (now) fields from the db / ui.

parent 345db294
......@@ -68,14 +68,8 @@ function hostmaster_bootstrap() {
$node->status = 1;
$node->services = array();
hosting_services_add($node, 'server', 'base', array(
'script_user' => d()->platform->server->script_user,
'config_path' => d()->platform->server->config_path,
'available' => 1,
));
hosting_services_add($node, 'http', 'apache', array(
'web_group' => d()->platform->server->web_group,
'restart_cmd' => d()->platform->server->restart_cmd,
'ports' => d()->platform->server->web_ports,
'available' => 1,
......
<?php
function hosting_server_context_options(&$task) {
$task->context_options['remote_host'] = $task->ref->title;
foreach (hosting_server_services() as $type => $info) {
if (isset($task->ref->services[$type])) {
$service = $task->ref->services[$type];
......
......@@ -20,16 +20,6 @@ function hosting_server_schema() {
'not null' => TRUE,
'default' => 0,
),
'script_user' => array(
'type' => 'text',
'size' => 'big',
'not null' => FALSE,
),
'config_path' => array(
'type' => 'text',
'size' => 'big',
'not null' => FALSE,
),
),
'primary key' => array('vid'),
);
......@@ -102,3 +92,16 @@ function hosting_server_update_6001() {
return $ret;
}
/**
* Drop the script_user and config_path columns which are no longer needed.
* Also remove hosting_service entries which are no longer relevant.
*/
function hosting_server_update_6002() {
$ret = array();
db_query("DELETE FROM {hosting_service} WHERE service='server'");
db_drop_field($ret, "hosting_server", "script_user");
db_drop_field($ret, "hosting_server", "config_path");
return $ret;
}
......@@ -88,24 +88,6 @@ function hosting_server_access($op, $node, $account) {
}
}
/**
* Implementation of hook_hosting_service()
*/
function hosting_server_hosting_service() {
return array(
'server' => 'base',
);
}
function hosting_server_hosting_service_type() {
return array(
'server' => array(
'title' => t('Server configuration'),
'weight' => -20,
),
);
}
function hosting_server_services() {
static $services;
......@@ -207,33 +189,25 @@ function hosting_server_form(&$node) {
'#weight' => isset($service['weight']) ? $service['weight'] : 0,
);
if ($name === 'server') {
$form['services'][$name]['type'] = array(
'#type' => 'value',
'#value' => 'base',
);
$form['services'][$name]['type'] = array(
'#type' => 'radios',
'#weight' => -99,
'#options' => array_merge(array('null' => 'None'), drupal_map_assoc(array_keys($service['types']))),
'#default_value' => isset($node->services[$name]->available) && $node->services[$name]->available ? $node->services[$name]->type : 'null',
);
}
foreach ($service['types'] as $type => $class) {
$form['services'][$name][$type] = array(
'#prefix' => '<div id="provision-service-settings-' . $name . '-' . $type . '" class="provision-service-settings-' . $name . '">',
'#suffix' => '</div>',
);
if (isset($node->services[$name]) && $node->services[$name]->type === $type) {
$node->services[$name]->form($form['services'][$name][$type]);
}
else {
$form['services'][$name]['type'] = array(
'#type' => 'radios',
'#weight' => -99,
'#options' => array_merge(array('null' => 'None'), drupal_map_assoc(array_keys($service['types']))),
'#default_value' => isset($node->services[$name]->available) && $node->services[$name]->available ? $node->services[$name]->type : 'null',
);
}
foreach ($service['types'] as $type => $class) {
$form['services'][$name][$type] = array(
'#prefix' => '<div id="provision-service-settings-' . $name . '-' . $type . '" class="provision-service-settings-' . $name . '">',
'#suffix' => '</div>',
);
if (isset($node->services[$name]) && $node->services[$name]->type === $type) {
$node->services[$name]->form($form['services'][$name][$type]);
}
else {
$service_object = hosting_services_new_object($name, $type, $node);
$service_object->form($form['services'][$name][$type]);
}
$service_object = hosting_services_new_object($name, $type, $node);
$service_object->form($form['services'][$name][$type]);
}
}
......@@ -293,6 +267,10 @@ function hosting_server_insert($node) {
hosting_context_register($node->nid, 'server_' . preg_replace("/[!\W\.\-]/", "", $node->title));
}
db_query("INSERT INTO {hosting_server} (vid, nid)
VALUES (%d, %d, '%s', '%s')",
$node->vid, $node->nid);
hosting_server_invoke_services($node, 'save', $node);
hosting_server_invoke_services($node, 'insert', $node);
......@@ -305,6 +283,7 @@ function hosting_server_insert($node) {
* Implementation of hook_delete_revision().
*/
function hosting_nodeapi_server_delete_revision(&$node) {
db_query('DELETE FROM {hosting_server} WHERE vid = %d', $node->vid);
hosting_server_invoke_services($node, 'delete_revision');
}
......@@ -312,6 +291,7 @@ function hosting_nodeapi_server_delete_revision(&$node) {
* Implementation of hook_delete().
*/
function hosting_server_delete($node) {
db_query('DELETE FROM {hosting_server} WHERE nid = %d', $node->nid);
hosting_server_invoke_services($node, 'delete_revision');
}
......
......@@ -61,9 +61,7 @@ class hostingService {
public function validate(&$node, &$form) {}
public function context_options($task_type, $ref_type, &$task) {
if ($this->type !== 'base') {
$task->context_options[$this->service . '_service_type'] = $this->type;
}
$task->context_options[$this->service . '_service_type'] = $this->type;
}
}
......@@ -71,50 +69,13 @@ class hostingService_server_base extends hostingService {
protected $service = 'server';
public $type = 'base';
function form(&$form) {
$form['script_user'] = array(
'#type' => 'textfield',
'#title' => t('System account'),
'#required' => $this->available,
'#description' => t('The system account that the hosted files will belong to, for security reasons.<br />This should be a different account to the account the server is running as.'),
'#default_value' => ($this->script_user) ? $this->script_user : HOSTING_DEFAULT_SCRIPT_USER,
'#size' => 20,
'#maxlength' => 255,
'#weight' => -6,
);
$form['config_path'] = array(
'#type' => 'textfield',
'#title' => t('Configuration path'),
'#required' => $this->available,
'#size' => 40,
'#default_value' => ($this->config_path) ? $this->config_path : HOSTING_DEFAULT_CONFIG_PATH,
'#description' => t("The path on the server where configuration files will be stored.<br />
It is essential that this directory should not be accessible via a web browser."),
'#maxlength' => 255,
'#weight' => -4,
);
}
function validate(&$node, &$form) {
if ($this->script_user == 'root') {
form_set_error('script_user', t('For security reasons, you should not run drush commands as the root user. Please choose a different system account name.'));
}
}
function insert() {
parent::insert();
db_query("INSERT INTO {hosting_server} (vid, nid, script_user, config_path)
VALUES (%d, %d, '%s', '%s')",
$this->server->vid, $this->server->nid, $this->script_user, $this->config_path);
}
function delete_revision() {
parent::delete_revision();
db_query('DELETE FROM {hosting_server} WHERE vid = %d', $this->server->vid);
}
function delete() {
......@@ -122,31 +83,11 @@ class hostingService_server_base extends hostingService {
db_query('DELETE FROM {hosting_server} WHERE nid = %d', $this->server->nid);
}
function load() {
parent::load();
$this->mergeData('SELECT script_user, config_path FROM {hosting_server} WHERE vid = %d', $this->server->vid);
}
function view(&$render) {
$render['script_user'] = array(
'#type' => 'item',
'#title' => t('Script user'),
'#value' => filter_xss($this->script_user),
);
$render['config_path'] = array(
'#type' => 'item',
'#title' => t('Configuration path'),
'#value' => filter_xss($this->config_path),
);
}
/**
* Override hostingService::options() because we don't want to initialize
* this service in provision.
*/
public function context_options($task_type, $ref_type, &$task) {
$task->context_options['remote_host'] = $this->server->title;
$task->context_options['script_user'] = $this->script_user;
}
}
......@@ -20,11 +20,6 @@ function hosting_web_server_schema() {
'not null' => TRUE,
'default' => 0,
),
'web_group' => array(
'type' => 'text',
'size' => 'big',
'not null' => FALSE,
),
'restart_cmd' => array(
'type' => 'text',
'size' => 'big',
......@@ -70,9 +65,8 @@ function hosting_web_server_update_6000() {
$ret = array();
// THIS IS A MYSQL-ism, but we need it at this point.
db_query("INSERT INTO {hosting_service} (nid, vid, service, type, available) SELECT nid, vid, 'server', 'base', 1 FROM {hosting_web_server}");
db_query("INSERT INTO {hosting_service} (nid, vid, service, type, available) SELECT nid, vid, 'http', 'apache', 1 FROM {hosting_web_server}");
db_query("INSERT INTO {hosting_server} (nid, vid, script_user, config_path) SELECT nid, vid, script_user, config_path FROM {hosting_web_server}");
db_query("INSERT INTO {hosting_server} (nid, vid) SELECT nid, vid FROM {hosting_web_server}");
db_query("UPDATE {node} SET type='server' WHERE type='web_server'");
......@@ -85,3 +79,16 @@ function hosting_web_server_update_6000() {
return $ret;
}
/**
* Remove the web_group field which now needs to be consistent between servers.
*/
function hosting_web_server_update_6001() {
$ret = array();
// THIS IS A MYSQL-ism, but we need it at this point.
db_drop_field($ret, "hosting_web_server", "web_group");
return $ret;
}
......@@ -9,14 +9,14 @@ class hostingService_http_apache extends hostingService_http {
public function load() {
parent::load();
$this->mergeData('SELECT web_group, restart_cmd, ports FROM {hosting_web_server} WHERE vid = %d', $this->server->vid);
$this->mergeData('SELECT restart_cmd, ports FROM {hosting_web_server} WHERE vid = %d', $this->server->vid);
}
function insert() {
parent::insert();
db_query("INSERT INTO {hosting_web_server} (vid, nid, web_group, restart_cmd, ports)
VALUES (%d, %d, '%s', '%s', '%s')",
$this->server->vid, $this->server->nid, $this->web_group, $this->restart_cmd, $this->ports);
db_query("INSERT INTO {hosting_web_server} (vid, nid, restart_cmd, ports)
VALUES (%d, %d, '%s', '%s')",
$this->server->vid, $this->server->nid, $this->restart_cmd, $this->ports);
}
......@@ -66,17 +66,6 @@ class hostingService_http_apache extends hostingService_http {
'#maxlength' => 255,
'#weight' => -7,
);
$form['web_group'] = array(
'#type' => 'textfield',
'#title' => t('Web server group'),
'#required' => $this->available,
'#description' => t('The group that the hosted files will belong to.<br />This should be the group the web server is running as.'),
'#default_value' => ($this->web_group) ? $this->web_group : HOSTING_DEFAULT_WEB_GROUP,
'#size' => 20,
'#maxlength' => 75,
'#weight' => -5,
);
}
......@@ -89,11 +78,6 @@ class hostingService_http_apache extends hostingService_http {
'#value' => filter_xss($this->ports),
);
}
$render['web_group'] = array(
'#type' => 'item',
'#title' => t('Web server group'),
'#value' => filter_xss($this->web_group),
);
$render['restart_cmd'] = array(
'#type' => 'item',
'#title' => t('Restart command'),
......@@ -131,7 +115,6 @@ class hostingService_http_apache extends hostingService_http {
}
}
$task->context_options['web_group'] = $this->web_group;
$task->context_options['restart_cmd'] = $this->restart_cmd;
}
}
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