1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-03-26 06:50:09 +03:00

Feature #1404: Add poweron/poweroff actions to Sunstone and SelfService

(cherry picked from commit c400ee76174fbdd61e0ab6f6fdca5064dce566e5)
This commit is contained in:
Hector Sanjuan 2012-09-06 11:49:38 +02:00 committed by Ruben S. Montero
parent 23230922dc
commit 1486d045d8
7 changed files with 177 additions and 62 deletions

View File

@ -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}
}

View File

@ -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");

View File

@ -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 = '<img style="display:inline-block;margin-right:5px;;" src="images/yellow_bullet.png" alt="'+vm_state+'" title="'+vm_state+'" />';
break;
case "ACTIVE":

View File

@ -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)

View File

@ -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'])

View File

@ -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");
},

View File

@ -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"),