Revision 5fc29256

View differences:

src/sunstone/public/app/tabs/datastores-tab.js
8 8
  var DATATABLE_ID = "dataTableDatastores";
9 9

  
10 10
  var _dialogs = [
11
    require('./datastores-tab/dialogs/create')
11
  ];
12

  
13
  var _formPanels = [
14
    require('./datastores-tab/form-panels/create')
12 15
  ];
13 16

  
14 17
  var _panels = [
......
29 32
    actions: Actions,
30 33
    dataTable: new Table(DATATABLE_ID, {actions: true, info: true}),
31 34
    panels: _panels,
35
    formPanels: _formPanels,
32 36
    dialogs: _dialogs
33 37
  };
34 38

  
src/sunstone/public/app/tabs/datastores-tab/actions.js
7 7
  var OpenNebulaAction = require('opennebula/action');
8 8

  
9 9
  var TAB_ID = require('./tabId');
10
  var CREATE_DIALOG_ID = require('./dialogs/create/dialogId');
10
  var CREATE_DIALOG_ID = require('./form-panels/create/formPanelId');
11 11

  
12 12
  var _actions = {
13 13
    "Datastore.create" : {
14 14
      type: "create",
15 15
      call : OpenNebulaDatastore.create,
16 16
      callback : function(request, response) {
17
        Sunstone.getDialog(CREATE_DIALOG_ID).hide();
18
        Sunstone.getDialog(CREATE_DIALOG_ID).reset();
17
        Sunstone.resetFormPanel(TAB_ID, CREATE_DIALOG_ID);
18
        Sunstone.hideFormPanel(TAB_ID);
19 19
        Sunstone.getDataTable(TAB_ID).addElement(request, response);
20 20
        Notifier.notifyCustom(Locale.tr("Datastore created"), " ID: " + response.DATASTORE.ID, false);
21 21
      },
22
      error : Notifier.onError
22
      error: function(request, response) {
23
        Sunstone.hideFormPanelLoading(TAB_ID);
24
        Notifier.onError(request, response);
25
      },
23 26
    },
24 27

  
25 28
    "Datastore.create_dialog" : {
26 29
      type: "custom",
27 30
      call: function() {
28
        Sunstone.getDialog(CREATE_DIALOG_ID).show();
31
        Sunstone.showFormPanel(TAB_ID, CREATE_DIALOG_ID, "create");
29 32
      }
30 33
    },
31 34

  
src/sunstone/public/app/tabs/datastores-tab/dialogs/create.js
1
define(function(require) {
2
  /*
3
    DEPENDENCIES
4
   */
5
  
6
  var BaseDialog = require('utils/dialogs/dialog');
7
  var TemplateHTML = require('hbs!./create/html');
8
  var Sunstone = require('sunstone');
9
  var Notifier = require('utils/notifier');
10
  var Tips = require('utils/tips');
11
  var ResourceSelect = require('utils/resource-select')
12
  
13
  /*
14
    CONSTANTS
15
   */
16
  
17
  var DIALOG_ID = require('./create/dialogId');
18

  
19
  /*
20
    CONSTRUCTOR
21
   */
22

  
23
  function Dialog() {
24
    this.dialogId = DIALOG_ID;
25
    BaseDialog.call(this);
26
  };
27

  
28
  Dialog.DIALOG_ID = DIALOG_ID;
29
  Dialog.prototype = Object.create(BaseDialog.prototype);
30
  Dialog.prototype.constructor = Dialog;
31
  Dialog.prototype.html = _html;
32
  Dialog.prototype.onShow = _onShow;
33
  Dialog.prototype.setup = _setup;
34

  
35
  return Dialog;
36
  
37
  /*
38
    FUNCTION DEFINITIONS
39
   */
40

  
41
  function _html() {
42
    return TemplateHTML({dialogId: DIALOG_ID});
43
  }
44

  
45
  function _onShow(dialog) {
46
    $("#name", dialog).focus();
47

  
48
    var cluster_id = $("div#cluster_id .resource_list_select", dialog).val();
49
    if (!cluster_id) cluster_id = "-1";
50

  
51
    var cluster_id_raw = $("div#datastore_cluster_raw .resource_list_select", dialog).val();
52
    if (!cluster_id_raw) cluster_id_raw = "-1";
53

  
54
    ResourceSelect.insert('div#cluster_id', dialog, "Cluster", cluster_id, false);
55
    ResourceSelect.insert('div#datastore_cluster_raw', dialog, "Cluster", cluster_id_raw, false);
56
    
57
    return false;
58
  }
59

  
60
  // Set up the create datastore dialog
61
  function _setup(dialog) {
62
    Tips.setup(dialog);
63

  
64
    // Show custom driver input only when custom is selected in selects
65
    $('input[name="ds_tab_custom_ds_mad"],' +
66
      'input[name="ds_tab_custom_tm_mad"]', dialog).parent().hide();
67

  
68
    $('select#ds_mad', dialog).change(function() {
69
      if ($(this).val() == "custom")
70
          $('input[name="ds_tab_custom_ds_mad"]').parent().show();
71
      else
72
          $('input[name="ds_tab_custom_ds_mad"]').parent().hide();
73
    });
74

  
75
    $('select#tm_mad', dialog).change(function() {
76
      if ($(this).val() == "custom")
77
          $('input[name="ds_tab_custom_tm_mad"]').parent().show();
78
      else
79
          $('input[name="ds_tab_custom_tm_mad"]').parent().hide();
80
    });
81

  
82
    $('#presets').change(function() {
83
      _hideAll(dialog);
84
      var choice_str = $(this).val();
85
      switch (choice_str)
86
      {
87
        case 'fs':
88
          _selectFilesystem();
89
          break;
90
        case 'vmware_vmfs':
91
          _selectVmwareVmfs();
92
          break;
93
        case 'block_lvm':
94
          _selectBlockLvm();
95
          break;
96
        case 'fs_lvm':
97
          _selectFsLvm();
98
          break;
99
        case 'ceph':
100
          _selectCeph();
101
          break;
102
        case 'gluster':
103
          _selectGluster();
104
          break;
105
        case 'dev':
106
          _selectDevices();
107
          break;
108
        case 'custom':
109
          _selectCustom();
110
          break;
111
      }
112
    });
113

  
114
    $('#create_datastore_submit', dialog).click(function() {
115
      var name            = $('#name', dialog).val();
116
      var cluster_id      = $(".resource_list_select", $('#cluster_id', dialog)).val();
117
      var ds_type         = $('input[name=ds_type]:checked', dialog).val();
118
      var ds_mad          = $('#ds_mad', dialog).val();
119
      ds_mad              = ds_mad == "custom" ? $('input[name="ds_tab_custom_ds_mad"]').val() : ds_mad;
120
      var tm_mad          = $('#tm_mad', dialog).val();
121
      tm_mad              = tm_mad == "custom" ? $('input[name="ds_tab_custom_tm_mad"]').val() : tm_mad;
122
      var type            = $('#disk_type', dialog).val();
123

  
124
      var safe_dirs       = $('#safe_dirs', dialog).val();
125
      var base_path       = $('#base_path', dialog).val();
126
      var restricted_dirs = $('#restricted_dirs', dialog).val();
127
      var limit_transfer_bw = $('#limit_transfer_bw', dialog).val();
128
      var datastore_capacity_check = $('#datastore_capacity_check', dialog).is(':checked');
129
      var no_decompress   = $('#no_decompress', dialog).is(':checked');
130

  
131
      var bridge_list     = $('#bridge_list', dialog).val();
132
      var ds_tmp_dir     = $('#ds_tmp_dir', dialog).val();
133
      var vg_name         = $('#vg_name', dialog).val();
134
      var limit_mb        = $('#limit_mb', dialog).val();
135
      var gluster_host    = $('#gluster_host', dialog).val();
136
      var gluster_volume  = $('#gluster_volume', dialog).val();
137
      var pool_name       = $('#pool_name', dialog).val();
138
      var ceph_host       = $('#ceph_host', dialog).val();
139
      var ceph_secret     = $('#ceph_secret', dialog).val();
140
      var ceph_user       = $('#ceph_user', dialog).val();
141
      var rbd_format      = $('#rbd_format', dialog).val();
142
      var staging_dir     = $('#staging_dir', dialog).val();
143

  
144
      if (!name) {
145
        Notifier.notifyError("Please provide a name");
146
        return false;
147
      };
148

  
149
      var ds_obj = {
150
        "datastore" : {
151
          "name" : name,
152
          "tm_mad" : tm_mad,
153
          "disk_type" : type,
154
          "type" : ds_type
155
        },
156
        "cluster_id" : cluster_id
157
      };
158

  
159
      // If we are adding a system datastore then
160
      // we do not use ds_mad
161
      if (ds_type != "SYSTEM_DS")
162
          ds_obj.datastore.ds_mad = ds_mad;
163

  
164
      if (base_path)
165
          ds_obj.datastore.base_path = base_path;
166

  
167
      if (safe_dirs)
168
          ds_obj.datastore.safe_dirs = safe_dirs;
169

  
170
      if (restricted_dirs)
171
          ds_obj.datastore.restricted_dirs = restricted_dirs;
172

  
173
      if (limit_transfer_bw)
174
          ds_obj.datastore.limit_transfer_bw = limit_transfer_bw;
175

  
176
      if (no_decompress)
177
          ds_obj.datastore.no_decompress = "YES";
178

  
179
      if (datastore_capacity_check)
180
          ds_obj.datastore.datastore_capacity_check = "YES";
181

  
182
      if (bridge_list)
183
          ds_obj.datastore.bridge_list = bridge_list;
184

  
185
      if (ds_tmp_dir)
186
          ds_obj.datastore.ds_tmp_dir = ds_tmp_dir;
187

  
188
      if (vg_name)
189
          ds_obj.datastore.vg_name = vg_name;
190

  
191
      if (limit_mb)
192
          ds_obj.datastore.limit_mb = limit_mb;
193

  
194
      if (gluster_host)
195
          ds_obj.datastore.gluster_host = gluster_host;
196

  
197
      if (gluster_volume)
198
          ds_obj.datastore.gluster_volume = gluster_volume;
199

  
200
      if (pool_name)
201
          ds_obj.datastore.pool_name = pool_name;
202

  
203
      if (ceph_host)
204
          ds_obj.datastore.ceph_host = ceph_host;
205

  
206
      if (ceph_secret)
207
          ds_obj.datastore.ceph_secret = ceph_secret;
208

  
209
      if (ceph_user)
210
          ds_obj.datastore.ceph_user = ceph_user;
211

  
212
      if (rbd_format)
213
          ds_obj.datastore.rbd_format = rbd_format;
214

  
215
      if (staging_dir)
216
          ds_obj.datastore.staging_dir = staging_dir;
217

  
218
      Sunstone.runAction("Datastore.create", ds_obj);
219
      return false;
220
    });
221

  
222
    $('#create_datastore_submit_manual', dialog).click(function() {
223
      var template   = $('#template', dialog).val();
224
      var cluster_id = $(".resource_list_select", $('#datastore_cluster_raw', dialog)).val();
225

  
226
      if (!cluster_id) {
227
        Notifier.notifyError(tr("Please select a cluster for this datastore"));
228
        return false;
229
      };
230

  
231
      var ds_obj = {
232
        "datastore" : {
233
          "datastore_raw" : template
234
        },
235
        "cluster_id" : cluster_id
236
      };
237
      Sunstone.runAction("Datastore.create", ds_obj);
238
      return false;
239
    });
240

  
241
    // Hide disk_type
242
    $('select#disk_type').parent().hide();
243

  
244
    _hideAll(dialog);
245
    _selectFilesystem();
246
  }
247

  
248
  function _hideAll(dialog) {
249
    // Hide all the options that depends on datastore type
250
    // and reset the selects
251

  
252
    $('input#image_ds_type').attr('checked', 'true');
253
    $('input[name=ds_type]').removeAttr('disabled', 'disabled');
254

  
255
    $('label[for="bridge_list"],input#bridge_list', dialog).parent().hide();
256
    $('label[for="ds_tmp_dir"],input#ds_tmp_dir', dialog).parent().hide();
257
    $('label[for="vg_name"],input#vg_name', dialog).hide();
258
    $('label[for="gluster_host"],input#gluster_host', dialog).parent().hide();
259
    $('label[for="gluster_volume"],input#gluster_volume', dialog).parent().hide();
260
    $('label[for="pool_name"],input#pool_name', dialog).parent().hide();
261
    $('label[for="ceph_host"],input#ceph_host', dialog).parent().hide();
262
    $('label[for="ceph_secret"],input#ceph_secret', dialog).parent().hide();
263
    $('label[for="ceph_user"],input#ceph_user', dialog).parent().hide();
264
    $('label[for="rbd_format"],input#rbd_format', dialog).parent().hide();
265
    $('label[for="staging_dir"],input#staging_dir', dialog).parent().hide();
266
    $('label[for="limit_transfer_bw"],input#limit_transfer_bw', dialog).parent().hide();
267
    $('label[for="no_decompress"],input#no_decompress', dialog).parent().hide();
268
    $('select#ds_mad').removeAttr('disabled');
269
    $('select#tm_mad').removeAttr('disabled');
270
    $('select#tm_mad').children('option').each(function() {
271
        $(this).removeAttr('disabled');
272
      });
273
    $('select#disk_type').removeAttr('disabled');
274
    $('select#disk_type').children('option').each(function() {
275
        $(this).removeAttr('disabled');
276
      });
277

  
278
    $('input[name="ds_tab_custom_ds_mad"]', dialog).parent().hide();
279
    $('input[name="ds_tab_custom_tm_mad"]', dialog).parent().hide();
280
  }
281

  
282
  function _selectFilesystem(dialog) {
283
    $('select#ds_mad').val('fs');
284
    $('select#tm_mad').val('shared');
285
    $('select#ds_mad').attr('disabled', 'disabled');
286
    $('select#tm_mad').children('option').each(function() {
287
        var value_str = $(this).val();
288
        $(this).attr('disabled', 'disabled');
289
        if (value_str == "qcow2"  ||
290
            value_str == "shared" ||
291
            value_str == "ssh") {
292
          $(this).removeAttr('disabled');
293
        }
294
      });
295
    $('select#disk_type').val('file');
296
    $('select#disk_type').attr('disabled', 'disabled');
297
    $('label[for="limit_transfer_bw"],input#limit_transfer_bw').parent().fadeIn();
298
    $('label[for="no_decompress"],input#no_decompress').parent().fadeIn();
299
    $('label[for="datastore_capacity_check"],input#datastore_capacity_check').parent().fadeIn();
300
    $('input#safe_dirs').removeAttr('disabled');
301
    $('select#disk_type').removeAttr('disabled');
302
    $('input#base_path').removeAttr('disabled');
303
    $('input#limit_mb').removeAttr('disabled');
304
    $('input#restricted_dirs').removeAttr('disabled');
305
    $('label[for="bridge_list"],input#bridge_list').parent().fadeIn();
306
    $('label[for="staging_dir"],input#staging_dir').parent().fadeIn();
307
  }
308

  
309
  function _selectVmwareVmfs(dialog) {
310
    $('label[for="bridge_list"],input#bridge_list').parent().fadeIn();
311
    $('label[for="ds_tmp_dir"],input#ds_tmp_dir').parent().fadeIn();
312
    $('select#ds_mad').val('vmfs');
313
    $('select#ds_mad').attr('disabled', 'disabled');
314
    $('select#tm_mad').val('vmfs');
315
    $('select#tm_mad').attr('disabled', 'disabled');
316
    $('label[for="limit_transfer_bw"],input#limit_transfer_bw').parent().fadeIn();
317
    $('label[for="no_decompress"],input#no_decompress').parent().fadeIn();
318
    $('label[for="datastore_capacity_check"],input#datastore_capacity_check').parent().fadeIn();
319
    $('select#disk_type').val('file');
320
    $('select#disk_type').attr('disabled', 'disabled');
321
    $('input#safe_dirs').removeAttr('disabled');
322
    $('input#base_path').removeAttr('disabled');
323
    $('input#limit_mb').removeAttr('disabled');
324
    $('input#restricted_dirs').removeAttr('disabled');
325
  }
326

  
327
  function _selectCeph(dialog) {
328
    $('input#image_ds_type').attr('checked', 'true');
329
    $('input[name=ds_type]').attr('disabled', 'disabled');
330
    $('select#ds_mad').val('ceph');
331
    $('select#ds_mad').attr('disabled', 'disabled');
332
    $('select#tm_mad').val('ceph');
333
    $('select#tm_mad').attr('disabled', 'disabled');
334
    $('label[for="bridge_list"],input#bridge_list').parent().fadeIn();
335
    $('label[for="pool_name"],input#pool_name').parent().fadeIn();
336
    $('label[for="ceph_host"],input#ceph_host').parent().fadeIn();
337
    $('label[for="ceph_secret"],input#ceph_secret').parent().fadeIn();
338
    $('label[for="ceph_user"],input#ceph_user').parent().fadeIn();
339
    $('label[for="rbd_format"],input#rbd_format').parent().fadeIn();
340
    $('label[for="staging_dir"],input#staging_dir').parent().fadeIn();
341
    $('label[for="limit_transfer_bw"],input#limit_transfer_bw').parent().fadeIn();
342
    $('label[for="no_decompress"],input#no_decompress').parent().fadeIn();
343
    $('label[for="datastore_capacity_check"],input#datastore_capacity_check').parent().fadeIn();
344
    $('select#disk_type').val('RBD');
345
    $('select#disk_type').attr('disabled', 'disabled');
346
    $('input#safe_dirs').removeAttr('disabled');
347
    $('input#base_path').removeAttr('disabled');
348
    $('input#limit_mb').removeAttr('disabled');
349
    $('input#restricted_dirs').removeAttr('disabled');
350
  }
351

  
352
  function _selectBlockLvm(dialog) {
353
    $('select#ds_mad').val('lvm');
354
    $('select#ds_mad').attr('disabled', 'disabled');
355
    $('select#tm_mad').val('lvm');
356
    $('select#tm_mad').attr('disabled', 'disabled');
357
    $('input#image_ds_type').attr('checked', 'true');
358
    $('input[name=ds_type]').attr('disabled', 'disabled');
359
    $('label[for="bridge_list"],input#bridge_list').parent().fadeIn();
360
    $('label[for="vg_name"],input#vg_name').fadeIn();
361
    $('label[for="limit_transfer_bw"],input#limit_transfer_bw').parent().fadeIn();
362
    $('label[for="no_decompress"],input#no_decompress').parent().fadeIn();
363
    $('label[for="datastore_capacity_check"],input#datastore_capacity_check').parent().fadeIn();
364
    $('select#disk_type').val('block');
365
    $('select#disk_type').attr('disabled', 'disabled');
366
    $('input#safe_dirs').removeAttr('disabled');
367
    $('input#base_path').removeAttr('disabled');
368
    $('input#limit_mb').removeAttr('disabled');
369
    $('input#restricted_dirs').removeAttr('disabled');
370
  }
371

  
372
  function _selectFsLvm(dialog) {
373
    $('select#ds_mad').val('fs');
374
    $('select#ds_mad').attr('disabled', 'disabled');
375
    $('select#tm_mad').val('fs_lvm');
376
    $('select#tm_mad').attr('disabled', 'disabled');
377
    $('input#image_ds_type').attr('checked', 'true');
378
    $('input[name=ds_type]').attr('disabled', 'disabled');
379
    $('label[for="limit_transfer_bw"],input#limit_transfer_bw').parent().fadeIn();
380
    $('label[for="no_decompress"],input#no_decompress').parent().fadeIn();
381
    $('label[for="datastore_capacity_check"],input#datastore_capacity_check').parent().fadeIn();
382
    $('select#disk_type').val('block');
383
    $('select#disk_type').attr('disabled', 'disabled');
384
    $('input#safe_dirs').removeAttr('disabled');
385
    $('input#base_path').removeAttr('disabled');
386
    $('input#limit_mb').removeAttr('disabled');
387
    $('input#restricted_dirs').removeAttr('disabled');
388
  }
389

  
390
  function _selectGluster(dialog) {
391
    $('select#ds_mad').val('fs');
392
    $('select#ds_mad').attr('disabled', 'disabled');
393
    $('select#tm_mad').val('shared');
394
    $('select#tm_mad').children('option').each(function() {
395
        var value_str = $(this).val();
396
        $(this).attr('disabled', 'disabled');
397
        if (value_str == "shared"  ||
398
            value_str == "ssh") {
399
          $(this).removeAttr('disabled');
400
        }
401
      });
402
    $('input#image_ds_type').attr('checked', 'true');
403
    $('input[name=ds_type]').attr('disabled', 'disabled');
404
    $('select#disk_type').val('gluster');
405
    $('select#disk_type').attr('disabled', 'disabled');
406
    $('label[for="gluster_host"],input#gluster_host').parent().fadeIn();
407
    $('label[for="gluster_volume"],input#gluster_volume').parent().fadeIn();
408
    $('label[for="limit_transfer_bw"],input#limit_transfer_bw').parent().fadeIn();
409
    $('label[for="no_decompress"],input#no_decompress').parent().fadeIn();
410
    $('label[for="datastore_capacity_check"],input#datastore_capacity_check').parent().fadeIn();
411
    $('input#safe_dirs').removeAttr('disabled');
412
    $('input#base_path').removeAttr('disabled');
413
    $('input#limit_mb').removeAttr('disabled');
414
    $('input#restricted_dirs').removeAttr('disabled');
415
  }
416

  
417
  function _selectDevices(dialog) {
418
    $('select#ds_mad').val('dev');
419
    $('select#ds_mad').attr('disabled', 'disabled');
420
    $('select#tm_mad').val('dev');
421
    $('select#tm_mad').attr('disabled', 'disabled');
422
    $('input#image_ds_type').attr('checked', 'true');
423
    $('input[name=ds_type]').attr('disabled', 'disabled');
424
    $('select#disk_type').val('block');
425
    $('select#disk_type').attr('disabled', 'disabled');
426
    $('label[for="limit_transfer_bw"],input#limit_transfer_bw').parent().hide();
427
    $('label[for="no_decompress"],input#no_decompress').parent().hide();
428
    $('label[for="datastore_capacity_check"],input#datastore_capacity_check').parent().hide();
429
    $('input#safe_dirs').attr('disabled', 'disabled');
430
    $('input#base_path').attr('disabled', 'disabled');
431
    $('input#limit_mb').attr('disabled', 'disabled');
432
    $('input#restricted_dirs').attr('disabled', 'disabled');
433
  }
434

  
435
  function _selectCustom(dialog) {
436
    _hideAll(dialog);
437
    $('select#ds_mad').val('fs');
438
    $('select#tm_mad').val('shared');
439
    $('input#safe_dirs').removeAttr('disabled');
440
    $('select#disk_type').removeAttr('disabled');
441
    $('input#base_path').removeAttr('disabled');
442
    $('input#limit_mb').removeAttr('disabled');
443
    $('input#restricted_dirs').removeAttr('disabled');
444
    $('label[for="limit_transfer_bw"],input#limit_transfer_bw').parent().fadeIn();
445
    $('label[for="no_decompress"],input#no_decompress').parent().fadeIn();
446
    $('label[for="datastore_capacity_check"],input#datastore_capacity_check').parent().fadeIn();
447
  }
448
});
src/sunstone/public/app/tabs/datastores-tab/dialogs/create/dialogId.js
1
define(function(require){
2
  return 'createDatastoreDialog';
3
})
src/sunstone/public/app/tabs/datastores-tab/dialogs/create/html.hbs
1
<div id="{{dialogId}}" class="reveal-modal medium max-height" role="dialog" data-reveal>
2
  <div class="row">
3
    <div class="large-5 columns">
4
      <h3 id="create_cluster_header" class="subheader">{{tr "Create Datastore"}}</h3>
5
    </div>
6
    <div class="large-7 columns">
7
      <dl class="tabs right wizard_tabs" data-tab>
8
        <dd class="active">
9
          <a href="#datastore_easyTab">{{tr "Wizard"}}</a>
10
        </dd>
11
        <dd>
12
          <a href="#datastore_manualTab">{{tr "Advanced mode"}}</a>
13
        </dd>
14
      </dl>
15
    </div>
16
  </div>
17
  <div class="reveal-body">
18
    <form id="{{dialogId}}Form" action="" class="creation">
19
      <div class="tabs-content">
20
        <div id="datastore_easyTab" class="active content">
21
          <div class="row">
22
            <div class="large-6 columns">
23
              <label for="name" >{{tr "Name"}}:</label>
24
              <input type="text" name="name" id="name"/>
25
            </div>
26
          </div>
27
          <div class="row">
28
            <div class="large-6 columns">
29
              <label for="presets">{{tr "Presets"}}</label>
30
              <select id="presets" name="presets">
31
                <option value="fs">{{tr "Filesystem"}}</option>
32
                <option value="vmware_vmfs">{{tr "VMware VMFS"}}</option>
33
                <option value="block_lvm">{{tr "Block LVM"}}</option>
34
                <option value="fs_lvm">{{tr "FS LVM"}}</option>
35
                <option value="ceph">{{tr "Ceph"}}</option>
36
                <option value="gluster">{{tr "Gluster"}}</option>
37
                <option value="dev">{{tr "Devices"}}</option>
38
                <option value="custom">{{tr "Custom"}}</option>
39
              </select>
40
            </div>
41
            <div class="large-6 columns">
42
              <label for="cluster">{{tr "Cluster"}}</label>
43
              <div id="cluster_id" name="cluster_id"></div>
44
            </div>
45
          </div>
46
          <div class="row">
47
            <div class="large-12 columns">
48
              <fieldset>
49
                <legend>{{tr "Type"}}</legend>
50
                <div class="large-12 columns text-center">
51
                  <input id="image_ds_type" type="radio" name="ds_type" value="IMAGE_DS" checked/>
52
                  <label for="image_ds_type">{{tr "Images"}}</label>
53
                  <input id="system_ds_type" type="radio" name="ds_type" value="SYSTEM_DS" />
54
                  <label for="system_ds_type">{{tr "System"}}</label>
55
                  <input id="file_ds_type" type="radio" name="ds_type" value="FILE_DS" />
56
                  <label for="file_ds_type">{{tr "Files"}}</label>
57
                </div>
58
              </fieldset>
59
            </div>
60
          </div>
61
          <div class="row">
62
            <div class="large-12 columns">
63
              <fieldset>
64
                <legend>{{tr "Managers"}}</legend>
65
                <div class="large-6 columns">
66
                  <label for="ds_mad">{{tr "Datastore"}}</label>
67
                  <select id="ds_mad" name="ds_mad">
68
                    <option value="fs">{{tr "Filesystem"}}</option>
69
                    <option value="vmware">{{tr "VMware"}}</option>
70
                    <option value="lvm">{{tr "LVM"}}</option>
71
                    <option value="vmfs">{{tr "VMFS"}}</option>
72
                    <option value="ceph">{{tr "Ceph"}}</option>
73
                    <option value="dev">{{tr "Devices"}}</option>
74
                    <option value="custom">{{tr "Custom"}}</option>
75
                  </select>
76
                  <div>
77
                    <label>{{tr "Custom DS_MAD"}}:</label>
78
                    <input type="text" name="ds_tab_custom_ds_mad" />
79
                  </div>
80
                </div>
81
                <div class="large-6 columns">
82
                  <label for="tm_mad">{{tr "Transfer"}}:</label>
83
                  <select id="tm_mad" name="tm_mad">
84
                    <option value="shared">{{tr "Shared"}}</option>
85
                    <option value="ssh">{{tr "SSH"}}</option>
86
                    <option value="qcow2">{{tr "qcow2"}}</option>
87
                    <option value="lvm">{{tr "LVM"}}</option>
88
                    <option value="fs_lvm">{{tr "FS LVM"}}</option>
89
                    <option value="vmfs">{{tr "VMFS"}}</option>
90
                    <option value="ceph">{{tr "Ceph"}}</option>
91
                    <option value="dev">{{tr "Devices"}}</option>
92
                    <option value="custom">{{tr "Custom"}}</option>
93
                  </select>
94
                  <div>
95
                    <label>{{tr "Custom TM_MAD"}}:</label>
96
                    <input type="text" name="ds_tab_custom_tm_mad" />
97
                  </div>
98
                </div>
99
              </fieldset>
100
            </div>
101
          </div>
102
          <div class="row">
103
            <div class="large-6 columns">
104
              <label for="disk_type">{{tr "Disk type"}}:</label>
105
              <select id="disk_type" name="disk_type">
106
                <option value="file">{{tr "File"}}</option>
107
                <option value="block">{{tr "Block"}}</option>
108
                <option value="RBD">{{tr "RBD"}}</option>
109
                <option value="gluster">{{tr "Gluster"}}</option>
110
              </select>
111
            </div>
112
          </div>
113
          <div class="row">
114
            <div class="large-12 columns">
115
              <label for="safe_dirs">
116
                {{tr "Safe Directories"}}
117
                <span class="tip">
118
                  {{tr "If you need to un-block a directory under one of the RESTRICTED_DIRS"}}
119
                </span>
120
              </label>
121
              <input type="text" name="safe_dirs" id="safe_dirs" />
122
            </div>
123
            <div class="large-12 columns">
124
              <label for="restricted_dirs">
125
                {{tr "Restricted Directories"}}
126
                <span class="tip">
127
                  {{tr "Paths that can not be used to register images. A space separated list of paths. This will prevent users registering important files as VM images and accessing them thourgh their VMs. OpenNebula will automatically add its configuration directories: /var/lib/one, /etc/one and oneadmin's home ($HOME)."}}
128
                </span>
129
              </label>
130
              <input type="text" name="restricted_dirs" id="restricted_dirs" />
131
            </div>
132
            <div class="large-6 columns">
133
              <label for="base_path">
134
                {{tr "Base Path"}}
135
                <span class="tip">
136
                  {{tr "When needed, the front-end will access the datastores using BASE_PATH (defaults to /var/lib/one/datastores)."}}
137
                </span>
138
              </label>
139
              <input type="text" name="base_path" id="base_path" />
140
            </div>
141
            <div class="large-6 columns">
142
              <label for="limit_transfer_bw">
143
                {{tr "Transfer BW Limit"}}
144
                <span class="tip">
145
                  {{tr "Specify the maximum transfer rate in bytes/second when downloading images from a http/https URL. Suffixes K, M or G can be used."}}
146
                </span>
147
              </label>
148
              <input type="text" name="limit_transfer_bw" id="limit_transfer_bw" />
149
            </div>
150
            <div class="large-6 columns">
151
              <label for="limit_mb">
152
                {{tr "Limit"}}
153
                <span class="tip">
154
                  {{tr "Optional limit, in MB. If set, OpenNebula will only use this amount of storage, instead of the whole free disk."}}
155
                </span>
156
              </label>
157
              <input type="text" name="limit_mb" id="limit_mb" />
158
            </div>
159
            <div class="large-12 columns">
160
              <input id="no_decompress" type="checkbox" name="no_decompress" value="YES" />
161
              <label for="no_decompress">{{tr "Do not try to untar or decompress"}}</label>
162
            </div>
163
            <div class="large-12 columns">
164
              <input id="datastore_capacity_check" type="checkbox" name="datastore_capacity_check" value="YES" />
165
              <label for="datastore_capacity_check">
166
                {{tr "Check available capacity of the datastore before creating a new image"}}
167
              </label>
168
            </div>
169
            <div class="large-12 columns">
170
              <label for="bridge_list">
171
                {{tr "Host Bridge List"}}
172
                <span class="tip">
173
                  {{tr "Space separated list of Server names or IPs where OpenNebula will be staging the new images into. This server will act as the entry point for new inmages in the datastore."}}
174
                </span>
175
              </label>
176
              <input type="text" name="bridge_list" id="bridge_list" />
177
            </div>
178
            <div class="large-6 columns">
179
              <label for="ds_tmp_dir">
180
                {{tr "DS Tmp Dir"}}
181
                <span class="tip">
182
                  {{tr "Path in the OpenNebula front-end to be used as a buffer to stage in files in vmfs datastores."}}
183
                </span>
184
              </label>
185
              <input type="text" name="ds_tmp_dir" id="ds_tmp_dir" />
186
            </div>
187
            <div class="large-6 columns">
188
              <label for="vg_name">{{tr "Volume Group Name"}}</label>
189
              <input type="text" name="vg_name" id="vg_name" />
190
            </div>
191
            <div class="large-6 columns">
192
              <label for="gluster_host">
193
                {{tr "Gluster Host"}}
194
                <span class="tip">
195
                  {{tr "Host and port of one (and only one) Gluster server (host:port)"}}
196
                </span>
197
              </label>
198
              <input type="text" name="gluster_host" id="gluster_host" />
199
            </div>
200
            <div class="large-6 columns">
201
              <label for="gluster_volume">
202
                {{tr "Gluster Volume"}}
203
                <span class="tip">{{tr "Gluster volume to use for the datastore"}}</span>
204
              </label>
205
              <input type="text" name="gluster_volume" id="gluster_volume" />
206
            </div>
207
            <div class="large-6 columns">
208
              <label for="pool_name">
209
                {{tr "Pool Name"}}
210
                <span class="tip">
211
                  {{tr "The OpenNebula Ceph pool name. Defaults to 'one' (this pool must exist before using the drivers)."}}
212
                </span>
213
              </label>
214
              <input type="text" name="pool_name" id="pool_name" />
215
            </div>
216
            <div class="large-6 columns">
217
              <label for="ceph_host">
218
                {{tr "Ceph Host"}}
219
                <span class="tip">
220
                  {{tr "Space-separated list of Ceph monitors. Example: host1 host2:port2 host3 host4:port4 (if no port is specified, the default one is chosen) (Required for Libvirt 1.x when cephx is enabled)."}}
221
                </span>
222
              </label>
223
              <input type="text" name="ceph_host" id="ceph_host" />
224
            </div>
225
            <div class="large-6 columns">
226
              <label for="ceph_user">
227
                {{tr "Ceph User"}}
228
                <span class="tip">
229
                  {{tr "The OpenNebula Ceph user name. If set it is used by RBD commands. This ceph user must exist before using the drivers. Required for Libvirt 1.x when cephx is enabled ."}}
230
                </span>
231
              </label>
232
              <input type="text" name="ceph_user" id="ceph_user" />
233
            </div>
234
            <div class="large-6 columns">
235
              <label for="ceph_secret">
236
                {{tr "Ceph Secret"}}
237
                <span class="tip">
238
                  {{tr "A generated UUID for a LibVirt secret (to hold the CephX authentication key in Libvirt on each hypervisor). This should be generated when creating the Ceph datastore in OpenNebula. (Required for Libvirt 1.x when cephx is enabled)."}}
239
                </span>
240
              </label>
241
              <input type="text" name="ceph_secret" id="ceph_secret" />
242
            </div>
243
            <div class="large-6 columns">
244
              <label class="fs" for="staging_dir">
245
                {{tr "Staging Dir"}}
246
                <span class="tip">
247
                  {{tr "FS: Default path where images will be temporarily copied to in the host carrying out the registration operation (chosen from the bridge list). If empty, defaults to /var/tmp."}}
248
                  <br>
249
                  <br>
250
                  {{tr "Ceph: Default path for image operations in the OpenNebula Ceph frontend."}}
251
                </span>
252
              </label>
253
              <input type="text" name="staging_dir" id="staging_dir" />
254
            </div>
255
            <div class="large-6 columns">
256
              <label for="rbd_format">
257
                {{tr "RBD Format"}}
258
                <span class="tip">
259
                  {{tr "By default RBD Format 2 will be used. If RBD_FORMAT=2 is specified then when instantiating non-persistent images the Ceph driver will perform rbd snap instead of rbd copy."}}
260
                </span>
261
              </label>
262
              <input type="text" name="rbd_format" id="rbd_format" />
263
            </div>
264
          </div>
265
          <div class="reveal-footer">
266
            <div class="form_buttons">
267
              <button class="button radius right success" type="submit" id="create_datastore_submit" value="OpenNebula.Datastore.create">{{tr "Create"}}</button>
268
              <button class="button radius secondary resetDialog" type="reset" value="reset">{{tr "Reset"}}</button>
269
            </div>
270
          </div>
271
        </div>
272
        <div id="datastore_manualTab" class="content">
273
          <div class="row">
274
            <div class="columns large-6">
275
              <label for="datastore_cluster_raw">{{tr "Cluster"}}</label>
276
              <div id="datastore_cluster_raw" name="datastore_cluster_raw"></div>
277
            </div>
278
          </div>
279
          <div class="row">
280
            <div class="columns large-12">
281
              <textarea id="template" rows="15"></textarea>
282
            </div>
283
          </div>
284
          <div class="reveal-footer">
285
            <div class="form_buttons">
286
              <button class="button success radius right" id="create_datastore_submit_manual" value="datastore/create">{{tr "Create"}}</button>
287
              <button class="button secondary radius resetDialog" type="reset" value="reset">{{tr "Reset"}}</button>
288
            </div>
289
          </div>
290
        </div>
291
      </div>
292
    </form>
293
    <a class="close-reveal-modal">&#215;</a>
294
  </div>
295
</div>
src/sunstone/public/app/tabs/datastores-tab/form-panels/create.js
1
define(function(require) {
2
  /*
3
    DEPENDENCIES
4
   */
5
  
6
  require('foundation.tab');
7
  var BaseFormPanel = require('utils/form-panels/form-panel');
8
  var Sunstone = require('sunstone');
9
  var Locale = require('utils/locale');
10
  var Notifier = require('utils/notifier');
11
  var Tips = require('utils/tips');
12
  var ResourceSelect = require('utils/resource-select');
13

  
14
  /*
15
    TEMPLATES
16
   */
17

  
18
  var TemplateWizardHTML = require('hbs!./create/wizard');
19
  var TemplateAdvancedHTML = require('hbs!./create/advanced');
20

  
21
  /*
22
    CONSTANTS
23
   */
24
  
25
  var FORM_PANEL_ID = require('./create/formPanelId');
26
  var TAB_ID = require('../tabId');
27

  
28
  /*
29
    CONSTRUCTOR
30
   */
31

  
32
  function FormPanel() {
33
    this.formPanelId = FORM_PANEL_ID;
34
    this.tabId = TAB_ID;
35
    this.actions = {
36
      'create': {
37
        'title': Locale.tr("Create Datastore"),
38
        'buttonText': Locale.tr("Create"),
39
        'resetButton': true
40
      }
41
    };
42

  
43
    BaseFormPanel.call(this);
44
  }
45

  
46
  FormPanel.FORM_PANEL_ID = FORM_PANEL_ID;
47
  FormPanel.prototype = Object.create(BaseFormPanel.prototype);
48
  FormPanel.prototype.constructor = FormPanel;
49
  FormPanel.prototype.htmlWizard = _htmlWizard;
50
  FormPanel.prototype.htmlAdvanced = _htmlAdvanced;
51
  FormPanel.prototype.submitWizard = _submitWizard;
52
  FormPanel.prototype.submitAdvanced = _submitAdvanced;
53
  FormPanel.prototype.onShow = _onShow;
54
  FormPanel.prototype.setup = _setup;
55

  
56
  return FormPanel;
57
  
58
  /*
59
    FUNCTION DEFINITIONS
60
   */
61

  
62
  function _htmlWizard() {
63
    return TemplateWizardHTML({
64
      'formPanelId': this.formPanelId,
65
    });
66
  }
67

  
68
  function _htmlAdvanced() {
69
    return TemplateAdvancedHTML({formPanelId: this.formPanelId});
70
  }
71

  
72
  function _onShow(dialog) {
73
    $("#name", dialog).focus();
74

  
75
    var cluster_id = $("div#cluster_id .resource_list_select", dialog).val();
76
    if (!cluster_id) cluster_id = "-1";
77

  
78
    var cluster_id_raw = $("div#datastore_cluster_raw .resource_list_select", dialog).val();
79
    if (!cluster_id_raw) cluster_id_raw = "-1";
80

  
81
    ResourceSelect.insert('div#cluster_id', dialog, "Cluster", cluster_id, false);
82
    ResourceSelect.insert('div#datastore_cluster_raw', dialog, "Cluster", cluster_id_raw, false);
83
    
84
    return false;
85
  }
86

  
87
  // Set up the create datastore dialog
88
  function _setup(dialog) {
89
    Tips.setup(dialog);
90

  
91
    // Show custom driver input only when custom is selected in selects
92
    $('input[name="ds_tab_custom_ds_mad"],' +
93
      'input[name="ds_tab_custom_tm_mad"]', dialog).parent().hide();
94

  
95
    $('select#ds_mad', dialog).change(function() {
96
      if ($(this).val() == "custom")
97
          $('input[name="ds_tab_custom_ds_mad"]').parent().show();
98
      else
99
          $('input[name="ds_tab_custom_ds_mad"]').parent().hide();
100
    });
101

  
102
    $('select#tm_mad', dialog).change(function() {
103
      if ($(this).val() == "custom")
104
          $('input[name="ds_tab_custom_tm_mad"]').parent().show();
105
      else
106
          $('input[name="ds_tab_custom_tm_mad"]').parent().hide();
107
    });
108

  
109
    $('#presets').change(function() {
110
      _hideAll(dialog);
111
      var choice_str = $(this).val();
112
      switch (choice_str)
113
      {
114
        case 'fs':
115
          _selectFilesystem();
116
          break;
117
        case 'vmware_vmfs':
118
          _selectVmwareVmfs();
119
          break;
120
        case 'block_lvm':
121
          _selectBlockLvm();
122
          break;
123
        case 'fs_lvm':
124
          _selectFsLvm();
125
          break;
126
        case 'ceph':
127
          _selectCeph();
128
          break;
129
        case 'gluster':
130
          _selectGluster();
131
          break;
132
        case 'dev':
133
          _selectDevices();
134
          break;
135
        case 'custom':
136
          _selectCustom();
137
          break;
138
      }
139
    });
140

  
141
    // Hide disk_type
142
    $('select#disk_type').parent().hide();
143

  
144
    _hideAll(dialog);
145
    _selectFilesystem();
146
  }
147

  
148

  
149
  function _submitWizard(dialog) {
150
    var name            = $('#name', dialog).val();
151
    var cluster_id      = $(".resource_list_select", $('#cluster_id', dialog)).val();
152
    var ds_type         = $('input[name=ds_type]:checked', dialog).val();
153
    var ds_mad          = $('#ds_mad', dialog).val();
154
    ds_mad              = ds_mad == "custom" ? $('input[name="ds_tab_custom_ds_mad"]').val() : ds_mad;
155
    var tm_mad          = $('#tm_mad', dialog).val();
156
    tm_mad              = tm_mad == "custom" ? $('input[name="ds_tab_custom_tm_mad"]').val() : tm_mad;
157
    var type            = $('#disk_type', dialog).val();
158

  
159
    var safe_dirs       = $('#safe_dirs', dialog).val();
160
    var base_path       = $('#base_path', dialog).val();
161
    var restricted_dirs = $('#restricted_dirs', dialog).val();
162
    var limit_transfer_bw = $('#limit_transfer_bw', dialog).val();
163
    var datastore_capacity_check = $('#datastore_capacity_check', dialog).is(':checked');
164
    var no_decompress   = $('#no_decompress', dialog).is(':checked');
165

  
166
    var bridge_list     = $('#bridge_list', dialog).val();
167
    var ds_tmp_dir     = $('#ds_tmp_dir', dialog).val();
168
    var vg_name         = $('#vg_name', dialog).val();
169
    var limit_mb        = $('#limit_mb', dialog).val();
170
    var gluster_host    = $('#gluster_host', dialog).val();
171
    var gluster_volume  = $('#gluster_volume', dialog).val();
172
    var pool_name       = $('#pool_name', dialog).val();
173
    var ceph_host       = $('#ceph_host', dialog).val();
174
    var ceph_secret     = $('#ceph_secret', dialog).val();
175
    var ceph_user       = $('#ceph_user', dialog).val();
176
    var rbd_format      = $('#rbd_format', dialog).val();
177
    var staging_dir     = $('#staging_dir', dialog).val();
178

  
179
    var ds_obj = {
180
      "datastore" : {
181
        "name" : name,
182
        "tm_mad" : tm_mad,
183
        "disk_type" : type,
184
        "type" : ds_type
185
      },
186
      "cluster_id" : cluster_id
187
    };
188

  
189
    // If we are adding a system datastore then
190
    // we do not use ds_mad
191
    if (ds_type != "SYSTEM_DS")
192
        ds_obj.datastore.ds_mad = ds_mad;
193

  
194
    if (base_path)
195
        ds_obj.datastore.base_path = base_path;
196

  
197
    if (safe_dirs)
198
        ds_obj.datastore.safe_dirs = safe_dirs;
199

  
200
    if (restricted_dirs)
201
        ds_obj.datastore.restricted_dirs = restricted_dirs;
202

  
203
    if (limit_transfer_bw)
204
        ds_obj.datastore.limit_transfer_bw = limit_transfer_bw;
205

  
206
    if (no_decompress)
207
        ds_obj.datastore.no_decompress = "YES";
208

  
209
    if (datastore_capacity_check)
210
        ds_obj.datastore.datastore_capacity_check = "YES";
211

  
212
    if (bridge_list)
213
        ds_obj.datastore.bridge_list = bridge_list;
214

  
215
    if (ds_tmp_dir)
216
        ds_obj.datastore.ds_tmp_dir = ds_tmp_dir;
217

  
218
    if (vg_name)
219
        ds_obj.datastore.vg_name = vg_name;
220

  
221
    if (limit_mb)
222
        ds_obj.datastore.limit_mb = limit_mb;
223

  
224
    if (gluster_host)
225
        ds_obj.datastore.gluster_host = gluster_host;
226

  
227
    if (gluster_volume)
228
        ds_obj.datastore.gluster_volume = gluster_volume;
229

  
230
    if (pool_name)
231
        ds_obj.datastore.pool_name = pool_name;
232

  
233
    if (ceph_host)
234
        ds_obj.datastore.ceph_host = ceph_host;
235

  
236
    if (ceph_secret)
237
        ds_obj.datastore.ceph_secret = ceph_secret;
238

  
239
    if (ceph_user)
240
        ds_obj.datastore.ceph_user = ceph_user;
241

  
242
    if (rbd_format)
243
        ds_obj.datastore.rbd_format = rbd_format;
244

  
245
    if (staging_dir)
246
        ds_obj.datastore.staging_dir = staging_dir;
247

  
248
    Sunstone.runAction("Datastore.create", ds_obj);
249
    return false;
250
  }
251

  
252
  function _submitAdvanced(dialog) {
253
    var template   = $('#template', dialog).val();
254
    var cluster_id = $(".resource_list_select", $('#datastore_cluster_raw', dialog)).val();
255

  
256
    if (!cluster_id) {
257
      Notifier.notifyError(tr("Please select a cluster for this datastore"));
258
      return false;
259
    }
260

  
261
    var ds_obj = {
262
      "datastore" : {
263
        "datastore_raw" : template
264
      },
265
      "cluster_id" : cluster_id
266
    };
267

  
268
    Sunstone.runAction("Datastore.create", ds_obj);
269
    return false;
270
  }
271

  
272
  function _hideAll(dialog) {
273
    // Hide all the options that depends on datastore type
274
    // and reset the selects
275

  
276
    $('input#image_ds_type').attr('checked', 'true');
277
    $('input[name=ds_type]').removeAttr('disabled', 'disabled');
278

  
279
    $('label[for="bridge_list"],input#bridge_list', dialog).parent().hide();
280
    $('label[for="ds_tmp_dir"],input#ds_tmp_dir', dialog).parent().hide();
281
    $('label[for="vg_name"],input#vg_name', dialog).hide();
282
    $('label[for="gluster_host"],input#gluster_host', dialog).parent().hide();
283
    $('label[for="gluster_volume"],input#gluster_volume', dialog).parent().hide();
284
    $('label[for="pool_name"],input#pool_name', dialog).parent().hide();
285
    $('label[for="ceph_host"],input#ceph_host', dialog).parent().hide();
286
    $('label[for="ceph_secret"],input#ceph_secret', dialog).parent().hide();
287
    $('label[for="ceph_user"],input#ceph_user', dialog).parent().hide();
288
    $('label[for="rbd_format"],input#rbd_format', dialog).parent().hide();
289
    $('label[for="staging_dir"],input#staging_dir', dialog).parent().hide();
290
    $('label[for="limit_transfer_bw"],input#limit_transfer_bw', dialog).parent().hide();
291
    $('label[for="no_decompress"],input#no_decompress', dialog).parent().hide();
292
    $('select#ds_mad').removeAttr('disabled');
293
    $('select#tm_mad').removeAttr('disabled');
294
    $('select#tm_mad').children('option').each(function() {
295
        $(this).removeAttr('disabled');
296
      });
297
    $('select#disk_type').removeAttr('disabled');
298
    $('select#disk_type').children('option').each(function() {
299
        $(this).removeAttr('disabled');
300
      });
301

  
302
    $('input[name="ds_tab_custom_ds_mad"]', dialog).parent().hide();
303
    $('input[name="ds_tab_custom_tm_mad"]', dialog).parent().hide();
304
  }
305

  
306
  function _selectFilesystem(dialog) {
307
    $('select#ds_mad').val('fs');
308
    $('select#tm_mad').val('shared');
309
    $('select#ds_mad').attr('disabled', 'disabled');
310
    $('select#tm_mad').children('option').each(function() {
311
        var value_str = $(this).val();
312
        $(this).attr('disabled', 'disabled');
313
        if (value_str == "qcow2"  ||
314
            value_str == "shared" ||
315
            value_str == "ssh") {
316
          $(this).removeAttr('disabled');
317
        }
318
      });
319
    $('select#disk_type').val('file');
320
    $('select#disk_type').attr('disabled', 'disabled');
321
    $('label[for="limit_transfer_bw"],input#limit_transfer_bw').parent().fadeIn();
322
    $('label[for="no_decompress"],input#no_decompress').parent().fadeIn();
323
    $('label[for="datastore_capacity_check"],input#datastore_capacity_check').parent().fadeIn();
324
    $('input#safe_dirs').removeAttr('disabled');
325
    $('select#disk_type').removeAttr('disabled');
326
    $('input#base_path').removeAttr('disabled');
327
    $('input#limit_mb').removeAttr('disabled');
328
    $('input#restricted_dirs').removeAttr('disabled');
329
    $('label[for="bridge_list"],input#bridge_list').parent().fadeIn();
330
    $('label[for="staging_dir"],input#staging_dir').parent().fadeIn();
331
  }
332

  
333
  function _selectVmwareVmfs(dialog) {
334
    $('label[for="bridge_list"],input#bridge_list').parent().fadeIn();
335
    $('label[for="ds_tmp_dir"],input#ds_tmp_dir').parent().fadeIn();
336
    $('select#ds_mad').val('vmfs');
337
    $('select#ds_mad').attr('disabled', 'disabled');
338
    $('select#tm_mad').val('vmfs');
339
    $('select#tm_mad').attr('disabled', 'disabled');
340
    $('label[for="limit_transfer_bw"],input#limit_transfer_bw').parent().fadeIn();
341
    $('label[for="no_decompress"],input#no_decompress').parent().fadeIn();
342
    $('label[for="datastore_capacity_check"],input#datastore_capacity_check').parent().fadeIn();
343
    $('select#disk_type').val('file');
344
    $('select#disk_type').attr('disabled', 'disabled');
345
    $('input#safe_dirs').removeAttr('disabled');
346
    $('input#base_path').removeAttr('disabled');
347
    $('input#limit_mb').removeAttr('disabled');
348
    $('input#restricted_dirs').removeAttr('disabled');
349
  }
350

  
351
  function _selectCeph(dialog) {
352
    $('input#image_ds_type').attr('checked', 'true');
353
    $('input[name=ds_type]').attr('disabled', 'disabled');
354
    $('select#ds_mad').val('ceph');
355
    $('select#ds_mad').attr('disabled', 'disabled');
356
    $('select#tm_mad').val('ceph');
357
    $('select#tm_mad').attr('disabled', 'disabled');
358
    $('label[for="bridge_list"],input#bridge_list').parent().fadeIn();
359
    $('label[for="pool_name"],input#pool_name').parent().fadeIn();
360
    $('label[for="ceph_host"],input#ceph_host').parent().fadeIn();
361
    $('label[for="ceph_secret"],input#ceph_secret').parent().fadeIn();
362
    $('label[for="ceph_user"],input#ceph_user').parent().fadeIn();
363
    $('label[for="rbd_format"],input#rbd_format').parent().fadeIn();
364
    $('label[for="staging_dir"],input#staging_dir').parent().fadeIn();
365
    $('label[for="limit_transfer_bw"],input#limit_transfer_bw').parent().fadeIn();
366
    $('label[for="no_decompress"],input#no_decompress').parent().fadeIn();
367
    $('label[for="datastore_capacity_check"],input#datastore_capacity_check').parent().fadeIn();
368
    $('select#disk_type').val('RBD');
369
    $('select#disk_type').attr('disabled', 'disabled');
370
    $('input#safe_dirs').removeAttr('disabled');
371
    $('input#base_path').removeAttr('disabled');
372
    $('input#limit_mb').removeAttr('disabled');
373
    $('input#restricted_dirs').removeAttr('disabled');
374
  }
375

  
376
  function _selectBlockLvm(dialog) {
377
    $('select#ds_mad').val('lvm');
378
    $('select#ds_mad').attr('disabled', 'disabled');
379
    $('select#tm_mad').val('lvm');
380
    $('select#tm_mad').attr('disabled', 'disabled');
381
    $('input#image_ds_type').attr('checked', 'true');
382
    $('input[name=ds_type]').attr('disabled', 'disabled');
383
    $('label[for="bridge_list"],input#bridge_list').parent().fadeIn();
384
    $('label[for="vg_name"],input#vg_name').fadeIn();
385
    $('label[for="limit_transfer_bw"],input#limit_transfer_bw').parent().fadeIn();
386
    $('label[for="no_decompress"],input#no_decompress').parent().fadeIn();
387
    $('label[for="datastore_capacity_check"],input#datastore_capacity_check').parent().fadeIn();
388
    $('select#disk_type').val('block');
389
    $('select#disk_type').attr('disabled', 'disabled');
390
    $('input#safe_dirs').removeAttr('disabled');
391
    $('input#base_path').removeAttr('disabled');
392
    $('input#limit_mb').removeAttr('disabled');
393
    $('input#restricted_dirs').removeAttr('disabled');
394
  }
395

  
396
  function _selectFsLvm(dialog) {
397
    $('select#ds_mad').val('fs');
398
    $('select#ds_mad').attr('disabled', 'disabled');
399
    $('select#tm_mad').val('fs_lvm');
400
    $('select#tm_mad').attr('disabled', 'disabled');
401
    $('input#image_ds_type').attr('checked', 'true');
402
    $('input[name=ds_type]').attr('disabled', 'disabled');
403
    $('label[for="limit_transfer_bw"],input#limit_transfer_bw').parent().fadeIn();
404
    $('label[for="no_decompress"],input#no_decompress').parent().fadeIn();
405
    $('label[for="datastore_capacity_check"],input#datastore_capacity_check').parent().fadeIn();
406
    $('select#disk_type').val('block');
407
    $('select#disk_type').attr('disabled', 'disabled');
408
    $('input#safe_dirs').removeAttr('disabled');
409
    $('input#base_path').removeAttr('disabled');
410
    $('input#limit_mb').removeAttr('disabled');
411
    $('input#restricted_dirs').removeAttr('disabled');
412
  }
413

  
414
  function _selectGluster(dialog) {
415
    $('select#ds_mad').val('fs');
416
    $('select#ds_mad').attr('disabled', 'disabled');
417
    $('select#tm_mad').val('shared');
418
    $('select#tm_mad').children('option').each(function() {
419
        var value_str = $(this).val();
420
        $(this).attr('disabled', 'disabled');
421
        if (value_str == "shared"  ||
422
            value_str == "ssh") {
423
          $(this).removeAttr('disabled');
424
        }
425
      });
426
    $('input#image_ds_type').attr('checked', 'true');
427
    $('input[name=ds_type]').attr('disabled', 'disabled');
428
    $('select#disk_type').val('gluster');
429
    $('select#disk_type').attr('disabled', 'disabled');
430
    $('label[for="gluster_host"],input#gluster_host').parent().fadeIn();
431
    $('label[for="gluster_volume"],input#gluster_volume').parent().fadeIn();
432
    $('label[for="limit_transfer_bw"],input#limit_transfer_bw').parent().fadeIn();
433
    $('label[for="no_decompress"],input#no_decompress').parent().fadeIn();
434
    $('label[for="datastore_capacity_check"],input#datastore_capacity_check').parent().fadeIn();
435
    $('input#safe_dirs').removeAttr('disabled');
436
    $('input#base_path').removeAttr('disabled');
437
    $('input#limit_mb').removeAttr('disabled');
438
    $('input#restricted_dirs').removeAttr('disabled');
439
  }
440

  
441
  function _selectDevices(dialog) {
442
    $('select#ds_mad').val('dev');
443
    $('select#ds_mad').attr('disabled', 'disabled');
444
    $('select#tm_mad').val('dev');
445
    $('select#tm_mad').attr('disabled', 'disabled');
446
    $('input#image_ds_type').attr('checked', 'true');
447
    $('input[name=ds_type]').attr('disabled', 'disabled');
448
    $('select#disk_type').val('block');
449
    $('select#disk_type').attr('disabled', 'disabled');
450
    $('label[for="limit_transfer_bw"],input#limit_transfer_bw').parent().hide();
451
    $('label[for="no_decompress"],input#no_decompress').parent().hide();
452
    $('label[for="datastore_capacity_check"],input#datastore_capacity_check').parent().hide();
453
    $('input#safe_dirs').attr('disabled', 'disabled');
454
    $('input#base_path').attr('disabled', 'disabled');
455
    $('input#limit_mb').attr('disabled', 'disabled');
456
    $('input#restricted_dirs').attr('disabled', 'disabled');
457
  }
458

  
459
  function _selectCustom(dialog) {
460
    _hideAll(dialog);
461
    $('select#ds_mad').val('fs');
462
    $('select#tm_mad').val('shared');
463
    $('input#safe_dirs').removeAttr('disabled');
464
    $('select#disk_type').removeAttr('disabled');
465
    $('input#base_path').removeAttr('disabled');
466
    $('input#limit_mb').removeAttr('disabled');
467
    $('input#restricted_dirs').removeAttr('disabled');
468
    $('label[for="limit_transfer_bw"],input#limit_transfer_bw').parent().fadeIn();
469
    $('label[for="no_decompress"],input#no_decompress').parent().fadeIn();
470
    $('label[for="datastore_capacity_check"],input#datastore_capacity_check').parent().fadeIn();
471
  }
472
});
src/sunstone/public/app/tabs/datastores-tab/form-panels/create/advanced.hbs
1
<form data-abide="ajax" id="{{formPanelId}}Advanced" class="custom creation">
2
  <div class="row">
3
    <div class="columns large-6">
4
      <label for="datastore_cluster_raw">{{tr "Cluster"}}</label>
5
      <div id="datastore_cluster_raw" name="datastore_cluster_raw"></div>
6
    </div>
7
  </div>
8
  <div class="row">
9
    <div class="large-12 columns">
10
      <p>{{tr "Write the Virtual Network template here"}}</p>
11
    </div>
12
  </div>
13
  <div class="row">
14
    <div class="large-12 columns">
15
      <textarea id="template" rows="15" required></textarea>
16
    </div>
17
  </div>
18
</form>
19

  
20

  
21

  
22

  
src/sunstone/public/app/tabs/datastores-tab/form-panels/create/formPanelId.js
1
define(function(require){
2
  return 'createDatastoreForm';
3
})
src/sunstone/public/app/tabs/datastores-tab/form-panels/create/wizard.hbs
1
<form data-abide="ajax" id="{{formPanelId}}Wizard" class="custom creation">
2
  <div class="row">
3
    <div class="large-6 columns">
4
      <label for="name" >{{tr "Name"}}:</label>
5
      <input required type="text" name="name" id="name"/>
6
    </div>
7
  </div>
8
  <div class="row">
9
    <div class="large-6 columns">
10
      <label for="presets">{{tr "Presets"}}</label>
11
      <select id="presets" name="presets">
12
        <option value="fs">{{tr "Filesystem"}}</option>
13
        <option value="vmware_vmfs">{{tr "VMware VMFS"}}</option>
14
        <option value="block_lvm">{{tr "Block LVM"}}</option>
15
        <option value="fs_lvm">{{tr "FS LVM"}}</option>
16
        <option value="ceph">{{tr "Ceph"}}</option>
17
        <option value="gluster">{{tr "Gluster"}}</option>
18
        <option value="dev">{{tr "Devices"}}</option>
19
        <option value="custom">{{tr "Custom"}}</option>
20
      </select>
21
    </div>
22
    <div class="large-6 columns">
23
      <label for="cluster">{{tr "Cluster"}}</label>
24
      <div id="cluster_id" name="cluster_id"></div>
25
    </div>
26
  </div>
27
  <div class="row">
28
    <div class="large-12 columns">
29
      <fieldset>
30
        <legend>{{tr "Type"}}</legend>
31
        <div class="large-12 columns text-center">
32
          <input id="image_ds_type" type="radio" name="ds_type" value="IMAGE_DS" checked/>
33
          <label for="image_ds_type">{{tr "Images"}}</label>
34
          <input id="system_ds_type" type="radio" name="ds_type" value="SYSTEM_DS" />
35
          <label for="system_ds_type">{{tr "System"}}</label>
36
          <input id="file_ds_type" type="radio" name="ds_type" value="FILE_DS" />
37
          <label for="file_ds_type">{{tr "Files"}}</label>
38
        </div>
39
      </fieldset>
40
    </div>
41
  </div>
42
  <div class="row">
43
    <div class="large-12 columns">
44
      <fieldset>
45
        <legend>{{tr "Managers"}}</legend>
46
        <div class="large-6 columns">
47
          <label for="ds_mad">{{tr "Datastore"}}</label>
48
          <select id="ds_mad" name="ds_mad">
49
            <option value="fs">{{tr "Filesystem"}}</option>
50
            <option value="vmware">{{tr "VMware"}}</option>
51
            <option value="lvm">{{tr "LVM"}}</option>
52
            <option value="vmfs">{{tr "VMFS"}}</option>
53
            <option value="ceph">{{tr "Ceph"}}</option>
54
            <option value="dev">{{tr "Devices"}}</option>
55
            <option value="custom">{{tr "Custom"}}</option>
56
          </select>
57
          <div>
58
            <label>{{tr "Custom DS_MAD"}}:</label>
59
            <input type="text" name="ds_tab_custom_ds_mad" />
60
          </div>
61
        </div>
62
        <div class="large-6 columns">
63
          <label for="tm_mad">{{tr "Transfer"}}:</label>
64
          <select id="tm_mad" name="tm_mad">
65
            <option value="shared">{{tr "Shared"}}</option>
66
            <option value="ssh">{{tr "SSH"}}</option>
67
            <option value="qcow2">{{tr "qcow2"}}</option>
68
            <option value="lvm">{{tr "LVM"}}</option>
69
            <option value="fs_lvm">{{tr "FS LVM"}}</option>
70
            <option value="vmfs">{{tr "VMFS"}}</option>
71
            <option value="ceph">{{tr "Ceph"}}</option>
72
            <option value="dev">{{tr "Devices"}}</option>
73
            <option value="custom">{{tr "Custom"}}</option>
74
          </select>
75
          <div>
76
            <label>{{tr "Custom TM_MAD"}}:</label>
77
            <input type="text" name="ds_tab_custom_tm_mad" />
78
          </div>
79
        </div>
80
      </fieldset>
81
    </div>
82
  </div>
83
  <div class="row">
84
    <div class="large-6 columns">
85
      <label for="disk_type">{{tr "Disk type"}}:</label>
86
      <select id="disk_type" name="disk_type">
87
        <option value="file">{{tr "File"}}</option>
88
        <option value="block">{{tr "Block"}}</option>
89
        <option value="RBD">{{tr "RBD"}}</option>
90
        <option value="gluster">{{tr "Gluster"}}</option>
91
      </select>
92
    </div>
93
  </div>
94
  <div class="row">
95
    <div class="large-12 columns">
96
      <label for="safe_dirs">
97
        {{tr "Safe Directories"}}
98
        <span class="tip">
99
          {{tr "If you need to un-block a directory under one of the RESTRICTED_DIRS"}}
100
        </span>
101
      </label>
102
      <input type="text" name="safe_dirs" id="safe_dirs" />
103
    </div>
104
    <div class="large-12 columns">
105
      <label for="restricted_dirs">
106
        {{tr "Restricted Directories"}}
107
        <span class="tip">
108
          {{tr "Paths that can not be used to register images. A space separated list of paths. This will prevent users registering important files as VM images and accessing them thourgh their VMs. OpenNebula will automatically add its configuration directories: /var/lib/one, /etc/one and oneadmin's home ($HOME)."}}
109
        </span>
110
      </label>
111
      <input type="text" name="restricted_dirs" id="restricted_dirs" />
112
    </div>
113
    <div class="large-6 columns">
114
      <label for="base_path">
115
        {{tr "Base Path"}}
116
        <span class="tip">
117
          {{tr "When needed, the front-end will access the datastores using BASE_PATH (defaults to /var/lib/one/datastores)."}}
118
        </span>
119
      </label>
120
      <input type="text" name="base_path" id="base_path" />
121
    </div>
122
    <div class="large-6 columns">
123
      <label for="limit_transfer_bw">
124
        {{tr "Transfer BW Limit"}}
125
        <span class="tip">
126
          {{tr "Specify the maximum transfer rate in bytes/second when downloading images from a http/https URL. Suffixes K, M or G can be used."}}
127
        </span>
128
      </label>
129
      <input type="text" name="limit_transfer_bw" id="limit_transfer_bw" />
130
    </div>
131
    <div class="large-6 columns">
132
      <label for="limit_mb">
133
        {{tr "Limit"}}
134
        <span class="tip">
135
          {{tr "Optional limit, in MB. If set, OpenNebula will only use this amount of storage, instead of the whole free disk."}}
136
        </span>
137
      </label>
138
      <input type="text" name="limit_mb" id="limit_mb" />
139
    </div>
140
    <div class="large-12 columns">
141
      <input id="no_decompress" type="checkbox" name="no_decompress" value="YES" />
142
      <label for="no_decompress">{{tr "Do not try to untar or decompress"}}</label>
143
    </div>
144
    <div class="large-12 columns">
145
      <input id="datastore_capacity_check" type="checkbox" name="datastore_capacity_check" value="YES" />
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff