diff --git a/src/sunstone/public/js/plugins/vms-tab.js b/src/sunstone/public/js/plugins/vms-tab.js
index 56621a8e52..a6027ad001 100644
--- a/src/sunstone/public/js/plugins/vms-tab.js
+++ b/src/sunstone/public/js/plugins/vms-tab.js
@@ -50,7 +50,7 @@ var netUsage = {
var create_vm_tmpl ='\
\
\
-
'+tr("Create Virtual Machine")+'
\
+
'+tr("Create Virtual Machine")+'
\
\
\
\
@@ -59,20 +59,20 @@ var create_vm_tmpl ='\
\
\
\
-
\
\
- '+tr("Number of instances")+':\
+ '+tr("Number of instances")+':\
'+tr("Number of Virtual Machines that will be created using this template")+'.\
\
- \
+ \
\
\
- \
- '+tr("Hold")+'\
+ \
+ '+tr("Hold")+'\
' + 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.") +'\
\
\
\
×\
@@ -2669,27 +2676,62 @@ function setupCreateVMDialog(){
$(document).foundation();
//dialog.addClass("reveal-modal large max-height").attr("data-reveal", "");
+ $("#create_vm_template_proceed", dialog).attr("disabled", "disabled");
+ $("#create_vm_inputs_step", dialog).hide();
+
setupTemplateTableSelect(dialog, "vm_create");
$('#refresh_button_vm_create', dialog).click();
+ $("#selected_resource_id_vm_create", dialog).on("change", function(){
+ var template_id = $(this).val();
+
+ $("#create_vm_inputs_step", dialog).hide();
+ $("#create_vm_user_inputs", dialog).empty();
+
+ OpenNebula.Template.show({
+ data : {
+ id: template_id
+ },
+ timeout: true,
+ success: function (request, template_json){
+ $("#create_vm_inputs_step", dialog).hide();
+ $("#create_vm_user_inputs", dialog).empty();
+
+ var has_inputs = generateVMTemplateUserInputs(
+ $("#create_vm_user_inputs", dialog),
+ template_json,
+ {text_header: ""});
+
+ if(has_inputs){
+ $("#create_vm_inputs_step", dialog).show();
+ }
+
+ $("#create_vm_template_proceed", dialog).removeAttr("disabled");
+ },
+ error: function(request,error_json, container){
+ onError(request,error_json, container);
+ }
+ });
+ });
+
setupTips(dialog);
$('#create_vm_form',dialog).submit(function(){
- var vm_name = $('#vm_name',this).val();
+ var vm_name = $('#create_vm_name',this).val();
var template_id = $("#selected_resource_id_vm_create", this).val();
- var n_times = $('#vm_n_times',this).val();
+ var n_times = $('#create_vm_n_times',this).val();
var n_times_int=1;
- var hold = $('#hold',this).prop("checked");
+ var hold = $('#create_vm_hold',this).prop("checked");
if (!template_id.length){
notifyError(tr("You have not selected a template"));
return false;
- };
+ }
if (n_times.length){
n_times_int=parseInt(n_times,10);
- };
+ }
var extra_msg = "";
if (n_times_int > 1) {
@@ -2702,14 +2744,17 @@ function setupCreateVMDialog(){
'hold': hold
};
+ var tmp_json = {};
+ retrieveWizardFields($(this), tmp_json);
+
+ extra_info['template'] = tmp_json;
+
if (!vm_name.length){ //empty name use OpenNebula core default
for (var i=0; i< n_times_int; i++){
extra_info['vm_name'] = "";
Sunstone.runAction("Template.instantiate_quiet", template_id, extra_info);
}
- }
- else
- {
+ } else {
if (vm_name.indexOf("%i") == -1){//no wildcard, all with the same name
for (var i=0; i< n_times_int; i++){
extra_info['vm_name'] = vm_name;
diff --git a/src/sunstone/public/js/sunstone.js b/src/sunstone/public/js/sunstone.js
index c46da9836b..c1f7bb7d14 100644
--- a/src/sunstone/public/js/sunstone.js
+++ b/src/sunstone/public/js/sunstone.js
@@ -5099,10 +5099,10 @@ function setupResourceTableSelect(section, context_id, options) {
$("td", this).addClass('markrow');
$('input.check_item', this).attr('checked','checked');
- $('#selected_resource_id_'+context_id, section).val(aData[options.id_index]);
+ $('#selected_resource_id_'+context_id, section).val(aData[options.id_index]).change();
$('#selected_resource_id_'+context_id, section).hide();
- $('#selected_resource_name_'+context_id, section).text(aData[options.name_index]);
+ $('#selected_resource_name_'+context_id, section).text(aData[options.name_index]).change();
$('#selected_resource_name_'+context_id, section).show();
return true;
@@ -5118,39 +5118,42 @@ function setupResourceTableSelect(section, context_id, options) {
// It will replace the div's html with a row for each USER_INPUTS
// opts.text_header: header text for the text & password inputs
// opts.network_header: header text for the network inputs
+// returns true if at least one input was inserted
function generateVMTemplateUserInputs(div, template_json, opts) {
- generateInstantiateUserInputs(
+ return generateInstantiateUserInputs(
div, template_json.VMTEMPLATE.TEMPLATE.USER_INPUTS, opts);
}
// It will replace the div's html with a row for each USER_INPUTS
// opts.text_header: header text for the text & password inputs
// opts.network_header: header text for the network inputs
+// returns true if at least one input was inserted
function generateServiceTemplateUserInputs(div, template_json, opts) {
- generateInstantiateUserInputs(
+ return generateInstantiateUserInputs(
div, template_json.DOCUMENT.TEMPLATE.BODY.custom_attrs, opts);
}
// It will replace the div's html with a row for each USER_INPUTS
// opts.text_header: header text for the text & password inputs
// opts.network_header: header text for the network inputs
+// returns true if at least one input was inserted
function generateInstantiateUserInputs(div, user_inputs, opts) {
div.empty();
if(user_inputs == undefined){
- return;
+ return false;
}
if(opts == undefined){
opts = {};
}
- if(!opts.text_header){
+ if(opts.text_header == undefined){
opts.text_header = tr("Custom Attributes");
}
- if(!opts.network_header){
+ if(opts.network_header == undefined){
opts.network_header = tr("Network");
}
@@ -5181,17 +5184,19 @@ function generateInstantiateUserInputs(div, user_inputs, opts) {
});
if (network_attrs.length > 0) {
- div.append(
- ' '+
- '