\
+
\
+ \
\
-
\
-
\
- \
-
\
-
\
- \
-
\
-
\
+
\
+ \
\
-
\
-
\
- \
-
\
-
\
- \
-
\
-
\
-
'+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")+'.
\
-
\
+
\
+
'+tr("Number of Virtual Machines that will be created using this template")+'.
\
\
-
\
-
\
- \
- \
\
-
×\
-';
+ \
+
\
+
\
+
\
+
\
+
\
+
\
+
\
+
\
+
\
+
\
+
\
+
\
+
\
+ \
+
×\
+ \
+
';
var vmachine_list_json = {};
var dataTable_vMachines;
@@ -157,7 +306,16 @@ var vm_actions = {
"VM.create_dialog" : {
type: "custom",
- call: popUpCreateVMDialog
+ call: function(){
+ popUpCreateVMDialog(false);
+ }
+ },
+
+ "VM.easy_provision" : {
+ type: "custom",
+ call: function(){
+ popUpCreateVMDialog(true);
+ }
},
"VM.list" : {
@@ -692,6 +850,12 @@ var vm_buttons = {
layout: "create",
alwaysActive: true
},
+ "VM.easy_provision" : {
+ type: "action",
+ layout: "create",
+ text: tr("Launch"),
+ alwaysActive: true
+ },
"VM.chown" : {
type: "confirm_with_select",
text: tr("Change owner"),
@@ -2732,28 +2896,123 @@ function setup_vm_snapshot_tab(){
// Sets up the create-template dialog and all the processing associated to it,
// which is a lot.
-function setupCreateVMDialog(){
+function setupCreateVMDialog(include_select_image){
dialogs_context.append('
');
//Insert HTML in place
$create_vm_dialog = $('#create_vm_dialog')
var dialog = $create_vm_dialog;
dialog.html(create_vm_tmpl);
+ dialog.addClass("reveal-modal large max-height");
- //Prepare jquery dialog
- //dialog.dialog({
- // autoOpen: false,
- // modal: true,
- // width: 400
- //});
- dialog.addClass("reveal-modal");
+ 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());
+ });
+
+ if (include_select_image) {
+ $("#select_image_step", dialog).show();
+ 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());
+ });
+ } else {
+ $("#select_image_step", dialog).hide();
+ }
- //$('button',dialog).button();
setupTips(dialog);
$('#create_vm_form',dialog).submit(function(){
var vm_name = $('#vm_name',this).val();
- var template_id = $('#template_id',this).val();
+ var template_id = $('#TEMPLATE_ID',this).val();
var n_times = $('#vm_n_times',this).val();
var n_times_int=1;
@@ -2766,29 +3025,40 @@ function setupCreateVMDialog(){
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
+ 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);
};
};
}
@@ -2802,7 +3072,8 @@ function setupCreateVMDialog(){
}
// Open creation dialog
-function popUpCreateVMDialog(){
+function popUpCreateVMDialog(include_select_image){
+ setupCreateVMDialog(include_select_image);
$create_vm_dialog.reveal();
}