1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-01-12 09:17:41 +03:00

Merge branch 'feature-1055'

This commit is contained in:
Ruben S. Montero 2012-05-18 14:23:20 +02:00
commit e587a8928b
28 changed files with 446 additions and 196 deletions

View File

@ -219,6 +219,15 @@ public:
int reboot(
int vid);
/**
* Resets a VM preserving any resource and RUNNING state
* @param vid VirtualMachine identification
* @return 0 on success, -1 if the VM does not exits or -2 if the VM is
* in a wrong a state
*/
int reset(
int vid);
/**
* Set the re-scheduling flag for the VM (must be in RUNNING state)
* @param vid VirtualMachine identification

View File

@ -67,7 +67,6 @@ public:
LIVE_MIGRATE, /**< Sent by the DM to live-migrate a VM */
SHUTDOWN, /**< Sent by the DM to shutdown a running VM */
RESTART, /**< Sent by the DM to restart a deployed VM */
REBOOT, /**< Sent by the DM to reboot a running VM */
DELETE, /**< Sent by the DM to delete a VM */
CLEAN, /**< Sent by the DM to cleanup a VM for resubmission*/
FINALIZE
@ -195,8 +194,6 @@ private:
void restart_action(int vid);
void reboot_action(int vid);
void delete_action(int vid);
void clean_action(int vid);

View File

@ -52,6 +52,7 @@ public:
MIGRATE,
RESTORE,
REBOOT,
RESET,
POLL,
TIMER,
DRIVER_CANCEL,
@ -269,6 +270,13 @@ private:
*/
void reboot_action(
int vid);
/**
* Resets a running VM.
* @param vid the id of the VM.
*/
void reset_action(
int vid);
/**
* Polls a VM.

View File

@ -116,7 +116,10 @@ private:
*/
void deploy (
const int oid,
const string& drv_msg) const;
const string& drv_msg) const
{
write_drv("DEPLOY", oid, drv_msg);
}
/**
* Sends a shutdown request to the MAD: "SHUTDOWN ID XML_DRV_MSG"
@ -125,7 +128,22 @@ private:
*/
void shutdown (
const int oid,
const string& drv_msg) const;
const string& drv_msg) const
{
write_drv("SHUTDOWN", oid, drv_msg);
}
/**
* Sends a reset request to the MAD: "RESET ID XML_DRV_MSG"
* @param oid the virtual machine id.
* @param drv_msg xml data for the mad operation
*/
void reset (
const int oid,
const string& drv_msg) const
{
write_drv("RESET", oid, drv_msg);
}
/**
* Sends a reboot request to the MAD: "REBOOT ID XML_DRV_MSG"
@ -134,7 +152,10 @@ private:
*/
void reboot (
const int oid,
const string& drv_msg) const;
const string& drv_msg) const
{
write_drv("REBOOT", oid, drv_msg);
}
/**
* Sends a cancel request to the MAD: "CANCEL ID XML_DRV_MSG"
@ -143,7 +164,10 @@ private:
*/
void cancel (
const int oid,
const string& drv_msg) const;
const string& drv_msg) const
{
write_drv("CANCEL", oid, drv_msg);
}
/**
* Sends a checkpoint request to the MAD: "CHECKPOINT ID XML_DRV_MSG"
@ -152,7 +176,10 @@ private:
*/
void checkpoint (
const int oid,
const string& drv_msg) const;
const string& drv_msg) const
{
write_drv("CHECKPOINT", oid, drv_msg);
}
/**
* Sends a save request to the MAD: "SAVE ID XML_DRV_MSG"
@ -161,7 +188,11 @@ private:
*/
void save (
const int oid,
const string& drv_msg) const;
const string& drv_msg) const
{
write_drv("SAVE", oid, drv_msg);
}
/**
* Sends a save request to the MAD: "RESTORE ID XML_DRV_MSG"
@ -170,7 +201,11 @@ private:
*/
void restore (
const int oid,
const string& drv_msg) const;
const string& drv_msg) const
{
write_drv("RESTORE", oid, drv_msg);
}
/**
* Sends a migrate request to the MAD: "MIGRATE ID XML_DRV_MSG"
@ -179,7 +214,10 @@ private:
*/
void migrate (
const int oid,
const string& drv_msg) const;
const string& drv_msg) const
{
write_drv("MIGRATE", oid, drv_msg);
}
/**
* Sends a poll request to the MAD: "POLL ID XML_DRV_MSG"
@ -188,7 +226,22 @@ private:
*/
void poll (
const int oid,
const string& drv_msg) const;
const string& drv_msg) const
{
write_drv("POLL", oid, drv_msg);
}
private:
void write_drv(const char * aname, const int oid, const string& msg) const
{
ostringstream os;
os << aname << " " << oid << " " << msg << endl;
write(os);
}
};
/* -------------------------------------------------------------------------- */

