From aa86d4c0d17ba0e9e4a6063f7ab367d07619ffa3 Mon Sep 17 00:00:00 2001 From: Hector Sanjuan Date: Wed, 25 Jan 2012 23:46:58 +0100 Subject: [PATCH] Feature #1030: Allow parametric values when creating several VMs in Sunstone. (cherry picked from commit aafd0087c2a0e9a33832628e05d8601eb6ebafd2) --- src/sunstone/public/js/plugins/vms-tab.js | 36 +++++++++++++++++------ 1 file changed, 27 insertions(+), 9 deletions(-) diff --git a/src/sunstone/public/js/plugins/vms-tab.js b/src/sunstone/public/js/plugins/vms-tab.js index 43c71961be..fa69971dd6 100644 --- a/src/sunstone/public/js/plugins/vms-tab.js +++ b/src/sunstone/public/js/plugins/vms-tab.js @@ -75,13 +75,21 @@ var vms_tab_content = var create_vm_tmpl ='
\
\
\ - \ -
\ - \ -
\ - \ - \ +
\ + \ + \ +
'+tr("Defaults to template name when emtpy")+'.
\ +
\ +
\ + \ + \ +
\ +
\ + \ + \ +
'+tr("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")+'.
\ +
\
\
\
\ @@ -846,6 +854,7 @@ function setupCreateVMDialog(){ }); $('button',dialog).button(); + setupTips(dialog); $('#create_vm_form',dialog).submit(function(){ var vm_name = $('#vm_name',this).val(); @@ -866,8 +875,16 @@ function setupCreateVMDialog(){ vm_name = $('#template_id option:selected',this).text(); }; - for (var i=0; i< n_times_int; i++){ - Sunstone.runAction("Template.instantiate",template_id,vm_name); + if (vm_name.indexOf("%i") == -1){ //no wildcard + for (var i=0; i< n_times_int; i++){ + Sunstone.runAction("Template.instantiate",template_id,vm_name); + }; + } else { //wildcard present: replace wildcard + var name = ""; + for (var i=0; i< n_times_int; i++){ + name = vm_name.replace(/%i/gi,i); + Sunstone.runAction("Template.instantiate",template_id,name); + }; }; Sunstone.runAction("VM.list"); @@ -1285,6 +1302,7 @@ $(document).ready(function(){ setupSaveasDialog(); setVMAutorefresh(); setupVNC(); + setupTips initCheckAllBoxes(dataTable_vMachines); tableCheckboxesListener(dataTable_vMachines);