diff --git a/src/sunstone/public/app/tabs/templates-tab/form-panels/create/wizard-tabs/os.js b/src/sunstone/public/app/tabs/templates-tab/form-panels/create/wizard-tabs/os.js index d230ef64e4..72c3789ac9 100644 --- a/src/sunstone/public/app/tabs/templates-tab/form-panels/create/wizard-tabs/os.js +++ b/src/sunstone/public/app/tabs/templates-tab/form-panels/create/wizard-tabs/os.js @@ -19,145 +19,146 @@ define(function(require) { DEPENDENCIES */ -// require('foundation.tab'); - var Config = require('sunstone-config'); - var Locale = require('utils/locale'); - var Tips = require('utils/tips'); - var WizardFields = require('utils/wizard-fields'); - var FilesTable = require('tabs/files-tab/datatable'); - var UniqueId = require('utils/unique-id'); - var OpenNebulaHost = require('opennebula/host'); + // require('foundation.tab'); + var Config = require("sunstone-config"); + var Locale = require("utils/locale"); + var Tips = require("utils/tips"); + var WizardFields = require("utils/wizard-fields"); + var FilesTable = require("tabs/files-tab/datatable"); + var UniqueId = require("utils/unique-id"); + var OpenNebulaHost = require("opennebula/host"); + /* TEMPLATES */ - var TemplateHTML = require('hbs!./os/html'); + var TemplateHTML = require("hbs!./os/html"); /* CONSTANTS */ - var WIZARD_TAB_ID = require('./os/wizardTabId'); + var WIZARD_TAB_ID = require("./os/wizardTabId"); var GUESTOS = [ - 'asianux3_64Guest', - 'asianux3Guest', - 'asianux4_64Guest', - 'asianux4Guest', - 'centos64Guest', - 'centosGuest', - 'darwin64Guest', - 'darwinGuest', - 'debian4_64Guest', - 'debian4Guest', - 'debian5_64Guest', - 'debian5Guest', - 'dosGuest', - 'eComStationGuest', - 'freebsd64Guest', - 'freebsdGuest', - 'mandriva64Guest', - 'mandrivaGuest', - 'netware4Guest', - 'netware5Guest', - 'netware6Guest', - 'nld9Guest', - 'oesGuest', - 'openServer5Guest', - 'openServer6Guest', - 'oracleLinux64Guest', - 'oracleLinuxGuest', - 'os2Guest', - 'other24xLinux64Guest', - 'other24xLinuxGuest', - 'other26xLinux64Guest', - 'other26xLinuxGuest', - 'otherGuest', - 'otherGuest64', - 'otherLinux64Guest', - 'otherLinuxGuest', - 'redhatGuest', - 'rhel2Guest', - 'rhel3_64Guest', - 'rhel3Guest', - 'rhel4_64Guest', - 'rhel4Guest', - 'rhel5_64Guest', - 'rhel5Guest', - 'rhel6_64Guest', - 'rhel6Guest', - 'sjdsGuest', - 'sles10_64Guest', - 'sles10Guest', - 'sles11_64Guest', - 'sles11Guest', - 'sles64Guest', - 'slesGuest', - 'solaris10_64Guest', - 'solaris10Guest', - 'solaris6Guest', - 'solaris7Guest', - 'solaris8Guest', - 'solaris9Guest', - 'suse64Guest', - 'suseGuest', - 'turboLinux64Guest', - 'turboLinuxGuest', - 'ubuntu64Guest', - 'ubuntuGuest', - 'unixWare7Guest', - 'win2000AdvServGuest', - 'win2000ProGuest', - 'win2000ServGuest', - 'win31Guest', - 'win95Guest', - 'win98Guest', - 'windows7_64Guest', - 'windows7Guest', - 'windows7Server64Guest', - 'winLonghorn64Guest', - 'winLonghornGuest', - 'winMeGuest', - 'winNetBusinessGuest', - 'winNetDatacenter64Guest', - 'winNetDatacenterGuest', - 'winNetEnterprise64Guest', - 'winNetEnterpriseGuest', - 'winNetStandard64Guest', - 'winNetStandardGuest', - 'winNetWebGuest', - 'winNTGuest', - 'winVista64Guest', - 'winVistaGuest', - 'winXPHomeGuest', - 'winXPPro64Guest', - 'winXPProGues' - ] + "asianux3_64Guest", + "asianux3Guest", + "asianux4_64Guest", + "asianux4Guest", + "centos64Guest", + "centosGuest", + "darwin64Guest", + "darwinGuest", + "debian4_64Guest", + "debian4Guest", + "debian5_64Guest", + "debian5Guest", + "dosGuest", + "eComStationGuest", + "freebsd64Guest", + "freebsdGuest", + "mandriva64Guest", + "mandrivaGuest", + "netware4Guest", + "netware5Guest", + "netware6Guest", + "nld9Guest", + "oesGuest", + "openServer5Guest", + "openServer6Guest", + "oracleLinux64Guest", + "oracleLinuxGuest", + "os2Guest", + "other24xLinux64Guest", + "other24xLinuxGuest", + "other26xLinux64Guest", + "other26xLinuxGuest", + "otherGuest", + "otherGuest64", + "otherLinux64Guest", + "otherLinuxGuest", + "redhatGuest", + "rhel2Guest", + "rhel3_64Guest", + "rhel3Guest", + "rhel4_64Guest", + "rhel4Guest", + "rhel5_64Guest", + "rhel5Guest", + "rhel6_64Guest", + "rhel6Guest", + "sjdsGuest", + "sles10_64Guest", + "sles10Guest", + "sles11_64Guest", + "sles11Guest", + "sles64Guest", + "slesGuest", + "solaris10_64Guest", + "solaris10Guest", + "solaris6Guest", + "solaris7Guest", + "solaris8Guest", + "solaris9Guest", + "suse64Guest", + "suseGuest", + "turboLinux64Guest", + "turboLinuxGuest", + "ubuntu64Guest", + "ubuntuGuest", + "unixWare7Guest", + "win2000AdvServGuest", + "win2000ProGuest", + "win2000ServGuest", + "win31Guest", + "win95Guest", + "win98Guest", + "windows7_64Guest", + "windows7Guest", + "windows7Server64Guest", + "winLonghorn64Guest", + "winLonghornGuest", + "winMeGuest", + "winNetBusinessGuest", + "winNetDatacenter64Guest", + "winNetDatacenterGuest", + "winNetEnterprise64Guest", + "winNetEnterpriseGuest", + "winNetStandard64Guest", + "winNetStandardGuest", + "winNetWebGuest", + "winNTGuest", + "winVista64Guest", + "winVistaGuest", + "winXPHomeGuest", + "winXPPro64Guest", + "winXPProGues" + ]; /* CONSTRUCTOR */ function WizardTab(opts) { - if (!Config.isTemplateCreationTabEnabled(opts.tabId, 'os_booting')) { + if (!Config.isTemplateCreationTabEnabled(opts.tabId, "os_booting")) { throw "Wizard Tab not enabled"; } this.wizardTabId = WIZARD_TAB_ID + UniqueId.id(); - this.icon = 'fa-power-off'; + this.icon = "fa-power-off"; this.title = Locale.tr("OS & CPU"); - this.classes = "hypervisor only_kvm" + this.classes = "hypervisor only_kvm"; this.kernelFilesTable = new FilesTable( this.wizardTabId + UniqueId.id(), - { 'select': true, - 'selectOptions': { + { "select": true, + "selectOptions": { "filter_fn": function(file) { return file.TYPE == 3; } // KERNEL } }); this.initrdFilesTable = new FilesTable( this.wizardTabId + UniqueId.id(), - { 'select': true, - 'selectOptions': { + { "select": true, + "selectOptions": { "filter_fn": function(file) { return file.TYPE == 4; } // RAMDISK } }); @@ -179,10 +180,10 @@ define(function(require) { function _html() { return TemplateHTML({ - 'uniqueId': UniqueId.id(), - 'guestOS': GUESTOS, - 'kernelFilesTableHTML': this.kernelFilesTable.dataTableHTML, - 'initrdFilesTableHTML': this.initrdFilesTable.dataTableHTML + "uniqueId": UniqueId.id(), + "guestOS": GUESTOS, + "kernelFilesTableHTML": this.kernelFilesTable.dataTableHTML, + "initrdFilesTableHTML": this.initrdFilesTable.dataTableHTML }); } @@ -191,7 +192,7 @@ define(function(require) { function _setup(context) { var that = this; - Foundation.reflow(context, 'tabs'); + Foundation.reflow(context, "tabs"); context.on("click", "button.boot-order-up", function(){ var tr = $(this).closest("tr"); @@ -218,39 +219,39 @@ define(function(require) { var kernelDSContext = $(".kernel_ds", context); var kernelDSInputsContext = $("#kernel_path_inputs", context); $("input[name='kernel_type']", context).change(function() { - if ($("input[name='kernel_type']:checked", context).val() == "kernel_ds") { + if ($("input[name='kernel_type']:checked", context).val() === "kernel_ds") { kernelDSContext.toggle(); kernelDSInputsContext.hide(); - $("[wizard_field]", kernelDSContext).prop('wizard_field_disabled', false); - $("[wizard_field]", kernelDSInputsContext).prop('wizard_field_disabled', true); + $("[wizard_field]", kernelDSContext).prop("wizard_field_disabled", false); + $("[wizard_field]", kernelDSInputsContext).prop("wizard_field_disabled", true); } else { kernelDSContext.hide(); kernelDSInputsContext.toggle(); - $("[wizard_field]", kernelDSInputsContext).prop('wizard_field_disabled', false); - $("[wizard_field]", kernelDSContext).prop('wizard_field_disabled', true); + $("[wizard_field]", kernelDSInputsContext).prop("wizard_field_disabled", false); + $("[wizard_field]", kernelDSContext).prop("wizard_field_disabled", true); } }); var initrdDSContext = $(".initrd_ds", context); var initrdDSInputsContext = $("#initrd_path_inputs", context); $("input[name='initrd_type']", context).change(function() { - if ($("input[name='initrd_type']:checked", context).val() == "initrd_ds") { + if ($("input[name='initrd_type']:checked", context).val() === "initrd_ds") { initrdDSContext.toggle(); initrdDSInputsContext.hide(); - $("[wizard_field]", initrdDSContext).prop('wizard_field_disabled', false); - $("[wizard_field]", initrdDSInputsContext).prop('wizard_field_disabled', true); + $("[wizard_field]", initrdDSContext).prop("wizard_field_disabled", false); + $("[wizard_field]", initrdDSInputsContext).prop("wizard_field_disabled", true); } else { initrdDSContext.hide(); initrdDSInputsContext.toggle(); - $("[wizard_field]", initrdDSInputsContext).prop('wizard_field_disabled', false); - $("[wizard_field]", initrdDSContext).prop('wizard_field_disabled', true); + $("[wizard_field]", initrdDSInputsContext).prop("wizard_field_disabled", false); + $("[wizard_field]", initrdDSContext).prop("wizard_field_disabled", true); } }); that.kernelFilesTable.initialize({ - 'selectOptions': { - 'select_callback': function(aData, options) { - $('#KERNEL_DS', context).val("$FILE[IMAGE_ID="+ aData[options.id_index] +"]"); + "selectOptions": { + "select_callback": function(aData, options) { + $("#KERNEL_DS", context).val("$FILE[IMAGE_ID="+ aData[options.id_index] +"]"); } } }); @@ -258,51 +259,50 @@ define(function(require) { that.initrdFilesTable.initialize({ - 'selectOptions': { - 'select_callback': function(aData, options) { - $('#INITRD_DS', context).val("$FILE[IMAGE_ID="+ aData[options.id_index] +"]"); + "selectOptions": { + "select_callback": function(aData, options) { + $("#INITRD_DS", context).val("$FILE[IMAGE_ID="+ aData[options.id_index] +"]"); } } }); that.initrdFilesTable.refreshResourceTableSelect(); fillMachineTypesAndCPUModel(); + } - function fillMachineTypesAndCPUModel(){ + function fillMachineTypesAndCPUModel(cpuModel, machineType){ OpenNebulaHost.kvmInfo({ data : {}, timeout: true, success: function (request, kvmInfo){ - var m = $("#machine-type").html(); - if (m === undefined){ + if ($("#model-cpu").html() === undefined){ machines = kvmInfo[0].set_kvm_machines; cpus = kvmInfo[0].set_cpu_models; var html = "'; - + html += ""; $("#kvm-info").append(html); - var html = ""; $("#cpu-model").append(html); } + + if (machineType && machineType.MACHINE){ $("#machine-type").val(machineType.MACHINE); } + if (cpuModel){ $("#model-cpu").val(cpuModel.MODEL); } }, error: function(request, error_json){ - console.error("There was an error requesting the KVM info: "+ + console.error("There was an error requesting the KVM info: " + error_json.error.message); } }); @@ -310,10 +310,10 @@ define(function(require) { function _retrieve(context) { var templateJSON = {}; - var osJSON = {} - $.extend(osJSON, WizardFields.retrieve('.bootTab', context)); - $.extend(osJSON, WizardFields.retrieve('.kernelTab', context)); - $.extend(osJSON, WizardFields.retrieve('.ramdiskTab', context)); + var osJSON = {}; + $.extend(osJSON, WizardFields.retrieve(".bootTab", context)); + $.extend(osJSON, WizardFields.retrieve(".kernelTab", context)); + $.extend(osJSON, WizardFields.retrieve(".ramdiskTab", context)); var boot = _retrieveBootValue(context); @@ -323,49 +323,47 @@ define(function(require) { osJSON["BOOT"] = ""; } - if (!$.isEmptyObject(osJSON)) { templateJSON['OS'] = osJSON; }; + if (!$.isEmptyObject(osJSON)) { templateJSON["OS"] = osJSON; }; - var featuresJSON = WizardFields.retrieve('.featuresTab', context) - if (!$.isEmptyObject(featuresJSON)) { templateJSON['FEATURES'] = featuresJSON; }; + var featuresJSON = WizardFields.retrieve(".featuresTab", context); + if (!$.isEmptyObject(featuresJSON)) { templateJSON["FEATURES"] = featuresJSON; }; - var cpuModelJSON = WizardFields.retrieve('.cpuTab', context); - if (!$.isEmptyObject(cpuModelJSON)) { templateJSON['CPU_MODEL'] = cpuModelJSON; }; + var cpuModelJSON = WizardFields.retrieve(".cpuTab", context); + if (!$.isEmptyObject(cpuModelJSON)) { templateJSON["CPU_MODEL"] = cpuModelJSON; }; return templateJSON; } function _fill(context, templateJSON) { - var osJSON = templateJSON['OS']; + var osJSON = templateJSON["OS"]; + var modelJSON = templateJSON["CPU_MODEL"]; if (osJSON) { - if (osJSON['KERNEL_DS'] == undefined && osJSON['KERNEL'] != undefined){ - $('input[value="kernel_path"]', context).click(); + if (osJSON["KERNEL_DS"] === undefined && osJSON["KERNEL"] !== undefined){ + $("input[value=\"kernel_path\"]", context).click(); } - if (osJSON['INITRD_DS'] == undefined && osJSON['INITRD'] != undefined){ - $('input[value="initrd_path"]', context).click(); + if (osJSON["INITRD_DS"] === undefined && osJSON["INITRD"] !== undefined){ + $("input[value=\"initrd_path\"]", context).click(); } WizardFields.fill(context, osJSON); - if (osJSON && osJSON['BOOT']) { - _fillBootValue(context, osJSON['BOOT']); + if (osJSON && osJSON["BOOT"]) { + _fillBootValue(context, osJSON["BOOT"]); } - - delete templateJSON['OS']; } - var featuresJSON = templateJSON['FEATURES']; + var featuresJSON = templateJSON["FEATURES"]; if (featuresJSON) { WizardFields.fill(context, featuresJSON); - delete templateJSON['FEATURES']; + delete templateJSON["FEATURES"]; } - var cpuModelJSON = templateJSON['CPU_MODEL']; - if (cpuModelJSON) { - WizardFields.fill(context, cpuModelJSON); - delete templateJSON['CPU_MODEL']; - } + fillMachineTypesAndCPUModel(modelJSON, osJSON); + + delete templateJSON["OS"]; + delete templateJSON["CPU_MODEL"]; } //---------------------------------------------------------------------------- @@ -391,20 +389,20 @@ define(function(require) { } }); - table.attr("value", devices.join(',')); + table.attr("value", devices.join(",")); } function _addBootRow(context, value, label) { $("table.boot-order tbody", context).append( - '