View File

@ -656,6 +656,7 @@ VMM_EXEC_KVM_SCRIPTS="src/vmm_mad/remotes/kvm/cancel \
src/vmm_mad/remotes/kvm/migrate_local \
src/vmm_mad/remotes/kvm/restore \
src/vmm_mad/remotes/kvm/reboot \
src/vmm_mad/remotes/kvm/reset \
src/vmm_mad/remotes/kvm/save \
src/vmm_mad/remotes/kvm/poll \
src/vmm_mad/remotes/kvm/poll_ganglia \
@ -671,6 +672,7 @@ VMM_EXEC_XEN_SCRIPTS="src/vmm_mad/remotes/xen/cancel \
src/vmm_mad/remotes/xen/migrate \
src/vmm_mad/remotes/xen/restore \
src/vmm_mad/remotes/xen/reboot \
src/vmm_mad/remotes/xen/reset \
src/vmm_mad/remotes/xen/save \
src/vmm_mad/remotes/xen/poll \
src/vmm_mad/remotes/xen/poll_ganglia \
@ -685,6 +687,7 @@ VMM_EXEC_VMWARE_SCRIPTS="src/vmm_mad/remotes/vmware/cancel \
src/vmm_mad/remotes/vmware/migrate \
src/vmm_mad/remotes/vmware/restore \
src/vmm_mad/remotes/vmware/reboot \
src/vmm_mad/remotes/vmware/reset \
src/vmm_mad/remotes/vmware/save \
src/vmm_mad/remotes/vmware/poll \
src/vmm_mad/remotes/vmware/checkpoint \

View File

@ -195,6 +195,18 @@ cmd=CommandParser::CmdParser.new(ARGV) do
end
end
reset_desc = <<-EOT.unindent
Resets the given VM
States: RUNNING
EOT
command :reset, reset_desc, [:range,:vmid_list] do
helper.perform_actions(args[0],options,"resetting") do |vm|
vm.reset
end
end
deploy_desc = <<-EOT.unindent
Deploys the given VM in the specified Host. This command forces the
deployment, in a standard installation the Scheduler is in charge

View File

@ -70,8 +70,9 @@ class VirtualMachineOCCI < VirtualMachine
"RESUME" => { :from => ["STOPPED", "SUSPENDED"], :action => :resume},
"CANCEL" => { :from => ["ACTIVE"], :action => :cancel},
"REBOOT" => { :from => ["ACTIVE"], :action => :reboot},
"RESET" => { :from => ["ACTIVE"], :action => :reset},
"SHUTDOWN" => { :from => ["ACTIVE"], :action => :shutdown},
"DONE" => { :from => VM_STATE, :action => :finalize}
"DONE" => { :from => VM_STATE, :action => :finalize}
}
# Class constructor

View File

