Skip to content
Snippets Groups Projects
Commit f700afe4 authored by baldwinlouie's avatar baldwinlouie
Browse files

Issue #1924120 by baldwinlouie: Implemented...

Issue #1924120 by baldwinlouie: Implemented cloud_metering_cloud_server_template_delete() and cloud_metering_aws_cloud_terminate_instance() to clean up the db
parent 2f4e35c1
No related branches found
No related tags found
No related merge requests found
......@@ -1393,7 +1393,7 @@ function _cloud_metering_validate_template_budget($form, &$form_state) {
$form_values = $form_state['values'];
$initial_budget = $form_values['initial_budget'];
$threshold = $form_values['cost_threshold'];
$instance_id = isset($form_values['instance_id']) ? $instance_id : 0;
$instance_id = isset($form_values['instance_id']) ? $form_values['instance_id'] : 0;
// check some initial entry
if (!is_numeric($initial_budget)) {
......@@ -1644,15 +1644,17 @@ function _cloud_metering_check_launch($template_id, $cloud_context) {
}
}
}
if ($launch) {
return cloud_perform_action($template_id, 'launch', $cloud_context);
}
}
else {
drupal_set_message(t('Failed to launch instance. The server template could not be found.', 'error'));
drupal_goto( CLOUD_SERVER_TEMPLATES_PATH . '/list/' . $cloud_context );
}
}
if ($launch) {
return cloud_perform_action($template_id, 'launch', $cloud_context);
}
else {
drupal_goto( CLOUD_SERVER_TEMPLATES_PATH . '/list/' . $cloud_context );
}
}
/**
......
......@@ -4,6 +4,7 @@ package = Cloud
dependencies[] = cloud
dependencies[] = cloud_pricing
dependencies[] = cloud_billing
dependencies[] = cloud_server_templates
core = 7.x
; Information added by drupal.org packaging script on 2011-12-22
......
......@@ -335,3 +335,18 @@ function cloud_metering_menu_alter(&$items) {
}
}
/**
* Implementation of hook_cloud_server_template_delete()
*/
function cloud_metering_cloud_server_template_delete($template_id, $cloud_context) {
_cloud_metering_delete_template_budget($template_id);
}
/**
* Implementation of hook_aws_ec2_terminate_instance()
*/
function cloud_metering_aws_cloud_terminate_instance($cloud_context, $instance_id) {
_cloud_metering_instance_budget_delete($cloud_context, $instance_id);
}
......@@ -117,6 +117,18 @@ function _cloud_metering_delete_cloud_data($cloud_context) {
->execute();
}
/**
* Delete an instance_id from the
* @param unknown_type $cloud_context
* @param unknown_type $instance_id
*/
function _cloud_metering_instance_budget_delete($cloud_context, $instance_id) {
db_delete(CLOUD_METERING_INSTANCES_BUDGET_TABLE)
->condition('instance_id', $instance_id)
->condition('cloud_context', $cloud_context)
->execute();
}
/**
* Update instance budget data
* @param string cloud_context
......@@ -233,6 +245,15 @@ function _cloud_metering_get_template_budget($template_id) {
return $return;
}
/**
* Delete template budget given a template_id
*/
function _cloud_metering_delete_template_budget($template_id) {
db_delete(CLOUD_METERING_TEMPLATES_BUDGET_TABLE)
->condition('template_id', $template_id)
->execute();
}
/**
* Update template budget
* @param int template_id
......
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