From 482d4ceda8defe51f657b0ed8c96e4ec26286665 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn?= Date: Tue, 1 Jul 2014 13:43:20 +0200 Subject: [PATCH] Feature #3017: Remove the easy provisioning wizard from sunstone --- src/sunstone/etc/sunstone-views/admin.yaml | 2 - src/sunstone/etc/sunstone-views/cloud.yaml | 6 +- src/sunstone/etc/sunstone-views/user.yaml | 2 - src/sunstone/etc/sunstone-views/vdcadmin.yaml | 6 +- .../etc/sunstone-views/vdcadmin46.yaml | 2 - .../public/js/plugins/templates-tab.js | 374 +++--------------- src/sunstone/public/js/plugins/vms-tab.js | 148 +------ 7 files changed, 62 insertions(+), 478 deletions(-) diff --git a/src/sunstone/etc/sunstone-views/admin.yaml b/src/sunstone/etc/sunstone-views/admin.yaml index ba2844fe87..f49b957b42 100644 --- a/src/sunstone/etc/sunstone-views/admin.yaml +++ b/src/sunstone/etc/sunstone-views/admin.yaml @@ -126,7 +126,6 @@ tabs: actions: VM.refresh: true VM.create_dialog: true - VM.easy_provision: false VM.chown: true VM.chgrp: true VM.chmod: true @@ -175,7 +174,6 @@ tabs: actions: Template.refresh: true Template.create_dialog: true - Template.easy_provision: false Template.update_dialog: true Template.instantiate_vms: true Template.chown: true diff --git a/src/sunstone/etc/sunstone-views/cloud.yaml b/src/sunstone/etc/sunstone-views/cloud.yaml index d3f463bc15..814d26ffc7 100644 --- a/src/sunstone/etc/sunstone-views/cloud.yaml +++ b/src/sunstone/etc/sunstone-views/cloud.yaml @@ -123,8 +123,7 @@ tabs: - 11 # VNC actions: VM.refresh: true - VM.create_dialog: false - VM.easy_provision: true + VM.create_dialog: true VM.chown: false VM.chgrp: false VM.chmod: true @@ -172,8 +171,7 @@ tabs: - 5 # Registration time actions: Template.refresh: true - Template.create_dialog: false - Template.easy_provision: true + Template.create_dialog: true Template.update_dialog: true Template.instantiate_vms: true Template.chown: false diff --git a/src/sunstone/etc/sunstone-views/user.yaml b/src/sunstone/etc/sunstone-views/user.yaml index 880de7783b..86fc6b1325 100644 --- a/src/sunstone/etc/sunstone-views/user.yaml +++ b/src/sunstone/etc/sunstone-views/user.yaml @@ -126,7 +126,6 @@ tabs: actions: VM.refresh: true VM.create_dialog: true - VM.easy_provision: false VM.chown: false VM.chgrp: false VM.chmod: true @@ -175,7 +174,6 @@ tabs: actions: Template.refresh: true Template.create_dialog: true - Template.easy_provision: false Template.update_dialog: true Template.instantiate_vms: true Template.chown: false diff --git a/src/sunstone/etc/sunstone-views/vdcadmin.yaml b/src/sunstone/etc/sunstone-views/vdcadmin.yaml index bac5b28c87..f799139d2b 100644 --- a/src/sunstone/etc/sunstone-views/vdcadmin.yaml +++ b/src/sunstone/etc/sunstone-views/vdcadmin.yaml @@ -123,8 +123,7 @@ tabs: - 11 # VNC actions: VM.refresh: true - VM.create_dialog: false - VM.easy_provision: true + VM.create_dialog: true VM.chown: false VM.chgrp: false VM.chmod: true @@ -172,8 +171,7 @@ tabs: - 5 # Registration time actions: Template.refresh: true - Template.create_dialog: false - Template.easy_provision: true + Template.create_dialog: true Template.update_dialog: true Template.instantiate_vms: true Template.chown: false diff --git a/src/sunstone/etc/sunstone-views/vdcadmin46.yaml b/src/sunstone/etc/sunstone-views/vdcadmin46.yaml index caea497b80..2436dbd004 100644 --- a/src/sunstone/etc/sunstone-views/vdcadmin46.yaml +++ b/src/sunstone/etc/sunstone-views/vdcadmin46.yaml @@ -126,7 +126,6 @@ tabs: actions: VM.refresh: true VM.create_dialog: false - VM.easy_provision: false VM.chown: true VM.chgrp: false VM.chmod: true @@ -175,7 +174,6 @@ tabs: actions: Template.refresh: true Template.create_dialog: false - Template.easy_provision: false Template.update_dialog: false Template.instantiate_vms: false Template.chown: true diff --git a/src/sunstone/public/js/plugins/templates-tab.js b/src/sunstone/public/js/plugins/templates-tab.js index 7dc62f33cb..4eec1a506a 100644 --- a/src/sunstone/public/js/plugins/templates-tab.js +++ b/src/sunstone/public/js/plugins/templates-tab.js @@ -106,127 +106,6 @@ var instantiate_vm_template_tmpl ='\ ×\ '; -var easy_provision_vm_template_tmpl ='\ -
\ -

