Revision cd6cdf26

View differences:

src/sunstone/public/js/plugins/templates-tab.js
4070 4070
            n_times_int=parseInt(n_times,10);
4071 4071
        };
4072 4072

  
4073
        if (!vm_name.length){
4074
            vm_name = getTemplateName(template_id);
4075
        };
4076

  
4077
        if (vm_name.indexOf("%i") == -1){ //no wildcard
4078
            for (var i=0; i< n_times_int; i++){
4079
                Sunstone.runAction("Template.instantiate",template_id,vm_name);
4080
            };
4081
        } else { //wildcard present: replace wildcard
4082
            var name = "";
4073
        if (!vm_name.length){ //empty name use OpenNebula core default
4083 4074
            for (var i=0; i< n_times_int; i++){
4084
                name = vm_name.replace(/%i/gi,i);
4085
                Sunstone.runAction("Template.instantiate",template_id,name);
4075
                Sunstone.runAction("Template.instantiate", template_id, "");
4086 4076
            };
4087
        };
4077
        }
4078
        else
4079
        {
4080
          if (vm_name.indexOf("%i") == -1){//no wildcard, all with the same name
4081
              for (var i=0; i< n_times_int; i++){
4082
                Sunstone.runAction("Template.instantiate", template_id, vm_name);
4083
              };
4084
          } else { //wildcard present: replace wildcard
4085
              var name = "";
4086
              for (var i=0; i< n_times_int; i++){
4087
                  name = vm_name.replace(/%i/gi,i);
4088
                  Sunstone.runAction("Template.instantiate", template_id, name);
4089
              };
4090
          };
4091
        }
4088 4092

  
4089 4093
        $instantiate_vm_template_dialog.trigger("reveal:close")
4090 4094
        return false;
src/sunstone/public/js/plugins/vms-tab.js
2703 2703
            n_times_int=parseInt(n_times,10);
2704 2704
        };
2705 2705

  
2706
        if (!vm_name.length){
2707
            vm_name = getTemplateName(template_id);
2708
        };
2709

  
2710
        if (vm_name.indexOf("%i") == -1){ //no wildcard
2706
        if (!vm_name.length){ //empty name use OpenNebula core default
2711 2707
            for (var i=0; i< n_times_int; i++){
2712
                Sunstone.runAction("Template.instantiate",template_id,vm_name);
2708
                Sunstone.runAction("Template.instantiate", template_id, "");
2713 2709
            };
2714
        } else { //wildcard present: replace wildcard
2715
            var name = "";
2716
            for (var i=0; i< n_times_int; i++){
2717
                name = vm_name.replace(/%i/gi,i);
2718
                Sunstone.runAction("Template.instantiate",template_id,name);
2719
            };
2720
        };
2710
        }
2711
        else
2712
        {
2713
          if (vm_name.indexOf("%i") == -1){ //no wildcard
2714
              for (var i=0; i< n_times_int; i++){
2715
                Sunstone.runAction("Template.instantiate", template_id, vm_name);
2716
              };
2717
          } else { //wildcard present: replace wildcard
2718
              var name = "";
2719
              for (var i=0; i< n_times_int; i++){
2720
                  name = vm_name.replace(/%i/gi,i);
2721
                  Sunstone.runAction("Template.instantiate", template_id, name);
2722
              };
2723
          };
2724
        }
2721 2725

  
2722 2726
        setTimeout(function(){
2723 2727
            Sunstone.runAction("VM.list");

Also available in: Unified diff