diff --git a/src/sunstone/etc/sunstone-views/kvm/admin.yaml b/src/sunstone/etc/sunstone-views/kvm/admin.yaml index b77f2b978f..1d5aecdb52 100644 --- a/src/sunstone/etc/sunstone-views/kvm/admin.yaml +++ b/src/sunstone/etc/sunstone-views/kvm/admin.yaml @@ -418,6 +418,10 @@ tabs: VM.unlock: true VM.edit_labels: true VM.menu_labels: true + VM.startvnc: true + VM.startspice: true + VM.save_rdp: true + VM.save_virt_viewer: true oneflow-services-tab: panel_tabs: service_info_tab: true diff --git a/src/sunstone/etc/sunstone-views/kvm/cloud.yaml b/src/sunstone/etc/sunstone-views/kvm/cloud.yaml index f8e7238335..96b4e7e625 100644 --- a/src/sunstone/etc/sunstone-views/kvm/cloud.yaml +++ b/src/sunstone/etc/sunstone-views/kvm/cloud.yaml @@ -91,6 +91,10 @@ tabs: VM.migrate_poff_hard: false VM.lockU: true VM.unlock: true + VM.startvnc: true + VM.startspice: true + VM.save_rdp: true + VM.save_virt_viewer: true dashboard: # Connected user's quotas quotas: true diff --git a/src/sunstone/etc/sunstone-views/kvm/groupadmin.yaml b/src/sunstone/etc/sunstone-views/kvm/groupadmin.yaml index 7d3da96f69..f19217a8dc 100644 --- a/src/sunstone/etc/sunstone-views/kvm/groupadmin.yaml +++ b/src/sunstone/etc/sunstone-views/kvm/groupadmin.yaml @@ -417,6 +417,10 @@ tabs: VM.unlock: true VM.edit_labels: true VM.menu_labels: true + VM.startvnc: true + VM.startspice: true + VM.save_rdp: true + VM.save_virt_viewer: true oneflow-services-tab: panel_tabs: service_info_tab: true diff --git a/src/sunstone/etc/sunstone-views/kvm/user.yaml b/src/sunstone/etc/sunstone-views/kvm/user.yaml index aa199986ae..52f4ddc3f3 100644 --- a/src/sunstone/etc/sunstone-views/kvm/user.yaml +++ b/src/sunstone/etc/sunstone-views/kvm/user.yaml @@ -410,6 +410,10 @@ tabs: VM.unlock: true VM.edit_labels: true VM.menu_labels: true + VM.save_rdp: true + VM.save_virt_viewer: true + VM.startvnc: true + VM.startspice: true oneflow-services-tab: panel_tabs: service_info_tab: true diff --git a/src/sunstone/etc/sunstone-views/mixed/admin.yaml b/src/sunstone/etc/sunstone-views/mixed/admin.yaml index c3496b30fd..7735b2b4d9 100644 --- a/src/sunstone/etc/sunstone-views/mixed/admin.yaml +++ b/src/sunstone/etc/sunstone-views/mixed/admin.yaml @@ -418,6 +418,10 @@ tabs: VM.unlock: true VM.edit_labels: true VM.menu_labels: true + VM.startvnc: true + VM.startspice: true + VM.save_rdp: true + VM.save_virt_viewer: true oneflow-services-tab: panel_tabs: service_info_tab: true diff --git a/src/sunstone/etc/sunstone-views/mixed/cloud.yaml b/src/sunstone/etc/sunstone-views/mixed/cloud.yaml index bd1560b3ec..43ab48a9a9 100644 --- a/src/sunstone/etc/sunstone-views/mixed/cloud.yaml +++ b/src/sunstone/etc/sunstone-views/mixed/cloud.yaml @@ -91,6 +91,10 @@ tabs: VM.save_as_template: true VM.lockU: true VM.unlock: true + VM.startvnc: true + VM.startspice: true + VM.save_rdp: true + VM.save_virt_viewer: true dashboard: # Connected user's quotas quotas: true diff --git a/src/sunstone/etc/sunstone-views/mixed/groupadmin.yaml b/src/sunstone/etc/sunstone-views/mixed/groupadmin.yaml index 38f3e56cf7..b0e31a961d 100644 --- a/src/sunstone/etc/sunstone-views/mixed/groupadmin.yaml +++ b/src/sunstone/etc/sunstone-views/mixed/groupadmin.yaml @@ -417,6 +417,10 @@ tabs: VM.unlock: true VM.edit_labels: true VM.menu_labels: true + VM.startvnc: true + VM.startspice: true + VM.save_rdp: true + VM.save_virt_viewer: true oneflow-services-tab: panel_tabs: service_info_tab: true diff --git a/src/sunstone/etc/sunstone-views/mixed/user.yaml b/src/sunstone/etc/sunstone-views/mixed/user.yaml index c2f0d9c090..e4394c8463 100644 --- a/src/sunstone/etc/sunstone-views/mixed/user.yaml +++ b/src/sunstone/etc/sunstone-views/mixed/user.yaml @@ -410,6 +410,10 @@ tabs: VM.unlock: true VM.edit_labels: true VM.menu_labels: true + VM.startvnc: true + VM.startspice: true + VM.save_rdp: true + VM.save_virt_viewer: true oneflow-services-tab: panel_tabs: service_info_tab: true diff --git a/src/sunstone/etc/sunstone-views/vcenter/admin.yaml b/src/sunstone/etc/sunstone-views/vcenter/admin.yaml index 18d13c3d7b..f6472f9f8c 100644 --- a/src/sunstone/etc/sunstone-views/vcenter/admin.yaml +++ b/src/sunstone/etc/sunstone-views/vcenter/admin.yaml @@ -416,6 +416,10 @@ tabs: VM.unlock: true VM.edit_labels: true VM.menu_labels: true + VM.startvnc: true + VM.startspice: true + VM.save_rdp: true + VM.save_virt_viewer: true oneflow-services-tab: panel_tabs: service_info_tab: true diff --git a/src/sunstone/etc/sunstone-views/vcenter/cloud.yaml b/src/sunstone/etc/sunstone-views/vcenter/cloud.yaml index 2c9731bd4d..8ebe4849fa 100644 --- a/src/sunstone/etc/sunstone-views/vcenter/cloud.yaml +++ b/src/sunstone/etc/sunstone-views/vcenter/cloud.yaml @@ -92,6 +92,10 @@ tabs: VM.save_as_template: true VM.lockU: true VM.unlock: true + VM.startvnc: true + VM.startspice: true + VM.save_rdp: true + VM.save_virt_viewer: true dashboard: # Connected user's quotas quotas: true diff --git a/src/sunstone/etc/sunstone-views/vcenter/groupadmin.yaml b/src/sunstone/etc/sunstone-views/vcenter/groupadmin.yaml index 82f059158c..091e4e97e2 100644 --- a/src/sunstone/etc/sunstone-views/vcenter/groupadmin.yaml +++ b/src/sunstone/etc/sunstone-views/vcenter/groupadmin.yaml @@ -417,6 +417,10 @@ tabs: VM.unlock: true VM.edit_labels: true VM.menu_labels: true + VM.startvnc: true + VM.startspice: true + VM.save_rdp: true + VM.save_virt_viewer: true oneflow-services-tab: panel_tabs: service_info_tab: true diff --git a/src/sunstone/etc/sunstone-views/vcenter/user.yaml b/src/sunstone/etc/sunstone-views/vcenter/user.yaml index c2f0d9c090..e4394c8463 100644 --- a/src/sunstone/etc/sunstone-views/vcenter/user.yaml +++ b/src/sunstone/etc/sunstone-views/vcenter/user.yaml @@ -410,6 +410,10 @@ tabs: VM.unlock: true VM.edit_labels: true VM.menu_labels: true + VM.startvnc: true + VM.startspice: true + VM.save_rdp: true + VM.save_virt_viewer: true oneflow-services-tab: panel_tabs: service_info_tab: true diff --git a/src/sunstone/public/app/opennebula/vm.js b/src/sunstone/public/app/opennebula/vm.js index aa6054971b..b05305f711 100644 --- a/src/sunstone/public/app/opennebula/vm.js +++ b/src/sunstone/public/app/opennebula/vm.js @@ -16,12 +16,12 @@ define(function(require) { var OpenNebulaAction = require("./action"), - OpenNebulaHelper = require("./helper"), - OpenNebulaError = require("./error"); - Locale = require("utils/locale"), - Navigation = require("utils/navigation"); - - var OpenNebulaCluster = require("./cluster"); + OpenNebulaHelper = require("./helper"), + OpenNebulaError = require("./error"); + OpenNebulaCluster = require("./cluster"), + Locale = require("utils/locale"), + Config = require("sunstone-config"), + Navigation = require("utils/navigation"); var RESOURCE = "VM"; @@ -921,35 +921,21 @@ define(function(require) { // returns true if the vnc button should be enabled function isVNCSupported(element) { - var rtn = false; - if(element && element.TEMPLATE && element.TEMPLATE.GRAPHICS && element.LCM_STATE){ - var graphics = element.TEMPLATE.GRAPHICS; - var state = parseInt(element.LCM_STATE); - rtn = graphics && - graphics.TYPE && - graphics.TYPE.toLowerCase() == "vnc" && - $.inArray(state, VNC_STATES) != -1; - } - return rtn; + return (Config.isTabActionEnabled("vms-tab", "VM.startvnc") && graphicSupported(element, "vnc")) + ? true : false; } function isSPICESupported(element) { - var rtn = false; - if(element && element.TEMPLATE && element.TEMPLATE.GRAPHICS && element.LCM_STATE){ - var graphics = element.TEMPLATE.GRAPHICS; - var state = parseInt(element.LCM_STATE); - rtn = graphics && - graphics.TYPE && - graphics.TYPE.toLowerCase() == "spice" && - $.inArray(state, VNC_STATES) != -1; - } - return rtn; + return (Config.isTabActionEnabled("vms-tab", "VM.startspice") && graphicSupported(element, "spice")) + ? true : false; } function isWFileSupported(element) { - // spice/vnc is assumed to be supported var history = retrieveLastHistoryRecord(element); - return (history) + return ( + Config.isTabActionEnabled("vms-tab", "VM.save_virt_viewer") && history && + (graphicSupported(element, "vnc") || graphicSupported(element, "spice")) + ) ? { hostname: history.HOSTNAME, type: element.TEMPLATE.GRAPHICS.TYPE.toLowerCase(), @@ -961,12 +947,14 @@ define(function(require) { // returns true if the RDP button should be enabled function isRDPSupported(element) { var hasRdp = false; - - if (element.TEMPLATE && element.TEMPLATE.NIC && element.LCM_STATE) { + if ( + Config.isTabActionEnabled("vms-tab", "VM.save_rdp") && + element && element.TEMPLATE && element.TEMPLATE.GRAPHICS && element.LCM_STATE + ) { var template = element.TEMPLATE; var state = parseInt(element.LCM_STATE); - if ($.inArray(state, RDP_STATES) != -1) { + if ($.inArray(state, RDP_STATES) != -1 && template.NIC) { hasRdp = hasRDP(template.NIC); if (!hasRdp && template.NIC_ALIAS) { @@ -991,6 +979,19 @@ define(function(require) { return activated; } + function graphicSupported(element, type) { + var rtn = false; + if (element && element.TEMPLATE && element.TEMPLATE.GRAPHICS && element.LCM_STATE) { + var graphics = element.TEMPLATE.GRAPHICS; + var state = parseInt(element.LCM_STATE); + rtn = graphics && + graphics.TYPE && + graphics.TYPE.toLowerCase() == type && + $.inArray(state, VNC_STATES) != -1; + } + return rtn; + } + function buttonVnc(id = "") { return ''; diff --git a/src/sunstone/public/app/sunstone/buttons.hbs b/src/sunstone/public/app/sunstone/buttons.hbs index 67c9bea8f2..0bb4ef27fc 100644 --- a/src/sunstone/public/app/sunstone/buttons.hbs +++ b/src/sunstone/public/app/sunstone/buttons.hbs @@ -41,7 +41,7 @@ - diff --git a/src/sunstone/public/app/tabs/oneflow-services-tab/panels/roles.js b/src/sunstone/public/app/tabs/oneflow-services-tab/panels/roles.js index 4a190eb60d..4be44a7ce2 100644 --- a/src/sunstone/public/app/tabs/oneflow-services-tab/panels/roles.js +++ b/src/sunstone/public/app/tabs/oneflow-services-tab/panels/roles.js @@ -244,22 +244,19 @@ define(function(require) { ips = OpenNebulaVM.ipsStr(data.VM); - var wFile = false, rdp = false; - if (OpenNebulaVM.isVNCSupported(data.VM)) { actions += OpenNebulaVM.buttonVnc(id); - wFile = OpenNebulaVM.isWFileSupported(data.VM); } else if (OpenNebulaVM.isSPICESupported(data.VM)) { actions += OpenNebulaVM.buttonSpice(id); - wFile = OpenNebulaVM.isWFileSupported(data.VM); } - + + var wFile = OpenNebulaVM.isWFileSupported(data.VM); if (wFile) { actions += OpenNebulaVM.buttonWFile(id, wFile); } - rdp = OpenNebulaVM.isRDPSupported(data.VM); + var rdp = OpenNebulaVM.isRDPSupported(data.VM); if (rdp) { actions += OpenNebulaVM.buttonRDP(rdp.IP, data.VM); } diff --git a/src/sunstone/public/app/tabs/vms-tab/hooks/state.js b/src/sunstone/public/app/tabs/vms-tab/hooks/state.js index 5edeaafe14..fba959d6fe 100644 --- a/src/sunstone/public/app/tabs/vms-tab/hooks/state.js +++ b/src/sunstone/public/app/tabs/vms-tab/hooks/state.js @@ -41,30 +41,34 @@ define(function(require) { StateActions.disableAllStateActions(); StateActions.enableStateActions(element.STATE, element.LCM_STATE); - var isWFileSupported = false; - if (OpenNebulaVM.isVNCSupported(element)) { + var isVNCSupported = OpenNebulaVM.isVNCSupported(element), + isSPICESupported = OpenNebulaVM.isSPICESupported(element), + isWFileSupported = OpenNebulaVM.isWFileSupported(element), + isRDPSupported = OpenNebulaVM.isRDPSupported(element); + + if (isVNCSupported) { $(".vnc-sunstone-info").show(); $(".spice-sunstone-info").hide(); - isWFileSupported = OpenNebulaVM.isWFileSupported(element); } - else if (OpenNebulaVM.isSPICESupported(element)) { + else if (isSPICESupported) { $(".spice-sunstone-info").show(); $(".vnc-sunstone-info").hide(); - isWFileSupported = OpenNebulaVM.isWFileSupported(element); } else { $(".spice-sunstone-info").hide(); $(".vnc-sunstone-info").hide(); } - (isWFileSupported) - ? $(".vv-sunstone-info").show() - : $(".vv-sunstone-info").hide(); + // Enable / disable virt-viewer button + isWFileSupported ? $(".vv-sunstone-info").show() : $(".vv-sunstone-info").hide(); // Enable / disable rdp button - (OpenNebulaVM.isRDPSupported(element)) - ? $(".rdp-sunstone-info").show() - : $(".rdp-sunstone-info").hide(); + isRDPSupported ? $(".rdp-sunstone-info").show() : $(".rdp-sunstone-info").hide(); + + // All remote buttons are disabled + if (!isVNCSupported && !isSPICESupported && !isWFileSupported && !isRDPSupported) { + $("#vmsremote_buttons").hide() + } if(config && config["system_config"] && diff --git a/src/sunstone/public/app/tabs/vms-tab/utils/datatable-common.js b/src/sunstone/public/app/tabs/vms-tab/utils/datatable-common.js index b6324b73d9..74057cc2e4 100644 --- a/src/sunstone/public/app/tabs/vms-tab/utils/datatable-common.js +++ b/src/sunstone/public/app/tabs/vms-tab/utils/datatable-common.js @@ -193,19 +193,18 @@ define(function(require) { ? OpenNebulaVM.shortLcmStateStr(element.LCM_STATE) : OpenNebulaVM.stateStr(element.STATE); - var actions = "", wFile = false; + var actions = ""; // VNC/SPICE icon if (OpenNebulaVM.isVNCSupported(element)) { actions += OpenNebulaVM.buttonVnc(element.ID); - wFile = OpenNebulaVM.isWFileSupported(element); } else if (OpenNebulaVM.isSPICESupported(element)) { actions += OpenNebulaVM.buttonSpice(element.ID); - wFile = OpenNebulaVM.isWFileSupported(element); } - + // virt-viewer file icon + wFile = OpenNebulaVM.isWFileSupported(element); wFile && (actions += OpenNebulaVM.buttonWFile(element.ID, wFile)); if(config &&