1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-03-16 22:50:10 +03:00

Feature #3748: Delete Template from Cloud View now deletes all the images

This commit is contained in:
Tino Vazquez 2015-07-21 14:06:41 +02:00
parent ca60bcb904
commit 8ef32e5676
3 changed files with 28 additions and 38 deletions

View File

@ -50,6 +50,8 @@ module OpenNebulaJSON
when "instantiate" then self.instantiate(action_hash['params'])
when "clone" then self.clone(action_hash['params'])
when "rename" then self.rename(action_hash['params'])
when "delete_from_provision"
then self.delete_from_provision(action_hash['params'])
else
error_msg = "#{action_hash['perform']} action not " <<
" available for this resource"
@ -115,5 +117,21 @@ module OpenNebulaJSON
def rename(params=Hash.new)
super(params['name'])
end
def delete_from_provision(params=Hash.new)
# Delete associated images
self.each("TEMPLATE/DISK/IMAGE_ID"){|image_id|
img = OpenNebula::Image.new_with_id(image_id.text, @client)
rc = img.delete
if OpenNebula::is_error?(rc)
error_msg = "Some of the resources associated with " <<
"this template couldn't be deleted. Error: " << rc.message
return OpenNebula::Error.new(error_msg)
end
}
# Delete template
self.delete
end
end
end

View File

@ -11,6 +11,9 @@ define(function(require) {
"del" : function(params) {
OpenNebulaAction.del(params, RESOURCE);
},
"delete_from_provision": function(params) {
OpenNebulaAction.simple_action(params, RESOURCE, "delete_from_provision");
},
"list" : function(params) {
OpenNebulaAction.list(params, RESOURCE);
},

View File

@ -222,7 +222,6 @@ define(function(require) {
context.on("click", ".provision_confirm_delete_template_button", function(){
var ul_context = $(this).parents(".provision-pricing-table");
var template_id = ul_context.attr("opennebula_id");
var image_id = ul_context.attr("saved_to_image_id");
var template_name = $(".provision-title", ul_context).text();
$(".provision_confirm_delete_template_div", context).html(
@ -236,7 +235,7 @@ define(function(require) {
'</span>'+
'</div>'+
'<div class="large-3 columns">'+
'<a href"#" class="provision_delete_template_button alert button large-12 radius right" style="margin-right: 15px" image_id="'+image_id+'" template_id="'+template_id+'">'+Locale.tr("Delete")+'</a>'+
'<a href"#" class="provision_delete_template_button alert button large-12 radius right" style="margin-right: 15px" template_id="'+template_id+'">'+Locale.tr("Delete")+'</a>'+
'</div>'+
'</div>'+
'<a href="#" class="close">&times;</a>'+
@ -244,55 +243,25 @@ define(function(require) {
});
context.on("click", ".provision_delete_template_button", function(){
/* TODO SAVED_TO_IMAGE_ID does not exists anymore and now all the images of the template
are cloned instead of only the main disk, therefore all the images should be deleted now.
Probably this could be done in the core
var button = $(this);
button.attr("disabled", "disabled");
var template_id = $(this).attr("template_id");
var image_id = $(this).attr("image_id");
OpenNebula.Image.del({
OpenNebula.Template.delete_from_provision({
timeout: true,
data : {
id : image_id
id : template_id
},
success: function (){
OpenNebula.Template.del({
timeout: true,
data : {
id : template_id
},
success: function (){
$(".provision_templates_list_refresh_button", context).trigger("click");
},
error: function (request,error_json, container) {
Notifier.onError(request, error_json, container);
}
})
$(".provision_templates_list_refresh_button", context).trigger("click");
},
error: function (request,error_json, container) {
if (error_json.error.http_status=="404") {
OpenNebula.Template.del({
timeout: true,
data : {
id : template_id
},
success: function (){
$(".provision_templates_list_refresh_button", context).trigger("click");
},
error: function (request,error_json, container) {
Notifier.onError(request, error_json, container);
$(".provision_templates_list_refresh_button", context).trigger("click");
}
})
} else {
Notifier.onError(request, error_json, container);
}
Notifier.onError(request, error_json, container);
$(".provision_templates_list_refresh_button", context).trigger("click");
}
})*/
})
});
}