'+tr("Instantiate VM Template")+'

\ -
\ -
\ -
\ -
\ - '+tr("Step 1: Specify a name and the number of instances")+'\ -
\ -
\ - \ - \ -
\ -
\ - \ - \ -
\ -
\ -
\ -
\ - '+tr("Step 2: Select a template")+'\ -
\ -
\ - \ -
\ -
\ - \ -
\ -
\ -
\ -
\ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ -
'+tr("ID")+''+tr("Owner")+''+tr("Group")+''+tr("Name")+''+tr("Registration time")+'
\ -
\ -
\ - \ -
\ -
\ - '+tr("Please select a template from the list")+'\ - \ - \ -
\ -
\ -
\ -
\ - '+tr("Step 3: Select an operating system")+'\ -
\ -
\ - \ -
\ -
\ - \ -
\ -
\ -
\ -
\ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ -
'+tr("ID")+''+tr("Owner")+''+tr("Group")+''+tr("Name")+''+tr("Datastore")+''+tr("Size")+''+tr("Type")+''+tr("Registration time")+''+tr("Persistent")+''+tr("Status")+''+tr("#VMS")+''+tr("Target")+'
\ -
\ -
\ - \ -
\ -
\ - '+tr("Please select an image from the list")+'\ - \ - \ -
\ -
\ -
\ - \ - ×\ - \ -
'; - var dataTable_templates; var $create_template_dialog; @@ -248,13 +127,6 @@ var template_actions = { call: popUpCreateTemplateDialog }, - "Template.easy_provision" : { - type: "custom", - call: function() { - popUpInstantiateVMTemplateDialog(true); - } - }, - "Template.list" : { type: "list", call: OpenNebula.Template.list, @@ -386,7 +258,7 @@ var template_actions = { "Template.instantiate_vms" : { type: "custom", call: function(){ - popUpInstantiateVMTemplateDialog(false); + popUpInstantiateVMTemplateDialog(); } }, /* @@ -461,11 +333,6 @@ var template_buttons = { type: "create_dialog", layout: "create" }, - "Template.easy_provision" : { - type: "create_dialog", - text: "Launch", - layout: "create" - }, "Template.update_dialog" : { type: "action", layout: "main", @@ -1287,28 +1154,6 @@ function update_datatable_template_images(datatable, fnDrawCallback) { }); } -function update_datatable_template_templates(datatable, fnDrawCallback) { - if (fnDrawCallback) { - datatable.unbind('draw'); - 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.unbind('draw'); @@ -4727,153 +4572,42 @@ function popUpTemplateCloneDialog(){ // Instantiate dialog // Sets up the instiantiate template dialog and all the processing associated to it -function setupInstantiateTemplateDialog(easy_provision){ +function setupInstantiateTemplateDialog(){ dialogs_context.append('
'); //Insert HTML in place $instantiate_vm_template_dialog = $('#instantiate_vm_template_dialog') var dialog = $instantiate_vm_template_dialog; - if (easy_provision) { - dialog.html(easy_provision_vm_template_tmpl); - dialog.addClass("reveal-modal large max-height").attr("data-reveal", ""); + dialog.html(instantiate_vm_template_tmpl); + dialog.addClass("reveal-modal").attr("data-reveal", ""); + dialog.removeClass("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]} - ], - "bSortClasses" : false, - "bDeferRender": true, - "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'); - } - }) - } - }); + $("#instantiate_vm_template_proceed", dialog).attr("disabled", "disabled"); - // Retrieve the images to fill the datatable - update_datatable_template_images(dataTable_template_images); + var selected_nodes = getSelectedNodes(dataTable_templates); + var template_id = ""+selected_nodes[0]; - $('#template_images_table_search', dialog).keyup(function(){ - dataTable_template_images.fnFilter( $(this).val() ); - }) + OpenNebula.Template.show({ + data : { + id: template_id + }, + timeout: true, + success: function (request, template_json){ - dataTable_template_images.fnSort( [ [1,config['user_config']['table_order']] ] ); + $("#instantiate_vm_user_inputs", dialog).empty(); - $('#template_images_table tbody', dialog).delegate("tr", "click", function(e){ - var aData = dataTable_template_images.fnGetData(this); + generateVMTemplateUserInputs( + $("#instantiate_vm_user_inputs", dialog), + template_json); - $("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]} - ], - "bSortClasses" : false, - "bDeferRender": true, - "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() ); - }) - - dataTable_template_templates.fnSort( [ [1,config['user_config']['table_order']] ] ); - - $('#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").attr("data-reveal", ""); - dialog.removeClass("max-height"); - - $("#instantiate_vm_template_proceed", dialog).attr("disabled", "disabled"); - - var selected_nodes = getSelectedNodes(dataTable_templates); - var template_id = ""+selected_nodes[0]; - - OpenNebula.Template.show({ - data : { - id: template_id - }, - timeout: true, - success: function (request, template_json){ - - $("#instantiate_vm_user_inputs", dialog).empty(); - - generateVMTemplateUserInputs( - $("#instantiate_vm_user_inputs", dialog), - template_json); - - $("#instantiate_vm_template_proceed", dialog).removeAttr("disabled"); - }, - error: function(request,error_json, container){ - onError(request,error_json, container); - $("#instantiate_vm_user_inputs", dialog).empty(); - } - }); - } + $("#instantiate_vm_template_proceed", dialog).removeAttr("disabled"); + }, + error: function(request,error_json, container){ + onError(request,error_json, container); + $("#instantiate_vm_user_inputs", dialog).empty(); + } + }); setupTips(dialog); @@ -4884,14 +4618,8 @@ function setupInstantiateTemplateDialog(easy_provision){ var hold = $('#hold',this).prop("checked"); - 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]; - } - + var selected_nodes = getSelectedNodes(dataTable_templates); + var template_id = ""+selected_nodes[0]; if (n_times.length){ n_times_int=parseInt(n_times,10); @@ -4905,43 +4633,41 @@ function setupInstantiateTemplateDialog(easy_provision){ notifySubmit("Template.instantiate",template_id, extra_msg); var extra_info = { - 'template': {}, 'hold': hold }; - if ($("#IMAGE_ID", this).val()) { - image_id = $("#IMAGE_ID", this).val(); - extra_info['template'] = { - 'disk': { - 'image_id': image_id - } - } - } - var tmp_json = {}; retrieveWizardFields($(this), tmp_json); - $.extend(extra_info['template'], tmp_json); + extra_info['template'] = tmp_json; if (!vm_name.length){ //empty name use OpenNebula core default for (var i=0; i< n_times_int; i++){ 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++){ + if (vm_name.indexOf("%i") == -1){//no wildcard, all with the same name extra_info['vm_name'] = vm_name; - Sunstone.runAction("Template.instantiate_quiet", template_id, extra_info); - }; - } else { //wildcard present: replace wildcard - for (var i=0; i< n_times_int; i++){ - extra_info['vm_name'] = vm_name.replace(/%i/gi,i); - Sunstone.runAction("Template.instantiate_quiet", template_id, extra_info); - }; - }; + + for (var i=0; i< n_times_int; i++){ + Sunstone.runAction( + "Template.instantiate_quiet", + template_id, + extra_info); + } + } else { //wildcard present: replace wildcard + for (var i=0; i< n_times_int; i++){ + extra_info['vm_name'] = vm_name.replace(/%i/gi,i); + + Sunstone.runAction( + "Template.instantiate_quiet", + template_id, + extra_info); + } + } } $instantiate_vm_template_dialog.foundation('reveal', 'close') @@ -4950,16 +4676,16 @@ function setupInstantiateTemplateDialog(easy_provision){ } // Open creation dialog -function popUpInstantiateVMTemplateDialog(easy_provision){ +function popUpInstantiateVMTemplateDialog(){ var selected_nodes = getSelectedNodes(dataTable_templates); - if ( easy_provision == false && selected_nodes.length != 1 ) + if ( selected_nodes.length != 1 ) { notifyMessage("Please select one (and just one) template to instantiate."); return false; } - setupInstantiateTemplateDialog(easy_provision); + setupInstantiateTemplateDialog(); $instantiate_vm_template_dialog.foundation().foundation('reveal', 'open'); $("input#vm_name",$instantiate_vm_template_dialog).focus(); } diff --git a/src/sunstone/public/js/plugins/vms-tab.js b/src/sunstone/public/js/plugins/vms-tab.js index 39c1677213..56621a8e52 100644 --- a/src/sunstone/public/js/plugins/vms-tab.js +++ b/src/sunstone/public/js/plugins/vms-tab.js @@ -82,57 +82,6 @@ var create_vm_tmpl ='\ '+tr("Step 2: Select a template")+'\ '+generateTemplateTableSelect("vm_create")+'\ \ -
\ -
\ - '+tr("Step 3: Select an operating system")+'\ -
\ -
\ - \ -
\ -
\ - \ -
\ -
\ -
\ -
\ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ -
'+tr("ID")+''+tr("Owner")+''+tr("Group")+''+tr("Name")+''+tr("Datastore")+''+tr("Size")+''+tr("Type")+''+tr("Registration time")+''+tr("Persistent")+''+tr("Status")+''+tr("#VMS")+''+tr("Target")+'
\ -
\ -
\ - \ -
\ -
\ - '+tr("Please select an image from the list")+'\ - \ - \ -
\ -
\ -
\ - \