From 0d163cd300024d3d093b765777a15e5ef1b9a3ff Mon Sep 17 00:00:00 2001 From: "Ruben S. Montero" Date: Sun, 7 Oct 2012 23:25:54 +0200 Subject: [PATCH] feature #1144: Hook for UNKNOWN --- share/etc/oned.conf | 1 + src/vm/VirtualMachinePool.cc | 24 +++++++++++++++++------- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/share/etc/oned.conf b/share/etc/oned.conf index d930ec4d2b..09aa168b43 100644 --- a/share/etc/oned.conf +++ b/share/etc/oned.conf @@ -327,6 +327,7 @@ DATASTORE_MAD = [ # - CREATE, when the VM is created (onevm create) # - PROLOG, when the VM is in the prolog state # - RUNNING, after the VM is successfully booted +# - UNKNOWN, when the VM is in the unknown state # - SHUTDOWN, after the VM is shutdown # - STOP, after the VM is stopped (including VM image transfers) # - DONE, after the VM is deleted or shutdown diff --git a/src/vm/VirtualMachinePool.cc b/src/vm/VirtualMachinePool.cc index 8b0ac72538..0d6c058335 100644 --- a/src/vm/VirtualMachinePool.cc +++ b/src/vm/VirtualMachinePool.cc @@ -102,15 +102,15 @@ VirtualMachinePool::VirtualMachinePool( if ( remote ) { - cmd_os << hook_location << "/" << cmd; + cmd_os << hook_location << "/" << cmd; } else { cmd_os << remotes_location << "/hooks/" << cmd; - } + } cmd = cmd_os.str(); - } + } if ( on == "CREATE" ) { @@ -180,6 +180,16 @@ VirtualMachinePool::VirtualMachinePool( state_hook = true; } + else if ( on == "UNKNOWN" ) + { + VirtualMachineStateHook * hook; + + hook = new VirtualMachineStateHook(name, cmd, arg, remote, + VirtualMachine::UNKNOWN, VirtualMachine::ACTIVE); + add_hook(hook); + + state_hook = true; + } else { ostringstream oss; @@ -230,7 +240,7 @@ int VirtualMachinePool::allocate ( { vm->state = VirtualMachine::PENDING; } - + // ------------------------------------------------------------------------ // Insert the Object in the pool // ------------------------------------------------------------------------ @@ -281,9 +291,9 @@ int VirtualMachinePool::get_pending( /* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */ -int VirtualMachinePool::dump_acct(ostringstream& oss, - const string& where, - int time_start, +int VirtualMachinePool::dump_acct(ostringstream& oss, + const string& where, + int time_start, int time_end) { ostringstream cmd;