Revision 9e19ea51

View differences:

src/sunstone/public/app/tabs/templates-tab/form-panels/instantiate.js
35 35
  var VcenterVMFolder = require('utils/vcenter-vm-folder');
36 36
  var CapacityInputs = require('tabs/templates-tab/form-panels/create/wizard-tabs/general/capacity-inputs');
37 37
  var Config = require('sunstone-config');
38
  var HostsTable = require('tabs/hosts-tab/datatable');
38 39

  
39 40
  /*
40 41
    CONSTANTS
......
172 173
      var networks = NicsSection.retrieve($(".nicsContext"  + template_id, context));
173 174

  
174 175
      var vmgroup = VMGroupSection.retrieve($(".vmgroupContext"+ template_id));
175

  
176 176
      if(vmgroup){
177 177
        $.extend(tmp_json, vmgroup);
178 178
      }
179 179

  
180
      var sched = WizardFields.retrieveInput($("#SCHED_REQUIREMENTS"  + template_id, context));
181
      if(sched){
182
        tmp_json.SCHED_REQUIREMENTS = sched;
183
      }
184

  
180 185
      var nics = [];
181 186
      var pcis = [];
182 187

  
......
261 266
        timeout: true,
262 267
        success: function (request, template_json) {
263 268
          that.template_objects.push(template_json);
269
          var options = {
270
            'select': true,
271
            'selectOptions': {
272
              'multiple_choice': true
273
            }
274
          }
264 275

  
276
          that.hostsTable = new HostsTable('HostsTable' + template_json.VMTEMPLATE.ID, options);
265 277
          templatesContext.append(
266 278
            TemplateRowHTML(
267 279
              { element: template_json.VMTEMPLATE,
268
                capacityInputsHTML: CapacityInputs.html()
280
                capacityInputsHTML: CapacityInputs.html(),
281
                hostsDatatable: that.hostsTable.dataTableHTML
269 282
              }) );
270 283

  
284
          $(".provision_host_selector" + template_json.VMTEMPLATE.ID, context).data("hostsTable", that.hostsTable);
285
          var selectOptions = {
286
            'selectOptions': {
287
              'select_callback': function(aData, options) {
288
                generateRequirements($(".provision_host_selector" + template_json.VMTEMPLATE.ID, context).data("hostsTable"), context, template_json.VMTEMPLATE.ID);
289
              },
290
              'unselect_callback': function(aData, options) {
291
                generateRequirements($(".provision_host_selector"+ template_json.VMTEMPLATE.ID, context).data("hostsTable"), context, template_json.VMTEMPLATE.ID);
292
              }
293
            }
294
          }
295
          that.hostsTable.initialize(selectOptions);
296
          that.hostsTable.refreshResourceTableSelect();
297

  
271 298
          DisksResize.insert({
272 299
            template_json: template_json,
273 300
            disksContext: $(".disksContext"  + template_json.VMTEMPLATE.ID, context),
......
356 383
    Tips.setup(context);
357 384
    return false;
358 385
  }
386
  function generateRequirements(hosts_table, context, id) {
387
      var req_string=[];
388
      //var req_ds_string=[];
389
      var selected_hosts = hosts_table.retrieveResourceTableSelect();
390
      //var selected_ds = this.datastoresTable.retrieveResourceTableSelect();
391

  
392
      $.each(selected_hosts, function(index, hostId) {
393
        req_string.push('ID="'+hostId+'"');
394
      });
395

  
396
      /*$.each(selected_ds, function(index, dsId) {
397
        req_ds_string.push('ID="'+dsId+'"');
398
      });*/
399

  
400
      $('#SCHED_REQUIREMENTS' + id, context).val(req_string.join(" | "));
401
      //$('#SCHED_DS_REQUIREMENTS', context).val(req_ds_string.join(" | "));
402
  };
359 403
});
src/sunstone/public/app/tabs/templates-tab/form-panels/instantiate/templateRow.hbs
67 67
      </fieldset>
68 68
    </div>
69 69
  </div>
70
  <div class="row">
71
    <div class="small-12 columns hostContext{{element.ID}}">
72
      <fieldset>
73
        <legend>
74
          <i class="fa fa-globe"></i> {{tr "Host"}}
75
        </legend>
76
        <div class="provision_host_selector{{element.ID}}" data-tab-content>{{{hostsDatatable}}}</div>
77
        <div class="row">
78
            <div class="large-12 columns">
79
              <label for="SCHED_REQUIREMENTS">
80
                {{tr "Expression"}}
81
                {{{tip (tr "Boolean expression that rules out entries from the pool of datastores suitable to run this VM.")}}}
82
              </label>
83
              <input type="text" wizard_field="SCHED_REQUIREMENTS" id="SCHED_REQUIREMENTS{{element.ID}}" name="requirements" />
84
            </div>
85
        </div>
86
      </fieldset>
87
    </div>
88
  </div>
70 89
   <div class="row">
71 90
    <div class="medium-6 small-12 columns vcenterVMFolderContext{{element.ID}}">
72 91
      <div class="provision_vcenter_vm_folder_selector">

Also available in: Unified diff