from .config import CrTplConfiguration
-__version__ = '0.10.2'
+__version__ = '0.10.3'
LOG = logging.getLogger(__name__)
TZ = pytz.timezone('Europe/Berlin')
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()
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):