hosting_db_server.module in Hostmaster (Aegir) 6
Allow Hostmaster to configure database servers.
File
modules/hosting/db_server/hosting_db_server.moduleView source
<?php
/**
* @file
* Allow Hostmaster to configure database servers.
*/
/**
* Implementation of hook_hosting_service().
*/
function hosting_db_server_hosting_service() {
return array(
'mysql' => 'db',
);
}
/**
* Implementation of hook_hosting_service_type().
*/
function hosting_db_server_hosting_service_type() {
return array(
'db' => array(
'title' => t('Database'),
),
);
}
/**
* Find the database server.
*/
function hosting_get_db_server($hostname) {
if (_hosting_valid_ip($hostname)) {
$ip = $hostname;
$hostname = gethostbyaddr($hostname);
}
else {
$ip = gethostbyname($hostname);
}
$result = db_result(db_query("SELECT nid FROM {node} WHERE title in ('%s', '%s') and type='server'", $ip, $hostname));
if ($result) {
return node_load($result);
}
return false;
}
/**
* Implementation of hook_nodeapi_TYPE_OP().
*/
function hosting_db_server_nodeapi_server_presave(&$node) {
if (empty($node->db_passwd) && !empty($node->nid)) {
$old = node_load($node->nid);
if (isset($old->db_passwd)) {
$node->db_passwd = $old->db_passwd;
}
}
}
/**
* Implementation of hook_views_api().
*/
function hosting_db_server_views_api() {
return array(
'api' => 2,
'path' => drupal_get_path('module', 'hosting_db_server'),
);
}
Functions
Name | Description |
---|---|
hosting_db_server_hosting_service | Implementation of hook_hosting_service(). |
hosting_db_server_hosting_service_type | Implementation of hook_hosting_service_type(). |
hosting_db_server_nodeapi_server_presave | Implementation of hook_nodeapi_TYPE_OP(). |
hosting_db_server_views_api | Implementation of hook_views_api(). |
hosting_get_db_server | Find the database server. |