mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-22 18:50:08 +03:00
feature #1055: Added reset action for KVM and VMware drivers
This commit is contained in:
parent
740f821a59
commit
e1a3c5c7db
@ -33,6 +33,7 @@ class VirtualMachineDriver < OpenNebulaDriver
|
||||
:deploy => "DEPLOY",
|
||||
:shutdown => "SHUTDOWN",
|
||||
:reboot => "REBOOT",
|
||||
:reset => "RESET",
|
||||
:cancel => "CANCEL",
|
||||
:save => "SAVE",
|
||||
:restore => "RESTORE",
|
||||
@ -75,14 +76,15 @@ class VirtualMachineDriver < OpenNebulaDriver
|
||||
|
||||
@hosts = Array.new
|
||||
|
||||
register_action(ACTION[:deploy].to_sym, method("deploy"))
|
||||
register_action(ACTION[:shutdown].to_sym, method("shutdown"))
|
||||
register_action(ACTION[:reboot].to_sym, method("reboot"))
|
||||
register_action(ACTION[:cancel].to_sym, method("cancel"))
|
||||
register_action(ACTION[:save].to_sym, method("save"))
|
||||
register_action(ACTION[:restore].to_sym, method("restore"))
|
||||
register_action(ACTION[:migrate].to_sym, method("migrate"))
|
||||
register_action(ACTION[:poll].to_sym, method("poll"))
|
||||
register_action(ACTION[:deploy].to_sym, method("deploy"))
|
||||
register_action(ACTION[:shutdown].to_sym, method("shutdown"))
|
||||
register_action(ACTION[:reboot].to_sym, method("reboot"))
|
||||
register_action(ACTION[:reset].to_sym, method("reset"))
|
||||
register_action(ACTION[:cancel].to_sym, method("cancel"))
|
||||
register_action(ACTION[:save].to_sym, method("save"))
|
||||
register_action(ACTION[:restore].to_sym, method("restore"))
|
||||
register_action(ACTION[:migrate].to_sym, method("migrate"))
|
||||
register_action(ACTION[:poll].to_sym, method("poll"))
|
||||
end
|
||||
|
||||
# Decodes the encoded XML driver message received from the core
|
||||
@ -122,6 +124,11 @@ class VirtualMachineDriver < OpenNebulaDriver
|
||||
send_message(ACTION[:reboot],RESULT[:failure],id,error)
|
||||
end
|
||||
|
||||
def reset(id, drv_message)
|
||||
error = "Action not implemented by driver #{self.class}"
|
||||
send_message(ACTION[:reset],RESULT[:failure],id,error)
|
||||
end
|
||||
|
||||
def cancel(id, drv_message)
|
||||
error = "Action not implemented by driver #{self.class}"
|
||||
send_message(ACTION[:cancel],RESULT[:failure],id,error)
|
||||
|
@ -56,6 +56,10 @@ class DummyDriver < VirtualMachineDriver
|
||||
send_message(ACTION[:reboot],RESULT[:success],id)
|
||||
end
|
||||
|
||||
def reset(id, drv_message)
|
||||
send_message(ACTION[:reset],RESULT[:success],id)
|
||||
end
|
||||
|
||||
def cancel(id, drv_message)
|
||||
send_message(ACTION[:cancel],RESULT[:success],id)
|
||||
end
|
||||
|
@ -470,6 +470,17 @@ class ExecDriver < VirtualMachineDriver
|
||||
|
||||
do_action("#{deploy_id} #{host}", id, host, ACTION[:reboot])
|
||||
end
|
||||
|
||||
#
|
||||
# RESET action, resets a running VM
|
||||
#
|
||||
def reset(id, drv_message)
|
||||
data = decode(drv_message)
|
||||
host = data.elements['HOST'].text
|
||||
deploy_id = data.elements['DEPLOY_ID'].text
|
||||
|
||||
do_action("#{deploy_id} #{host}", id, host, ACTION[:reset])
|
||||
end
|
||||
end
|
||||
|
||||
################################################################################
|
||||
|
27
src/vmm_mad/remotes/kvm/reset
Executable file
27
src/vmm_mad/remotes/kvm/reset
Executable file
@ -0,0 +1,27 @@
|
||||
#!/bin/bash
|
||||
|
||||
# -------------------------------------------------------------------------- #
|
||||
# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) #
|
||||
# #
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
|
||||
# not use this file except in compliance with the License. You may obtain #
|
||||
# a copy of the License at #
|
||||
# #
|
||||
# http://www.apache.org/licenses/LICENSE-2.0 #
|
||||
# #
|
||||
# Unless required by applicable law or agreed to in writing, software #
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, #
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
|
||||
# See the License for the specific language governing permissions and #
|
||||
# limitations under the License. #
|
||||
#--------------------------------------------------------------------------- #
|
||||
|
||||
source $(dirname $0)/kvmrc
|
||||
source $(dirname $0)/../../scripts_common.sh
|
||||
|
||||
deploy_id=$1
|
||||
|
||||
exec_and_log "virsh --connect $LIBVIRT_URI reset $deploy_id" \
|
||||
"Could not reset domain $deploy_id"
|
||||
|
||||
exit 0
|
37
src/vmm_mad/remotes/vmware/reset
Executable file
37
src/vmm_mad/remotes/vmware/reset
Executable file
@ -0,0 +1,37 @@
|
||||
#!/usr/bin/env ruby
|
||||
|
||||
# ---------------------------------------------------------------------------- #
|
||||
# Copyright 2010-2012, C12G Labs S.L #
|
||||
# #
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
|
||||
# not use this file except in compliance with the License. You may obtain #
|
||||
# a copy of the License at #
|
||||
# #
|
||||
# http://www.apache.org/licenses/LICENSE-2.0 #
|
||||
# #
|
||||
# Unless required by applicable law or agreed to in writing, software #
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, #
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
|
||||
# See the License for the specific language governing permissions and #
|
||||
# limitations under the License. #
|
||||
# ---------------------------------------------------------------------------- #
|
||||
|
||||
ONE_LOCATION=ENV["ONE_LOCATION"] if !defined?(ONE_LOCATION)
|
||||
|
||||
if !ONE_LOCATION
|
||||
RUBY_LIB_LOCATION="/usr/lib/one/ruby" if !defined?(RUBY_LIB_LOCATION)
|
||||
else
|
||||
RUBY_LIB_LOCATION=ONE_LOCATION+"/lib/ruby" if !defined?(RUBY_LIB_LOCATION)
|
||||
end
|
||||
|
||||
$: << RUBY_LIB_LOCATION
|
||||
$: << File.dirname(__FILE__)
|
||||
|
||||
require 'vmware_driver'
|
||||
|
||||
deploy_id = ARGV[0]
|
||||
host = ARGV[1]
|
||||
|
||||
vmware_drv = VMwareDriver.new(host)
|
||||
|
||||
vmware_drv.reset(deploy_id)
|
@ -112,6 +112,18 @@ class VMwareDriver
|
||||
|
||||
OpenNebula.log_debug("Domain #{deploy_id} successfully rebooted.")
|
||||
end
|
||||
|
||||
# ------------------------------------------------------------------------ #
|
||||
# Reset a running VM #
|
||||
# ------------------------------------------------------------------------ #
|
||||
def reset(deploy_id)
|
||||
rc, info = do_action("virsh -c #{@uri} reset #{deploy_id}")
|
||||
|
||||
exit info if rc == false
|
||||
|
||||
OpenNebula.log_debug("Domain #{deploy_id} successfully reseted.")
|
||||
end
|
||||
|
||||
# ------------------------------------------------------------------------ #
|
||||
# Migrate #
|
||||
# ------------------------------------------------------------------------ #
|
||||
|
Loading…
x
Reference in New Issue
Block a user