diff --git a/src/sunstone/etc/sunstone-views/admin.yaml b/src/sunstone/etc/sunstone-views/admin.yaml index 6c70b44273..c6e5c19cce 100644 --- a/src/sunstone/etc/sunstone-views/admin.yaml +++ b/src/sunstone/etc/sunstone-views/admin.yaml @@ -256,10 +256,8 @@ tabs: VM.poweroff_hard: true VM.undeploy: true VM.undeploy_hard: true - VM.shutdown: true - VM.shutdown_hard: true - VM.delete: true - VM.delete_recreate: true + VM.terminate: true + VM.terminate_hard: true VM.resize: true VM.attachdisk: true VM.detachdisk: true @@ -274,7 +272,7 @@ tabs: VM.disk_snapshot_delete: true VM.resched: true VM.unresched: true - VM.saveas_template: true + VM.save_as_template: true VM.updateconf: true oneflow-services-tab: panel_tabs: diff --git a/src/sunstone/etc/sunstone-views/admin_vcenter.yaml b/src/sunstone/etc/sunstone-views/admin_vcenter.yaml index 67bccd551a..e495e74afc 100644 --- a/src/sunstone/etc/sunstone-views/admin_vcenter.yaml +++ b/src/sunstone/etc/sunstone-views/admin_vcenter.yaml @@ -256,10 +256,8 @@ tabs: VM.poweroff_hard: true VM.undeploy: true VM.undeploy_hard: true - VM.shutdown: true - VM.shutdown_hard: true - VM.delete: true - VM.delete_recreate: true + VM.terminate: true + VM.terminate_hard: true VM.resize: true VM.attachdisk: true VM.detachdisk: true @@ -274,7 +272,7 @@ tabs: VM.disk_snapshot_delete: false VM.resched: true VM.unresched: true - VM.saveas_template: false + VM.save_as_template: false VM.updateconf: true oneflow-services-tab: panel_tabs: diff --git a/src/sunstone/etc/sunstone-views/cloud.yaml b/src/sunstone/etc/sunstone-views/cloud.yaml index 5888c8423a..bc6a7d7830 100644 --- a/src/sunstone/etc/sunstone-views/cloud.yaml +++ b/src/sunstone/etc/sunstone-views/cloud.yaml @@ -40,8 +40,8 @@ tabs: VM.poweroff_hard: true VM.undeploy: false VM.undeploy_hard: false - VM.shutdown_hard: true - VM.delete: true + VM.terminate: true + VM.terminate_hard: true VM.resize: false VM.attachdisk: false VM.detachdisk: false @@ -54,6 +54,7 @@ tabs: VM.disk_snapshot_create: false VM.disk_snapshot_revert: false VM.disk_snapshot_delete: false + VM.save_as_template: true dashboard: quotas: true vms: true diff --git a/src/sunstone/etc/sunstone-views/cloud_vcenter.yaml b/src/sunstone/etc/sunstone-views/cloud_vcenter.yaml index 93bd7bbecb..9ff4e46bf1 100644 --- a/src/sunstone/etc/sunstone-views/cloud_vcenter.yaml +++ b/src/sunstone/etc/sunstone-views/cloud_vcenter.yaml @@ -40,8 +40,8 @@ tabs: VM.poweroff_hard: true VM.undeploy: false VM.undeploy_hard: false - VM.shutdown_hard: true - VM.delete: true + VM.terminate: true + VM.terminate_hard: true VM.resize: false VM.attachdisk: false VM.detachdisk: false @@ -54,6 +54,7 @@ tabs: VM.disk_snapshot_create: false VM.disk_snapshot_revert: false VM.disk_snapshot_delete: false + VM.save_as_template: true dashboard: quotas: true vms: true diff --git a/src/sunstone/etc/sunstone-views/groupadmin.yaml b/src/sunstone/etc/sunstone-views/groupadmin.yaml index 5a1a63f552..b894917038 100644 --- a/src/sunstone/etc/sunstone-views/groupadmin.yaml +++ b/src/sunstone/etc/sunstone-views/groupadmin.yaml @@ -255,10 +255,8 @@ tabs: VM.poweroff_hard: true VM.undeploy: true VM.undeploy_hard: true - VM.shutdown: true - VM.shutdown_hard: true - VM.delete: true - VM.delete_recreate: false + VM.terminate: true + VM.terminate_hard: true VM.resize: false VM.attachdisk: false VM.detachdisk: false @@ -273,7 +271,7 @@ tabs: VM.disk_snapshot_delete: false VM.resched: false VM.unresched: false - VM.saveas_template: true + VM.save_as_template: true VM.updateconf: false oneflow-services-tab: panel_tabs: diff --git a/src/sunstone/etc/sunstone-views/groupadmin_vcenter.yaml b/src/sunstone/etc/sunstone-views/groupadmin_vcenter.yaml index c990261526..3abfd73456 100644 --- a/src/sunstone/etc/sunstone-views/groupadmin_vcenter.yaml +++ b/src/sunstone/etc/sunstone-views/groupadmin_vcenter.yaml @@ -257,10 +257,8 @@ tabs: VM.poweroff_hard: true VM.undeploy: true VM.undeploy_hard: true - VM.shutdown: true - VM.shutdown_hard: true - VM.delete: true - VM.delete_recreate: false + VM.terminate: true + VM.terminate_hard: true VM.resize: false VM.attachdisk: false VM.detachdisk: false @@ -275,7 +273,7 @@ tabs: VM.disk_snapshot_delete: false VM.resched: false VM.unresched: false - VM.saveas_template: false + VM.save_as_template: false VM.updateconf: false oneflow-services-tab: panel_tabs: diff --git a/src/sunstone/etc/sunstone-views/user.yaml b/src/sunstone/etc/sunstone-views/user.yaml index 7733969f1c..ff6742b87b 100644 --- a/src/sunstone/etc/sunstone-views/user.yaml +++ b/src/sunstone/etc/sunstone-views/user.yaml @@ -259,10 +259,8 @@ tabs: VM.poweroff_hard: true VM.undeploy: true VM.undeploy_hard: true - VM.shutdown: true - VM.shutdown_hard: true - VM.delete: true - VM.delete_recreate: true + VM.terminate: true + VM.terminate_hard: true VM.resize: true VM.attachdisk: true VM.detachdisk: true @@ -277,7 +275,7 @@ tabs: VM.disk_snapshot_delete: true VM.resched: false VM.unresched: false - VM.saveas_template: true + VM.save_as_template: true VM.updateconf: true oneflow-services-tab: panel_tabs: diff --git a/src/sunstone/models/OpenNebulaJSON/VirtualMachineJSON.rb b/src/sunstone/models/OpenNebulaJSON/VirtualMachineJSON.rb index 1555879e43..9c3186c1c3 100644 --- a/src/sunstone/models/OpenNebulaJSON/VirtualMachineJSON.rb +++ b/src/sunstone/models/OpenNebulaJSON/VirtualMachineJSON.rb @@ -44,7 +44,6 @@ module OpenNebulaJSON rc = case action_hash['perform'] when "deploy" then self.deploy(action_hash['params']) - when "finalize" then self.finalize when "hold" then self.hold when "livemigrate" then self.migrate(action_hash['params'], true) when "migrate" then self.migrate(action_hash['params'], false) @@ -52,7 +51,6 @@ module OpenNebulaJSON when "release" then self.release when "stop" then self.stop when "suspend" then self.suspend - when "reset" then self.reset when "disk_saveas" then self.disk_saveas(action_hash['params']) when "snapshot_create" then self.snapshot_create(action_hash['params']) when "snapshot_revert" then self.snapshot_revert(action_hash['params']) @@ -60,10 +58,9 @@ module OpenNebulaJSON when "disk_snapshot_create" then self.disk_snapshot_create(action_hash['params']) when "disk_snapshot_revert" then self.disk_snapshot_revert(action_hash['params']) when "disk_snapshot_delete" then self.disk_snapshot_delete(action_hash['params']) - when "shutdown" then self.shutdown(action_hash['params']) - when "reboot" then self.reboot + when "terminate" then self.terminate(action_hash['params']) + when "reboot" then self.reboot(action_hash['params']) when "poweroff" then self.poweroff(action_hash['params']) - when "resubmit" then self.resubmit when "chown" then self.chown(action_hash['params']) when "chmod" then self.chmod_octet(action_hash['params']) when "resize" then self.resize(action_hash['params']) @@ -86,10 +83,6 @@ module OpenNebulaJSON end end - def delete - super() - end - def deploy(params=Hash.new) super(params['host_id'], params['enforce'], params['ds_id']) end @@ -98,7 +91,11 @@ module OpenNebulaJSON super(params['hard']) end - def shutdown(params=Hash.new) + def terminate(params=Hash.new) + super(params['hard']) + end + + def reboot(params=Hash.new) super(params['hard']) end diff --git a/src/sunstone/public/app/opennebula/vm.js b/src/sunstone/public/app/opennebula/vm.js index 0a2ecf9932..a8aae1d8a2 100644 --- a/src/sunstone/public/app/opennebula/vm.js +++ b/src/sunstone/public/app/opennebula/vm.js @@ -298,33 +298,35 @@ define(function(require) { ]; var MIGRATE_ACTION_STR = [ - "none", - "migrate", - "live-migrate", - "shutdown", - "shutdown-hard", - "undeploy", - "undeploy-hard", - "hold", - "release", - "stop", - "suspend", - "resume", - "boot", - "delete", - "delete-recreate", - "reboot", - "reboot-hard", - "resched", - "unresched", - "poweroff", - "poweroff-hard", - "disk-attach", - "disk-detach", - "nic-attach", - "nic-detach", - "snap-create", - "snap-delete" + "none", // NONE_ACTION = 0 + "migrate", // MIGRATE_ACTION = 1 + "live-migrate", // LIVE_MIGRATE_ACTION = 2 + "shutdown", // //SHUTDOWN_ACTION = 3 + "shutdown-hard", // //SHUTDOWN_HARD_ACTION = 4 + "undeploy", // UNDEPLOY_ACTION = 5 + "undeploy-hard", // UNDEPLOY_HARD_ACTION = 6 + "hold", // HOLD_ACTION = 7 + "release", // RELEASE_ACTION = 8 + "stop", // STOP_ACTION = 9 + "suspend", // SUSPEND_ACTION = 10 + "resume", // RESUME_ACTION = 11 + "boot", // //BOOT_ACTION = 12 + "delete", // DELETE_ACTION = 13 + "delete-recreate", // DELETE_RECREATE_ACTION = 14 + "reboot", // REBOOT_ACTION = 15 + "reboot-hard", // REBOOT_HARD_ACTION = 16 + "resched", // RESCHED_ACTION = 17 + "unresched", // UNRESCHED_ACTION = 18 + "poweroff", // POWEROFF_ACTION = 19 + "poweroff-hard", // POWEROFF_HARD_ACTION = 20 + "disk-attach", // DISK_ATTACH_ACTION = 21 + "disk-detach", // DISK_DETACH_ACTION = 22 + "nic-attach", // NIC_ATTACH_ACTION = 23 + "nic-detach", // NIC_DETACH_ACTION = 24 + "snap-create", // DISK_SNAPSHOT_CREATE_ACTION = 25 + "snap-delete", // DISK_SNAPSHOT_DELETE_ACTION = 26 + "terminate", // TERMINATE_ACTION = 27 + "terminate-hard" // TERMINATE_HARD_ACTION = 28 ]; var VM = { @@ -332,9 +334,6 @@ define(function(require) { "create": function(params) { OpenNebulaAction.create(params, RESOURCE); }, - "del": function(params) { - OpenNebulaAction.del(params, RESOURCE); - }, "list": function(params) { OpenNebulaAction.list(params, RESOURCE); }, @@ -351,13 +350,13 @@ define(function(require) { var action_obj = params.data.extra_param; OpenNebulaAction.simple_action(params, RESOURCE, "chmod", action_obj); }, - "shutdown": function(params) { + "terminate": function(params) { var action_obj = {"hard": false}; - OpenNebulaAction.simple_action(params, RESOURCE, "shutdown", action_obj); + OpenNebulaAction.simple_action(params, RESOURCE, "terminate", action_obj); }, - "shutdown_hard" : function(params) { + "terminate_hard" : function(params) { var action_obj = {"hard": true}; - OpenNebulaAction.simple_action(params, RESOURCE, "shutdown", action_obj); + OpenNebulaAction.simple_action(params, RESOURCE, "terminate", action_obj); }, "hold": function(params) { OpenNebulaAction.simple_action(params, RESOURCE, "hold"); @@ -377,9 +376,6 @@ define(function(require) { "resume": function(params) { OpenNebulaAction.simple_action(params, RESOURCE, "resume"); }, - "resubmit": function(params) { - OpenNebulaAction.simple_action(params, RESOURCE, "resubmit"); - }, "poweroff" : function(params) { var action_obj = {"hard": false}; OpenNebulaAction.simple_action(params, RESOURCE, "poweroff", action_obj); @@ -396,11 +392,13 @@ define(function(require) { var action_obj = {"hard": true}; OpenNebulaAction.simple_action(params, RESOURCE, "undeploy", action_obj); }, - "reboot" : function(params) { - OpenNebulaAction.simple_action(params, RESOURCE, "reboot"); + "reboot": function(params) { + var action_obj = {"hard": false}; + OpenNebulaAction.simple_action(params, RESOURCE, "reboot", action_obj); }, - "reset" : function(params) { - OpenNebulaAction.simple_action(params, RESOURCE, "reset"); + "reboot_hard" : function(params) { + var action_obj = {"hard": true}; + OpenNebulaAction.simple_action(params, RESOURCE, "reboot", action_obj); }, "log": function(params) { diff --git a/src/sunstone/public/app/tabs/provision-tab/vms/confirm_poweroff.hbs b/src/sunstone/public/app/tabs/provision-tab/vms/confirm_poweroff.hbs new file mode 100644 index 0000000000..5a38c9ae76 --- /dev/null +++ b/src/sunstone/public/app/tabs/provision-tab/vms/confirm_poweroff.hbs @@ -0,0 +1,47 @@ +
+
+
+ + {{tr "This action will power off this Virtual Machine. The Virtual Machine will remain in the poweroff state, and can be powered on later"}} + {{#if opts.both}} +
+
+ {{tr "You can send the power off signal to the Virtual Machine (this is equivalent to execute the command from the console). If that doesn't affect your Virtual Machine, try to Power off the machine (this is equivalent to pressing the power off button in a physical computer)."}} + {{/if}} +
+
+
+
+
+
+ + {{#if opts.both}} + + {{else}} + {{#if opts.hard}} + + {{else}} + + {{/if}} + {{/if}} +
+
+ +
\ No newline at end of file diff --git a/src/sunstone/public/app/tabs/provision-tab/vms/confirm_reboot.hbs b/src/sunstone/public/app/tabs/provision-tab/vms/confirm_reboot.hbs new file mode 100644 index 0000000000..81a3086e0d --- /dev/null +++ b/src/sunstone/public/app/tabs/provision-tab/vms/confirm_reboot.hbs @@ -0,0 +1,47 @@ +
+
+
+ + {{tr "This action will reboot this Virtual Machine."}} + {{#if opts.both}} +
+
+ {{tr "You can send the reboot signal to the Virtual Machine (this is equivalent to execute the reboot command form the console). If that doesn't affect your Virtual Machine, try to Reboot the machine (this is equivalent to pressing the reset button a physical computer)."}} + {{/if}} +
+
+
+
+
+
+ + {{#if opts.both}} + + {{else}} + {{#if opts.hard}} + + {{else}} + + {{/if}} + {{/if}} +
+
+ +
\ No newline at end of file diff --git a/src/sunstone/public/app/tabs/provision-tab/vms/confirm_save_as_template.hbs b/src/sunstone/public/app/tabs/provision-tab/vms/confirm_save_as_template.hbs new file mode 100644 index 0000000000..e267b02d6e --- /dev/null +++ b/src/sunstone/public/app/tabs/provision-tab/vms/confirm_save_as_template.hbs @@ -0,0 +1,55 @@ +
+
+
+ + {{tr "This Virtual Machine will be saved in a new Template."}} +
+ {{tr "You can then create a new Virtual Machine using this Template."}} +
+
+
+
+
+
+ +
+
+
+
+
+ + {{tr "The new Virtual Machine's disks can be made persistent. In a persistent Virtual Machine the changes made survive after it is destroyed. On the other hand, you cannot create more than one simultaneous Virtual Machine from a Template with persistent disks."}} + +
+
+
+
+
+ +
+
+
+
+
+ +
+
+ +
\ No newline at end of file diff --git a/src/sunstone/public/app/tabs/provision-tab/vms/confirm_terminate.hbs b/src/sunstone/public/app/tabs/provision-tab/vms/confirm_terminate.hbs new file mode 100644 index 0000000000..315c9d6f52 --- /dev/null +++ b/src/sunstone/public/app/tabs/provision-tab/vms/confirm_terminate.hbs @@ -0,0 +1,47 @@ +
+
+
+ + {{tr "Be careful, this action will shutdown and destroy your Virtual Machine"}} + {{#if opts.both}} +
+
+ {{tr "You can send the shutdown signal to the Virtual Machine (this is equivalent to execute the command from the console). If that doesn't affect your Virtual Machine, try to terminate the machine (this is equivalent to pressing the power off button in a physical computer)."}} + {{/if}} +
+
+
+
+
+
+ + {{#if opts.both}} + + {{else}} + {{#if opts.hard}} + + {{else}} + + {{/if}} + {{/if}} +
+
+ +
\ No newline at end of file diff --git a/src/sunstone/public/app/tabs/provision-tab/vms/confirm_undeploy.hbs b/src/sunstone/public/app/tabs/provision-tab/vms/confirm_undeploy.hbs new file mode 100644 index 0000000000..831ae7f22d --- /dev/null +++ b/src/sunstone/public/app/tabs/provision-tab/vms/confirm_undeploy.hbs @@ -0,0 +1,47 @@ +
+
+
+ + {{tr "This action will power off this Virtual Machine and will be undeployed from the physical machine"}} + {{#if opts.both}} +
+
+ {{tr "You can send the power off signal to the Virtual Machine (this is equivalent to execute the command from the console). If that doesn't affect your Virtual Machine, try to Power off the machine (this is equivalent to pressing the power off button in a physical computer)."}} + {{/if}} +
+
+
+
+
+
+ + {{#if opts.both}} + + {{else}} + {{#if opts.hard}} + + {{else}} + + {{/if}} + {{/if}} +
+
+ +
\ No newline at end of file diff --git a/src/sunstone/public/app/tabs/provision-tab/vms/info.hbs b/src/sunstone/public/app/tabs/provision-tab/vms/info.hbs index 1b844ab01b..39a3983dd2 100644 --- a/src/sunstone/public/app/tabs/provision-tab/vms/info.hbs +++ b/src/sunstone/public/app/tabs/provision-tab/vms/info.hbs @@ -43,61 +43,46 @@ - {{#isProvisionTabEnabled "provision-tab" "templates"}} + {{#isTabActionEnabled "provision-tab" "VM.save_as_template"}}
  • -
  • -
  • - {{/isProvisionTabEnabled}} + {{/isTabActionEnabled}}
  • - {{#isTabActionEnabled "provision-tab" "VM.delete"}}
  • -
  • - {{/isTabActionEnabled}} - {{#isTabActionEnabled "provision-tab" "VM.shutdown_hard"}} -
  • - -
  • - {{/isTabActionEnabled}} - {{#isTabActionEnabled "provision-tab" "VM.poweroff"}}
  • - {{/isTabActionEnabled}} - {{#isTabActionEnabled "provision-tab" "VM.undeploy"}}
  • - {{/isTabActionEnabled}} - {{#isTabActionEnabled "provision-tab" "VM.resume"}} + {{#isTabActionEnabled "provision-tab" "VM.resume"}}
  • -
  • - {{/isTabActionEnabled}} - {{#isTabActionEnabled "provision-tab" "VM.reboot"}} + {{/isTabActionEnabled}}
  • - {{/isTabActionEnabled}} diff --git a/src/sunstone/public/app/tabs/provision-tab/vms/list.js b/src/sunstone/public/app/tabs/provision-tab/vms/list.js index 0b9a8e3a83..4d9329f2db 100644 --- a/src/sunstone/public/app/tabs/provision-tab/vms/list.js +++ b/src/sunstone/public/app/tabs/provision-tab/vms/list.js @@ -26,8 +26,14 @@ define(function(require) { var ResourceSelect = require('utils/resource-select'); var Graphs = require('utils/graphs'); var TemplateUtils = require('utils/template-utils'); + var StateActions = require('tabs/vms-tab/utils/state-actions'); var TemplateVmsList = require('hbs!./list'); + var TemplateConfirmSaveAsTemplate = require('hbs!./confirm_save_as_template'); + var TemplateConfirmTerminate = require('hbs!./confirm_terminate'); + var TemplateConfirmPoweroff = require('hbs!./confirm_poweroff'); + var TemplateConfirmUndeploy = require('hbs!./confirm_undeploy'); + var TemplateConfirmReboot = require('hbs!./confirm_reboot'); var TAB_ID = require('../tabId'); var _accordionId = 0; @@ -255,86 +261,63 @@ define(function(require) { var data = response.VM var state = get_provision_vm_state(data); - switch (state.color) { - case "deploying": - $(".provision_reboot_confirm_button", context).hide(); - $(".provision_poweroff_confirm_button", context).hide(); - $(".provision_undeploy_confirm_button", context).hide(); - $(".provision_poweron_button", context).hide(); - $(".provision_delete_confirm_button", context).show(); - $(".provision_shutdownhard_confirm_button", context).hide(); - $(".provision_snapshot_button", context).hide(); - $(".provision_vnc_button", context).hide(); - $(".provision_snapshot_button_disabled", context).hide(); - $(".provision_vnc_button_disabled", context).hide(); - break; - case "running": - $(".provision_reboot_confirm_button", context).show(); - $(".provision_poweroff_confirm_button", context).show(); - $(".provision_undeploy_confirm_button", context).show(); - $(".provision_poweron_button", context).hide(); - $(".provision_delete_confirm_button", context).hide(); - $(".provision_shutdownhard_confirm_button", context).show(); - $(".provision_snapshot_button", context).hide(); - $(".provision_vnc_button", context).show(); - $(".provision_snapshot_button_disabled", context).show(); - $(".provision_vnc_button_disabled", context).hide(); - break; - case "off": - $(".provision_reboot_confirm_button", context).hide(); - $(".provision_poweroff_confirm_button", context).hide(); - $(".provision_undeploy_confirm_button", context).hide(); - $(".provision_poweron_button", context).show(); - $(".provision_delete_confirm_button", context).hide(); - $(".provision_shutdownhard_confirm_button", context).show(); - $(".provision_snapshot_button", context).show(); - $(".provision_vnc_button", context).hide(); - $(".provision_snapshot_button_disabled", context).hide(); - $(".provision_vnc_button_disabled", context).show(); - break; - case "undeployed": - $(".provision_reboot_confirm_button", context).hide(); - $(".provision_poweroff_confirm_button", context).hide(); - $(".provision_undeploy_confirm_button", context).hide(); - $(".provision_poweron_button", context).show(); - $(".provision_delete_confirm_button", context).hide(); - $(".provision_shutdownhard_confirm_button", context).show(); - $(".provision_snapshot_button", context).hide(); - $(".provision_vnc_button", context).hide(); - $(".provision_snapshot_button_disabled", context).hide(); - $(".provision_vnc_button_disabled", context).show(); - break; - case "powering_off": - case "error": - $(".provision_reboot_confirm_button", context).hide(); - $(".provision_poweroff_confirm_button", context).hide(); - $(".provision_undeploy_confirm_button", context).hide(); - $(".provision_poweron_button", context).hide(); - $(".provision_delete_confirm_button", context).show(); - $(".provision_shutdownhard_confirm_button", context).hide(); - $(".provision_snapshot_button", context).hide(); - $(".provision_vnc_button", context).hide(); - $(".provision_snapshot_button_disabled", context).hide(); - $(".provision_vnc_button_disabled", context).hide(); - break; - default: - color = 'secondary'; - $(".provision_reboot_confirm_button", context).hide(); - $(".provision_poweroff_confirm_button", context).hide(); - $(".provision_undeploy_confirm_button", context).hide(); - $(".provision_poweron_button", context).hide(); - $(".provision_delete_confirm_button", context).show(); - $(".provision_shutdownhard_confirm_button", context).hide(); - $(".provision_snapshot_button", context).hide(); - $(".provision_vnc_button", context).hide(); - $(".provision_snapshot_button_disabled", context).hide(); - $(".provision_vnc_button_disabled", context).hide(); - break; + // helper, cleaner code + function enabled(action){ + return Config.isTabActionEnabled("provision-tab", action) && + StateActions.enabledStateAction(action, data.STATE, data.LCM_STATE); } - if (!OpenNebula.VM.isVNCSupported(data) && !OpenNebula.VM.isSPICESupported(data)) { - $(".provision_vnc_button", context).hide(); - $(".provision_vnc_button_disabled", context).hide(); + if (enabled("VM.reboot") || enabled("VM.reboot_hard")){ + $(".provision_reboot_confirm_button", context).show(); + } else { + $(".provision_reboot_confirm_button", context).hide(); + } + + if (enabled("VM.poweroff") || enabled("VM.poweroff_hard")){ + $(".provision_poweroff_confirm_button", context).show(); + } else { + $(".provision_poweroff_confirm_button", context).hide(); + } + + if (enabled("VM.undeploy") || enabled("VM.undeploy_hard")){ + $(".provision_undeploy_confirm_button", context).show(); + } else { + $(".provision_undeploy_confirm_button", context).hide(); + } + + if (enabled("VM.resume")){ + $(".provision_resume_button", context).show(); + } else { + $(".provision_resume_button", context).hide(); + } + + if (enabled("VM.terminate") || enabled("VM.terminate_hard")){ + $(".provision_terminate_confirm_button", context).show(); + } else { + $(".provision_terminate_confirm_button", context).hide(); + } + + if(Config.isTabActionEnabled("provision-tab", "VM.save_as_template")){ + if (enabled("VM.save_as_template")){ + $(".provision_save_as_template_confirm_button", context).show(); + $(".provision_save_as_template_confirm_button_disabled", context).hide(); + } else { + $(".provision_save_as_template_confirm_button", context).hide(); + $(".provision_save_as_template_confirm_button_disabled", context).show(); + } + }else{ + $(".provision_save_as_template_confirm_button", context).hide(); + $(".provision_save_as_template_confirm_button_disabled", context).hide(); + } + + if (OpenNebula.VM.isVNCSupported(data) || + OpenNebula.VM.isSPICESupported(data)) { + + $(".provision_vnc_button", context).show(); + $(".provision_vnc_button_disabled", context).hide(); + }else{ + $(".provision_vnc_button", context).hide(); + $(".provision_vnc_button_disabled", context).show(); } $(".provision_info_vm", context).attr("vm_id", data.ID); @@ -487,65 +470,13 @@ define(function(require) { }) } - if (Config.isProvisionTabEnabled("provision-tab", "templates")) { - context.on("click", ".provision_snapshot_button", function(){ + if (Config.isTabActionEnabled("provision-tab", "VM.save_as_template")) { + context.on("click", ".provision_save_as_template_confirm_button", function(){ $(".provision_confirm_action:first", context).html( - '
    '+ - '
    '+ - '
    '+ - ''+ - Locale.tr("This Virtual Machine will be saved in a new Template.")+ - '
    '+ - Locale.tr("You can then create a new Virtual Machine using this Template.")+ - '
    '+ - '
    '+ - '
    '+ - '
    '+ - '
    '+ - '
    '+ - ''+ - '
    '+ - '
    '+ - '
    '+ - '
    '+ - '
    '+ - ''+ - Locale.tr("The new Virtual Machine's disks can be made persistent. In a persistent Virtual Machine the changes made survive after it is destroyed. On the other hand, you cannot create more than one simultaneous Virtual Machine from a Template with persistent disks.")+ - ''+ - '
    '+ - '
    '+ - '
    '+ - '
    '+ - '
    '+ - ''+ - '
    '+ - '
    '+ - '
    '+ - '
    '+ - '
    '+ - ''+ - '
    '+ - '
    '+ - ''+ - '
    '); + TemplateConfirmSaveAsTemplate()); }); - context.on("click", ".provision_snapshot_create_button", function(){ + context.on("click", ".provision_save_as_template_button", function(){ var button = $(this); button.attr("disabled", "disabled"); var context = $(".provision_info_vm[vm_id]"); @@ -586,200 +517,98 @@ define(function(require) { }); } - context.on("click", ".provision_delete_confirm_button", function(){ - $(".provision_confirm_action:first", context).html( - '
    '+ - '
    '+ - '
    '+ - ''+ - Locale.tr("Be careful, this action will immediately destroy your Virtual Machine")+ - '
    '+ - Locale.tr("All the information will be lost!")+ - '
    '+ - '
    '+ - '
    '+ - ''+ - '
    '+ - '
    '+ - ''+ - '
    '); - }); + context.on("click", ".provision_terminate_confirm_button", function(){ + var data = $(".provision_info_vm", context).data("vm"); - context.on("click", ".provision_shutdownhard_confirm_button", function(){ - $(".provision_confirm_action:first", context).html( - '
    '+ - '
    '+ - '
    '+ - ''+ - Locale.tr("Be careful, this action will immediately destroy your Virtual Machine")+ - '
    '+ - Locale.tr("All the information will be lost!")+ - '
    '+ - '
    '+ - '
    '+ - ''+ - '
    '+ - '
    '+ - ''+ - '
    '); + var hard = Config.isTabActionEnabled("provision-tab", "VM.terminate_hard") && + StateActions.enabledStateAction("VM.terminate_hard", data.STATE, data.LCM_STATE); + + var soft = Config.isTabActionEnabled("provision-tab", "VM.terminate") && + StateActions.enabledStateAction("VM.terminate", data.STATE, data.LCM_STATE); + + var opts = {}; + + if(hard && soft){ + opts.both = true; + } else if(hard){ + opts.hard = true; + } + + $(".provision_confirm_action:first", context).html(TemplateConfirmTerminate({opts: opts})); }); context.on("click", ".provision_poweroff_confirm_button", function(){ - $(".provision_confirm_action:first", context).html( - '
    '+ - '
    '+ - '
    '+ - ''+ - Locale.tr("This action will power off this Virtual Machine. The Virtual Machine will remain in the poweroff state, and can be powered on later")+ - '
    '+ - '
    '+ - Locale.tr("You can send the power off signal to the Virtual Machine (this is equivalent to execute the command from the console). If that doesn't effect your Virtual Machine, try to Power off the machine (this is equivalent to pressing the power off button in a physical computer).")+ - '
    '+ - '
    '+ - '
    '+ - '
    '+ - '
    '+ - '
    '+ - ''+ - ''+ - '
    '+ - '
    '+ - ''+ - '
    '); + var data = $(".provision_info_vm", context).data("vm"); + + var hard = Config.isTabActionEnabled("provision-tab", "VM.poweroff_hard") && + StateActions.enabledStateAction("VM.poweroff_hard", data.STATE, data.LCM_STATE); + + var soft = Config.isTabActionEnabled("provision-tab", "VM.poweroff") && + StateActions.enabledStateAction("VM.poweroff", data.STATE, data.LCM_STATE); + + var opts = {}; + + if(hard && soft){ + opts.both = true; + } else if(hard){ + opts.hard = true; + } + + $(".provision_confirm_action:first", context).html(TemplateConfirmPoweroff({opts: opts})); }); context.on("click", ".provision_undeploy_confirm_button", function(){ - $(".provision_confirm_action:first", context).html( - '
    '+ - '
    '+ - '
    '+ - ''+ - Locale.tr("This action will power off this Virtual Machine and will be undeployed from the physical machine")+ - '
    '+ - '
    '+ - Locale.tr("You can send the power off signal to the Virtual Machine (this is equivalent to execute the command from the console). If that doesn't effect your Virtual Machine, try to Power off the machine (this is equivalent to pressing the power off button in a physical computer).")+ - '
    '+ - '
    '+ - '
    '+ - '
    '+ - '
    '+ - '
    '+ - ''+ - ''+ - '
    '+ - '
    '+ - ''+ - '
    '); + var data = $(".provision_info_vm", context).data("vm"); + + var hard = Config.isTabActionEnabled("provision-tab", "VM.undeploy_hard") && + StateActions.enabledStateAction("VM.undeploy_hard", data.STATE, data.LCM_STATE); + + var soft = Config.isTabActionEnabled("provision-tab", "VM.undeploy") && + StateActions.enabledStateAction("VM.undeploy", data.STATE, data.LCM_STATE); + + var opts = {}; + + if(hard && soft){ + opts.both = true; + } else if(hard){ + opts.hard = true; + } + + $(".provision_confirm_action:first", context).html(TemplateConfirmUndeploy({opts: opts})); }); context.on("click", ".provision_reboot_confirm_button", function(){ - $(".provision_confirm_action:first", context).html( - '
    '+ - '
    '+ - '
    '+ - ''+ - Locale.tr("This action will reboot this Virtual Machine.")+ - '
    '+ - '
    '+ - Locale.tr("You can send the reboot signal to the Virtual Machine (this is equivalent to execute the reboot command form the console). If that doesn't effect your Virtual Machine, try to Reboot the machine (this is equivalent to pressing the reset button a physical computer).")+ - '
    '+ - '
    '+ - '
    '+ - '
    '+ - '
    '+ - '
    '+ - ''+ - ''+ - '
    '+ - '
    '+ - ''+ - '
    '); + var data = $(".provision_info_vm", context).data("vm"); + + var hard = Config.isTabActionEnabled("provision-tab", "VM.reboot_hard") && + StateActions.enabledStateAction("VM.reboot_hard", data.STATE, data.LCM_STATE); + + var soft = Config.isTabActionEnabled("provision-tab", "VM.reboot") && + StateActions.enabledStateAction("VM.reboot", data.STATE, data.LCM_STATE); + + var opts = {}; + + if(hard && soft){ + opts.both = true; + } else if(hard){ + opts.hard = true; + } + + $(".provision_confirm_action:first", context).html(TemplateConfirmReboot({opts: opts})); }); - context.on("click", ".provision_delete_button", function(){ + context.on("click", ".provision_terminate_button", function(){ var button = $(this); button.attr("disabled", "disabled"); var vm_id = $(".provision_info_vm", context).attr("vm_id"); + var terminate_action = $('input[name=provision_terminate_radio]:checked').val() - OpenNebula.VM.del({ + OpenNebula.VM[terminate_action]({ data : { id: vm_id }, success: function(request, response){ - $(".provision_back", context).click(); - $(".provision_vms_list_refresh_button", context).click(); - button.removeAttr("disabled"); - }, - error: function(request, response){ - Notifier.onError(request, response); - button.removeAttr("disabled"); - } - }) - - return false; - }); - - context.on("click", ".provision_shutdownhard_button", function(){ - var button = $(this); - button.attr("disabled", "disabled"); - var vm_id = $(".provision_info_vm", context).attr("vm_id"); - - OpenNebula.VM.shutdown_hard({ - data : { - id: vm_id - }, - success: function(request, response){ - $(".provision_back", context).click(); - $(".provision_vms_list_refresh_button", context).click(); + update_provision_vm_info(vm_id, context); button.removeAttr("disabled"); }, error: function(request, response){ @@ -861,7 +690,7 @@ define(function(require) { return false; }); - context.on("click", ".provision_poweron_button", function(){ + context.on("click", ".provision_resume_button", function(){ var button = $(this); button.attr("disabled", "disabled"); var vm_id = $(".provision_info_vm", context).attr("vm_id"); diff --git a/src/sunstone/public/app/tabs/vms-tab/actions.js b/src/sunstone/public/app/tabs/vms-tab/actions.js index 5184c7f116..aa2dde4ab8 100644 --- a/src/sunstone/public/app/tabs/vms-tab/actions.js +++ b/src/sunstone/public/app/tabs/vms-tab/actions.js @@ -56,24 +56,21 @@ define(function(require) { error: Notifier.onError }, "VM.refresh": _commonActions.refresh(), - "VM.delete": _commonActions.del(), "VM.chown": _commonActions.multipleAction('chown'), "VM.chgrp": _commonActions.multipleAction('chgrp'), - "VM.hold": _commonActions.multipleAction('hold'), "VM.release": _commonActions.multipleAction('release'), "VM.suspend": _commonActions.multipleAction('suspend'), "VM.resume": _commonActions.multipleAction('resume'), "VM.stop": _commonActions.multipleAction('stop'), - "VM.reboot_hard": _commonActions.multipleAction('reset'), - "VM.delete_recreate": _commonActions.multipleAction('resubmit'), "VM.reboot": _commonActions.multipleAction('reboot'), + "VM.reboot_hard": _commonActions.multipleAction('reboot_hard'), "VM.poweroff": _commonActions.multipleAction('poweroff'), "VM.poweroff_hard": _commonActions.multipleAction('poweroff_hard'), "VM.undeploy": _commonActions.multipleAction('undeploy'), "VM.undeploy_hard": _commonActions.multipleAction('undeploy_hard'), - "VM.shutdown": _commonActions.multipleAction('shutdown'), - "VM.shutdown_hard": _commonActions.multipleAction('shutdown_hard'), + "VM.terminate": _commonActions.multipleAction('terminate'), + "VM.terminate_hard": _commonActions.multipleAction('terminate_hard'), "VM.recover": _commonActions.multipleAction('recover'), "VM.resched": _commonActions.multipleAction('resched'), "VM.unresched": _commonActions.multipleAction('unresched'), @@ -198,7 +195,7 @@ define(function(require) { }, notify: true }, - "VM.saveas_template" : { + "VM.save_as_template" : { type: "single", call: function() { var dialog = Sunstone.getDialog(SAVE_AS_TEMPLATE_DIALOG_ID); diff --git a/src/sunstone/public/app/tabs/vms-tab/buttons.js b/src/sunstone/public/app/tabs/vms-tab/buttons.js index ded203a51a..7b6396d89e 100644 --- a/src/sunstone/public/app/tabs/vms-tab/buttons.js +++ b/src/sunstone/public/app/tabs/vms-tab/buttons.js @@ -140,33 +140,18 @@ define(function(require) { tip: Locale.tr("Shuts down the given VM. The VM is saved in the system Datastore."), custom_classes : "state-dependent" }, - "VM.shutdown" : { + "VM.terminate" : { type: "confirm", - text: Locale.tr("Shutdown"), + text: Locale.tr("Terminate"), layout: "vmsdelete_buttons", - tip: Locale.tr("This will initiate the shutdown process in the selected VMs"), + tip: Locale.tr("This will initiate the terminate process in the selected VMs"), custom_classes : "state-dependent" }, - "VM.shutdown_hard" : { + "VM.terminate_hard" : { type: "confirm", - text: Locale.tr("Shutdown") + ' ' + Locale.tr("hard") + '', + text: Locale.tr("Terminate") + ' ' + Locale.tr("hard") + '', layout: "vmsdelete_buttons", - tip: Locale.tr("This will initiate the shutdown-hard (forced) process in the selected VMs"), - custom_classes : "state-dependent" - }, - - "VM.delete" : { - type: "confirm", - text: Locale.tr("Delete"), - layout: "vmsdelete_buttons", - tip: Locale.tr("This will delete the selected VMs from the database"), - custom_classes : "state-dependent" - }, - "VM.delete_recreate" : { - type: "confirm", - text: Locale.tr("Delete") + ' ' + Locale.tr("recreate") + '', - layout: "vmsrepeat_buttons", - tip: Locale.tr("This will delete and recreate VMs to PENDING state"), + tip: Locale.tr("This will initiate the terminate-hard (forced) process in the selected VMs"), custom_classes : "state-dependent" }, "VM.resched" : { @@ -188,14 +173,19 @@ define(function(require) { text: Locale.tr("Recover"), layout: "vmsplanification_buttons", custom_select: '' , + \ + \ + \ + \ + \ + ' , tip: Locale.tr("Recovers a stuck VM that is waiting for a driver operation. \ The recovery may be done by failing, succeeding or retrying the current operation. \ YOU NEED TO MANUALLY CHECK THE VM STATUS ON THE HOST, to decide if the operation \ - was successful or not, or if it can be retried."), + was successful or not, or if it can be retried.\ +
    \ +
    Delete: This will delete the selected VMs\ +
    Delete-recreate: This will delete and recreate VMs to PENDING state"), custom_classes : "state-dependent" }, "VM.startvnc" : { @@ -210,7 +200,7 @@ define(function(require) { custom_classes: "only-sunstone-info spice-sunstone-info", tip: Locale.tr("SPICE") }, - "VM.saveas_template" : { + "VM.save_as_template" : { type: "action", text: '', tip: Locale.tr("This Virtual Machine will be saved in a new Template. You can then create a new Virtual Machine using this Template"), diff --git a/src/sunstone/public/app/tabs/vms-tab/utils/state-actions.js b/src/sunstone/public/app/tabs/vms-tab/utils/state-actions.js index c982df68f9..12e7635234 100644 --- a/src/sunstone/public/app/tabs/vms-tab/utils/state-actions.js +++ b/src/sunstone/public/app/tabs/vms-tab/utils/state-actions.js @@ -20,47 +20,47 @@ define(function(require) { var STATE_ACTIONS = {}; STATE_ACTIONS[OpenNebulaVM.STATES.INIT] = - ["VM.delete", "VM.delete_recreate", "VM.resize"]; + ["VM.resize", "VM.terminate_hard", "VM.recover"]; STATE_ACTIONS[OpenNebulaVM.STATES.PENDING] = - ["VM.delete", "VM.delete_recreate", "VM.hold", "VM.deploy", "VM.updateconf"]; + ["VM.hold", "VM.deploy", "VM.updateconf", "VM.terminate_hard", "VM.recover"]; STATE_ACTIONS[OpenNebulaVM.STATES.HOLD] = - ["VM.delete", "VM.delete_recreate", "VM.release", "VM.deploy", "VM.updateconf"]; + ["VM.release", "VM.deploy", "VM.updateconf", "VM.terminate_hard", "VM.recover"]; STATE_ACTIONS[OpenNebulaVM.STATES.ACTIVE] = - ["VM.delete", "VM.delete_recreate", "VM.recover"]; + ["VM.recover"]; STATE_ACTIONS[OpenNebulaVM.STATES.STOPPED] = - ["VM.delete", "VM.delete_recreate", "VM.resume", "VM.deploy"]; + ["VM.resume", "VM.deploy", "VM.terminate_hard", "VM.recover"]; STATE_ACTIONS[OpenNebulaVM.STATES.SUSPENDED] = - ["VM.delete", "VM.resume", "VM.disk_saveas", "VM.disk_snapshot_create", "VM.disk_snapshot_revert", "VM.disk_snapshot_delete", "VM.stop", "VM.shutdown_hard"]; + ["VM.resume", "VM.disk_saveas", "VM.disk_snapshot_create", "VM.disk_snapshot_revert", "VM.disk_snapshot_delete", "VM.stop", "VM.terminate_hard", "VM.recover"]; STATE_ACTIONS[OpenNebulaVM.STATES.DONE] = []; STATE_ACTIONS[OpenNebulaVM.STATES.FAILED] = - ["VM.delete", "VM.delete_recreate", "VM.resize"]; + []; STATE_ACTIONS[OpenNebulaVM.STATES.POWEROFF] = - ["VM.delete", "VM.resume", "VM.resize", "VM.attachdisk", "VM.detachdisk", "VM.attachnic", "VM.detachnic", "VM.disk_saveas", "VM.disk_snapshot_create", "VM.disk_snapshot_revert", "VM.disk_snapshot_delete", "VM.migrate", "VM.undeploy", "VM.undeploy_hard", "VM.shutdown_hard", "VM.saveas_template", "VM.updateconf"]; + ["VM.resume", "VM.resize", "VM.attachdisk", "VM.detachdisk", "VM.attachnic", "VM.detachnic", "VM.disk_saveas", "VM.disk_snapshot_create", "VM.disk_snapshot_revert", "VM.disk_snapshot_delete", "VM.migrate", "VM.undeploy", "VM.undeploy_hard", "VM.save_as_template", "VM.updateconf", "VM.terminate_hard", "VM.recover"]; STATE_ACTIONS[OpenNebulaVM.STATES.UNDEPLOYED] = - ["VM.delete", "VM.delete_recreate", "VM.resume", "VM.resize", "VM.deploy", "VM.updateconf"]; + ["VM.resume", "VM.resize", "VM.deploy", "VM.updateconf", "VM.terminate_hard", "VM.recover"]; STATE_ACTIONS[OpenNebulaVM.STATES.CLONING] = - ["VM.delete", "VM.delete_recreate", "VM.updateconf"]; + ["VM.updateconf", "VM.terminate_hard", "VM.recover"]; STATE_ACTIONS[OpenNebulaVM.STATES.CLONING_FAILURE] = - ["VM.delete", "VM.delete_recreate", "VM.recover", "VM.updateconf"]; + ["VM.updateconf", "VM.terminate_hard", "VM.recover"]; var LCM_STATE_ACTIONS = {}; LCM_STATE_ACTIONS[ OpenNebulaVM.LCM_STATES.LCM_INIT ] = []; LCM_STATE_ACTIONS[ OpenNebulaVM.LCM_STATES.PROLOG ] = ["VM.updateconf"]; LCM_STATE_ACTIONS[ OpenNebulaVM.LCM_STATES.BOOT ] = []; LCM_STATE_ACTIONS[ OpenNebulaVM.LCM_STATES.RUNNING ] = - ["VM.shutdown", "VM.shutdown_hard", "VM.stop", "VM.suspend", "VM.reboot", "VM.reboot_hard", "VM.resched", "VM.unresched", "VM.poweroff", "VM.poweroff_hard", "VM.undeploy", "VM.undeploy_hard", "VM.migrate", "VM.migrate_live", "VM.attachdisk", "VM.detachdisk", "VM.attachnic", "VM.detachnic", "VM.disk_saveas", "VM.disk_snapshot_create", "VM.disk_snapshot_delete"]; + ["VM.stop", "VM.suspend", "VM.reboot", "VM.reboot_hard", "VM.resched", "VM.unresched", "VM.poweroff", "VM.poweroff_hard", "VM.undeploy", "VM.undeploy_hard", "VM.migrate", "VM.migrate_live", "VM.attachdisk", "VM.detachdisk", "VM.attachnic", "VM.detachnic", "VM.disk_saveas", "VM.disk_snapshot_create", "VM.disk_snapshot_delete", "VM.terminate", "VM.terminate_hard"]; LCM_STATE_ACTIONS[ OpenNebulaVM.LCM_STATES.MIGRATE ] = []; LCM_STATE_ACTIONS[ OpenNebulaVM.LCM_STATES.SAVE_STOP ] = []; LCM_STATE_ACTIONS[ OpenNebulaVM.LCM_STATES.SAVE_SUSPEND ] = []; @@ -74,7 +74,7 @@ define(function(require) { LCM_STATE_ACTIONS[ OpenNebulaVM.LCM_STATES.FAILURE ] = []; LCM_STATE_ACTIONS[ OpenNebulaVM.LCM_STATES.CLEANUP_RESUBMIT ] = ["VM.updateconf"]; LCM_STATE_ACTIONS[ OpenNebulaVM.LCM_STATES.UNKNOWN ] = - ["VM.shutdown", "VM.shutdown_hard", "VM.resched", "VM.unresched", "VM.poweroff", "VM.poweroff_hard", "VM.undeploy", "VM.undeploy_hard", "VM.migrate", "VM.migrate_live", "VM.resume"]; + ["VM.resched", "VM.unresched", "VM.poweroff", "VM.poweroff_hard", "VM.undeploy", "VM.undeploy_hard", "VM.migrate", "VM.migrate_live", "VM.resume", "VM.terminate", "VM.terminate_hard"]; LCM_STATE_ACTIONS[ OpenNebulaVM.LCM_STATES.HOTPLUG ] = []; LCM_STATE_ACTIONS[ OpenNebulaVM.LCM_STATES.SHUTDOWN_POWEROFF ] = ["VM.updateconf"]; LCM_STATE_ACTIONS[ OpenNebulaVM.LCM_STATES.BOOT_UNKNOWN ] = []; diff --git a/src/sunstone/public/app/utils/dialogs/confirm-with-select.js b/src/sunstone/public/app/utils/dialogs/confirm-with-select.js index 3399005776..ae8377d3f7 100644 --- a/src/sunstone/public/app/utils/dialogs/confirm-with-select.js +++ b/src/sunstone/public/app/utils/dialogs/confirm-with-select.js @@ -119,7 +119,7 @@ define(function(require) { tip = this.button.tip } - $('#confirm_with_select_tip', dialog).text(tip); + $('#confirm_with_select_tip', dialog).html(tip); var action = Sunstone.getAction(this.actionId); var elements = action.elements();