Commit cd04dfd2 authored by Michael Hanselmann's avatar Michael Hanselmann
Browse files

hv_*: Always return from Verify, style fixes



Change all “Verify” methods in hypervisor abstractions to explicitely
return None if no problem was detected. Remove punctuation from error
messages. Update docstrings with “@return” and some small mistakes.
Signed-off-by: default avatarMichael Hanselmann <hansmi@google.com>
Reviewed-by: default avatarIustin Pop <iustin@google.com>
parent 8bb2df7d
......@@ -266,6 +266,8 @@ class BaseHypervisor(object):
def Verify(self):
"""Verify the hypervisor.
@return: Problem description if something is wrong, C{None} otherwise
"""
raise NotImplementedError
......
......@@ -281,9 +281,13 @@ class ChrootManager(hv_base.BaseHypervisor):
For the chroot manager, it just checks the existence of the base dir.
@return: Problem description if something is wrong, C{None} otherwise
"""
if not os.path.exists(self._ROOT_DIR):
return "The required directory '%s' does not exist." % self._ROOT_DIR
if os.path.exists(self._ROOT_DIR):
return None
else:
return "The required directory '%s' does not exist" % self._ROOT_DIR
@classmethod
def PowercycleNode(cls):
......
......@@ -239,9 +239,13 @@ class FakeHypervisor(hv_base.BaseHypervisor):
For the fake hypervisor, it just checks the existence of the base
dir.
@return: Problem description if something is wrong, C{None} otherwise
"""
if not os.path.exists(self._ROOT_DIR):
return "The required directory '%s' does not exist." % self._ROOT_DIR
if os.path.exists(self._ROOT_DIR):
return None
else:
return "The required directory '%s' does not exist" % self._ROOT_DIR
@classmethod
def PowercycleNode(cls):
......
......@@ -2019,16 +2019,19 @@ class KVMHypervisor(hv_base.BaseHypervisor):
def Verify(self):
"""Verify the hypervisor.
Check that the binary exists.
Check that the required binaries exist.
@return: Problem description if something is wrong, C{None} otherwise
"""
# FIXME: this is the global kvm version, but the actual version can be
# customized as an hv parameter. we should use the nodegroup's default kvm
# path parameter here.
if not os.path.exists(constants.KVM_PATH):
return "The kvm binary ('%s') does not exist." % constants.KVM_PATH
return "The KVM binary ('%s') does not exist" % constants.KVM_PATH
if not os.path.exists(constants.SOCAT_PATH):
return "The socat binary ('%s') does not exist." % constants.SOCAT_PATH
return "The socat binary ('%s') does not exist" % constants.SOCAT_PATH
return None
@classmethod
def CheckParameterSyntax(cls, hvparams):
......
......@@ -401,11 +401,15 @@ class LXCHypervisor(hv_base.BaseHypervisor):
def Verify(self):
"""Verify the hypervisor.
For the chroot manager, it just checks the existence of the base dir.
For the LXC manager, it just checks the existence of the base dir.
@return: Problem description if something is wrong, C{None} otherwise
"""
if not os.path.exists(self._ROOT_DIR):
return "The required directory '%s' does not exist." % self._ROOT_DIR
if os.path.exists(self._ROOT_DIR):
return None
else:
return "The required directory '%s' does not exist" % self._ROOT_DIR
@classmethod
def PowercycleNode(cls):
......
......@@ -435,11 +435,15 @@ class XenHypervisor(hv_base.BaseHypervisor):
For Xen, this verifies that the xend process is running.
@return: Problem description if something is wrong, C{None} otherwise
"""
result = utils.RunCmd([constants.XEN_CMD, "info"])
if result.failed:
return "'xm info' failed: %s, %s" % (result.fail_reason, result.output)
return None
@staticmethod
def _GetConfigFileDiskData(block_devices, blockdev_prefix):
"""Get disk directive for xen config file.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment