diff --git a/src/cloud/occi/lib/VirtualMachineOCCI.rb b/src/cloud/occi/lib/VirtualMachineOCCI.rb index eb8db6d926..0af7e05e2c 100644 --- a/src/cloud/occi/lib/VirtualMachineOCCI.rb +++ b/src/cloud/occi/lib/VirtualMachineOCCI.rb @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- # -------------------------------------------------------------------------- # # Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # # # @@ -72,6 +73,9 @@ class VirtualMachineOCCI < VirtualMachine "REBOOT" => { :from => ["ACTIVE"], :action => :reboot}, "RESET" => { :from => ["ACTIVE"], :action => :reset}, "SHUTDOWN" => { :from => ["ACTIVE"], :action => :shutdown}, + "RESTART" => { :from => ["ACTIVE"], :action => :restart}, + "RESUBMIT" => { :from => ["ACTIVE", "FAILED"], :action => :resubmit}, + "POWEROFF" => { :from => ["ACTIVE"], :action => :poweroff}, "DONE" => { :from => VM_STATE, :action => :finalize} } diff --git a/src/cloud/occi/lib/ui/public/js/occi.js b/src/cloud/occi/lib/ui/public/js/occi.js index bdceef2429..8c4780455d 100644 --- a/src/cloud/occi/lib/ui/public/js/occi.js +++ b/src/cloud/occi/lib/ui/public/js/occi.js @@ -466,6 +466,18 @@ var OCCI = { params.data.body = { state : "RESUME" }; OCCI.Action.update(params,OCCI.VM.resource,"resume"); }, + "restart": function(params){ + params.data.body = { state : "RESTART" }; + OCCI.Action.update(params,OCCI.VM.resource,"restart"); + }, + "poweroff": function(params){ + params.data.body = { state : "POWEROFF" }; + OCCI.Action.update(params,OCCI.VM.resource,"poweroff"); + }, + "resubmit": function(params){ + params.data.body = { state : "RESUBMIT" }; + OCCI.Action.update(params,OCCI.VM.resource,"resubmit"); + }, "done": function(params){ params.data.body = { state : "DONE" }; OCCI.Action.update(params,OCCI.VM.resource,"done"); diff --git a/src/cloud/occi/lib/ui/public/js/plugins/compute.js b/src/cloud/occi/lib/ui/public/js/plugins/compute.js index ed11ac8e09..e69b818ff0 100644 --- a/src/cloud/occi/lib/ui/public/js/plugins/compute.js +++ b/src/cloud/occi/lib/ui/public/js/plugins/compute.js @@ -291,6 +291,42 @@ var vm_actions = { }, error: onError, notify: true + }, + + "VM.restart" : { + type: "multiple", + call: OCCI.VM.restart, + callback: updateVMachineElement, + elements: vmElements, + error: onError, + notify: true + }, + + "VM.resubmit" : { + type: "multiple", + call: OCCI.VM.resubmit, + callback: updateVMachineElement, + elements: vmElements, + error: onError, + notify: true + }, + + "VM.poweron" : { //restart alias + type: "multiple", + call: OCCI.VM.restart, + callback: updateVMachineElement, + elements: vmElements, + error: onError, + notify: true + }, + + "VM.poweroff" : { + type: "multiple", + call: OCCI.VM.poweroff, + callback: updateVMachineElement, + elements: vmElements, + error: onError, + notify: true } /* @@ -363,6 +399,26 @@ var vm_buttons = { text: tr("Reset"), tip: "This will perform a hard reset on selected VMs" }, + "VM.restart" : { + type: "confirm", + text: tr("Restart"), + tip: tr("This will redeploy selected VMs") + }, + "VM.resubmit" : { + type: "confirm", + text: tr("Resubmit"), + tip: tr("This will resubmits VMs to PENDING state") + }, + "VM.poweron" : { + type : "confirm", + text: tr("Power On"), + tip: tr("This will start on powered off machines") + }, + "VM.poweroff" : { + type : "confirm", + text: tr("Power Off"), + tip: tr("This will send a power off signal to running VMs. They can be powered on later.") + }, "VM.cancel" : { type: "confirm", text: tr("Cancel"), @@ -513,6 +569,7 @@ function VMStateBulletStr(vm){ case "HOLD": case "STOPPED": case "SUSPENDED": + case "POWEROFF": state_html = ''+vm_state+''; break; case "ACTIVE": diff --git a/src/ozones/Server/public/js/ozones.js b/src/ozones/Server/public/js/ozones.js index 8e76421896..e41a7206eb 100644 --- a/src/ozones/Server/public/js/ozones.js +++ b/src/ozones/Server/public/js/ozones.js @@ -44,81 +44,86 @@ var oZones = { "Helper": { "resource_state": function(type, value) { + var state; switch(type) { case "HOST": case "host": - return ["INIT", - "MONITORING_MONITORED", - "MONITORED", - "ERROR", - "DISABLED", - "MONITORING_ERROR"][value]; + state = tr(["INIT", + "MONITORING_MONITORED", + "MONITORED", + "ERROR", + "DISABLED", + "MONITORING_ERROR"][value]); break; case "HOST_SIMPLE": case "host_simple": - return ["INIT", - "UPDATE", - "ON", - "ERROR", - "OFF", - "RETRY"][value]; + state = tr(["INIT", + "UPDATE", + "ON", + "ERROR", + "OFF", + "RETRY"][value]); break; case "VM": case "vm": - return ["INIT", - "PENDING", - "HOLD", - "ACTIVE", - "STOPPED", - "SUSPENDED", - "DONE", - "FAILED"][value]; + state = tr(["INIT", + "PENDING", + "HOLD", + "ACTIVE", + "STOPPED", + "SUSPENDED", + "DONE", + "FAILED", + "POWEROFF"][value]); break; case "VM_LCM": case "vm_lcm": - return ["LCM_INIT", - "PROLOG", - "BOOT", - "RUNNING", - "MIGRATE", - "SAVE_STOP", - "SAVE_SUSPEND", - "SAVE_MIGRATE", - "PROLOG_MIGRATE", - "PROLOG_RESUME", - "EPILOG_STOP", - "EPILOG", - "SHUTDOWN", - "CANCEL", - "FAILURE", - "CLEANUP", - "UNKNOWN", - "HOTPLUG"][value]; + state = tr(["LCM_INIT", + "PROLOG", + "BOOT", + "RUNNING", + "MIGRATE", + "SAVE_STOP", + "SAVE_SUSPEND", + "SAVE_MIGRATE", + "PROLOG_MIGRATE", + "PROLOG_RESUME", + "EPILOG_STOP", + "EPILOG", + "SHUTDOWN", + "CANCEL", + "FAILURE", + "CLEANUP", + "UNKNOWN", + "HOTPLUG", + "SHUTDOWN_POWEROFF"][value]); break; case "IMAGE": case "image": - return ["INIT", - "READY", - "USED", - "DISABLED", - "LOCKED", - "ERROR", - "CLONE", - "DELETE", - "USED_PERS"][value]; + state = tr(["INIT", + "READY", + "USED", + "DISABLED", + "LOCKED", + "ERROR", + "CLONE", + "DELETE", + "USED_PERS"][value]); break; case "VM_MIGRATE_REASON": case "vm_migrate_reason": - return ["NONE", - "ERROR", - "STOP_RESUME", - "USER", - "CANCEL"][value]; + state = tr(["NONE", + "ERROR", + "STOP_RESUME", + "USER", + "CANCEL"][value]); break; default: - return; + return value; } + if (!state) state = value + return state; }, "image_type": function(value) diff --git a/src/sunstone/models/OpenNebulaJSON/VirtualMachineJSON.rb b/src/sunstone/models/OpenNebulaJSON/VirtualMachineJSON.rb index de4c6a4c1a..c44524b2d0 100644 --- a/src/sunstone/models/OpenNebulaJSON/VirtualMachineJSON.rb +++ b/src/sunstone/models/OpenNebulaJSON/VirtualMachineJSON.rb @@ -64,6 +64,7 @@ module OpenNebulaJSON when "saveas" then self.save_as(action_hash['params']) when "shutdown" then self.shutdown when "reboot" then self.reboot + when "poweroff" then self.poweroff when "resubmit" then self.resubmit when "chown" then self.chown(action_hash['params']) when "chmod" then self.chmod_octet(action_hash['params']) diff --git a/src/sunstone/public/js/opennebula.js b/src/sunstone/public/js/opennebula.js index 4f49bdc911..f1a90dc805 100644 --- a/src/sunstone/public/js/opennebula.js +++ b/src/sunstone/public/js/opennebula.js @@ -44,11 +44,12 @@ var OpenNebula = { "Helper": { "resource_state": function(type, value) { + var state; switch(type) { case "HOST": case "host": - return tr(["INIT", + state = tr(["INIT", "MONITORING_MONITORED", "MONITORED", "ERROR", @@ -57,7 +58,7 @@ var OpenNebula = { break; case "HOST_SIMPLE": case "host_simple": - return tr(["INIT", + state = tr(["INIT", "UPDATE", "ON", "ERROR", @@ -66,18 +67,19 @@ var OpenNebula = { break; case "VM": case "vm": - return tr(["INIT", + state = tr(["INIT", "PENDING", "HOLD", "ACTIVE", "STOPPED", "SUSPENDED", "DONE", - "FAILED"][value]); + "FAILED", + "POWEROFF"][value]); break; case "VM_LCM": case "vm_lcm": - return tr(["LCM_INIT", + state = tr(["LCM_INIT", "PROLOG", "BOOT", "RUNNING", @@ -94,11 +96,12 @@ var OpenNebula = { "FAILURE", "CLEANUP", "UNKNOWN", - "HOTPLUG"][value]); + "HOTPLUG", + "SHUTDOWN_POWEROFF"][value]); break; case "IMAGE": case "image": - return tr(["INIT", + state = tr(["INIT", "READY", "USED", "DISABLED", @@ -110,15 +113,17 @@ var OpenNebula = { break; case "VM_MIGRATE_REASON": case "vm_migrate_reason": - return tr(["NONE", + state = tr(["NONE", "ERROR", "STOP_RESUME", "USER", "CANCEL"][value]); break; default: - return; + return value; } + if (!state) state = value + return state; }, "image_type": function(value) @@ -622,6 +627,9 @@ var OpenNebula = { "resubmit": function(params){ OpenNebula.Action.simple_action(params,OpenNebula.VM.resource,"resubmit"); }, + "poweroff" : function(params){ + OpenNebula.Action.simple_action(params,OpenNebula.VM.resource,"poweroff"); + }, "reboot" : function(params){ OpenNebula.Action.simple_action(params,OpenNebula.VM.resource,"reboot"); }, diff --git a/src/sunstone/public/js/plugins/vms-tab.js b/src/sunstone/public/js/plugins/vms-tab.js index db851c66ef..3f0837280f 100644 --- a/src/sunstone/public/js/plugins/vms-tab.js +++ b/src/sunstone/public/js/plugins/vms-tab.js @@ -343,6 +343,24 @@ var vm_actions = { notify: true }, + "VM.poweron" : { // alias for restart + type: "multiple", + call: OpenNebula.VM.restart, + callback: vmShow, + elements: vmElements, + error: onError, + notify: true + }, + + "VM.poweroff" : { + type: "multiple", + call: OpenNebula.VM.poweroff, + callback: vmShow, + elements: vmElements, + error: onError, + notify: true + }, + "VM.saveas" : { type: "single", call: OpenNebula.VM.saveas, @@ -582,6 +600,16 @@ var vm_buttons = { text: tr("Resubmit"), tip: tr("This will resubmits VMs to PENDING state") }, + "VM.poweron" : { + type : "confirm", + text: tr("Power On"), + tip: tr("This will start on powered off machines") + }, + "VM.poweroff" : { + type : "confirm", + text: tr("Power Off"), + tip: tr("This will send a power off signal to running VMs. They can be powered on later.") + }, "VM.reboot" : { type : "confirm", text: tr("Reboot"),