diff --git a/src/rm/RequestManagerVMTemplate.cc b/src/rm/RequestManagerVMTemplate.cc index 68b854a8fb..6c49a2ea5e 100644 --- a/src/rm/RequestManagerVMTemplate.cc +++ b/src/rm/RequestManagerVMTemplate.cc @@ -255,10 +255,7 @@ Request::ErrorCode VMTemplateInstantiate::merge( const string &str_uattrs, RequestAttributes& att) { - if (str_uattrs.empty()) - { - return SUCCESS; - } + int rc; @@ -270,11 +267,15 @@ Request::ErrorCode VMTemplateInstantiate::merge( if ( rc != 0 ) { return INTERNAL; + } + else if (uattrs.empty()) + { + return SUCCESS; } if (att.uid!=UserPool::ONEADMIN_ID && att.gid!=GroupPool::ONEADMIN_ID) { - if (uattrs.check_restricted(aname, tmpl)) + if (uattrs.check_restricted(aname, tmpl)) { att.resp_msg ="User Template includes a restricted attribute " + aname; diff --git a/src/sunstone/public/app/tabs/provision-tab.js b/src/sunstone/public/app/tabs/provision-tab.js index 2e106a5b07..56e8033dcc 100644 --- a/src/sunstone/public/app/tabs/provision-tab.js +++ b/src/sunstone/public/app/tabs/provision-tab.js @@ -926,6 +926,9 @@ define(function(require) { tab.on("click", "#provision_create_vm .provision_select_template .provision-pricing-table.only-one" , function(){ var create_vm_context = $("#provision_create_vm"); + var that = this; + + that.template_base_json = {}; if ($(this).hasClass("selected")){ //$(".provision_disk_selector", create_vm_context).html(""); @@ -954,6 +957,17 @@ define(function(require) { $("#provision_create_vm .provision_vmgroup").show(); $("#provision_create_vm .provision_ds").show(); + OpenNebulaTemplate.show({ + data : { + id: template_id, + extended: false + }, + timeout: true, + success: function (request, template_json) { + that.template_base_json= template_json; + } + }); + OpenNebula.Template.show({ data : { id: template_id, @@ -975,6 +989,7 @@ define(function(require) { pers = false; } DisksResize.insert({ + template_base_json: that.template_base_json, template_json: template_json, disksContext: disksContext, force_persistent: pers, diff --git a/src/sunstone/public/app/tabs/templates-tab/form-panels/instantiate.js b/src/sunstone/public/app/tabs/templates-tab/form-panels/instantiate.js index 4f065607d3..dbb44f3358 100644 --- a/src/sunstone/public/app/tabs/templates-tab/form-panels/instantiate.js +++ b/src/sunstone/public/app/tabs/templates-tab/form-panels/instantiate.js @@ -371,14 +371,29 @@ define(function(require) { this.selected_nodes = selected_nodes; this.template_objects = []; + this.template_base_objects = {}; var templatesContext = $(".list_of_templates", context); var idsLength = this.selected_nodes.length; var idsDone = 0; + $.each(this.selected_nodes, function(index, template_id) { + OpenNebulaTemplate.show({ + data : { + id: template_id, + extended: false + }, + timeout: true, + success: function (request, template_json) { + that.template_base_objects[template_json.VMTEMPLATE.ID] = template_json; + } + }); + }); + templatesContext.html(""); $.each(this.selected_nodes, function(index, template_id) { + OpenNebulaTemplate.show({ data : { id: template_id, @@ -463,6 +478,7 @@ define(function(require) { } DisksResize.insert({ + template_base_json: that.template_base_objects[template_json.VMTEMPLATE.ID], template_json: template_json, disksContext: $(".disksContext" + template_json.VMTEMPLATE.ID, context), force_persistent: $("input.instantiate_pers", context).prop("checked"), diff --git a/src/sunstone/public/app/utils/disks-resize.js b/src/sunstone/public/app/utils/disks-resize.js index 814dcc916d..e366009a5a 100644 --- a/src/sunstone/public/app/utils/disks-resize.js +++ b/src/sunstone/public/app/utils/disks-resize.js @@ -76,6 +76,16 @@ define(function(require){ disks = [template_disk] } + if (opts.template_base_json) { + var template_base_disk = opts.template_base_json.VMTEMPLATE.TEMPLATE.DISK + var disks_base = [] + if ($.isArray(template_base_disk)) { + disks_base = template_base_disk + } else if (!$.isEmptyObject(template_base_disk)) { + disks_base = [template_base_disk] + } + } + if (disks.length > 0) { disksContext.html(DisksResizeTemplate()); @@ -101,17 +111,23 @@ define(function(require){ var diskContext; $(".disksContainer", disksContext).html(""); - $.each(disks, function(disk_id, disk) { - diskContext = $( - '