diff --git a/src/sunstone/models/OpenNebulaJSON/TemplateJSON.rb b/src/sunstone/models/OpenNebulaJSON/TemplateJSON.rb index d49b9f0f8b..d0deb31ab1 100644 --- a/src/sunstone/models/OpenNebulaJSON/TemplateJSON.rb +++ b/src/sunstone/models/OpenNebulaJSON/TemplateJSON.rb @@ -70,14 +70,7 @@ module OpenNebulaJSON end def update(params=Hash.new) - template_hash = parse_json(params, 'vmtemplate') - if template_hash['template_raw'] - template = template_hash['template_raw'] - else - template = template_to_str(template_hash) - end - - super(template) + super(params['template_raw']) end def chown(params=Hash.new) diff --git a/src/sunstone/public/app/opennebula/template.js b/src/sunstone/public/app/opennebula/template.js index 9498d59652..73f2b166f0 100644 --- a/src/sunstone/public/app/opennebula/template.js +++ b/src/sunstone/public/app/opennebula/template.js @@ -51,7 +51,7 @@ define(function(require) { OpenNebulaAction.simple_action(params, RESOURCE, "chmod_from_provision", action_obj); }, "update" : function(params) { - var action_obj = params.data.extra_param; + var action_obj = {"template_raw" : params.data.extra_param}; OpenNebulaAction.simple_action(params, RESOURCE, "update", action_obj); }, "publish" : function(params) { diff --git a/src/sunstone/public/app/tabs/templates-tab/form-panels/create.js b/src/sunstone/public/app/tabs/templates-tab/form-panels/create.js index ce17a753b2..edba2f8d28 100644 --- a/src/sunstone/public/app/tabs/templates-tab/form-panels/create.js +++ b/src/sunstone/public/app/tabs/templates-tab/form-panels/create.js @@ -158,9 +158,7 @@ define(function(require) { {'vmtemplate': templateJSON}); return false; } else if (this.action == "update") { - Sunstone.runAction("Template.update", - this.resourceId, - JSON.stringify({'vmtemplate': templateJSON})); + Sunstone.runAction("Template.update", this.resourceId, TemplateUtils.templateToString(templateJSON)); return false; } } @@ -173,9 +171,7 @@ define(function(require) { return false; } else if (this.action == "update") { - Sunstone.runAction("Template.update", - this.resourceId, - JSON.stringify({"vmtemplate": {"template_raw": template}})); + Sunstone.runAction("Template.update", this.resourceId, template); return false; } }