diff --git a/src/sunstone/models/OpenNebulaJSON/HostJSON.rb b/src/sunstone/models/OpenNebulaJSON/HostJSON.rb index 94d88a07ec..fdc0280b42 100644 --- a/src/sunstone/models/OpenNebulaJSON/HostJSON.rb +++ b/src/sunstone/models/OpenNebulaJSON/HostJSON.rb @@ -26,10 +26,19 @@ module OpenNebulaJSON return host_hash end - self.allocate(host_hash['name'], + id = self.allocate(host_hash['name'], host_hash['im_mad'], host_hash['vm_mad'], host_hash['cluster_id'].to_i) + delete_values = ['name', 'im_mad', 'vm_mad', 'cluster_id'] + + template_str = hash_to_str(host_hash, delete_values) + if !template_str.nil? + params=Hash.new + params['template_raw'] = template_str + params['append'] = true + self.update(params) + end end def delete diff --git a/src/sunstone/models/OpenNebulaJSON/JSONUtils.rb b/src/sunstone/models/OpenNebulaJSON/JSONUtils.rb index 1071168461..6f8db308a3 100644 --- a/src/sunstone/models/OpenNebulaJSON/JSONUtils.rb +++ b/src/sunstone/models/OpenNebulaJSON/JSONUtils.rb @@ -113,5 +113,31 @@ module OpenNebulaJSON str end + + def hash_to_str(template_hash, delete_values) + for del in delete_values + template_hash.delete(del) + end + + if !template_hash.empty? + template_str = "" + template_hash.collect do |key,value| + if value.kind_of?(Array) + template_str << key.to_s.upcase << " = \[" + for obj in value + if obj.kind_of?(Hash) + obj.collect do |key,value| + template_str << key.to_s.upcase << " = \""<< value.to_s << "\"\n" + end + end + end + template_str << "\]\n" + else + template_str << key.to_s.upcase << " = \""<< value.to_s << "\"\n" + end + end + end + return template_str + end end end diff --git a/src/sunstone/public/app/tabs/hosts-tab/form-panels/create.js b/src/sunstone/public/app/tabs/hosts-tab/form-panels/create.js index ec5cd68860..003d8a7d48 100644 --- a/src/sunstone/public/app/tabs/hosts-tab/form-panels/create.js +++ b/src/sunstone/public/app/tabs/hosts-tab/form-panels/create.js @@ -119,25 +119,47 @@ define(function(require) { $("#host_type_mad", context).on("change", function() { $("#vmm_mad", context).val(this.value).change(); $("#im_mad", context).val(this.value).change(); + $(".vcenter_credentials", context).hide(); + $(".ec2_extra", context).hide(); + $(".drivers", context).hide(); + $("#name_container", context).show(); if (this.value == "custom") { - $(".vcenter_credentials", context).hide(); - $("#name_container", context).show(); Sunstone.showFormPanelSubmit(TAB_ID); $(".drivers", context).show(); } else if (this.value == "vcenter") { $("#name_container", context).hide(); $(".vcenter_credentials", context).show(); Sunstone.hideFormPanelSubmit(TAB_ID); - $(".drivers", context).hide(); - } else { - $(".vcenter_credentials", context).hide(); - $("#name_container", context).show(); + } else if (this.value == "ec2") { + $(".ec2_extra", context).show(); + Sunstone.showFormPanelSubmit(TAB_ID); + } else { Sunstone.showFormPanelSubmit(TAB_ID); - $(".drivers", context).hide(); } }); + context.off("click", ".add_custom_tag"); + context.on("click", ".add_custom_tag", function(){ + $("tbody.capacity_ec2", context).append( + "