Revision 59fb94b3
src/sunstone/public/app/tabs/templates-tab.js | ||
---|---|---|
8 | 8 |
var DATATABLE_ID = "dataTableTemplates"; |
9 | 9 |
|
10 | 10 |
var _dialogs = [ |
11 |
require('./templates-tab/dialogs/clone'), |
|
12 |
require('./templates-tab/dialogs/instantiate') |
|
11 |
require('./templates-tab/dialogs/clone') |
|
13 | 12 |
]; |
14 | 13 |
|
15 | 14 |
var _panels = [ |
... | ... | |
19 | 18 |
|
20 | 19 |
var _formPanels = [ |
21 | 20 |
require('./templates-tab/form-panels/create'), |
22 |
require('./templates-tab/form-panels/import') |
|
23 |
] |
|
21 |
require('./templates-tab/form-panels/import'), |
|
22 |
require('./templates-tab/form-panels/instantiate') |
|
23 |
]; |
|
24 | 24 |
|
25 | 25 |
var Tab = { |
26 | 26 |
tabId: TAB_ID, |
src/sunstone/public/app/tabs/templates-tab/actions.js | ||
---|---|---|
9 | 9 |
var TAB_ID = require('./tabId'); |
10 | 10 |
var CREATE_DIALOG_ID = require('./form-panels/create/formPanelId'); |
11 | 11 |
var CLONE_DIALOG_ID = require('./dialogs/clone/dialogId'); |
12 |
var INSTANTIATE_DIALOG_ID = require('./dialogs/instantiate/dialogId');
|
|
12 |
var INSTANTIATE_DIALOG_ID = require('./form-panels/instantiate/formPanelId');
|
|
13 | 13 |
var IMPORT_DIALOG_ID = require('./form-panels/import/formPanelId'); |
14 | 14 |
|
15 | 15 |
var XML_ROOT = "VMTEMPLATE" |
... | ... | |
97 | 97 |
type: "multiple", |
98 | 98 |
call: OpenNebulaTemplate.instantiate, |
99 | 99 |
callback: function(req) { |
100 |
Sunstone.hideFormPanel(TAB_ID); |
|
100 | 101 |
OpenNebulaAction.clear_cache("VM"); |
101 | 102 |
}, |
102 | 103 |
elements: function() { |
... | ... | |
109 | 110 |
type: "single", |
110 | 111 |
call: OpenNebulaTemplate.instantiate, |
111 | 112 |
callback: function(req) { |
113 |
Sunstone.hideFormPanel(TAB_ID); |
|
112 | 114 |
OpenNebulaAction.clear_cache("VM"); |
113 | 115 |
}, |
114 | 116 |
error: Notifier.onError |
... | ... | |
116 | 118 |
"Template.instantiate_vms" : { |
117 | 119 |
type: "custom", |
118 | 120 |
call: function(){ |
119 |
Sunstone.getDialog(INSTANTIATE_DIALOG_ID).show(); |
|
121 |
//Sunstone.resetFormPanel(TAB_ID, INSTANTIATE_DIALOG_ID); |
|
122 |
var selected_nodes = Sunstone.getDataTable(TAB_ID).elements(); |
|
123 |
|
|
124 |
Sunstone.showFormPanel(TAB_ID, INSTANTIATE_DIALOG_ID, "instantiate", |
|
125 |
function(formPanelInstance, context) { |
|
126 |
formPanelInstance.setTemplateIds(context, selected_nodes); |
|
127 |
}); |
|
120 | 128 |
} |
121 | 129 |
}, |
122 | 130 |
"Template.clone_dialog" : { |
src/sunstone/public/app/tabs/templates-tab/dialogs/instantiate.js | ||
---|---|---|
1 |
define(function(require) { |
|
2 |
/* |
|
3 |
DEPENDENCIES |
|
4 |
*/ |
|
5 |
|
|
6 |
var BaseDialog = require('utils/dialogs/dialog'); |
|
7 |
var TemplateHTML = require('hbs!./instantiate/html'); |
|
8 |
var Sunstone = require('sunstone'); |
|
9 |
var Notifier = require('utils/notifier'); |
|
10 |
var OpenNebulaTemplate = require('opennebula/template'); |
|
11 |
var Locale = require('utils/locale'); |
|
12 |
var Tips = require('utils/tips'); |
|
13 |
var UserInputs = require('utils/user-inputs'); |
|
14 |
var WizardFields = require('utils/wizard-fields'); |
|
15 |
var DisksResize = require('utils/disks-resize'); |
|
16 |
var CapacityInputs = require('tabs/templates-tab/form-panels/create/wizard-tabs/general/capacity-inputs'); |
|
17 |
|
|
18 |
/* |
|
19 |
CONSTANTS |
|
20 |
*/ |
|
21 |
|
|
22 |
var DIALOG_ID = require('./instantiate/dialogId'); |
|
23 |
var TEMPLATES_TAB_ID = require('tabs/templates-tab/tabId') |
|
24 |
|
|
25 |
/* |
|
26 |
CONSTRUCTOR |
|
27 |
*/ |
|
28 |
|
|
29 |
function Dialog() { |
|
30 |
this.dialogId = DIALOG_ID; |
|
31 |
|
|
32 |
BaseDialog.call(this); |
|
33 |
}; |
|
34 |
|
|
35 |
Dialog.DIALOG_ID = DIALOG_ID; |
|
36 |
Dialog.prototype = Object.create(BaseDialog.prototype); |
|
37 |
Dialog.prototype.constructor = Dialog; |
|
38 |
Dialog.prototype.html = _html; |
|
39 |
Dialog.prototype.onShow = _onShow; |
|
40 |
Dialog.prototype.setup = _setup; |
|
41 |
|
|
42 |
return Dialog; |
|
43 |
|
|
44 |
/* |
|
45 |
FUNCTION DEFINITIONS |
|
46 |
*/ |
|
47 |
|
|
48 |
function _html() { |
|
49 |
return TemplateHTML({ |
|
50 |
'dialogId': this.dialogId |
|
51 |
}); |
|
52 |
} |
|
53 |
|
|
54 |
function _setup(context) { |
|
55 |
var that = this; |
|
56 |
context.foundation('abide', 'reflow'); |
|
57 |
|
|
58 |
context.off('invalid.fndtn.abide', '#' + DIALOG_ID + 'Form'); |
|
59 |
context.off('valid.fndtn.abide', '#' + DIALOG_ID + 'Form'); |
|
60 |
context.on('invalid.fndtn.abide', '#' + DIALOG_ID + 'Form', function(e) { |
|
61 |
Notifier.notifyError(Locale.tr("One or more required fields are missing or malformed.")); |
|
62 |
return false; |
|
63 |
}).on('valid.fndtn.abide', '#' + DIALOG_ID + 'Form', function(e) { |
|
64 |
var vm_name = $('#vm_name', this).val(); |
|
65 |
var n_times = $('#vm_n_times', this).val(); |
|
66 |
var n_times_int = 1; |
|
67 |
|
|
68 |
var hold = $('#hold', this).prop("checked"); |
|
69 |
|
|
70 |
var selected_nodes = Sunstone.getDataTable(TEMPLATES_TAB_ID).elements(); |
|
71 |
|
|
72 |
$.each(selected_nodes, function(index, template_id) { |
|
73 |
if (n_times.length) { |
|
74 |
n_times_int = parseInt(n_times, 10); |
|
75 |
}; |
|
76 |
|
|
77 |
var extra_msg = ""; |
|
78 |
if (n_times_int > 1) { |
|
79 |
extra_msg = n_times_int + " times"; |
|
80 |
} |
|
81 |
|
|
82 |
Notifier.notifySubmit("Template.instantiate", template_id, extra_msg); |
|
83 |
|
|
84 |
var extra_info = { |
|
85 |
'hold': hold |
|
86 |
}; |
|
87 |
|
|
88 |
var tmp_json = WizardFields.retrieve($(".template_user_inputs" + template_id, context)); |
|
89 |
var disks = DisksResize.retrieve($(".disksContext" + template_id, context)); |
|
90 |
if (disks.length > 0) { |
|
91 |
tmp_json.DISK = disks; |
|
92 |
} |
|
93 |
|
|
94 |
capacityContext = $(".capacityContext" + template_id, context); |
|
95 |
$.extend(tmp_json, CapacityInputs.retrieveResize(capacityContext)); |
|
96 |
|
|
97 |
extra_info['template'] = tmp_json; |
|
98 |
|
|
99 |
if (!vm_name.length) { //empty name use OpenNebula core default |
|
100 |
for (var i = 0; i < n_times_int; i++) { |
|
101 |
extra_info['vm_name'] = ""; |
|
102 |
Sunstone.runAction("Template.instantiate_quiet", template_id, extra_info); |
|
103 |
} |
|
104 |
} else { |
|
105 |
if (vm_name.indexOf("%i") == -1) {//no wildcard, all with the same name |
|
106 |
extra_info['vm_name'] = vm_name; |
|
107 |
|
|
108 |
for (var i = 0; i < n_times_int; i++) { |
|
109 |
Sunstone.runAction( |
|
110 |
"Template.instantiate_quiet", |
|
111 |
template_id, |
|
112 |
extra_info); |
|
113 |
} |
|
114 |
} else { //wildcard present: replace wildcard |
|
115 |
for (var i = 0; i < n_times_int; i++) { |
|
116 |
extra_info['vm_name'] = vm_name.replace(/%i/gi, i); |
|
117 |
|
|
118 |
Sunstone.runAction( |
|
119 |
"Template.instantiate_quiet", |
|
120 |
template_id, |
|
121 |
extra_info); |
|
122 |
} |
|
123 |
} |
|
124 |
} |
|
125 |
}) |
|
126 |
|
|
127 |
Sunstone.getDialog(DIALOG_ID).hide(); |
|
128 |
Sunstone.getDialog(DIALOG_ID).reset(); |
|
129 |
return false; |
|
130 |
}); |
|
131 |
} |
|
132 |
|
|
133 |
function _onShow(context) { |
|
134 |
$("#instantiate_vm_template_proceed", context).attr("disabled", "disabled"); |
|
135 |
var selected_nodes = Sunstone.getDataTable(TEMPLATES_TAB_ID).elements(); |
|
136 |
|
|
137 |
var templatesContext = $(".list_of_templates", context) |
|
138 |
templatesContext.html(""); |
|
139 |
|
|
140 |
$.each(selected_nodes, function(index, template_id) { |
|
141 |
OpenNebulaTemplate.show({ |
|
142 |
data : { |
|
143 |
id: template_id |
|
144 |
}, |
|
145 |
timeout: true, |
|
146 |
success: function (request, template_json) { |
|
147 |
templatesContext.append( |
|
148 |
'<h3 style="border-bottom: 1px solid #efefef; padding-bottom: 10px;">' + |
|
149 |
'<span style="border-bottom: 2px solid #0098c3; padding: 0px 50px 10px 0px;">' + |
|
150 |
template_json.VMTEMPLATE.NAME + |
|
151 |
'</span>' + |
|
152 |
'</h3>'+ |
|
153 |
'<div class="large-11 columns large-centered capacityContext' + template_json.VMTEMPLATE.ID + '">' + |
|
154 |
'<div class="row">'+ |
|
155 |
'<div class="large-12 columns">'+ |
|
156 |
'<h3 class="subheader text-right">'+ |
|
157 |
'<span class="left">'+ |
|
158 |
'<i class="fa fa-laptop fa-lg"></i> '+ |
|
159 |
Locale.tr("Capacity")+ |
|
160 |
'</span>'+ |
|
161 |
'</h3>'+ |
|
162 |
'</div>'+ |
|
163 |
'</div>'+ |
|
164 |
'<div class="row">'+ |
|
165 |
CapacityInputs.html() + |
|
166 |
'</div>'+ |
|
167 |
'</div>' + |
|
168 |
'<div class="large-11 columns large-centered disksContext' + template_json.VMTEMPLATE.ID + '"></div>' + |
|
169 |
'<div class="large-11 columns large-centered template_user_inputs' + template_json.VMTEMPLATE.ID + '"></div>'+ |
|
170 |
'<br>'); |
|
171 |
|
|
172 |
DisksResize.insert(template_json, $(".disksContext" + template_json.VMTEMPLATE.ID, context)); |
|
173 |
|
|
174 |
var inputs_div = $(".template_user_inputs" + template_json.VMTEMPLATE.ID, context); |
|
175 |
|
|
176 |
UserInputs.vmTemplateInsert( |
|
177 |
inputs_div, |
|
178 |
template_json, |
|
179 |
{text_header: '<i class="fa fa-gears fa-lg"></i> '+Locale.tr("Custom Attributes")}); |
|
180 |
|
|
181 |
inputs_div.data("opennebula_id", template_json.VMTEMPLATE.ID) |
|
182 |
|
|
183 |
capacityContext = $(".capacityContext" + template_json.VMTEMPLATE.ID, context); |
|
184 |
CapacityInputs.setup(capacityContext); |
|
185 |
CapacityInputs.fill(capacityContext, template_json.VMTEMPLATE); |
|
186 |
|
|
187 |
if (template_json.VMTEMPLATE.TEMPLATE.SUNSTONE_CAPACITY_SELECT && |
|
188 |
template_json.VMTEMPLATE.TEMPLATE.SUNSTONE_CAPACITY_SELECT.toUpperCase() == "NO"){ |
|
189 |
|
|
190 |
capacityContext.hide(); |
|
191 |
} |
|
192 |
}, |
|
193 |
error: function(request, error_json, container) { |
|
194 |
Notifier.onError(request, error_json, container); |
|
195 |
$("#instantiate_vm_user_inputs", context).empty(); |
|
196 |
} |
|
197 |
}); |
|
198 |
}) |
|
199 |
|
|
200 |
$("#instantiate_vm_template_proceed", context).removeAttr("disabled"); |
|
201 |
|
|
202 |
Tips.setup(context); |
|
203 |
return false; |
|
204 |
} |
|
205 |
}); |
src/sunstone/public/app/tabs/templates-tab/dialogs/instantiate/dialogId.js | ||
---|---|---|
1 |
define(function(require){ |
|
2 |
return 'instantiateTemplateDialog'; |
|
3 |
}) |
src/sunstone/public/app/tabs/templates-tab/dialogs/instantiate/html.hbs | ||
---|---|---|
1 |
<div id="{{dialogId}}" class="reveal-modal large" role="dialog" data-reveal > |
|
2 |
<div class="row"> |
|
3 |
<div class="large-12 columns"> |
|
4 |
<h3 id="create_vnet_header" class="subheader">{{tr "Instantiate VM Template"}}</h3> |
|
5 |
</div> |
|
6 |
</div> |
|
7 |
<form data-abide="ajax" id="{{dialogId}}Form" action="" class="custom creation"> |
|
8 |
<div class="row"> |
|
9 |
<div class="large-4 columns"> |
|
10 |
<label for="vm_name"> |
|
11 |
{{tr "VM Name"}} |
|
12 |
<span class="tip"> |
|
13 |
{{tr "Defaults to template name when emtpy. You can use the wildcard %i. When creating several VMs, %i will be replaced with a different number starting from 0 in each of them"}}. |
|
14 |
</span> |
|
15 |
</label> |
|
16 |
<input type="text" name="vm_name" id="vm_name" /> |
|
17 |
</div> |
|
18 |
<div class="large-4 columns"> |
|
19 |
<label for="vm_n_times"> |
|
20 |
{{tr "Number of instances"}} |
|
21 |
<span class="tip"> |
|
22 |
{{tr "Number of Virtual Machines that will be created using this template"}}. |
|
23 |
</span> |
|
24 |
</label> |
|
25 |
<input type="text" name="vm_n_times" id="vm_n_times" value="1"> |
|
26 |
</div> |
|
27 |
<div class="large-4 columns"> |
|
28 |
<input type="checkbox" name="hold" id="hold"/> |
|
29 |
<label for="hold"> |
|
30 |
{{tr "Hold"}} |
|
31 |
<span class="tip"> |
|
32 |
{{tr "Sets the new VM to hold state, instead of pending. The scheduler will not deploy VMs in this state. It can be released later, or deployed manually."}} |
|
33 |
</span> |
|
34 |
</label> |
|
35 |
</div> |
|
36 |
</div> |
|
37 |
<div class="row"> |
|
38 |
<div class="large-11 large-centered columns list_of_templates"> |
|
39 |
</div> |
|
40 |
</div> |
|
41 |
<div class="form_buttons"> |
|
42 |
<button class="button radius right success" id="instantiate_vm_template_proceed" value="Template.instantiate_vms">{{tr "Instantiate"}}</button> |
|
43 |
</div> |
|
44 |
<a class="close-reveal-modal">×</a> |
|
45 |
</form> |
|
46 |
</div> |
src/sunstone/public/app/tabs/templates-tab/form-panels/instantiate.js | ||
---|---|---|
1 |
define(function(require) { |
|
2 |
/* |
|
3 |
DEPENDENCIES |
|
4 |
*/ |
|
5 |
|
|
6 |
var BaseFormPanel = require('utils/form-panels/form-panel'); |
|
7 |
var TemplateHTML = require('hbs!./instantiate/html'); |
|
8 |
var Sunstone = require('sunstone'); |
|
9 |
var Notifier = require('utils/notifier'); |
|
10 |
var OpenNebulaTemplate = require('opennebula/template'); |
|
11 |
var Locale = require('utils/locale'); |
|
12 |
var Tips = require('utils/tips'); |
|
13 |
var UserInputs = require('utils/user-inputs'); |
|
14 |
var WizardFields = require('utils/wizard-fields'); |
|
15 |
var DisksResize = require('utils/disks-resize'); |
|
16 |
var CapacityInputs = require('tabs/templates-tab/form-panels/create/wizard-tabs/general/capacity-inputs'); |
|
17 |
|
|
18 |
/* |
|
19 |
CONSTANTS |
|
20 |
*/ |
|
21 |
|
|
22 |
var FORM_PANEL_ID = require('./instantiate/formPanelId'); |
|
23 |
var TAB_ID = require('../tabId'); |
|
24 |
|
|
25 |
/* |
|
26 |
CONSTRUCTOR |
|
27 |
*/ |
|
28 |
|
|
29 |
function FormPanel() { |
|
30 |
this.formPanelId = FORM_PANEL_ID; |
|
31 |
this.tabId = TAB_ID; |
|
32 |
this.actions = { |
|
33 |
'instantiate': { |
|
34 |
'title': Locale.tr("Instantiate VM Template"), |
|
35 |
'buttonText': Locale.tr("Instantiate"), |
|
36 |
'resetButton': false |
|
37 |
} |
|
38 |
}; |
|
39 |
|
|
40 |
BaseFormPanel.call(this); |
|
41 |
} |
|
42 |
|
|
43 |
FormPanel.FORM_PANEL_ID = FORM_PANEL_ID; |
|
44 |
FormPanel.prototype = Object.create(BaseFormPanel.prototype); |
|
45 |
FormPanel.prototype.constructor = FormPanel; |
|
46 |
FormPanel.prototype.setTemplateIds = _setTemplateIds; |
|
47 |
FormPanel.prototype.htmlWizard = _html; |
|
48 |
FormPanel.prototype.submitWizard = _submitWizard; |
|
49 |
FormPanel.prototype.onShow = _onShow; |
|
50 |
FormPanel.prototype.setup = _setup; |
|
51 |
|
|
52 |
return FormPanel; |
|
53 |
|
|
54 |
/* |
|
55 |
FUNCTION DEFINITIONS |
|
56 |
*/ |
|
57 |
|
|
58 |
function _html() { |
|
59 |
return TemplateHTML({ |
|
60 |
'formPanelId': this.formPanelId |
|
61 |
}); |
|
62 |
} |
|
63 |
|
|
64 |
function _setup(context) { |
|
65 |
context.foundation('abide', 'reflow'); |
|
66 |
} |
|
67 |
|
|
68 |
function _submitWizard(context) { |
|
69 |
var vm_name = $('#vm_name', context).val(); |
|
70 |
var n_times = $('#vm_n_times', context).val(); |
|
71 |
var n_times_int = 1; |
|
72 |
|
|
73 |
var hold = $('#hold', context).prop("checked"); |
|
74 |
|
|
75 |
$.each(this.selected_nodes, function(index, template_id) { |
|
76 |
if (n_times.length) { |
|
77 |
n_times_int = parseInt(n_times, 10); |
|
78 |
} |
|
79 |
|
|
80 |
var extra_msg = ""; |
|
81 |
if (n_times_int > 1) { |
|
82 |
extra_msg = n_times_int + " times"; |
|
83 |
} |
|
84 |
|
|
85 |
Notifier.notifySubmit("Template.instantiate", template_id, extra_msg); |
|
86 |
|
|
87 |
var extra_info = { |
|
88 |
'hold': hold |
|
89 |
}; |
|
90 |
|
|
91 |
var tmp_json = WizardFields.retrieve($(".template_user_inputs" + template_id, context)); |
|
92 |
var disks = DisksResize.retrieve($(".disksContext" + template_id, context)); |
|
93 |
if (disks.length > 0) { |
|
94 |
tmp_json.DISK = disks; |
|
95 |
} |
|
96 |
|
|
97 |
capacityContext = $(".capacityContext" + template_id, context); |
|
98 |
$.extend(tmp_json, CapacityInputs.retrieveResize(capacityContext)); |
|
99 |
|
|
100 |
extra_info['template'] = tmp_json; |
|
101 |
|
|
102 |
if (!vm_name.length) { //empty name use OpenNebula core default |
|
103 |
for (var i = 0; i < n_times_int; i++) { |
|
104 |
extra_info['vm_name'] = ""; |
|
105 |
Sunstone.runAction("Template.instantiate_quiet", template_id, extra_info); |
|
106 |
} |
|
107 |
} else { |
|
108 |
if (vm_name.indexOf("%i") == -1) {//no wildcard, all with the same name |
|
109 |
extra_info['vm_name'] = vm_name; |
|
110 |
|
|
111 |
for (var i = 0; i < n_times_int; i++) { |
|
112 |
Sunstone.runAction( |
|
113 |
"Template.instantiate_quiet", |
|
114 |
template_id, |
|
115 |
extra_info); |
|
116 |
} |
|
117 |
} else { //wildcard present: replace wildcard |
|
118 |
for (var i = 0; i < n_times_int; i++) { |
|
119 |
extra_info['vm_name'] = vm_name.replace(/%i/gi, i); |
|
120 |
|
|
121 |
Sunstone.runAction( |
|
122 |
"Template.instantiate_quiet", |
|
123 |
template_id, |
|
124 |
extra_info); |
|
125 |
} |
|
126 |
} |
|
127 |
} |
|
128 |
}); |
|
129 |
|
|
130 |
return false; |
|
131 |
} |
|
132 |
|
|
133 |
function _setTemplateIds(context, selected_nodes) { |
|
134 |
this.selected_nodes = selected_nodes; |
|
135 |
|
|
136 |
var templatesContext = $(".list_of_templates", context); |
|
137 |
|
|
138 |
var idsLength = this.selected_nodes.length; |
|
139 |
var idsDone = 0; |
|
140 |
|
|
141 |
$.each(this.selected_nodes, function(index, template_id) { |
|
142 |
OpenNebulaTemplate.show({ |
|
143 |
data : { |
|
144 |
id: template_id |
|
145 |
}, |
|
146 |
timeout: true, |
|
147 |
success: function (request, template_json) { |
|
148 |
templatesContext.append( |
|
149 |
'<h3 style="border-bottom: 1px solid #efefef; padding-bottom: 10px;">' + |
|
150 |
'<span style="border-bottom: 2px solid #0098c3; padding: 0px 50px 10px 0px;">' + |
|
151 |
template_json.VMTEMPLATE.NAME + |
|
152 |
'</span>' + |
|
153 |
'</h3>'+ |
|
154 |
'<div class="large-11 columns large-centered capacityContext' + template_json.VMTEMPLATE.ID + '">' + |
|
155 |
'<div class="row">'+ |
|
156 |
'<div class="large-12 columns">'+ |
|
157 |
'<h3 class="subheader text-right">'+ |
|
158 |
'<span class="left">'+ |
|
159 |
'<i class="fa fa-laptop fa-lg"></i> '+ |
|
160 |
Locale.tr("Capacity")+ |
|
161 |
'</span>'+ |
|
162 |
'</h3>'+ |
|
163 |
'</div>'+ |
|
164 |
'</div>'+ |
|
165 |
'<div class="row">'+ |
|
166 |
CapacityInputs.html() + |
|
167 |
'</div>'+ |
|
168 |
'</div>' + |
|
169 |
'<div class="large-11 columns large-centered disksContext' + template_json.VMTEMPLATE.ID + '"></div>' + |
|
170 |
'<div class="large-11 columns large-centered template_user_inputs' + template_json.VMTEMPLATE.ID + '"></div>'+ |
|
171 |
'<br>'); |
|
172 |
|
|
173 |
DisksResize.insert(template_json, $(".disksContext" + template_json.VMTEMPLATE.ID, context)); |
|
174 |
|
|
175 |
var inputs_div = $(".template_user_inputs" + template_json.VMTEMPLATE.ID, context); |
|
176 |
|
|
177 |
UserInputs.vmTemplateInsert( |
|
178 |
inputs_div, |
|
179 |
template_json, |
|
180 |
{text_header: '<i class="fa fa-gears fa-lg"></i> '+Locale.tr("Custom Attributes")}); |
|
181 |
|
|
182 |
inputs_div.data("opennebula_id", template_json.VMTEMPLATE.ID); |
|
183 |
|
|
184 |
capacityContext = $(".capacityContext" + template_json.VMTEMPLATE.ID, context); |
|
185 |
CapacityInputs.setup(capacityContext); |
|
186 |
CapacityInputs.fill(capacityContext, template_json.VMTEMPLATE); |
|
187 |
|
|
188 |
if (template_json.VMTEMPLATE.TEMPLATE.SUNSTONE_CAPACITY_SELECT && |
|
189 |
template_json.VMTEMPLATE.TEMPLATE.SUNSTONE_CAPACITY_SELECT.toUpperCase() == "NO"){ |
|
190 |
|
|
191 |
capacityContext.hide(); |
|
192 |
} |
|
193 |
|
|
194 |
idsDone += 1; |
|
195 |
if (idsLength == idsDone){ |
|
196 |
Sunstone.enableFormPanelSubmit(TAB_ID); |
|
197 |
} |
|
198 |
}, |
|
199 |
error: function(request, error_json, container) { |
|
200 |
Notifier.onError(request, error_json, container); |
|
201 |
$("#instantiate_vm_user_inputs", context).empty(); |
|
202 |
} |
|
203 |
}); |
|
204 |
}); |
|
205 |
} |
|
206 |
|
|
207 |
function _onShow(context) { |
|
208 |
Sunstone.disableFormPanelSubmit(TAB_ID); |
|
209 |
|
|
210 |
var templatesContext = $(".list_of_templates", context); |
|
211 |
templatesContext.html(""); |
|
212 |
|
|
213 |
Tips.setup(context); |
|
214 |
return false; |
|
215 |
} |
|
216 |
}); |
src/sunstone/public/app/tabs/templates-tab/form-panels/instantiate/formPanelId.js | ||
---|---|---|
1 |
define(function(require){ |
|
2 |
return 'instantiateTemplateDialog'; |
|
3 |
}) |
src/sunstone/public/app/tabs/templates-tab/form-panels/instantiate/html.hbs | ||
---|---|---|
1 |
<form data-abide="ajax" id="{{formPanelId}}Wizard" class="custom creation"> |
|
2 |
<div class="row"> |
|
3 |
<div class="large-4 columns"> |
|
4 |
<label for="vm_name"> |
|
5 |
{{tr "VM Name"}} |
|
6 |
<span class="tip"> |
|
7 |
{{tr "Defaults to template name when emtpy. You can use the wildcard %i. When creating several VMs, %i will be replaced with a different number starting from 0 in each of them"}}. |
|
8 |
</span> |
|
9 |
</label> |
|
10 |
<input type="text" name="vm_name" id="vm_name" /> |
|
11 |
</div> |
|
12 |
<div class="large-4 columns"> |
|
13 |
<label for="vm_n_times"> |
|
14 |
{{tr "Number of instances"}} |
|
15 |
<span class="tip"> |
|
16 |
{{tr "Number of Virtual Machines that will be created using this template"}}. |
|
17 |
</span> |
|
18 |
</label> |
|
19 |
<input type="text" name="vm_n_times" id="vm_n_times" value="1"> |
|
20 |
</div> |
|
21 |
<div class="large-4 columns"> |
|
22 |
<input type="checkbox" name="hold" id="hold"/> |
|
23 |
<label for="hold"> |
|
24 |
{{tr "Hold"}} |
|
25 |
<span class="tip"> |
|
26 |
{{tr "Sets the new VM to hold state, instead of pending. The scheduler will not deploy VMs in this state. It can be released later, or deployed manually."}} |
|
27 |
</span> |
|
28 |
</label> |
|
29 |
</div> |
|
30 |
</div> |
|
31 |
<div class="row"> |
|
32 |
<div class="large-11 large-centered columns list_of_templates"> |
|
33 |
</div> |
|
34 |
</div> |
|
35 |
</form> |
Also available in: Unified diff