diff --git a/src/sunstone/public/app/tabs/templates-tab/form-panels/create/wizard-tabs/scheduling.js b/src/sunstone/public/app/tabs/templates-tab/form-panels/create/wizard-tabs/scheduling.js index e69fdcba83..88dbbfbe66 100644 --- a/src/sunstone/public/app/tabs/templates-tab/form-panels/create/wizard-tabs/scheduling.js +++ b/src/sunstone/public/app/tabs/templates-tab/form-panels/create/wizard-tabs/scheduling.js @@ -27,6 +27,7 @@ define(function(require) { var TemplateUtils = require('utils/template-utils'); var HostsTable = require('tabs/hosts-tab/datatable'); var ClustersTable = require('tabs/clusters-tab/datatable'); + var DatastoresTable = require('tabs/datastores-tab/datatable'); var UniqueId = require('utils/unique-id'); /* @@ -62,6 +63,7 @@ define(function(require) { } this.hostsTable = new HostsTable('HostsTable' + UniqueId.id(), options); this.clustersTable = new ClustersTable('ClustersTable' + UniqueId.id(), options); + this.datastoresTable = new DatastoresTable('DatastoresTable' + UniqueId.id(), options); } WizardTab.prototype.constructor = WizardTab; @@ -81,7 +83,8 @@ define(function(require) { function _html() { return TemplateHTML({ 'hostsTableSelectHTML': this.hostsTable.dataTableHTML, - 'clustersTableSelectHTML': this.clustersTable.dataTableHTML + 'clustersTableSelectHTML': this.clustersTable.dataTableHTML, + 'dsTableSelectHTML': this.datastoresTable.dataTableHTML }); } @@ -125,6 +128,8 @@ define(function(require) { that.hostsTable.refreshResourceTableSelect(); that.clustersTable.initialize(selectOptions); that.clustersTable.refreshResourceTableSelect(); + that.datastoresTable.initialize(selectOptions); + that.datastoresTable.refreshResourceTableSelect(); } function _retrieve(context) { @@ -132,7 +137,6 @@ define(function(require) { } function _fill(context, templateJSON) { - WizardFields.fill(context, templateJSON); var reqJSON = templateJSON['SCHED_REQUIREMENTS']; if (reqJSON) { @@ -163,16 +167,22 @@ define(function(require) { } this.clustersTable.selectResourceTableSelect(selectedResources); - - delete templateJSON['SCHED_REQUIREMENTS']; } var dsReqJSON = templateJSON['SCHED_DS_REQUIREMENTS']; if (dsReqJSON) { var dsReq = TemplateUtils.escapeDoubleQuotes(dsReqJSON); - delete templateJSON['SCHED_DS_REQUIREMENTS']; - } + var ds_id_regexp = /(\s|\||\b)ID=\\"([0-9]+)\\"/g; + var ds = []; + while (match = ds_id_regexp.exec(dsReq)) { + ds.push(match[2]) + } + var selectedResources = { + ids : ds + } + this.datastoresTable.selectResourceTableSelect(selectedResources); + } var rankJSON = templateJSON["SCHED_RANK"]; if (rankJSON) { @@ -207,12 +217,16 @@ define(function(require) { delete templateJSON["SCHED_DS_RANK"]; } + + WizardFields.fill(context, templateJSON); } function _generateRequirements(context) { var req_string=[]; + var req_ds_string=[]; var selected_hosts = this.hostsTable.retrieveResourceTableSelect(); var selected_clusters = this.clustersTable.retrieveResourceTableSelect(); + var selected_ds = this.datastoresTable.retrieveResourceTableSelect(); $.each(selected_hosts, function(index, hostId) { req_string.push('ID="'+hostId+'"'); @@ -222,6 +236,11 @@ define(function(require) { req_string.push('CLUSTER_ID="'+clusterId+'"'); }); + $.each(selected_ds, function(index, dsId) { + req_ds_string.push('ID="'+dsId+'"'); + }); + $('#SCHED_REQUIREMENTS', 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/create/wizard-tabs/scheduling/html.hbs b/src/sunstone/public/app/tabs/templates-tab/form-panels/create/wizard-tabs/scheduling/html.hbs index facadd26c0..a2d6453eae 100644 --- a/src/sunstone/public/app/tabs/templates-tab/form-panels/create/wizard-tabs/scheduling/html.hbs +++ b/src/sunstone/public/app/tabs/templates-tab/form-panels/create/wizard-tabs/scheduling/html.hbs @@ -53,6 +53,7 @@