On Fri, Jan 3, 2014 at 9:42 AM, Jose A. Lopes <[email protected]> wrote: > Add user shutdown parameter for KVM. Based on this parameter, decide > what information to report for a KVM instance, for example, > distinguish between 'ADMIN_down' and 'USER_down'. > > Signed-off-by: Jose A. Lopes <[email protected]> > --- > lib/cmdlib/instance_query.py | 4 +++- > lib/hypervisor/hv_kvm.py | 1 + > src/Ganeti/Constants.hs | 5 +++++ > src/Ganeti/Query/Instance.hs | 9 ++++++++- > 4 files changed, 17 insertions(+), 2 deletions(-) > > diff --git a/lib/cmdlib/instance_query.py b/lib/cmdlib/instance_query.py > index 42c2666..e7eca22 100644 > --- a/lib/cmdlib/instance_query.py > +++ b/lib/cmdlib/instance_query.py > @@ -225,7 +225,9 @@ class LUInstanceQueryData(NoHooksLU): > remote_info.Raise("Error checking node %s" % pnode.name) > remote_info = remote_info.payload > if remote_info and "state" in remote_info: > - if hv_base.HvInstanceState.IsShutdown(remote_info["state"]): > + if hv_base.HvInstanceState.IsShutdown(remote_info["state"]) \ > + and (instance.hypervisor != constants.HT_KVM > + or instance.hvparams[constants.HV_KVM_USER_SHUTDOWN]): > remote_state = "user down" > else: > remote_state = "up" > diff --git a/lib/hypervisor/hv_kvm.py b/lib/hypervisor/hv_kvm.py > index ed854fe..dc6eaeb 100644 > --- a/lib/hypervisor/hv_kvm.py > +++ b/lib/hypervisor/hv_kvm.py > @@ -682,6 +682,7 @@ class KVMHypervisor(hv_base.BaseHypervisor): > hv_base.ParamInSet(False, constants.HT_KVM_FLAG_VALUES), > constants.HV_VHOST_NET: hv_base.NO_CHECK, > constants.HV_KVM_USE_CHROOT: hv_base.NO_CHECK, > + constants.HV_KVM_USER_SHUTDOWN: hv_base.NO_CHECK, > constants.HV_MEM_PATH: hv_base.OPT_DIR_CHECK, > constants.HV_REBOOT_BEHAVIOR: > hv_base.ParamInSet(True, constants.REBOOT_BEHAVIORS), > diff --git a/src/Ganeti/Constants.hs b/src/Ganeti/Constants.hs > index 301b5fa..23b47bb 100644 > --- a/src/Ganeti/Constants.hs > +++ b/src/Ganeti/Constants.hs > @@ -1544,6 +1544,9 @@ hvKvmSpiceZlibGlzImgCompr = > "spice_zlib_glz_wan_compression" > hvKvmUseChroot :: String > hvKvmUseChroot = "use_chroot" > > +hvKvmUserShutdown :: String > +hvKvmUserShutdown = "user_shutdown" > + > hvMemPath :: String > hvMemPath = "mem_path" > > @@ -1700,6 +1703,7 @@ hvsParameterTypes = Map.fromList > , (hvKvmSpiceUseVdagent, VTypeBool) > , (hvKvmSpiceZlibGlzImgCompr, VTypeString) > , (hvKvmUseChroot, VTypeBool) > + , (hvKvmUserShutdown, VTypeBool) > , (hvMemPath, VTypeString) > , (hvMigrationBandwidth, VTypeInt) > , (hvMigrationDowntime, VTypeInt) > @@ -3660,6 +3664,7 @@ hvcDefaults = > , (hvKvmFlag, PyValueEx "") > , (hvVhostNet, PyValueEx False) > , (hvKvmUseChroot, PyValueEx False) > + , (hvKvmUserShutdown, PyValueEx False) > , (hvMemPath, PyValueEx "") > , (hvRebootBehavior, PyValueEx > instanceRebootAllowed) > , (hvCpuMask, PyValueEx cpuPinningAll) > diff --git a/src/Ganeti/Query/Instance.hs b/src/Ganeti/Query/Instance.hs > index ea49700..1e074df 100644 > --- a/src/Ganeti/Query/Instance.hs > +++ b/src/Ganeti/Query/Instance.hs > @@ -627,11 +627,18 @@ liveInstanceStatus (instInfo, foundOnPrimary) inst > case instanceState of > InstanceStateRunning | adminState == AdminUp -> Running > | otherwise -> ErrorUp > - InstanceStateShutdown | adminState == AdminUp -> UserDown > + InstanceStateShutdown | adminState == AdminUp && allowDown -> UserDown > | otherwise -> StatusDown > where adminState = instAdminState inst > instanceState = instInfoState instInfo > > + hvparams = fromContainer $ instHvparams inst > + > + allowDown = > + instHypervisor inst /= Kvm || > + (Map.member C.hvKvmUserShutdown hvparams && > + hvparams Map.! C.hvKvmUserShutdown == J.JSBool True) > + > -- | Determines the status of a dead instance. > deadInstanceStatus :: Instance -> InstanceStatus > deadInstanceStatus inst = > -- > 1.8.5.1 >
LGTM, thanks. -- Google Germany GmbH Dienerstr. 12 80331 München Registergericht und -nummer: Hamburg, HRB 86891 Sitz der Gesellschaft: Hamburg Geschäftsführer: Graham Law, Christine Elizabeth Flores
