]> Frank Brehm's Git Trees - pixelpark/create-vmware-tpl.git/commitdiff
Retrieving Cluster information
authorFrank Brehm <frank.brehm@pixelpark.com>
Wed, 24 Oct 2018 09:53:07 +0000 (11:53 +0200)
committerFrank Brehm <frank.brehm@pixelpark.com>
Wed, 24 Oct 2018 09:53:07 +0000 (11:53 +0200)
lib/cr_vmware_tpl/__init__.py
lib/cr_vmware_tpl/handler.py
python_fb_tools

index 35f539426970f5da6ec8f548eeb532562a633550..1b9460ad4d8ba35883b63faabaf265296630da87 100644 (file)
@@ -1,6 +1,6 @@
 #!/bin/env python3
 # -*- coding: utf-8 -*-
 
-__version__ = '0.2.1'
+__version__ = '0.3.1'
 
 # vim: ts=4 et list
index 1af36312482df27a0d1b7ce68e82a78193c2a438..2c7598e8afaab82b94f75a265fd97e0cecb348cc 100644 (file)
@@ -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):
 
index ff5009c6121ba6918b3f57f235bbd41091e6710d..01981d48e153607edd4f4d17e1388cc4b8419fa7 160000 (submodule)
@@ -1 +1 @@
-Subproject commit ff5009c6121ba6918b3f57f235bbd41091e6710d
+Subproject commit 01981d48e153607edd4f4d17e1388cc4b8419fa7