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 31d7087fe4..3dcb1d75aa 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 @@ -35,6 +35,7 @@ define(function(require) { var VcenterVMFolder = require('utils/vcenter-vm-folder'); var CapacityInputs = require('tabs/templates-tab/form-panels/create/wizard-tabs/general/capacity-inputs'); var Config = require('sunstone-config'); + var HostsTable = require('tabs/hosts-tab/datatable'); /* CONSTANTS @@ -172,11 +173,15 @@ define(function(require) { var networks = NicsSection.retrieve($(".nicsContext" + template_id, context)); var vmgroup = VMGroupSection.retrieve($(".vmgroupContext"+ template_id)); - if(vmgroup){ $.extend(tmp_json, vmgroup); } + var sched = WizardFields.retrieveInput($("#SCHED_REQUIREMENTS" + template_id, context)); + if(sched){ + tmp_json.SCHED_REQUIREMENTS = sched; + } + var nics = []; var pcis = []; @@ -261,13 +266,35 @@ define(function(require) { timeout: true, success: function (request, template_json) { that.template_objects.push(template_json); + var options = { + 'select': true, + 'selectOptions': { + 'multiple_choice': true + } + } + that.hostsTable = new HostsTable('HostsTable' + template_json.VMTEMPLATE.ID, options); templatesContext.append( TemplateRowHTML( { element: template_json.VMTEMPLATE, - capacityInputsHTML: CapacityInputs.html() + capacityInputsHTML: CapacityInputs.html(), + hostsDatatable: that.hostsTable.dataTableHTML }) ); + $(".provision_host_selector" + template_json.VMTEMPLATE.ID, context).data("hostsTable", that.hostsTable); + var selectOptions = { + 'selectOptions': { + 'select_callback': function(aData, options) { + generateRequirements($(".provision_host_selector" + template_json.VMTEMPLATE.ID, context).data("hostsTable"), context, template_json.VMTEMPLATE.ID); + }, + 'unselect_callback': function(aData, options) { + generateRequirements($(".provision_host_selector"+ template_json.VMTEMPLATE.ID, context).data("hostsTable"), context, template_json.VMTEMPLATE.ID); + } + } + } + that.hostsTable.initialize(selectOptions); + that.hostsTable.refreshResourceTableSelect(); + DisksResize.insert({ template_json: template_json, disksContext: $(".disksContext" + template_json.VMTEMPLATE.ID, context), @@ -356,4 +383,21 @@ define(function(require) { Tips.setup(context); return false; } + function generateRequirements(hosts_table, context, id) { + var req_string=[]; + //var req_ds_string=[]; + var selected_hosts = hosts_table.retrieveResourceTableSelect(); + //var selected_ds = this.datastoresTable.retrieveResourceTableSelect(); + + $.each(selected_hosts, function(index, hostId) { + req_string.push('ID="'+hostId+'"'); + }); + + /*$.each(selected_ds, function(index, dsId) { + req_ds_string.push('ID="'+dsId+'"'); + });*/ + + $('#SCHED_REQUIREMENTS' + id, context).val(req_string.join(" | ")); + //$('#SCHED_DS_REQUIREMENTS', context).val(req_ds_string.join(" | ")); + }; }); diff --git a/src/sunstone/public/app/tabs/templates-tab/form-panels/instantiate/templateRow.hbs b/src/sunstone/public/app/tabs/templates-tab/form-panels/instantiate/templateRow.hbs index 835e5c93ba..9ea6dd7639 100644 --- a/src/sunstone/public/app/tabs/templates-tab/form-panels/instantiate/templateRow.hbs +++ b/src/sunstone/public/app/tabs/templates-tab/form-panels/instantiate/templateRow.hbs @@ -66,6 +66,25 @@ + +