$.each(["memory","cpu","vcpu"], function(i,classname){ var name = classname.toUpperCase(); if (userInputsJSON[name] != undefined){ var attr = UserInputs.unmarshall(userInputsJSON[name]); $("."+classname+"_modify_type", context).val(attr.type).change(); if (attr.type == "range" || attr.type == "range-float"){ var values = attr.params.split(".."); // "2..8" if (values.length == 2){ var param_context = $("div."+classname+"_modify_opt."+attr.type, context); $("input.user_input_params_min", param_context).val(values[0]).trigger("input"); $("input.user_input_params_max", param_context).val(values[1]).trigger("input"); } else { console.error('Wrong user input parameters for "'+name+'". Expected "MIN..MAX", received "'+attr.params+'"'); } } else if (attr.type == "list"){ $("input."+classname+"_modify_opt."+attr.type, context).val(attr.params).trigger("input"); } delete userInputsJSON[name]; } });
$.each(elements, function(id, element) { var opts = {}; if (element.ds && element.ds !== '') { opts.datastore = UserInputs.unmarshall(element.ds); } if (element.rp && element.rp !== '') { opts.resourcePool = UserInputs.unmarshall(element.rp); } opts.data = element; var trow = $(RowTemplate(opts)).appendTo(tbody); $('.check_item', trow).data("import_data", element); });
var rowCallback = function(row, data, index) { var opts = {}; if (data.ds && data.ds !== '') { opts.datastore = UserInputs.unmarshall(data.ds); } if (data.rp && data.rp !== '') { opts.resourcePool = UserInputs.unmarshall(data.rp); } opts.data = data; var templateRow = $(RowTemplate(opts)).appendTo($('#' + tableId)); $('.check_item', templateRow).data("template_name", data.name) $('.check_item', templateRow).data("one_template", data.one); return row; }
$.each(elements, function(id, element) { var opts = {}; opts.data = element; opts.id = UniqueId.id(); if (element.rp && element.rp !== '') { opts.resourcePool = UserInputs.unmarshall(element.rp); opts.resourcePool.params = opts.resourcePool.params.split(","); /* $.each(opts.resourcePool.params, function(){ $("#available_rps_" + opts.id + " [value ='" + this + "']").mousedown(function(e) { e.preventDefault(); $(this).prop('selected', !$(this).prop('selected')); return false; }); });*/ } var trow = $(RowTemplate(opts)).appendTo(tbody); Tips.setup(trow); $("#modify_rp_" + opts.id).change(function(){ var val = $("#modify_rp_" + opts.id).val(); if (val == "default"){ $("#div_rp_" + opts.id).hide(); } else if (val == "fixed"){ $("#div_rp_" + opts.id).show(); $("#available_rps_" + opts.id).attr("multiple", false); } else { $("#div_rp_" + opts.id).show(); $("#available_rps_" + opts.id).attr("multiple", true); } }); $("#linked_clone_"+opts.id).on("change", function(){ if ($("#linked_clone_"+opts.id).is(":checked")){ $("#create_"+opts.id).show(); } else { $("#create_"+opts.id).hide(); $("#create_copy_"+opts.id).prop("checked", false); $("#name_"+opts.id).hide(); } }); $("#create_copy_"+opts.id).on("change", function(){ if ($("#create_copy_"+opts.id).is(":checked")){ $("#name_"+opts.id).show(); } else { $("#name_"+opts.id).hide(); } }); $('.check_item', trow).data("import_data", element); });
$.each(response, function(template_name, element){ var opts = {}; opts.data = element; opts.id = UniqueId.id(); if (element.rp && element.rp !== "") { opts.resourcePool = UserInputs.unmarshall(element.rp); opts.resourcePool.params = opts.resourcePool.params.split(","); } var trow = $(RowTemplate(opts)).appendTo(tbody); Tips.setup(trow); setupAdvanced(opts, trow); $(".check_item", trow).data("import_data", element); });
function _fill(context, templateJSON) { if (templateJSON['MEMORY_COST'] && templateJSON['MEMORY_UNIT_COST'] && templateJSON['MEMORY_UNIT_COST'] == "GB") { templateJSON['MEMORY_COST'] = templateJSON['MEMORY_COST'] * 1024; } if (templateJSON['DISK_COST']) { templateJSON['DISK_COST'] = templateJSON['DISK_COST'] * 1024; } that.templateDISKS = $.extend(true, {}, templateJSON.DISK); localStorage.setItem("disksJSON", JSON.stringify(that.templateDISKS)); var sunstone_template = templateJSON.SUNSTONE; if (sunstone_template) { if (sunstone_template["NETWORK_SELECT"] && sunstone_template["NETWORK_SELECT"].toUpperCase() == "NO") { $("#sunstone_network_select", context).attr("checked", "checked"); } delete sunstone_template["NETWORK_SELECT"]; } if (Config.isFeatureEnabled("vcenter_vm_folder")) { if (templateJSON["HYPERVISOR"] == 'vcenter' && templateJSON["VCENTER_VM_FOLDER"]) { WizardFields.fillInput($("#vcenter_vm_folder", context), templateJSON["VCENTER_VM_FOLDER"]); } } else { $(".vcenter_vm_folder_input", context).remove(); } delete templateJSON["VCENTER_VM_FOLDER"]; if (templateJSON["HYPERVISOR"] == 'vcenter') { var publicClouds = templateJSON["PUBLIC_CLOUD"]; if (publicClouds != undefined) { if (!$.isArray(publicClouds)){ publicClouds = [publicClouds]; } $.each(publicClouds, function(){ if(this["TYPE"] == "vcenter"){ WizardFields.fillInput($("#vcenter_template_ref", context), this["VCENTER_TEMPLATE_REF"]); return false; } }); } } // LXD specific attributes if (templateJSON["HYPERVISOR"] == 'lxd') { fillLXD(context, templateJSON) } if (templateJSON["HYPERVISOR"]) { $("input[name='hypervisor'][value='"+templateJSON["HYPERVISOR"]+"']", context).trigger("click") delete templateJSON["HYPERVISOR"]; } if (templateJSON["USER_INPUTS"]) { if (templateJSON["USER_INPUTS"]["VCENTER_RESOURCE_POOL"]) { var rp = UserInputs.unmarshall(templateJSON["USER_INPUTS"]["VCENTER_RESOURCE_POOL"]); $('.modify_rp', context).val('list'); $('.initial_rp', context).val(rp.initial); $('.available_rps', context).val(rp.params); delete templateJSON["USER_INPUTS"]["VCENTER_RESOURCE_POOL"]; } } if (templateJSON["VCENTER_RESOURCE_POOL"]) { $('.modify_rp', context).val('fixed'); WizardFields.fillInput($('.initial_rp', context), templateJSON["VCENTER_RESOURCE_POOL"]); delete templateJSON["VCENTER_RESOURCE_POOL"]; } if (templateJSON["VCENTER_TEMPLATE_REF"]){ WizardFields.fillInput($("#vcenter_template_ref", context), templateJSON["VCENTER_TEMPLATE_REF"]); delete templateJSON["VCENTER_TEMPLATE_REF"]; } if (templateJSON["VCENTER_CCR_REF"]){ WizardFields.fillInput($("#vcenter_ccr_ref", context), templateJSON["VCENTER_CCR_REF"]); delete templateJSON["VCENTER_CCR_REF"]; } if (templateJSON["VCENTER_INSTANCE_ID"]){ WizardFields.fillInput($("#vcenter_instance_id", context), templateJSON["VCENTER_INSTANCE_ID"]); delete templateJSON["VCENTER_INSTANCE_ID"]; } CapacityCreate.fill($("div.capacityCreate", context), templateJSON); if (templateJSON["AS_UID"]){ var asuidJSON = templateJSON["AS_UID"]; var selectedResources = { ids : asuidJSON }; this.usersTable.selectResourceTableSelect(selectedResources); delete templateJSON["AS_UID"]; } if (templateJSON["AS_GID"]){ var asgidJSON = templateJSON["AS_GID"]; var selectedResources = { ids : asgidJSON }; this.groupTable.selectResourceTableSelect(selectedResources); delete templateJSON["AS_GID"]; } WizardFields.fill(context, templateJSON); }
function _fill(context, templateJSON) { var sunstone_template = templateJSON.SUNSTONE; if (sunstone_template) { if (sunstone_template["NETWORK_SELECT"] && sunstone_template["NETWORK_SELECT"].toUpperCase() == "NO") { $("#sunstone_network_select", context).attr("checked", "checked"); } delete sunstone_template["NETWORK_SELECT"]; } if (templateJSON["HYPERVISOR"] == 'vcenter' && templateJSON["KEEP_DISKS_ON_DONE"] && templateJSON["KEEP_DISKS_ON_DONE"].toLowerCase() == "yes" ) { $("#KEEP_DISKS", context).attr("checked", "checked"); } delete templateJSON["KEEP_DISKS_ON_DONE"]; if (templateJSON["HYPERVISOR"] == 'vcenter') { var publicClouds = templateJSON["PUBLIC_CLOUD"]; if (publicClouds != undefined) { if (!$.isArray(publicClouds)){ publicClouds = [publicClouds]; } $.each(publicClouds, function(){ if(this["TYPE"] == "vcenter"){ WizardFields.fillInput($("#vcenter_template_uuid", context), this["VM_TEMPLATE"]); return false; } }); } } if (templateJSON["HYPERVISOR"]) { $("input[name='hypervisor'][value='"+templateJSON["HYPERVISOR"]+"']", context).trigger("click") delete templateJSON["HYPERVISOR"]; } if (templateJSON["USER_INPUTS"]) { if (templateJSON["USER_INPUTS"]["VCENTER_DATASTORE"]) { var ds = UserInputs.unmarshall(templateJSON["USER_INPUTS"]["VCENTER_DATASTORE"]); $('.modify_datastore', context).val('list'); $('.initial_datastore', context).val(ds.initial); $('.available_datastores', context).val(ds.params); } if (templateJSON["USER_INPUTS"]["RESOURCE_POOL"]) { var rp = UserInputs.unmarshall(templateJSON["USER_INPUTS"]["RESOURCE_POOL"]); $('.modify_rp', context).val('list'); $('.initial_rp', context).val(rp.initial); $('.available_rps', context).val(rp.params); } } if (templateJSON["VCENTER_DATASTORE"]) { $('.modify_datastore', context).val('fixed'); WizardFields.fillInput($('.initial_datastore', context), templateJSON["VCENTER_DATASTORE"]); } if (templateJSON["RESOURCE_POOL"]) { $('.modify_rp', context).val('fixed'); WizardFields.fillInput($('.initial_rp', context), templateJSON["RESOURCE_POOL"]); } CapacityCreate.fill($("div.capacityCreate", context), templateJSON); WizardFields.fill(context, templateJSON); }
function _fill(context, templateJSON) { var sunstone_template = templateJSON.SUNSTONE; if(templateJSON["MEMORY_UNIT_COST"] =="GB") templateJSON["MEMORY_COST"] = templateJSON["MEMORY_COST"] / 1024; if (sunstone_template) { if (sunstone_template["NETWORK_SELECT"] && sunstone_template["NETWORK_SELECT"].toUpperCase() == "NO") { $("#sunstone_network_select", context).attr("checked", "checked"); } delete sunstone_template["NETWORK_SELECT"]; } if (Config.isFeatureEnabled("vcenter_vm_folder")) { if (templateJSON["HYPERVISOR"] == 'vcenter' && templateJSON["VCENTER_VM_FOLDER"]) { WizardFields.fillInput($("#vcenter_vm_folder", context), templateJSON["VCENTER_VM_FOLDER"]); } } else { $(".vcenter_vm_folder_input", context).remove(); } delete templateJSON["VCENTER_VM_FOLDER"]; if (templateJSON["HYPERVISOR"] == 'vcenter') { var publicClouds = templateJSON["PUBLIC_CLOUD"]; if (publicClouds != undefined) { if (!$.isArray(publicClouds)){ publicClouds = [publicClouds]; } $.each(publicClouds, function(){ if(this["TYPE"] == "vcenter"){ WizardFields.fillInput($("#vcenter_template_ref", context), this["VCENTER_TEMPLATE_REF"]); return false; } }); } } if (templateJSON["HYPERVISOR"]) { $("input[name='hypervisor'][value='"+templateJSON["HYPERVISOR"]+"']", context).trigger("click") delete templateJSON["HYPERVISOR"]; } if (templateJSON["USER_INPUTS"]) { if (templateJSON["USER_INPUTS"]["VCENTER_RESOURCE_POOL"]) { var rp = UserInputs.unmarshall(templateJSON["USER_INPUTS"]["VCENTER_RESOURCE_POOL"]); $('.modify_rp', context).val('list'); $('.initial_rp', context).val(rp.initial); $('.available_rps', context).val(rp.params); delete templateJSON["USER_INPUTS"]["VCENTER_RESOURCE_POOL"]; } } if (templateJSON["VCENTER_RESOURCE_POOL"]) { $('.modify_rp', context).val('fixed'); WizardFields.fillInput($('.initial_rp', context), templateJSON["VCENTER_RESOURCE_POOL"]); delete templateJSON["VCENTER_RESOURCE_POOL"]; } if(templateJSON["VCENTER_TEMPLATE_REF"]){ WizardFields.fillInput($("#vcenter_template_ref", context), templateJSON["VCENTER_TEMPLATE_REF"]); delete templateJSON["VCENTER_TEMPLATE_REF"]; } if(templateJSON["VCENTER_CCR_REF"]){ WizardFields.fillInput($("#vcenter_ccr_ref", context), templateJSON["VCENTER_CCR_REF"]); delete templateJSON["VCENTER_CCR_REF"]; } if(templateJSON["VCENTER_INSTANCE_ID"]){ WizardFields.fillInput($("#vcenter_instance_id", context), templateJSON["VCENTER_INSTANCE_ID"]); delete templateJSON["VCENTER_INSTANCE_ID"]; } CapacityCreate.fill($("div.capacityCreate", context), templateJSON); WizardFields.fill(context, templateJSON); }