mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-06 13:22:48 +00:00
VMware: add new module vmware_export_ovf (#50589)
This commit is contained in:
committed by
Abhijeet Kasurde
parent
1126f76d4d
commit
4f8cd6bf96
@@ -13,6 +13,7 @@ import ssl
|
||||
import time
|
||||
import traceback
|
||||
from random import randint
|
||||
from distutils.version import StrictVersion
|
||||
|
||||
REQUESTS_IMP_ERR = None
|
||||
try:
|
||||
@@ -1101,6 +1102,28 @@ class PyVmomi(object):
|
||||
|
||||
return host_obj_list
|
||||
|
||||
def host_version_at_least(self, version=None, vm_obj=None, host_name=None):
|
||||
"""
|
||||
Check that the ESXi Host is at least a specific version number
|
||||
Args:
|
||||
vm_obj: virtual machine object, required one of vm_obj, host_name
|
||||
host_name (string): ESXi host name
|
||||
version (tuple): a version tuple, for example (6, 7, 0)
|
||||
Returns: bool
|
||||
"""
|
||||
if vm_obj:
|
||||
host_system = vm_obj.summary.runtime.host
|
||||
elif host_name:
|
||||
host_system = self.find_hostsystem_by_name(host_name=host_name)
|
||||
else:
|
||||
self.module.fail_json(msg='VM object or ESXi host name must be set one.')
|
||||
if host_system and version:
|
||||
host_version = host_system.summary.config.product.version
|
||||
return StrictVersion(host_version) >= StrictVersion('.'.join(map(str, version)))
|
||||
else:
|
||||
self.module.fail_json(msg='Unable to get the ESXi host from vm: %s, or hostname %s,'
|
||||
'or the passed ESXi version: %s is None.' % (vm_obj, host_name, version))
|
||||
|
||||
# Network related functions
|
||||
@staticmethod
|
||||
def find_host_portgroup_by_name(host, portgroup_name):
|
||||
|
||||
Reference in New Issue
Block a user