From 986c1282baaceeaf743e555a83d27283696e534b Mon Sep 17 00:00:00 2001 From: Hector Sanjuan Date: Wed, 25 Jan 2012 23:47:39 +0100 Subject: [PATCH] Feature #1030: Allow parametric values when creating several VMs in SelfService --- .../occi/lib/ui/public/js/plugins/compute.js | 25 ++++++++++++------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/src/cloud/occi/lib/ui/public/js/plugins/compute.js b/src/cloud/occi/lib/ui/public/js/plugins/compute.js index 5550566e49..993faf93ab 100644 --- a/src/cloud/occi/lib/ui/public/js/plugins/compute.js +++ b/src/cloud/occi/lib/ui/public/js/plugins/compute.js @@ -89,8 +89,11 @@ var create_vm_tmpl ='
\ \ \
\ - \ - \ +
\ + \ + \ +
'+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")+'.
\ +
\
\
\ \ @@ -686,6 +689,8 @@ function popUpCreateVMDialog(){ text: true }); + setupTips(dialog); + var net_select = makeSelectOptions(dataTable_vNetworks, 1,//id_col 2,//name_col @@ -772,17 +777,19 @@ function popUpCreateVMDialog(){ if (n_times.length){ n_times_int=parseInt(n_times,10); - } + }; - if (n_times_int>1){ - if (!vm_name.length){ - vm_name = $('#template_id option:selected',this).text(); - } + if (vm_name.indexOf("%i") == -1){ //no wildcard for (var i=0; i< n_times_int; i++){ Sunstone.runAction("VM.create",vm); }; - } else { - Sunstone.runAction("VM.create",vm); + } else { //wildcard present: replace wildcard + var name = ""; + for (var i=0; i< n_times_int; i++){ + name = vm_name.replace(/%i/gi,i); + vm["NAME"] = name; + Sunstone.runAction("VM.create",vm); + }; }; popUpVMDashboard();