summaryrefslogtreecommitdiff
path: root/cloudinit/sources/helpers/vmware/imc
diff options
context:
space:
mode:
authorxiaofengw-vmware <42736879+xiaofengw-vmware@users.noreply.github.com>2020-03-27 00:31:04 +0800
committerGitHub <noreply@github.com>2020-03-26 12:31:04 -0400
commit1fefeef92fd1881b21e124b83f2adefd3e014087 (patch)
treedbfc6177930df50a9bc800c3f286d48b052a83ae /cloudinit/sources/helpers/vmware/imc
parentbacd63a782daf44937f23a1a33555cb579ae4fb5 (diff)
downloadvyos-cloud-init-1fefeef92fd1881b21e124b83f2adefd3e014087.tar.gz
vyos-cloud-init-1fefeef92fd1881b21e124b83f2adefd3e014087.zip
VMWware: support to update guest info gc status if enabled (#261)
Diffstat (limited to 'cloudinit/sources/helpers/vmware/imc')
-rw-r--r--cloudinit/sources/helpers/vmware/imc/config.py11
-rw-r--r--cloudinit/sources/helpers/vmware/imc/guestcust_util.py9
2 files changed, 20 insertions, 0 deletions
diff --git a/cloudinit/sources/helpers/vmware/imc/config.py b/cloudinit/sources/helpers/vmware/imc/config.py
index 2eaeff34..f2a81416 100644
--- a/cloudinit/sources/helpers/vmware/imc/config.py
+++ b/cloudinit/sources/helpers/vmware/imc/config.py
@@ -25,6 +25,7 @@ class Config(object):
SUFFIX = 'DNS|SUFFIX|'
TIMEZONE = 'DATETIME|TIMEZONE'
UTC = 'DATETIME|UTC'
+ POST_GC_STATUS = 'MISC|POST-GC-STATUS'
def __init__(self, configFile):
self._configFile = configFile
@@ -104,4 +105,14 @@ class Config(object):
def custom_script_name(self):
"""Return the name of custom (pre/post) script."""
return self._configFile.get(Config.CUSTOM_SCRIPT, None)
+
+ @property
+ def post_gc_status(self):
+ """Return whether to post guestinfo.gc.status VMX property."""
+ postGcStatus = self._configFile.get(Config.POST_GC_STATUS, 'no')
+ postGcStatus = postGcStatus.lower()
+ if postGcStatus not in ('yes', 'no'):
+ raise ValueError('PostGcStatus value should be yes/no')
+ return postGcStatus == 'yes'
+
# vi: ts=4 expandtab
diff --git a/cloudinit/sources/helpers/vmware/imc/guestcust_util.py b/cloudinit/sources/helpers/vmware/imc/guestcust_util.py
index 3d369d04..c60a38d7 100644
--- a/cloudinit/sources/helpers/vmware/imc/guestcust_util.py
+++ b/cloudinit/sources/helpers/vmware/imc/guestcust_util.py
@@ -154,4 +154,13 @@ def get_tools_config(section, key, defaultVal):
return retValue
+# Sets message to the VMX guestinfo.gc.status property to the
+# underlying VMware Virtualization Platform.
+def set_gc_status(config, gcMsg):
+ if config and config.post_gc_status:
+ rpc = "info-set guestinfo.gc.status %s" % gcMsg
+ return send_rpc(rpc)
+ return None
+
+
# vi: ts=4 expandtab