Skip to content
Snippets Groups Projects
Commit dfd8433e authored by Yas Naoi's avatar Yas Naoi
Browse files

Merge branch '7.x-1.x' of yas@git.drupal.org:project/cloud.git into 7.x-1.x

parents c9fb496e 3c32527f
No related branches found
No related tags found
No related merge requests found
......@@ -68,7 +68,7 @@ function cloud_billing_report($form, $form_submit = '', $cloud_context = '') {
$total += $total_instance_type_charge;
}
$form['date' ][$start] = array(
$form['date'][$start] = array(
array(
'#markup' => l($start . ' to ' . $end,
'reports/usage_estimate/' . $start . '/' . $end . '/details/' . $cloud_name,
......@@ -137,7 +137,7 @@ function cloud_billing_report_details($form, $form_submit = '', $start = '', $en
}
$column = 'name';
$filter = cloud_get_filter_value( $form_submit, 'filter' );
$filter = cloud_get_filter_value( $form_submit, 'filter' );
$filter_col = cloud_get_filter_value( $form_submit, 'operation' );
$query_args = array();
......@@ -168,7 +168,7 @@ function cloud_billing_report_details($form, $form_submit = '', $start = '', $en
$query = _cloud_billing_get_instance_types($cloud_context);
$order = isset($_REQUEST['order']) ? $_REQUEST['order'] : FALSE;
$sort = isset($_REQUEST['sort']) ? $_REQUEST['sort'] : FALSE;
$sort = isset($_REQUEST['sort' ]) ? $_REQUEST['sort' ] : FALSE;
if (empty($order) === FALSE) {
......@@ -201,8 +201,8 @@ function cloud_billing_report_details($form, $form_submit = '', $start = '', $en
$instance_type = $billing_obj->instance_type;
$query_types = _cloud_billing_generate_report($start, $end, $cloud_context, $instance_type);
$result_types = db_query($query_types);
$query_types = _cloud_billing_generate_report($start, $end, $cloud_context, $instance_type);
$result_types = db_query($query_types);
$total_instances = 0;
$total_hours_calc = 0;
......@@ -236,23 +236,23 @@ function cloud_billing_report_details($form, $form_submit = '', $start = '', $en
$form['instance_type'][$billing_obj->id] = array('#markup' => t( $billing_obj->instance_type ));
$form['description' ][$billing_obj->id] = array('#markup' => t( $billing_obj->description . ' instance ' ));
$form['stinstnaces' ][$billing_obj->id] = array('#markup' => t(($total_instances > 0)
? $total_instances
: 0 ));
? number_format($total_instances)
: 0 ));
$form['usage' ][$billing_obj->id] = array('#markup' => t(($total_hours_calc > 0)
? $total_hours_calc
: 0 ));
? number_format($total_hours_calc, 0)
: 0 ));
$form['totals' ][$billing_obj->id] = array('#markup' => t( '$' . number_format($total_instance_type_charge, 2)));
$form['start' ][$billing_obj->id] = array('#markup' => $start_date);
$form['end' ][$billing_obj->id] = array('#markup' => $end_date);
$form['end' ][$billing_obj->id] = array('#markup' => $end_date );
$total += $total_instance_type_charge;
$t_usage += $st_usage ;
$t_instances += $total_instances;
$t_usage += $st_usage ;
$t_instances += $total_instances ;
}
$form['Total' ] = array('#markup' => '$' . number_format($total, 2));
$form['tUsage' ] = array('#markup' => $t_usage);
$form['tInstances'] = array('#markup' => $t_instances);
$form['Total' ] = array('#markup' => '$' . number_format($total, 2));
$form['tUsage' ] = array('#markup' => number_format($t_usage ));
$form['tInstances' ] = array('#markup' => number_format($t_instances));
$form['cloud_context'] = array(
'#type' => 'hidden',
'#value' => $cloud_context,
......@@ -425,10 +425,10 @@ function _cloud_billing_syncronize_records() {
$launch_date = $instances['launch_time'];
if (!array_key_exists($instance_id, $all_instances_list)) {
$query_args[] = 'instance_state_name';
$query_args[] = 'terminated';
$query_args[] = 'terminated_date';
$query_args[] = $launch_date;
$query_args[] = 'instance_state_name';
$query_args[] = 'terminated';
$query_args[] = 'terminated_date';
$query_args[] = $launch_date;
//Update Billing Instance Detials
$update_instance = _cloud_billing_update_instances($instance_id, $query_args);
......
......@@ -107,7 +107,7 @@ function cloud_monitoring_menu() {
//add detailed view support - For Amazon based clouds
$clouds = aws_cloud_get_all_clouds();
foreach ($clouds as $cloud) {
$cloud_menu_path = cloud_get_menu_path($cloud['cloud_name']);
$cloud_menu_path = cloud_get_menu_path($cloud->cloud_name);
$items[$cloud_menu_path . '/instances/describe/%/monitor'] = array(
'title' => 'Monitor',
'description' => 'Monitor',
......
<?php
<?php
/**
* @file
......@@ -17,9 +17,9 @@
* Updated by yas 2011/02/02
*/
/**
* scripting callback function
*/
/**
* scripting callback function
*/
function _cloud_scripting_list($module) {
return drupal_get_form('cloud_scripting_list');
}
......@@ -52,7 +52,7 @@ function cloud_scripting_list($form, $form_submit) {
$filter = trim($filter);
$filter_col = cloud_get_filter_value( $form_submit, 'operation');
$filter_col = isset($filter_col) && $filter_col ? $filter_col : 0; // default: Script Name
$filter_col = isset($filter_col) && $filter_col ? $filter_col : 0; // default: Script Name
if ( $filter_col == 0 ) {
$column = 'Script Name';
......@@ -84,30 +84,30 @@ function cloud_scripting_list($form, $form_submit) {
}
$form['options']['label' ] = array(
'#type' => 'item' ,
'#title' => t('Filter'),
'#type' => 'item' ,
'#title' => t('Filter') ,
);
$form['options']['operation'] = array(
'#type' => 'select' ,
'#options' => $options ,
'#type' => 'select' ,
'#options' => $options ,
'#default_value' => $filter_col,
'#disabled' => $filter_disabled,
);
$form['options']['filter' ] = array(
'#type' => 'textfield',
'#size' => 40 ,
'#type' => 'textfield' ,
'#size' => 40 ,
'#default_value' => $filter ,
'#disabled' => $filter_disabled,
);
$form['options']['submit' ] = array(
'#type' => 'submit' ,
'#value' => t('Apply') ,
'#type' => 'submit' ,
'#value' => t('Apply') ,
'#disabled' => $filter_disabled,
);
if (user_access('create script') ) {
$form['options']['script'] = array(
'#type' => 'submit' ,
'#value' => t('Create'),
'#type' => 'submit' ,
'#value' => t('Create') ,
);
}
......@@ -117,7 +117,7 @@ function cloud_scripting_list($form, $form_submit) {
array(
'data' => t('Nickname'),
'field' => 'name',
'sort' => 'asc',
'sort' => 'asc',
'class' => array('nickname-column'),
),
array(
......@@ -147,27 +147,27 @@ function cloud_scripting_list($form, $form_submit) {
),
);
$query = _cloud_scripting_get_scripts();
$query = $query
->extend('PagerDefault')
->extend('TableSort')
$query = _cloud_scripting_get_scripts();
$query = $query
->extend('PagerDefault')
->extend('TableSort')
->orderByHeader($form['header']['#markup']);
$query
->condition($query_args[0], '%%' . $query_args[1] . '%%', 'like')
->fields('a')
->limit(CLOUD_SCRIPTING_PAGER_LIMIT);
$query
->condition($query_args[0], '%%' . $query_args[1] . '%%', 'like')
->fields('a')
->limit(CLOUD_SCRIPTING_PAGER_LIMIT);
$result = $query->execute();
$scripting_options = cloud_server_templates_get_scripting_options();
foreach ($result as $scripts_obj) {
$form['Name' ][$scripts_obj->script_id] = array('#markup' => l( $scripts_obj->name, CLOUD_SCRIPTING_PATH . '/describe/' . $scripts_obj->script_id . '/info', array('query' => array('id' => urlencode($scripts_obj->script_id))) )); //, array(), 'id=' . urlencode($scripts_obj->id) , NULL, FALSE, TRUE ) ) );
$form['Name' ][$scripts_obj->script_id] = array('#markup' => l( $scripts_obj->name, CLOUD_SCRIPTING_PATH . '/describe/' . $scripts_obj->script_id . '/info', array('query' => array('id' => urlencode($scripts_obj->script_id))) )); //, array(), 'id=' . urlencode($scripts_obj->id) , NULL, FALSE, TRUE ) ) );
$form['Type' ][$scripts_obj->script_id] = array('#markup' => check_plain( $scripting_options['CLOUD_SCRIPTING_TYPE_OPTIONS'][$scripts_obj->type] ));
$form['Packages'][$scripts_obj->script_id] = array('#markup' => check_plain( $scripts_obj->packages ));
$form['Inputs' ][$scripts_obj->script_id] = array('#markup' => check_plain( $scripts_obj->inputs ));
$form['Created'][$scripts_obj->script_id] = array('#markup' => format_date(strtotime($scripts_obj->created), 'short'));
$form['Updated'][$scripts_obj->script_id] = array('#markup' => format_date(strtotime($scripts_obj->updated), 'short'));
$form['Updated'][$scripts_obj->script_id] = array('#markup' => format_date(strtotime($scripts_obj->updated), 'short'));
$form['Actions'][$scripts_obj->script_id] = array('#markup' => cloud_scripting_action(array('script_id' => $scripts_obj->script_id, 'script_name' => $scripts_obj->name)));
}
......@@ -186,75 +186,75 @@ function theme_cloud_scripting_list($variables) {
foreach (element_children($form['Name']) as $key) {
$rows[] = array(
array(
'data' => drupal_render($form['Name'][$key]),
'data' => drupal_render($form['Name'][$key]),
'class' => array('nickname-column'),
),
drupal_render($form['Type' ][$key]),
drupal_render($form['Packages'][$key]),
drupal_render($form['Inputs' ][$key]),
drupal_render($form['Created'][$key]),
drupal_render($form['Updated'][$key]),
array(
'data' => drupal_render($form['Actions'][$key]),
'class' => array('action-column'),
drupal_render($form['Updated'][$key]),
array(
'data' => drupal_render($form['Actions'][$key]),
'class' => array('action-column'),
),
);
}
}
$output = drupal_render($form['options']);
$output .= theme('table', array('header' => $form['header']['#markup'], 'rows' => $rows));
$output .= theme('table', array('header' => $form['header']['#markup'], 'rows' => $rows));
$output .= theme('pager');
$output .= drupal_render_children($form);
return $output;
}
/**
* Function to render scripting actions links
*/
function cloud_scripting_action($scripting_info) {
$action_data = array();
if (user_access('delete script')) {
$prop['onclick'] = cloud_get_messagebox('Are you sure you want to delete the Script "' . $scripting_info['script_name'] . '" ?');
$action_data[] = cloud_display_action(
'images/icon_delete.png',
t('Delete'),
CLOUD_SCRIPTING_PATH . '/' . urlencode($scripting_info['script_id']) . '/delete',
array('query' => array('id' => urlencode($scripting_info['script_id'])), 'html' => TRUE), $prop['onclick']
);
}
if (user_access('edit script')) {
$action_data[] = cloud_display_action(
'images/icon_clear.png',
t('Edit'),
CLOUD_SCRIPTING_PATH . '/' . urlencode($scripting_info['script_id']) . '/edit',
array('query' => array('id' => urlencode($scripting_info['script_id'])), 'html' => TRUE)
);
}
// allow other modules to add action icons
$user_actions = module_invoke_all('cloud_scripting_action_data', $scripting_info);
$action_data = array_merge($action_data, $user_actions);
return implode($action_data);
}
/**
* Function for submitting cloud scripting listing page
*/
function cloud_scripting_list_submit($form_id, &$form_state) {
$form_values =& $form_state['values'];
if ($form_values['op'] == t('Create')) {
$form_state['redirect'] = CLOUD_SCRIPTING_PATH . '/create';
}
elseif ($form_values['op'] == t('Apply')) {
$param_arr = array(
'filter' => $form_values['filter'],
'operation' => $form_values['operation'],
);
$form_state['redirect'] = array(current_path(), array('query' => $param_arr));
}
}
/**
* Function to render scripting actions links
*/
function cloud_scripting_action($scripting_info) {
$action_data = array();
if (user_access('delete script')) {
$prop['onclick'] = cloud_get_messagebox('Are you sure you want to delete the Script "' . $scripting_info['script_name'] . '" ?');
$action_data[] = cloud_display_action(
'images/icon_delete.png',
t('Delete'),
CLOUD_SCRIPTING_PATH . '/' . urlencode($scripting_info['script_id']) . '/delete',
array('query' => array('id' => urlencode($scripting_info['script_id'])), 'html' => TRUE), $prop['onclick']
);
}
if (user_access('edit script')) {
$action_data[] = cloud_display_action(
'images/icon_clear.png',
t('Edit'),
CLOUD_SCRIPTING_PATH . '/' . urlencode($scripting_info['script_id']) . '/edit',
array('query' => array('id' => urlencode($scripting_info['script_id'])), 'html' => TRUE)
);
}
// allow other modules to add action icons
$user_actions = module_invoke_all('cloud_scripting_action_data', $scripting_info);
$action_data = array_merge($action_data, $user_actions);
return implode($action_data);
}
/**
* Function for submitting cloud scripting listing page
*/
function cloud_scripting_list_submit($form_id, &$form_state) {
$form_values =& $form_state['values'];
if ($form_values['op'] == t('Create')) {
$form_state['redirect'] = CLOUD_SCRIPTING_PATH . '/create';
}
elseif ($form_values['op'] == t('Apply')) {
$param_arr = array(
'filter' => $form_values['filter'],
'operation' => $form_values['operation'],
);
$form_state['redirect'] = array(current_path(), array('query' => $param_arr));
}
}
/**
......@@ -269,14 +269,14 @@ function cloud_scripting_desc_info($form, $form_submit = '', $script_id = '') {
$query = _cloud_scripting_get_scripts();
$query->condition('script_id', $script_id, '=');
$result = $query
->execute()
$result = $query
->execute()
->fetchObject();
$form['fieldset_script_info'] = array(
'#type' => 'fieldset',
'#title' => t('Details'),
);
);
if ($result) {
$script_name = $result->name;
......@@ -306,54 +306,54 @@ function cloud_scripting_desc_info($form, $form_submit = '', $script_id = '') {
$form['Script']['id'] = array('#type' => 'value', '#value' => $result->script_id);
$form['submit_buttons'] = array(
'#type' => 'fieldset',
'#prefix' => '<span class="clear"></span><div class="container-inline"><div class="buttons">',
'#suffix' => '</div></div>',
);
if (user_access('edit script')) {
$form['submit_buttons']['Edit'] = array(
'#type' => 'submit',
'#value' => t('Edit'),
);
}
if (user_access('delete script')) {
$confirm_msg = cloud_get_messagebox('Are you sure you want to delete the Script "' . $script_name . '" ?');
$onclick = $confirm_msg;
$form['submit_buttons']['Delete'] = array(
'#type' => 'submit',
'#value' => t('Delete'),
'#attributes' => array('onclick' => $onclick),
);
}
$form['submit_buttons']['List Scripts'] = array(
'#type' => 'submit',
'#value' => t('List Scripts'),
$form['submit_buttons'] = array(
'#type' => 'fieldset',
'#prefix' => '<span class="clear"></span><div class="container-inline"><div class="buttons">',
'#suffix' => '</div></div>',
);
if (user_access('edit script')) {
$form['submit_buttons']['Edit'] = array(
'#type' => 'submit',
'#value' => t('Edit'),
);
}
if (user_access('delete script')) {
$confirm_msg = cloud_get_messagebox('Are you sure you want to delete the Script "' . $script_name . '" ?');
$onclick = $confirm_msg;
$form['submit_buttons']['Delete'] = array(
'#type' => 'submit',
'#value' => t('Delete'),
'#attributes' => array('onclick' => $onclick),
);
}
$form['submit_buttons']['List Scripts'] = array(
'#type' => 'submit',
'#value' => t('List Scripts'),
);
}
}
return $form;
}
/**
* Submit function for cloud scription details page
*/
function cloud_scripting_desc_info_submit($form, &$form_state) {
$op = $form_state['values']['op'];
$script_id = $form_state['values']['id'];
switch ($op) {
case 'Edit':
$form_state['redirect'] = CLOUD_SCRIPTING_PATH . '/' . $script_id . '/edit';
break;
case 'Delete':
$form_state['redirect'] = CLOUD_SCRIPTING_PATH . '/' . $script_id . '/delete';
break;
default:
$form_state['redirect'] = CLOUD_SCRIPTING_PATH . '/' . 'list';
break;
}
/**
* Submit function for cloud scription details page
*/
function cloud_scripting_desc_info_submit($form, &$form_state) {
$op = $form_state['values']['op'];
$script_id = $form_state['values']['id'];
switch ($op) {
case 'Edit':
$form_state['redirect'] = CLOUD_SCRIPTING_PATH . '/' . $script_id . '/edit';
break;
case 'Delete':
$form_state['redirect'] = CLOUD_SCRIPTING_PATH . '/' . $script_id . '/delete';
break;
default:
$form_state['redirect'] = CLOUD_SCRIPTING_PATH . '/' . 'list';
break;
}
}
/**
......@@ -385,7 +385,7 @@ function theme_cloud_scripting_desc_info($variables) {
),
array(
drupal_render($form['script']['script_label' ]),
drupal_render($form['script'] )
drupal_render($form['script'] )
. drupal_render($form['script']['script_text' ]),
),
array(
......@@ -483,7 +483,7 @@ function theme_cloud_scripting_desc_script($variables) {
),
array(
drupal_render($form['script']['script_label' ]),
drupal_render($form['script'] )
drupal_render($form['script'] )
. drupal_render($form['script']['script_text' ]),
),
);
......@@ -495,7 +495,7 @@ function theme_cloud_scripting_desc_script($variables) {
return $output;
}
/**
/**
* Delete a script
*/
function cloud_scripting_delete($script_id = '') {
......@@ -594,7 +594,7 @@ function cloud_scripting_new($form, $form_submit = '', $script_id = '') {
}
/**
/**
* Theme the new scripting form
*/
function theme_cloud_scripting_new($variables) {
......@@ -679,12 +679,12 @@ function cloud_scripting_new_submit($form_id, &$form_state) {
$script_id = $form_values['script_id'];
_cloud_scripting_update_script($form_values, $script_id );
drupal_set_message(t('Script has been saved.'));
}
}
$form_state['redirect'] = CLOUD_SCRIPTING_PATH . '/list';
}
/**
* Update script status for an instance
/**
* Update script status for an instance
*/
function _cloud_scripting_update_instance_status($dns) {
......@@ -697,33 +697,33 @@ function _cloud_scripting_update_instance_status($dns) {
$scripts_arr = _cloud_scripting_get_scripts_for_instance($instance_id);
if (sizeof($scripts_arr) == 0 ) {
if ( _cloud_scripting_check_is_executed($instance_id) > 0 ) {
// Scripts are to be executed
// Scripts are to be executed
$result_script_status = _instance_status_update($instance_id, CLOUD_INSTANCE_STATUS_BOOTING );
}
else {
// No scripts present
// No scripts present
$result_script_status = _instance_status_update($instance_id, CLOUD_INSTANCE_STATUS_OPERATIONAL );
}
}
else {
// Scripts are to be executed
// Scripts are to be executed
$result_script_status = _instance_status_update($instance_id, CLOUD_INSTANCE_STATUS_BOOTING );
}
}
}
/**
* Check if a script has been executed
/**
* Check if a script has been executed
*/
function _cloud_scripting_check_is_executed($instance_id) {
$check_scripts_query = " SELECT COUNT(*) AS script_cnt FROM ( SELECT ds.template_id AS tid FROM cloud_cluster_servers ds
LEFT JOIN {" . CLOUD_SERVER_TEMPLATES_TABLE . "} st
ON ds.template_id=st.template_id
WHERE ds.instance_id=:instance_id
) tmp_tb
LEFT JOIN {" . CLOUD_SERVER_TEMPLATES_SCRIPTS_TABLE . "} sts
ON tmp_tb.tid=sts.server_template_id
$check_scripts_query = " SELECT COUNT(*) AS script_cnt FROM ( SELECT ds.template_id AS tid FROM cloud_cluster_servers ds
LEFT JOIN {" . CLOUD_SERVER_TEMPLATES_TABLE . "} st
ON ds.template_id=st.template_id
WHERE ds.instance_id=:instance_id
) tmp_tb
LEFT JOIN {" . CLOUD_SERVER_TEMPLATES_SCRIPTS_TABLE . "} sts
ON tmp_tb.tid=sts.server_template_id
";
$check_scripts_query_args = array(
......@@ -736,25 +736,25 @@ function _cloud_scripting_check_is_executed($instance_id) {
return $script_cnt;
}
$check_scripts_array_query = "SELECT COUNT(*) AS script_cnt
FROM
(
SELECT arrayid FROM
( SELECT tas.arrayid as arrayid FROM {" . CLOUD_AUTO_SCALING_ARRAY_LAUNCH_TABLE . "} tas
WHERE tas.instance_id=:instance_id ) vas
LEFT JOIN {" . INSTANCE_ARRAY_TABLE . "} sia on vas.arrayid = sia.id
LEFT JOIN {" . CLOUD_SERVER_TEMPLATES_TABLE . "} st on sia.server_template_id=st.template_id
LEFT JOIN {" . CLOUD_SERVER_TEMPLATES_SCRIPTS_TABLE . "} sts on st.template_id=sts.server_template_id
$check_scripts_array_query = "SELECT COUNT(*) AS script_cnt
FROM
(
SELECT arrayid FROM
( SELECT tas.arrayid as arrayid FROM {" . CLOUD_AUTO_SCALING_ARRAY_LAUNCH_TABLE . "} tas
WHERE tas.instance_id=:instance_id ) vas
LEFT JOIN {" . INSTANCE_ARRAY_TABLE . "} sia on vas.arrayid = sia.id
LEFT JOIN {" . CLOUD_SERVER_TEMPLATES_TABLE . "} st on sia.server_template_id=st.template_id
LEFT JOIN {" . CLOUD_SERVER_TEMPLATES_SCRIPTS_TABLE . "} sts on st.template_id=sts.server_template_id
) cnt_tbl ";
$check_scripts_array_query_args = array(
':instance_id' => $instance_id,
);
$result_arr = db_query($check_scripts_array_query, $check_scripts_array_query_args );
return $result_arr->fetchField();
$result_arr = db_query($check_scripts_array_query, $check_scripts_array_query_args );
return $result_arr->fetchField();
}
/**
* Redirect to script listing page
/**
* Redirect to script listing page
*/
function _cloud_scripting_getdata($src = '') {
if ( $src == NULL || empty($src) ) {
......
......@@ -148,9 +148,9 @@ function aws_cloud_menu() {
);
foreach ($clouds as $cloud) {
$cloud_context = $cloud['cloud_name'];
$cloud_display_name = $cloud['cloud_display_name'];
$cloud_menu_path = cloud_get_menu_path($cloud_context);
$cloud_context = $cloud->cloud_name;
$cloud_display_name = $cloud->cloud_display_name;
$cloud_menu_path = cloud_get_menu_path($cloud_context);
$items[$cloud_menu_path] = array(
'title' => $cloud_display_name,
......@@ -818,9 +818,11 @@ function aws_cloud_permission() {
foreach ($clouds as $cloud) {
foreach ($tmp_perm_arr as $key) {
$perm[$cloud['cloud_name'] . ' ' . $key] = array(
'title' => t($cloud['cloud_name'] . ' ' . $key),
'description' => t('Permission to "@key" on "@cloud"', array('@key' => $key, '@cloud' => $cloud['cloud_name'])),
$cloud_name = $cloud->cloud_name;
$perm[$cloud_name . ' ' . $key] = array(
'title' => t($cloud_name . ' ' . $key),
'description' => t('Permission to "@key" on "@cloud"', array(
'@key' => $key, '@cloud' => $cloud_name)),
);
}
}
......@@ -833,7 +835,7 @@ function aws_cloud_permission() {
function aws_cloud_cron() {
$clouds = aws_cloud_get_all_clouds();
foreach ($clouds as $cloud) {
aws_cloud_fetch_data($cloud['cloud_name']); // This will fetch Cloud related information
aws_cloud_fetch_data($cloud->cloud_name); // This will fetch Cloud related information
// load the bundle code and run it
module_load_include('inc', 'aws_cloud', 'includes/aws_cloud_bundle_instance');
aws_cloud_process_bundle_instance();
......@@ -848,7 +850,7 @@ function aws_cloud_user_validate($op, &$edit, &$account, $category = NULL) {
case 'login':
$clouds = aws_cloud_get_all_clouds();
foreach ($clouds as $cloud) {
aws_cloud_ssh_keys_check_load($cloud['cloud_name'], $account->name);
aws_cloud_ssh_keys_check_load($cloud->cloud_name, $account->name);
}
break;
}
......
......@@ -13,28 +13,52 @@
*/
function aws_cloud_get_all_clouds($sort_string = NULL) {
//Only return sub-clouds that are defined by aws_cloud or other clouds
//using the same mechanism
return aws_cloud_get_all_clouds_query()->execute();
}
/**
* Gets all the clouds in the database
*/
function aws_cloud_get_all_clouds_query() {
//Only return sub-clouds that are defined by aws_cloud or other clouds
//using the same mechanism
$base_clouds = aws_cloud_get_cloud_data();
$keys = array();
foreach (array_keys($base_clouds) as $key) {
$keys[] = "'{$key}'";
$keys[] = $key;
}
$query = "SELECT c.cloud_name, c.cloud_id, c.start_duration, c.cloud_display_name, c.start_duration, c.scaling_server_url, c.last_update_time, c.host_entries_refresh_time, c.module, c.base_cloud,
cd.api_version, cd.host_uri, cd.aws_access_key, cd.aws_secret_key, cd.user_id, cd.image_upload_url, cd.image_register_url, cd.certificate from {" . CLOUD_CLOUDS_TABLE . "} c
left join {" . AWS_CLOUD_DETAILS_TABLE . "} cd on cd.cloud_name = c.cloud_name ";
$query = db_select(CLOUD_CLOUDS_TABLE, 'c')
->fields('c', array('cloud_name',
'cloud_id',
'start_duration',
'cloud_display_name',
'start_duration',
'scaling_server_url',
'last_update_time',
'host_entries_refresh_time',
'module',
'base_cloud'))
->fields('cd', array('api_version',
'host_uri',
'aws_access_key',
'aws_secret_key',
'user_id',
'image_upload_url',
'image_register_url',
'certificate'));
$query->leftJoin(AWS_CLOUD_DETAILS_TABLE, 'cd', 'c.cloud_name = cd.cloud_name');
if (count($keys) > 0) {
$str_to_search = implode(',', $keys);
$query .= "where c.base_cloud in ( $str_to_search )";
}
if (isset($sort_string)) {
$query .= $sort_string;
$query->condition('c.base_cloud', $keys, 'IN');
}
return cloud_get_db_results($query);
return $query;
}
/**
......
......@@ -8,6 +8,7 @@
*
*/
// Updated by yas 2015/06/15
// Updated by yas 2015/05/08
// Updated by yas 2015/05/07
// Updated by yas 2015/03/26
......@@ -36,8 +37,8 @@ function aws_cloud_list() {
function aws_cloud_add_button() {
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Add Cloud'),
'#type' => 'submit',
'#value' => t('Add Cloud'),
'#submit' => array('aws_cloud_add_cloud'),
);
......@@ -77,19 +78,19 @@ function aws_cloud_edit($cloud_name = NULL) {
else {
$edit = array(//No need to put so many variables.
'base_cloud' => '',
'cloud_name' => '',
'cloud_display_name' => '',
'api_version' => '',
'host_uri' => '',
'aws_access_key' => '',
'aws_secret_key' => '',
'user_id' => '',
'image_upload_url' => '',
'image_register_url' => '',
'certificate' => '',
'monitoring_server_url' => '',
'monitoring_server_user_id' => '',
'base_cloud' => '',
'cloud_name' => '',
'cloud_display_name' => '',
'api_version' => '',
'host_uri' => '',
'aws_access_key' => '',
'aws_secret_key' => '',
'user_id' => '',
'image_upload_url' => '',
'image_register_url' => '',
'certificate' => '',
'monitoring_server_url' => '',
'monitoring_server_user_id' => '',
'monitoring_server_password' => '',
);
......@@ -110,25 +111,25 @@ function aws_cloud_add_form($form, $form_state, $edit = array(), $op = '') {
);
$form['cloud']['destination'] = array(
'#type' => 'hidden',
'#name' => 'destination',
'#type' => 'hidden',
'#name' => 'destination',
'#value' => 'admin/config/clouds',
);
$form['cloud']['submit'] = array(
'#type' => 'submit',
'#type' => 'submit',
'#value' => ($op == 'edit') ? 'Update' : 'Create',
);
if ($op == 'edit') {
$form['cloud']['delete'] = array(
'#type' => 'submit',
'#value' => t('Delete'),
'#type' => 'submit',
'#value' => t('Delete'),
'#submit' => array('aws_cloud_delete_submit'),
);
$form['cloud']['list'] = array(
'#type' => 'submit',
'#value' => t('List Clouds'),
'#type' => 'submit',
'#value' => t('List Clouds'),
'#submit' => array('aws_cloud_list_submit'),
);
}
......@@ -136,189 +137,189 @@ function aws_cloud_add_form($form, $form_state, $edit = array(), $op = '') {
if ($op == 'edit') {
$form['cloud']['base_cloud_display'] = array(
'#type' => 'item',
'#title' => t('Base Cloud'),
'#type' => 'item',
'#title' => t('Base Cloud'),
'#description' => t('This value cannot be editted'),
'#options' => _aws_cloud_base_cloud_options(),
'#value' => $edit['base_cloud'],
'#options' => _aws_cloud_base_cloud_options(),
'#value' => $edit['base_cloud'],
);
$form['cloud']['cloud_name_display'] = array(
'#type' => 'item',
'#title' => t('Cloud Name'),
'#type' => 'item',
'#title' => t('Cloud Name'),
'#description' => t('This value cannot be editted'),
'#value' => $edit['cloud_name'],
'#value' => $edit['cloud_name'],
//'#disabled' => ($op == 'edit') ? TRUE: FALSE,
);
$form['cloud']['base_cloud'] = array(
'#type' => 'value',
'#title' => t('Base Cloud'),
'#description' => t('Select the cloud type'),
'#required' => TRUE,
'#options' => _aws_cloud_base_cloud_options(),
'#type' => 'value',
'#title' => t('Base Cloud'),
'#description' => t('Select the cloud type'),
'#required' => TRUE,
'#options' => _aws_cloud_base_cloud_options(),
'#default_value' => $edit['base_cloud'],
);
$form['cloud']['cloud_name'] = array(
'#type' => 'value',
'#title' => t('Cloud Name'),
'#description' => t('Machine name: e.g. amazon_ec2_east'),
'#required' => TRUE,
'#type' => 'value',
'#title' => t('Cloud Name'),
'#description' => t('Machine name: e.g. amazon_ec2_east'),
'#required' => TRUE,
'#default_value' => $edit['cloud_name'],
);
}
else {
$form['cloud']['base_cloud'] = array(
'#type' => 'select',
'#title' => t('Base Cloud'),
'#description' => t('Select the cloud type for pre-defined billing model for hourly rate'),
'#required' => TRUE,
'#options' => _aws_cloud_base_cloud_options(),
'#type' => 'select',
'#title' => t('Base Cloud'),
'#description' => t('Select the cloud type for pre-defined billing model for hourly rate'),
'#required' => TRUE,
'#options' => _aws_cloud_base_cloud_options(),
'#default_value' => $edit['base_cloud'],
);
$form['cloud']['cloud_name'] = array(
'#type' => 'textfield',
'#title' => t('Cloud Name'),
'#description' => t('Cloud name as an identifier: e.g. amazon_ec2_us_east | amazon_ec2_us_west_1 | amazon_ec2_us_west_2 | amazon_ec2_eu_west_1 | amazon_ec2_ap_northeast_1 | amazon_ec2_ap_southeast_1 | amazon_ec2_ap_southeast_2 | openstack_nova - The Cloud Name must contain only lowercase letters, numbers, and underscores. Space cannot be included.'),
'#required' => TRUE,
'#type' => 'textfield',
'#title' => t('Cloud Name'),
'#description' => t('Cloud name as an identifier: e.g. amazon_ec2_us_east | amazon_ec2_us_west_1 | amazon_ec2_us_west_2 | amazon_ec2_eu_west_1 | amazon_ec2_ap_northeast_1 | amazon_ec2_ap_southeast_1 | amazon_ec2_ap_southeast_2 | openstack_nova - The Cloud Name must contain only lowercase letters, numbers, and underscores. Space cannot be included.'),
'#required' => TRUE,
'#default_value' => $edit['cloud_name'],
);
}
$form['cloud']['cloud_display_name'] = array(
'#title' => t('Cloud Display Name'),
'#type' => 'textfield',
'#title' => t('Cloud Display Name'),
'#description' => t('e.g. US East (Northern Virginia) Region (or AWS Virgina) | US West (Northern California) Region (or AWS California) | US West (Oregon) Region (or AWS Oregon) | EU (Ireland) Region (or AWS Ireland) | Asia Pacific (Tokyo) Region (or AWS Tokyo) | Asia Pacific (Singapore) Region (or AWS Singapore) | Asia Pacific (Sydney) Region (or AWS Sydney) | South America (São Paulo) Region (or AWS São Paulo) | OpenStack | Eucalyptus'),
'#required' => TRUE,
'#title' => t('Cloud Display Name'),
'#type' => 'textfield',
'#title' => t('Cloud Display Name'),
'#description' => t('e.g. US East (Northern Virginia) Region (or AWS Virgina) | US West (Northern California) Region (or AWS California) | US West (Oregon) Region (or AWS Oregon) | EU (Ireland) Region (or AWS Ireland) | Asia Pacific (Tokyo) Region (or AWS Tokyo) | Asia Pacific (Singapore) Region (or AWS Singapore) | Asia Pacific (Sydney) Region (or AWS Sydney) | South America (São Paulo) Region (or AWS São Paulo) | OpenStack | Eucalyptus'),
'#required' => TRUE,
'#default_value' => $edit['cloud_display_name'],
);
$form['cloud']['api_version'] = array(
'#title' => t('API Version'),
'#type' => 'textfield',
'#description' => t('The API Version of REST API (yyyy-mm-dd)'),
'#size' => 15,
'#required' => TRUE,
'#title' => t('API Version'),
'#type' => 'textfield',
'#description' => t('The API Version of REST API (yyyy-mm-dd)'),
'#size' => 15,
'#required' => TRUE,
'#default_value' => $edit['api_version'],
);
$form['cloud']['host_uri'] = array(
'#type' => 'textfield',
'#title' => t('API URI'),
'#description' => t("'http://' is NOT required: e.g. ec2.amazonaws.com | ec2.us-west-1.amazonaws.com | ec2.us-west-2.amazonaws.com | ec2.eu-west-1.amazonaws.com | ec2.ap-northeast-1.amazonaws.com | ec2.ap-southeast-1.amazonaws.com | ec2.ap-southeast-2.amazonaws.com | ec2.sa-east-1.amazonaws.com | OpenStack: 192.168.0.1:8773/services/Cloud | Cloud(n) JP: comp-apia.jp-e1.cloudn-service.com/awsapi | Cloud(n) US: comp-apia.us-e1.cloudn-service.com/awsapi"),
'#size' => 50,
'#maxlength' => 255,
'#required' => TRUE,
'#type' => 'textfield',
'#title' => t('API URI'),
'#description' => t("'http://' is NOT required: e.g. ec2.amazonaws.com | ec2.us-west-1.amazonaws.com | ec2.us-west-2.amazonaws.com | ec2.eu-west-1.amazonaws.com | ec2.ap-northeast-1.amazonaws.com | ec2.ap-southeast-1.amazonaws.com | ec2.ap-southeast-2.amazonaws.com | ec2.sa-east-1.amazonaws.com | OpenStack: 192.168.0.1:8773/services/Cloud | Cloud(n) JP: comp-apia.jp-e1.cloudn-service.com/awsapi | Cloud(n) US: comp-apia.us-e1.cloudn-service.com/awsapi"),
'#size' => 50,
'#maxlength' => 255,
'#required' => TRUE,
'#default_value' => $edit['host_uri'],
);
$form['cloud']['aws_access_key'] = array(
'#type' => 'textfield',
'#title' => t('Access Key'),
'#description' => t('16-32 Characters, e.g. 12ABCDEFGHIJKVWXYZ89'),
'#size' => 32,
'#required' => TRUE,
'#type' => 'textfield',
'#title' => t('Access Key'),
'#description' => t('16-32 Characters, e.g. 12ABCDEFGHIJKVWXYZ89'),
'#size' => 32,
'#required' => TRUE,
'#default_value' => $edit['aws_access_key'],
);
$form['cloud']['aws_secret_key'] = array(
'#type' => 'textfield',
'#title' => t('AWS Secret Key'),
'#size' => 55,
'#maxlength' => 50,
'#description' => t('e.g. 123ABC/defGHIjkl34+LMNopq567RSTuvwxYz89Z'),
'#required' => TRUE,
'#type' => 'textfield',
'#title' => t('AWS Secret Key'),
'#size' => 55,
'#maxlength' => 50,
'#description' => t('e.g. 123ABC/defGHIjkl34+LMNopq567RSTuvwxYz89Z'),
'#required' => TRUE,
'#default_value' => $edit['aws_secret_key'],
);
$form['cloud']['user_id'] = array(
'#type' => 'textfield',
'#title' => t('User ID'),
'#description' => t('e.g. 123456789012'),
'#size' => 15,
'#required' => TRUE,
'#type' => 'textfield',
'#title' => t('User ID'),
'#description' => t('e.g. 123456789012'),
'#size' => 15,
'#required' => TRUE,
'#default_value' => $edit['user_id'],
);
$form['cloud']['image_upload_url'] = array(
'#type' => 'textfield',
'#title' => t('Image Upload URL'),
'#type' => 'textfield',
'#title' => t('Image Upload URL'),
'#default_value' => '',
'#description' => t('e.g. https://s3.amazonaws.com'),
'#size' => 50,
'#maxlength' => 255,
'#required' => TRUE,
'#description' => t('e.g. https://s3.amazonaws.com'),
'#size' => 50,
'#maxlength' => 255,
'#required' => TRUE,
'#default_value' => $edit['image_upload_url'],
);
$form['cloud']['image_register_url'] = array(
'#type' => 'textfield',
'#title' => t('Image Register URL'),
'#type' => 'textfield',
'#title' => t('Image Register URL'),
'#default_value' => '',
'#description' => t("'https://' is REQUIRED: e.g. https://ec2.amazonaws.com | https://ec2.us-west-1.amazonaws.com | https://ec2.us-west-2.amazonaws.com | https://ec2.eu-west-1.amazonaws.com | https://ec2.ap-northeast-1.amazonaws.com | https://ec2.ap-southeast-1.amazonaws.com | https://ec2.ap-southeast-2.amazonaws.com | https://ec2.sa-east-1.amazonaws.com"),
'#size' => 50,
'#maxlength' => 255,
'#required' => TRUE,
'#description' => t("'https://' is REQUIRED: e.g. https://ec2.amazonaws.com | https://ec2.us-west-1.amazonaws.com | https://ec2.us-west-2.amazonaws.com | https://ec2.eu-west-1.amazonaws.com | https://ec2.ap-northeast-1.amazonaws.com | https://ec2.ap-southeast-1.amazonaws.com | https://ec2.ap-southeast-2.amazonaws.com | https://ec2.sa-east-1.amazonaws.com"),
'#size' => 50,
'#maxlength' => 255,
'#required' => TRUE,
'#default_value' => $edit['image_register_url'],
);
$form['cloud']['certificate'] = array(
'#type' => 'textarea',
'#title' => t('X.509 Certificate'),
'#description' => t('X.509 Certificate to use. You can temporarily put dummy string if you do not use Bundle Image capability.'),
'#rows' => 17,
'#size' => 66,
'#required' => FALSE,
'#type' => 'textarea',
'#title' => t('X.509 Certificate'),
'#description' => t('X.509 Certificate to use. You can temporarily put dummy string if you do not use Bundle Image capability.'),
'#rows' => 17,
'#size' => 66,
'#required' => FALSE,
'#default_value' => $edit['certificate'],
);
if (module_exists('cloud_failover')) {
$form['cloud']['monitoring_server_url'] = array(
'#type' => 'textfield',
'#title' => t('Monitoring Server URL'),
'#type' => 'textfield',
'#title' => t('Monitoring Server URL'),
'#default_value' => '',
'#description' => t('Monitoring Server URL'),
'#size' => 50,
'#maxlength' => 255,
'#required' => FALSE,
'#description' => t('Monitoring Server URL'),
'#size' => 50,
'#maxlength' => 255,
'#required' => FALSE,
'#default_value' => $edit['monitoring_server_url'],
);
$form['cloud']['monitoring_server_user_id'] = array(
'#type' => 'textfield',
'#title' => t('Monitoring Server UserID'),
'#type' => 'textfield',
'#title' => t('Monitoring Server UserID'),
'#default_value' => '',
'#description' => t('Monitoring Server UserID'),
'#size' => 50,
'#maxlength' => 255,
'#required' => FALSE,
'#description' => t('Monitoring Server UserID'),
'#size' => 50,
'#maxlength' => 255,
'#required' => FALSE,
'#default_value' => $edit['monitoring_server_user_id'],
);
$form['cloud']['monitoring_server_password'] = array(
'#type' => 'password',
'#title' => t('Monitoring Server PWD.'),
'#type' => 'password',
'#title' => t('Monitoring Server PWD.'),
'#default_value' => '',
'#description' => t('Monitoring Server Password'),
'#size' => 50,
'#maxlength' => 255,
'#required' => FALSE,
'#description' => t('Monitoring Server Password'),
'#size' => 50,
'#maxlength' => 255,
'#required' => FALSE,
'#default_value' => $edit['monitoring_server_password'],
);
}
$form['cloud']['submit_2'] = array(
'#type' => 'submit',
'#type' => 'submit',
'#value' => ($op == 'edit') ? 'Update' : 'Create',
);
if ($op == 'edit') {
$form['cloud']['delete_2'] = array(
'#type' => 'submit',
'#value' => t('Delete'),
'#type' => 'submit',
'#value' => t('Delete'),
'#submit' => array('aws_cloud_delete_submit'),
);
}
......@@ -334,7 +335,7 @@ function aws_cloud_add_form_validate($form, &$form_state) {
if ($form_state['values']['op'] == 'Create') {
$cloud_name = isset($form_state['values']['cloud_name'])
? trim($form_state['values']['cloud_name'])
? trim( $form_state['values']['cloud_name'])
: '';
if (!preg_match('!^[a-z0-9_]+$!', $cloud_name)) {
......@@ -473,44 +474,49 @@ function theme_aws_cloud_list() {
$header = array(
array(
'data' => t('Cloud Display Name'),
'data' => t('Cloud Display Name'),
'field' => 'cloud_display_name',
'sort' => 'asc',
'sort' => 'asc',
),
array(
'data' => t('Cloud Name' ),
'data' => t('Cloud Name' ),
'field' => 'cloud_name',
),
array(
'data' => t('Host Uri' ),
'data' => t('Host Uri' ),
'field' => 'host_uri',
),
array(
'data' => t('User Id' ),
'data' => t('User Id' ),
'field' => 'user_id',
),
array(
'data' => t('Action' ),
'data' => t('Action' ),
'class' => 'action-column',
),
);
$sort_string = '';
$clouds = aws_cloud_get_all_clouds($sort_string);
$query = aws_cloud_get_all_clouds_query();
$query->extend('PagerDefault')
->extend('TableSort')
->orderByHeader($header);
$clouds = $query->execute();
$rows = array();
foreach ($clouds as $cloud) {
$action_data = cloud_display_action('images/edit', t('Edit'), 'admin/config/clouds/'
. $cloud['cloud_name'] . '/edit' , array('query' => array(), 'html' => TRUE));
. $cloud->cloud_name . '/edit' , array('query' => array(), 'html' => TRUE));
$action_data .= cloud_display_action('images/icon_delete', t('Delete'), 'admin/config/clouds/'
. $cloud['cloud_name'] . '/delete', array('query' => array(), 'html' => TRUE));
. $cloud->cloud_name . '/delete', array('query' => array(), 'html' => TRUE));
$row =
array('data' => array(
l($cloud['cloud_display_name'], 'admin/config/clouds/' . $cloud['cloud_name'] . '/edit'),
$cloud['cloud_name' ],
$cloud['host_uri' ],
$cloud['user_id' ],
l($cloud->cloud_display_name, 'admin/config/clouds/' . $cloud->cloud_name . '/edit'),
$cloud->cloud_name ,
$cloud->host_uri ,
$cloud->user_id ,
$action_data,
));
$rows[] = $row;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment