1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-03-30 22:50:10 +03:00

feature #2166: Add easy provisioning button

This commit is contained in:
Daniel Molina 2013-07-11 12:39:11 +02:00
parent 0a89143d4b
commit a345a7c23b
3 changed files with 466 additions and 142 deletions

View File

@ -78,7 +78,12 @@ module OpenNebulaJSON
end
def instantiate(params=Hash.new)
super(params['vm_name'])
if params['template']
template = template_to_str(params['template'])
super(params['vm_name'], false, template)
else
super(params['vm_name'])
end
end
def clone(params=Hash.new)

View File

@ -1066,8 +1066,7 @@ var OpenNebula = {
OpenNebula.Action.simple_action(params,OpenNebula.Template.resource,"unpublish");
},
"instantiate" : function(params) {
var vm_name = params.data.extra_param ? params.data.extra_param : "";
var action_obj = { "vm_name" : vm_name };
var action_obj = params.data.extra_param ? params.data.extra_param : {};
OpenNebula.Action.simple_action(params,OpenNebula.Template.resource,
"instantiate",action_obj);
},

View File

@ -15,144 +15,295 @@
/* -------------------------------------------------------------------------- */
/*Templates tab plugin*/
var templates_tab_content = '\
<form class="custom" id="template_form" action="">\
<div class="panel">\
<div class="row">\
<div class="twelve columns">\
<h4 class="subheader header">\
<span class="header-resource">\
<i class="icon-file-alt"></i> '+tr("Templates")+'\
</span>\
<span class="header-info">\
<span/> <small></small>&emsp;\
</span>\
<span class="user-login">\
</span>\
</h4>\
</div>\
</div>\
<div class="row">\
<div class="ten columns">\
<div class="action_blocks">\
<div class="panel">\
<div class="row">\
<div class="twelve columns">\
<h4 class="subheader header">\
<span class="header-resource">\
<i class="icon-file-alt"></i> '+tr("Templates")+'\
</span>\
<span class="header-info">\
<span/> <small></small>&emsp;\
</span>\
<span class="user-login">\
</span>\
</h4>\
</div>\
</div>\
<div class="row">\
<div class="ten columns">\
<div class="action_blocks">\
</div>\
</div>\
<div class="two columns">\
<input id="template_search" type="text" placeholder="'+tr("Search")+'" />\
</div>\
<br>\
<br>\
</div>\
</div>\
<div class="two columns">\
<input id="template_search" type="text" placeholder="'+tr("Search")+'" />\
</div>\
<br>\
<br>\
</div>\
</div>\
<div class="row">\
<div class="twelve columns">\
<table id="datatable_templates" class="datatable twelve">\
<thead>\
<tr>\
<th class="check"><input type="checkbox" class="check_all" value=""></input></th>\
<th>'+tr("ID")+'</th>\
<th>'+tr("Owner")+'</th>\
<th>'+tr("Group")+'</th>\
<th>'+tr("Name")+'</th>\
<th>'+tr("Registration time")+'</th>\
</tr>\
</thead>\
<tbody id="tbodytemplates">\
</tbody>\
</table>\
</div>\
<table id="datatable_templates" class="datatable twelve">\
<thead>\
<tr>\
<th class="check"><input type="checkbox" class="check_all" value=""></input></th>\
<th>'+tr("ID")+'</th>\
<th>'+tr("Owner")+'</th>\
<th>'+tr("Group")+'</th>\
<th>'+tr("Name")+'</th>\
<th>'+tr("Registration time")+'</th>\
</tr>\
</thead>\
<tbody id="tbodytemplates">\
</tbody>\
</table>\
</div>\
</div>\
</form>';
var create_template_tmpl = '<div class="panel">'+
'<h3><small id="create_template_header">'+tr("Create VM Template")+'</small><small id="update_template_header" class="hidden">'+tr("Update VM Template")+'</small></h3>'+
'</div>'+
'<div class="reveal-body">'+
'<dl class="tabs">' +
'<dd id="wizard_mode" class="active"><a href="#easy">'+tr("Wizard")+'</a></dd>' +
'<dd id="advanced_mode"><a id="advanced_mode_a" href="#manual">'+tr("Advanced mode")+'</a></dd>' +
'</dl>' +
'<ul class="tabs-content">' +
'<li class="active" id="easyTab">' +
'<form class="custom creation">'+
'<div class="">'+
'<div class="columns three">'+
'<dl id="template_create_tabs" class="tabs vertical">'+
'</dl>'+
'</div>'+
'<div class="columns nine">'+
'<ul id="template_create_tabs_content" class="tabs-content">'+
'</ul>'+
'</div>'+
var create_template_tmpl = '\
<div class="panel">'+
'<h3><small id="create_template_header">'+tr("Create VM Template")+'</small><small id="update_template_header" class="hidden">'+tr("Update VM Template")+'</small></h3>'+
'</div>'+
'<div class="reveal-body">'+
'<dl class="tabs">' +
'<dd id="wizard_mode" class="active"><a href="#easy">'+tr("Wizard")+'</a></dd>' +
'<dd id="advanced_mode"><a id="advanced_mode_a" href="#manual">'+tr("Advanced mode")+'</a></dd>' +
'</dl>' +
'<ul class="tabs-content">' +
'<li class="active" id="easyTab">' +
'<form class="custom creation">'+
'<div class="">'+
'<div class="columns three">'+
'<dl id="template_create_tabs" class="tabs vertical">'+
'</dl>'+
'</div>'+
'<div class="reveal-footer">'+
'<hr>'+
'<button class="success button radius" id="create_template_form_easy" value="OpenNebula.Template.create" style="float: right">'+tr("Create")+'</button>'+
'<button class="button hidden radius" id="template_template_update_button" value="Template.update_template" style="float: right">'+tr("Update")+'</button>'+
'<button class="button secondary radius" id="template_template_reset_button" value="reset" type="reset">'+tr("Reset")+'</button>'+
'<button class="button secondary hidden radius" id="template_template_reset_button_update" value="reset" type="reset">'+tr("Reset")+'</button>'+
'<button class="close-reveal-modal button secondary radius" type="button" value="close">' + tr("Close") + '</button>'+
'<div class="columns nine">'+
'<ul id="template_create_tabs_content" class="tabs-content">'+
'</ul>'+
'</div>'+
'</form>'+
'</li>' +
'<li id="manualTab">' +
'<form id="create_template_form_manual" action="">' +
'<h4><small>'+tr("Write the Virtual Machine template here")+'</small></h4>' +
'<textarea id="template" rows="15" style="width:100%;"></textarea>' +
'<div class="reveal-footer">' +
'<hr>' +
'<div class="form_buttons">' +
'<button class="button success right radius" id="create_template_submit_manual" value="template/create">'+tr("Create")+'</button>' +
'<button class="button hidden radius" id="manual_template_update_button" value="Template.update_template" style="float: right">'+tr("Update")+'</button>'+
'<button class="button secondary radius" id="manual_template_reset_button_update" value="reset" type="reset">'+tr("Reset")+'</button>'+
'<button class="close-reveal-modal button secondary radius" type="button" value="close">' + tr("Close") + '</button>' +
'</div>' +
'</div>'+
'<div class="reveal-footer">'+
'<hr>'+
'<button class="success button radius" id="create_template_form_easy" value="OpenNebula.Template.create" style="float: right">'+tr("Create")+'</button>'+
'<button class="button hidden radius" id="template_template_update_button" value="Template.update_template" style="float: right">'+tr("Update")+'</button>'+
'<button class="button secondary radius" id="template_template_reset_button" value="reset" type="reset">'+tr("Reset")+'</button>'+
'<button class="button secondary hidden radius" id="template_template_reset_button_update" value="reset" type="reset">'+tr("Reset")+'</button>'+
'<button class="close-reveal-modal button secondary radius" type="button" value="close">' + tr("Close") + '</button>'+
'</div>'+
'</form>'+
'</li>' +
'<li id="manualTab">' +
'<form id="create_template_form_manual" action="">' +
'<h4><small>'+tr("Write the Virtual Machine template here")+'</small></h4>' +
'<textarea id="template" rows="15" style="width:100%;"></textarea>' +
'<div class="reveal-footer">' +
'<hr>' +
'<div class="form_buttons">' +
'<button class="button success right radius" id="create_template_submit_manual" value="template/create">'+tr("Create")+'</button>' +
'<button class="button hidden radius" id="manual_template_update_button" value="Template.update_template" style="float: right">'+tr("Update")+'</button>'+
'<button class="button secondary radius" id="manual_template_reset_button_update" value="reset" type="reset">'+tr("Reset")+'</button>'+
'<button class="close-reveal-modal button secondary radius" type="button" value="close">' + tr("Close") + '</button>' +
'</div>' +
'</form>' +
'</li>' +
'</ul>' +
'</div>'+
'<a class="close-reveal-modal">&#215;</a>';
'</div>' +
'</form>' +
'</li>' +
'</ul>' +
'</div>'+
'<a class="close-reveal-modal">&#215;</a>';
var instantiate_vm_template_tmpl ='\
<div class="panel">\
<h3>\
<small id="create_vnet_header">'+tr("Instantiate VM Template")+'</small>\
</h3>\
</div>\
<form id="instantiate_vm_template_form" action="">\
<div class="row centered">\
<div class="four columns">\
<label class="inline right" for="vm_name">'+tr("VM Name")+':</label>\
</div>\
<div class="seven columns">\
<input type="text" name="vm_name" id="vm_name" />\
</div>\
<div class="one columns">\
<div class="tip">'+tr("Defaults to template name when emtpy")+'.</div>\
</div>\
</div>\
<div class="row centered">\
<div class="four columns">\
<label class="inline right" for="vm_n_times">'+tr("Deploy # VMs")+':</label>\
</div>\
<div class="seven columns">\
<input type="text" name="vm_n_times" id="vm_n_times" value="1">\
</div>\
<div class="one columns">\
<div class="tip">'+tr("You can use the wildcard &#37;i. When creating several VMs, &#37;i will be replaced with a different number starting from 0 in each of them")+'.</div>\
</div>\
</div>\
<hr>\
<div class="form_buttons">\
<button class="button radius right success" id="instantiate_vm_tenplate_proceed" value="Template.instantiate_vms">'+tr("Instantiate")+'</button>\
<button class="close-reveal-modal button secondary radius" type="button" value="close">' + tr("Close") + '</button>\
</div>\
<a class="close-reveal-modal">&#215;</a>\
<div class="panel">\
<h3>\
<small id="create_vnet_header">'+tr("Instantiate VM Template")+'</small>\
</h3>\
</div>\
<form id="instantiate_vm_template_form" action="">\
<div class="row">\
<div class="seven columns">\
<div class="four columns">\
<label class="inline right" for="vm_name">'+tr("VM Name")+':</label>\
</div>\
<div class="seven columns">\
<input type="text" name="vm_name" id="vm_name" />\
</div>\
<div class="one columns">\
<div class="tip">'+tr("Defaults to template name when emtpy. You can use the wildcard &#37;i. When creating several VMs, &#37;i will be replaced with a different number starting from 0 in each of them")+'.</div>\
</div>\
</div>\
<div class="five columns">\
<div class="six columns">\
<label class="inline right" for="vm_n_times">'+tr("# VMs")+':</label>\
</div>\
<div class="five columns">\
<input type="text" name="vm_n_times" id="vm_n_times" value="1">\
</div>\
<div class="one columns">\
<div class="tip">'+tr("Number of Virtual Machines that will be created using this template")+'.</div>\
</div>\
</div>\
</div>\
<hr>\
<div class="form_buttons">\
<button class="button radius right success" id="instantiate_vm_tenplate_proceed" value="Template.instantiate_vms">'+tr("Instantiate")+'</button>\
<button class="close-reveal-modal button secondary radius" type="button" value="close">' + tr("Close") + '</button>\
</div>\
<a class="close-reveal-modal">&#215;</a>\
</form>';
var easy_provision_vm_template_tmpl ='\
<div class="panel">\
<h3>\
<small id="create_vnet_header">'+tr("Instantiate VM Template")+'</small>\
</h3>\
</div>\
<div class="reveal-body">\
<form id="instantiate_vm_template_form" action="">\
<div class="row">\
<fieldset>\
<legend>'+tr("Step 1: Specify a name and the number of instances")+'</legend>\
<div class="seven columns">\
<div class="four columns">\
<label class="inline right" for="vm_name">'+tr("VM Name")+':</label>\
</div>\
<div class="seven columns">\
<input type="text" name="vm_name" id="vm_name" />\
</div>\
<div class="one columns">\
<div class="tip">'+tr("Defaults to template name when emtpy. You can use the wildcard &#37;i. When creating several VMs, &#37;i will be replaced with a different number starting from 0 in each of them")+'.</div>\
</div>\
</div>\
<div class="five columns">\
<div class="six columns">\
<label class="inline right" for="vm_n_times">'+tr("# VMs")+':</label>\
</div>\
<div class="five columns">\
<input type="text" name="vm_n_times" id="vm_n_times" value="1">\
</div>\
<div class="one columns">\
<div class="tip">'+tr("Number of Virtual Machines that will be created using this template")+'.</div>\
</div>\
</div>\
</fieldset>\
</div>\
<br>\
<br>\
<br>\
<div class="row">\
<fieldset>\
<legend>'+tr("Step 3: Select a type of instance")+'</legend>\
<div class="row collapse">\
<div class="seven columns">\
<button id="refresh_template_templates_table_button_class" type="button" class="button small radius secondary"><i class="icon-refresh" /></button>\
</div>\
<div class="five columns">\
<input id="template_templates_table_search" type="text" placeholder="'+tr("Search")+'"/>\
</div>\
</div>\
<table id="template_templates_table" class="datatable twelve">\
<thead>\
<tr>\
<th></th>\
<th>'+tr("ID")+'</th>\
<th>'+tr("Owner")+'</th>\
<th>'+tr("Group")+'</th>\
<th>'+tr("Name")+'</th>\
<th>'+tr("Registration time")+'</th>\
</tr>\
</thead>\
<tbody id="tbodytemplates">\
</tbody>\
</table>\
<div class="row hidden">\
<div class="four columns">\
<label class="right inline" for="TEMPLATE_ID">'+tr("TEMPLATE_ID")+':</label>\
</div>\
<div class="six columns">\
<input type="text" id="TEMPLATE_ID" name="TEMPLATE_ID"/>\
</div>\
<div class="two columns">\
<div class="tip">\
</div>\
</div>\
</div>\
<br>\
<div id="selected_template" class="vm_param kvm_opt xen_opt vmware_opt">\
<span id="select_template" class="radius secondary label">'+tr("Please select a template from the list")+'</span>\
<span id="template_selected" class="radius secondary label hidden">'+tr("You selected the following template:")+'</span>\
<span class="radius label" type="text" id="TEMPLATE_NAME" name="template"></span>\
</div>\
</fieldset>\
</div>\
<br>\
<br>\
<br>\
<div class="row">\
<fieldset>\
<legend>'+tr("Step 3: Select an operation system")+'</legend>\
<div class="row collapse">\
<div class="seven columns">\
<button id="refresh_template_images_table_button_class" type="button" class="button small radius secondary"><i class="icon-refresh" /></button>\
</div>\
<div class="five columns">\
<input id="template_images_table_search" type="text" placeholder="'+tr("Search")+'"/>\
</div>\
</div>\
<table id="template_images_table" class="datatable twelve">\
<thead>\
<tr>\
<th></th>\
<th>'+tr("ID")+'</th>\
<th>'+tr("Owner")+'</th>\
<th>'+tr("Group")+'</th>\
<th>'+tr("Name")+'</th>\
<th>'+tr("Datastore")+'</th>\
<th>'+tr("Size")+'</th>\
<th>'+tr("Type")+'</th>\
<th>'+tr("Registration time")+'</th>\
<th>'+tr("Persistent")+'</th>\
<th>'+tr("Status")+'</th>\
<th>'+tr("#VMS")+'</th>\
<th>'+tr("Target")+'</th>\
</tr>\
</thead>\
<tbody id="tbodyimages">\
</tbody>\
</table>\
<div class="row hidden">\
<div class="four columns">\
<label class="right inline" for="IMAGE_ID">'+tr("IMAGE_ID")+':</label>\
</div>\
<div class="six columns">\
<input type="text" id="IMAGE_ID" name="IMAGE_ID"/>\
</div>\
<div class="two columns">\
<div class="tip">\
</div>\
</div>\
</div>\
<br>\
<div id="selected_image" class="vm_param kvm_opt xen_opt vmware_opt">\
<span id="select_image" class="radius secondary label">'+tr("Please select an image from the list")+'</span>\
<span id="image_selected" class="radius secondary label hidden">'+tr("You selected the following image:")+'</span>\
<span class="radius label" type="text" id="IMAGE_NAME" name="image"></span>\
</div>\
</fieldset>\
</div>\
<div class="form_buttons reveal-footer">\
<hr>\
<div class="form_buttons">\
<button class="button radius right success" id="instantiate_vm_tenplate_proceed" value="Template.instantiate_vms">'+tr("Instantiate")+'</button>\
<button class="close-reveal-modal button secondary radius" type="button" value="close">' + tr("Close") + '</button>\
</div>\
</div>\
<a class="close-reveal-modal">&#215;</a>\
</form>\
</div>';
var dataTable_templates;
var $create_template_dialog;
@ -171,6 +322,13 @@ var template_actions = {
call: popUpCreateTemplateDialog
},
"Template.easy_provision" : {
type: "custom",
call: function() {
popUpInstantiateVMTemplateDialog(true);
}
},
"Template.list" : {
type: "list",
call: OpenNebula.Template.list,
@ -289,13 +447,29 @@ var template_actions = {
nodes = getSelectedNodes(dataTable_templates);
if (nodes.length == 1)
{
popUpInstantiateVMTemplateDialog();
popUpInstantiateVMTemplateDialog(false);
}
else
{
Sunstone.runAction("Template.instantiate", nodes);
}
Sunstone.runAction("VM.refresh");
}
},
"Template.instantiate_and_merge" : {
type: "custom",
call: function(){
nodes = getSelectedNodes(dataTable_templates);
if (nodes.length == 1)
{
popUpMergeVMTemplateDialog();
}
else
{
notifyError(tr("Please select only one template in the table"))
}
Sunstone.runAction("VM.refresh");
}
},
@ -350,6 +524,11 @@ var template_buttons = {
type: "create_dialog",
layout: "create"
},
"Template.easy_provision" : {
type: "create_dialog",
text: "Launch",
layout: "create"
},
"Template.update_dialog" : {
type: "action",
layout: "more_select",
@ -1151,9 +1330,7 @@ function generate_disk_tab_content(str_disk_tab_id, str_datatable_id){
'</div>';
$("#refresh_template_images_table_button_class"+str_disk_tab_id).die();
$("#refresh_template_images_table_button_class"+str_disk_tab_id).live('click', function(){
// Retrieve the images to fill the datatable
update_datatable_template_images($('table[id='+str_datatable_id+']').dataTable());
});
@ -1223,6 +1400,27 @@ function update_datatable_template_images(datatable, fnDrawCallback) {
});
}
function update_datatable_template_templates(datatable, fnDrawCallback) {
if (fnDrawCallback) {
datatable.on('draw', fnDrawCallback);
}
OpenNebula.Template.list({
timeout: true,
success: function (request, templates_list){
var template_list_array = [];
$.each(templates_list,function(){
var template_element_array = templateElementArray(this);
if (template_element_array)
template_list_array.push(template_element_array);
});
updateView(template_list_array, datatable);
}
});
}
function update_datatable_template_files(datatable, fnDrawCallback) {
if (fnDrawCallback) {
datatable.on('draw', fnDrawCallback);
@ -4496,15 +4694,120 @@ function setTemplateAutorefresh() {
// Instantiate dialog
// Sets up the instiantiate template dialog and all the processing associated to it
function setupInstantiateTemplateDialog(){
function setupInstantiateTemplateDialog(easy_provision){
dialogs_context.append('<div title=\"'+tr("Instantiate VM Template")+'\" id="instantiate_vm_template_dialog"></div>');
//Insert HTML in place
$instantiate_vm_template_dialog = $('#instantiate_vm_template_dialog')
var dialog = $instantiate_vm_template_dialog;
dialog.html(instantiate_vm_template_tmpl);
dialog.addClass("reveal-modal");
if (easy_provision) {
dialog.html(easy_provision_vm_template_tmpl);
dialog.addClass("reveal-modal large max-height");
var dataTable_template_images = $('#template_images_table', dialog).dataTable({
"iDisplayLength": 4,
"bAutoWidth":false,
"sDom" : '<"H">t<"F"p>',
"aoColumnDefs": [
{ "sWidth": "35px", "aTargets": [0,1] },
{ "bVisible": false, "aTargets": [2,3,7,8,5,9,12]}
],
"fnDrawCallback": function(oSettings) {
var nodes = this.fnGetNodes();
$.each(nodes, function(){
if ($(this).find("td:eq(1)").html() == $('#IMAGE_ID', dialog).val()) {
$("td", this).addClass('markrow');
$('input.check_item', this).attr('checked','checked');
}
})
}
});
// Retrieve the images to fill the datatable
update_datatable_template_images(dataTable_template_images);
$('#template_images_table_search', dialog).keyup(function(){
dataTable_template_images.fnFilter( $(this).val() );
})
$('#template_images_table tbody', dialog).delegate("tr", "click", function(e){
var aData = dataTable_template_images.fnGetData(this);
$("td.markrow", dataTable_template_images).removeClass('markrow');
$('tbody input.check_item', dataTable_template_images).removeAttr('checked');
$('#image_selected', dialog).show();
$('#select_image', dialog).hide();
$('.alert-box', dialog).hide();
$("td", this).addClass('markrow');
$('input.check_item', this).attr('checked','checked');
$('#IMAGE_NAME', dialog).text(aData[4]);
$('#IMAGE_ID', dialog).val(aData[1]);
return true;
});
$("#refresh_template_images_table_button_class").die();
$("#refresh_template_images_table_button_class").live('click', function(){
update_datatable_template_images($('#template_images_table').dataTable());
});
var dataTable_template_templates = $('#template_templates_table', dialog).dataTable({
"iDisplayLength": 4,
"bAutoWidth":false,
"sDom" : '<"H">t<"F"p>',
"aoColumnDefs": [
{ "sWidth": "35px", "aTargets": [0,1] },
{ "bVisible": false, "aTargets": [1,2,3,5]}
],
"fnDrawCallback": function(oSettings) {
var nodes = this.fnGetNodes();
$.each(nodes, function(){
if ($(this).find("td:eq(1)").html() == $('#TEMPLATE_ID', dialog).val()) {
$("td", this).addClass('markrow');
$('input.check_item', this).attr('checked','checked');
}
})
}
});
// Retrieve the images to fill the datatable
update_datatable_template_templates(dataTable_template_templates);
$('#template_templates_table_search', dialog).keyup(function(){
dataTable_template_templates.fnFilter( $(this).val() );
})
$('#template_templates_table tbody', dialog).delegate("tr", "click", function(e){
var aData = dataTable_template_templates.fnGetData(this);
$("td.markrow", dataTable_template_templates).removeClass('markrow');
$('tbody input.check_item', dataTable_template_templates).removeAttr('checked');
$('#template_selected', dialog).show();
$('#select_template', dialog).hide();
$('.alert-box', dialog).hide();
$("td", this).addClass('markrow');
$('input.check_item', this).attr('checked','checked');
$('#TEMPLATE_NAME', dialog).text(aData[4]);
$('#TEMPLATE_ID', dialog).val(aData[1]);
return true;
});
$("#refresh_template_templates_table_button_class").die();
$("#refresh_template_templates_table_button_class").live('click', function(){
update_datatable_template_templates($('#template_templates_table').dataTable());
});
} else {
dialog.html(instantiate_vm_template_tmpl);
dialog.addClass("reveal-modal large");
dialog.removeClass("max-height")
}
setupTips(dialog);
@ -4513,36 +4816,53 @@ function setupInstantiateTemplateDialog(){
var n_times = $('#vm_n_times',this).val();
var n_times_int=1;
var selected_nodes = getSelectedNodes(dataTable_templates);
var template_id = ""+selected_nodes[0];
var template_id
if ($("#TEMPLATE_ID", this).val()) {
template_id = $("#TEMPLATE_ID", this).val();
} else {
var selected_nodes = getSelectedNodes(dataTable_templates);
template_id = ""+selected_nodes[0];
}
if (n_times.length){
n_times_int=parseInt(n_times,10);
};
var extra_info = "";
var extra_msg = "";
if (n_times_int > 1) {
extra_info = n_times_int+" times";
extra_msg = n_times_int+" times";
}
notifySubmit("Template.instantiate",template_id, extra_info);
notifySubmit("Template.instantiate",template_id, extra_msg);
var extra_info = {};
if ($("#IMAGE_ID", this).val()) {
image_id = $("#IMAGE_ID", this).val();
extra_info['template'] = {
'disk': {
'image_id': image_id
}
}
}
if (!vm_name.length){ //empty name use OpenNebula core default
for (var i=0; i< n_times_int; i++){
Sunstone.runAction("Template.instantiate_quiet", template_id, "");
extra_info['vm_name'] = "";
Sunstone.runAction("Template.instantiate_quiet", template_id, extra_info);
};
}
else
{
if (vm_name.indexOf("%i") == -1){//no wildcard, all with the same name
for (var i=0; i< n_times_int; i++){
Sunstone.runAction("Template.instantiate_quiet", template_id, vm_name);
extra_info['vm_name'] = vm_name;
Sunstone.runAction("Template.instantiate_quiet", template_id, extra_info);
};
} 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_quiet", template_id, name);
extra_info['vm_name'] = vm_name.replace(/%i/gi,i);
Sunstone.runAction("Template.instantiate_quiet", template_id, extra_info);
};
};
}
@ -4553,7 +4873,8 @@ function setupInstantiateTemplateDialog(){
}
// Open creation dialog
function popUpInstantiateVMTemplateDialog(){
function popUpInstantiateVMTemplateDialog(easy_provision){
setupInstantiateTemplateDialog(easy_provision);
$instantiate_vm_template_dialog.reveal();
}
@ -4580,7 +4901,6 @@ $(document).ready(function(){
})
Sunstone.runAction("Template.list");
setupInstantiateTemplateDialog();
setupCreateTemplateDialog();
setupTemplateCloneDialog();
setTemplateAutorefresh();