From: Frank Brehm Date: Wed, 24 Oct 2018 09:53:07 +0000 (+0200) Subject: Retrieving Cluster information X-Git-Tag: 0.3.2^2~33 X-Git-Url: https://git.uhu-banane.net/?a=commitdiff_plain;h=550a10ce4bfcfecbd7fb3bcef0bc216412ea3098;p=pixelpark%2Fcreate-vmware-tpl.git Retrieving Cluster information --- diff --git a/lib/cr_vmware_tpl/__init__.py b/lib/cr_vmware_tpl/__init__.py index 35f5394..1b9460a 100644 --- a/lib/cr_vmware_tpl/__init__.py +++ b/lib/cr_vmware_tpl/__init__.py @@ -1,6 +1,6 @@ #!/bin/env python3 # -*- coding: utf-8 -*- -__version__ = '0.2.1' +__version__ = '0.3.1' # vim: ts=4 et list diff --git a/lib/cr_vmware_tpl/handler.py b/lib/cr_vmware_tpl/handler.py index 1af3631..2c7598e 100644 --- a/lib/cr_vmware_tpl/handler.py +++ b/lib/cr_vmware_tpl/handler.py @@ -42,7 +42,7 @@ from fb_tools.vsphere.server import VsphereServer from .config import CrTplConfiguration -__version__ = '0.10.2' +__version__ = '0.10.3' LOG = logging.getLogger(__name__) TZ = pytz.timezone('Europe/Berlin') @@ -147,30 +147,37 @@ class CrTplHandler(BaseHandler): LOG.debug("Starting handling ...") self.vsphere.get_about() + self.vsphere.get_clusters() + cluster = self.vsphere.get_cluster_by_name(self.config.vsphere_cluster) + if cluster: + LOG.debug("Found VSphere cluster {!r}.".format(cluster.name)) + else: + LOG.error("Could not find VSphere cluster {!r}.".format(self.config.vsphere_cluster)) + return 6 return 0 - LOG.debug("Connecting to vSphere host {h}:{p} as {u!r} ...".format( - h=self.config.vsphere_host, p=self.config.vsphere_port, - u=self.config.vsphere_user)) +# LOG.debug("Connecting to vSphere host {h}:{p} as {u!r} ...".format( +# h=self.config.vsphere_host, p=self.config.vsphere_port, +# u=self.config.vsphere_user)) - ssl_context = None - if hasattr(ssl, '_create_unverified_context'): - ssl_context = ssl._create_unverified_context() +# ssl_context = None +# if hasattr(ssl, '_create_unverified_context'): +# ssl_context = ssl._create_unverified_context() - self.service_instance = SmartConnect( - host=self.config.vsphere_host, port=self.config.vsphere_port, - user=self.config.vsphere_user, pwd=self.config.password, - sslContext=ssl_context) +# self.service_instance = SmartConnect( +# host=self.config.vsphere_host, port=self.config.vsphere_port, +# user=self.config.vsphere_user, pwd=self.config.password, +# sslContext=ssl_context) - if not self.service_instance: - raise CannotConnectVsphereError( - host=self.config.vsphere_host, port=self.config.vsphere_port, - user=self.config.vsphere_user) +# if not self.service_instance: +# raise CannotConnectVsphereError( +# host=self.config.vsphere_host, port=self.config.vsphere_port, +# user=self.config.vsphere_user) try: - self.get_cluster() +# self.get_cluster() self.ensure_vm_folder() self.check_for_temp_tpl_vm() self.select_data_store() @@ -279,37 +286,6 @@ class CrTplHandler(BaseHandler): if pcfilter: pcfilter.Destroy() - # ------------------------------------------------------------------------- - def get_cluster(self, content=None): - - if not content: - content = self.service_instance.RetrieveContent() - - cluster_list = self.get_obj_list(content, [vim.ClusterComputeResource]) - if not len(cluster_list): - raise HandlerError( - "Strange: did not found a cluster object in data center {!r}.".format( - self.config.dc)) - - cluster = None - - for cl in cluster_list: - if not cl.configuration.drsConfig.enabled: - LOG.warn("Cluster {!r} is not enabled.".format(cl.name)) - continue - cluster = cl - - if not cluster: - raise HandlerError( - "Strange: did not found an enabled computing cluster in data center {!r}.".format( - self.config.dc)) - - self.tpl_cluster = cluster - if self.verbose > 2: - LOG.debug("Cluster config:\n{}".format(pp(cluster.configuration))) - LOG.debug("Cluster Resource pool summary:\n{}".format(cluster.resourcePool.summary)) - LOG.debug("Using cluster {!r}.".format(self.tpl_cluster.name)) - # ------------------------------------------------------------------------- def _create_folder(self, host_folder, folder_name, ftype=None): diff --git a/python_fb_tools b/python_fb_tools index ff5009c..01981d4 160000 --- a/python_fb_tools +++ b/python_fb_tools @@ -1 +1 @@ -Subproject commit ff5009c6121ba6918b3f57f235bbd41091e6710d +Subproject commit 01981d48e153607edd4f4d17e1388cc4b8419fa7