@ -415,6 +415,14 @@ var OCCI = {
params.data.body = { state : "STOPPED" };
OCCI.Action.update(params,OCCI.VM.resource,"stop");
},
"reboot": function(params){
params.data.body = { state : "REBOOT" };
OCCI.Action.update(params,OCCI.VM.resource,"reboot");
},
"reset": function(params){
params.data.body = { state : "RESET" };
OCCI.Action.update(params,OCCI.VM.resource,"reset");
},
"cancel": function(params){
params.data.body = { state : "CANCEL" };
OCCI.Action.update(params,OCCI.VM.resource,"cancel");

View File

@ -214,6 +214,24 @@ var vm_actions = {
notify: true
},
"VM.reboot" : {
type: "multiple",
call: OCCI.VM.reboot,
callback: updateVMachineElement,
elements: vmElements,
error: onError,
notify: true
},
"VM.reset" : {
type: "multiple",
call: OCCI.VM.reset,
callback: updateVMachineElement,
elements: vmElements,
error: onError,
notify: true
},
"VM.cancel" : {
type: "multiple",
call: OCCI.VM.cancel,
@ -336,6 +354,16 @@ var vm_buttons = {
text: tr("Stop"),
tip: "This will stop selected VMs"
},
"VM.reboot" : {
type: "confirm",
text: tr("Reboot"),
tip: "This will reboot [via acpi] selected VMs"
},
"VM.reset" : {
type: "confirm",
text: tr("Reset"),
tip: "This will perform a hard reset on selected VMs"
},
"VM.cancel" : {
type: "confirm",
text: tr("Cancel"),

View File

@ -557,10 +557,14 @@ int DispatchManager::reboot(int vid)
if (vm->get_state() == VirtualMachine::ACTIVE &&
vm->get_lcm_state() == VirtualMachine::RUNNING )
{
Nebula& nd = Nebula::instance();
LifeCycleManager * lcm = nd.get_lcm();
Nebula& nd = Nebula::instance();
VirtualMachineManager * vmm = nd.get_vmm();
lcm->trigger(LifeCycleManager::REBOOT,vid);
vmm->trigger(VirtualMachineManager::REBOOT,vid);
vm->set_resched(false); //Rebooting cancels re-scheduling actions
vmpool->update(vm);
}
else
{
@ -584,6 +588,55 @@ error:
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
int DispatchManager::reset(int vid)
{
VirtualMachine * vm;
ostringstream oss;
vm = vmpool->get(vid,true);
if ( vm == 0 )
{
return -1;
}
oss << "Resetting VM " << vid;
NebulaLog::log("DiM",Log::DEBUG,oss);
if (vm->get_state() == VirtualMachine::ACTIVE &&
vm->get_lcm_state() == VirtualMachine::RUNNING )
{
Nebula& nd = Nebula::instance();
VirtualMachineManager * vmm = nd.get_vmm();
vmm->trigger(VirtualMachineManager::RESET,vid);
vm->set_resched(false); //Resetting cancels re-scheduling actions
vmpool->update(vm);
}
else
{
goto error;
}
vm->unlock();
return 0;
error:
oss.str("");
oss << "Could not reset VM " << vid << ", wrong state.";
NebulaLog::log("DiM",Log::ERROR,oss);
vm->unlock();
return -2;
}
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
int DispatchManager::resched(int vid, bool do_resched)
{
VirtualMachine * vm;

View File

@ -439,41 +439,6 @@ void LifeCycleManager::cancel_action(int vid)
return;
}
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
void LifeCycleManager::reboot_action(int vid)
{
VirtualMachine * vm;
vm = vmpool->get(vid,true);
if ( vm == 0 )
{
return;
}
if (vm->get_state() == VirtualMachine::ACTIVE &&
vm->get_lcm_state() == VirtualMachine::RUNNING)
{
Nebula& nd = Nebula::instance();
VirtualMachineManager * vmm = nd.get_vmm();
vmm->trigger(VirtualMachineManager::REBOOT,vid);
vm->set_resched(false); //Rebooting cancel re-scheduling actions
vmpool->update(vm);
}
else
{
vm->log("LCM", Log::ERROR, "reboot_action, VM in a wrong state.");
}
vm->unlock();
return;
}
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */

View File

@ -165,10 +165,6 @@ void LifeCycleManager::trigger(Actions action, int _vid)
aname = "RESTART";
break;
case REBOOT:
aname = "REBOOT";
break;
case DELETE:
aname = "DELETE";
break;
@ -302,10 +298,6 @@ void LifeCycleManager::do_action(const string &action, void * arg)
{
restart_action(vid);
}
else if (action == "REBOOT")
{
reboot_action(vid);
}
else if (action == "DELETE")
{
delete_action(vid);

View File

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

View File

@ -417,6 +417,15 @@ public class VirtualMachine extends PoolElement{
return action("reboot");
}
/**
* Resets a running VM.
* @return If an error occurs the error message contains the reason.
*/
public OneResponse reset()
{
return action("reset");
}
/**
* Cancels the running VM.
* @return If an error occurs the error message contains the reason.

View File

@ -144,11 +144,16 @@ module OpenNebula
action('shutdown')
end
# Shutdowns an already deployed VM
# Reboots an already deployed VM
def reboot
action('reboot')
end
# Resets an already deployed VM
def reset
action('reset')
end
# Cancels a running VM
def cancel
action('cancel')

View File

@ -180,7 +180,7 @@ void VirtualMachineAction::request_execute(xmlrpc_c::paramList const& paramList,
string action = xmlrpc_c::value_string(paramList.getString(1));
int id = xmlrpc_c::value_int(paramList.getInt(2));
int rc;
int rc = -4;
Nebula& nd = Nebula::instance();
DispatchManager * dm = nd.get_dm();
@ -249,6 +249,10 @@ void VirtualMachineAction::request_execute(xmlrpc_c::paramList const& paramList,
{
rc = dm->resched(id, false);
}
else if (action == "reset")
{
rc = dm->reset(id);
}
switch (rc)
{

View File

@ -60,6 +60,7 @@ module OpenNebulaJSON
when "stop" then self.stop
when "suspend" then self.suspend
when "restart" then self.restart
when "reset" then self.reset
when "saveas" then self.save_as(action_hash['params'])
when "shutdown" then self.shutdown
when "reboot" then self.reboot

View File

@ -615,6 +615,9 @@ var OpenNebula = {
"reboot" : function(params){
OpenNebula.Action.simple_action(params,OpenNebula.VM.resource,"reboot");
},
"reset" : function(params){
OpenNebula.Action.simple_action(params,OpenNebula.VM.resource,"reset");
},
"log": function(params){
OpenNebula.Action.show(params,OpenNebula.VM.resource,"log");

View File

@ -301,6 +301,15 @@ var vm_actions = {
notify: true
},
"VM.reset" : {
type: "multiple",
call: OpenNebula.VM.reset,
callback: vmShow,
elements: vmElements,
error: onError,
notify: true
},
"VM.resubmit" : {
type: "multiple",
call: OpenNebula.VM.resubmit,
@ -569,6 +578,11 @@ var vm_buttons = {
text: tr("Reboot"),
tip: tr("This will send a reboot action to running VMs")
},
"VM.reset" : {
type: "confirm",
text: tr("Reset"),
tip: tr("This will perform a hard reboot on selected VMs")
},
"VM.saveasmultiple" : {
type: "action",
text: tr("Save as")

View File

@ -130,6 +130,10 @@ void VirtualMachineManager::trigger(Actions action, int _vid)
aname = "REBOOT";
break;
case RESET:
aname = "RESET";
break;
case SHUTDOWN:
aname = "SHUTDOWN";
break;
@ -206,6 +210,10 @@ void VirtualMachineManager::do_action(const string &action, void * arg)
{
reboot_action(vid);
}
else if (action == "RESET")
{
reset_action(vid);
}
else if (action == "SHUTDOWN")
{
shutdown_action(vid);
@ -650,6 +658,75 @@ error_common:
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
void VirtualMachineManager::reset_action(
int vid)
{
VirtualMachine * vm;
const VirtualMachineManagerDriver * vmd;
string vm_tmpl;
string * drv_msg;
ostringstream os;
// Get the VM from the pool
vm = vmpool->get(vid,true);
if (vm == 0)
{
return;
}
if (!vm->hasHistory())
{
goto error_history;
}
// Get the driver for this VM
vmd = get(vm->get_vmm_mad());
if ( vmd == 0 )
{
goto error_driver;
}
// Invoke driver method
drv_msg = format_message(
vm->get_hostname(),
vm->get_vnm_mad(),
"",
"",
vm->get_deploy_id(),
"",
"",
"",
vm->to_xml(vm_tmpl));
vmd->reset(vid, *drv_msg);
delete drv_msg;
vm->unlock();
return;
error_history:
os.str("");
os << "reset_action, VM has no history";
goto error_common;
error_driver:
os.str("");
os << "reset_action, error getting driver " << vm->get_vmm_mad();
error_common:
vm->log("VMM", Log::ERROR, os);
vm->unlock();
return;
}
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
void VirtualMachineManager::cancel_action(
int vid)
{

View File

@ -98,133 +98,6 @@ void VirtualMachineManagerDriver::get_default(
}
}
/* ************************************************************************** */
/* Driver ASCII Protocol Implementation */
/* ************************************************************************** */
void VirtualMachineManagerDriver::deploy (
const int oid,
const string& drv_msg) const
{
ostringstream os;
os << "DEPLOY " << oid << " " << drv_msg << endl;
write(os);
};
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
void VirtualMachineManagerDriver::shutdown (
const int oid,
const string& drv_msg) const
{
ostringstream os;
os << "SHUTDOWN " << oid << " " << drv_msg << endl;
write(os);
};
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
void VirtualMachineManagerDriver::cancel (
const int oid,
const string& drv_msg) const
{
ostringstream os;
os << "CANCEL " << oid << " " << drv_msg << endl;
write(os);
};
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
void VirtualMachineManagerDriver::checkpoint (
const int oid,
const string& drv_msg) const
{
ostringstream os;
os<< "CHECKPOINT " << oid << " " << drv_msg << endl;
write(os);
};
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
void VirtualMachineManagerDriver::save (
const int oid,
const string& drv_msg) const
{
ostringstream os;
os<< "SAVE " << oid << " " << drv_msg << endl;
write(os);
};
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
void VirtualMachineManagerDriver::restore (
const int oid,
const string& drv_msg) const
{
ostringstream os;
os << "RESTORE " << oid << " " << drv_msg << endl;
write(os);
};
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
void VirtualMachineManagerDriver::migrate (
const int oid,
const string& drv_msg) const
{
ostringstream os;
os<< "MIGRATE " << oid << " " << drv_msg << endl;
write(os);
};
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
void VirtualMachineManagerDriver::poll (
const int oid,
const string& drv_msg) const
{
ostringstream os;
os << "POLL " << oid << " " << drv_msg << endl;
write(os);
};
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
void VirtualMachineManagerDriver::reboot (
const int oid,
const string& drv_msg) const
{
ostringstream os;
os << "REBOOT " << oid << " " << drv_msg << endl;
write(os);
};
/* ************************************************************************** */
/* MAD Interface */
/* ************************************************************************** */
@ -450,6 +323,18 @@ void VirtualMachineManagerDriver::protocol(
vmpool->update(vm);
}
}
else if ( action == "RESET" )
{
if (result == "SUCCESS")
{
vm->log("VMM",Log::ERROR,"VM Successfully reseted.");
}
else
{
log_error(vm,os,is,"Error resetting VM, assume it's still running");
vmpool->update(vm);
}
}
else if ( action == "POLL" )
{
if (result == "SUCCESS")

View File

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

View File

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

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

View File

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

24
src/vmm_mad/remotes/xen/reset Executable file
View File

@ -0,0 +1,24 @@
#!/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)/xenrc
source $(dirname $0)/../../scripts_common.sh
deploy_id=$1
exec_and_log "$XM_RESET $deploy_id" "Could not reset domain $deploy_id"

View File

@ -23,6 +23,7 @@ export XM_CREDITS="sudo $XM_PATH sched-cred"
export XM_MIGRATE="sudo $XM_PATH migrate -l"
export XM_SAVE="sudo $XM_PATH save"
export XM_REBOOT="sudo $XM_PATH reboot"
export XM_RESET="sudo $XM_PATH reset"
export XM_RESTORE="sudo $XM_PATH restore"
export XM_LIST="sudo $XM_PATH list"
export XM_SHUTDOWN="sudo $XM_PATH shutdown"