From a8e187720633be130148eeb425a55ef49c5406cf Mon Sep 17 00:00:00 2001 From: Frank Brehm Date: Wed, 26 Aug 2020 13:12:44 +0200 Subject: [PATCH] Bugfixing and changes in debug output --- lib/cr_vmware_tpl/handler.py | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/lib/cr_vmware_tpl/handler.py b/lib/cr_vmware_tpl/handler.py index cd1bbf1..ecc1fce 100644 --- a/lib/cr_vmware_tpl/handler.py +++ b/lib/cr_vmware_tpl/handler.py @@ -44,7 +44,7 @@ from .cobbler import Cobbler from .xlate import XLATOR -__version__ = '1.8.2' +__version__ = '1.8.3' LOG = logging.getLogger(__name__) TZ = pytz.timezone('Europe/Berlin') @@ -397,9 +397,15 @@ class CrTplHandler(BaseHandler): ds_to_use = None if self.config.storage_cluster: ds_to_use = self.select_data_store_from_cluster() - msg = MSG_NO_CLUSTER.format( - size=self.config.data_size_gb, c_name=self.config.storage_cluster) - LOG.warn(msg) + if ds_to_use: + msg = _( + "Got datastore {n!r} as a member of datastore cluster {c!r}.").format( + n=ds_to_use.name, c=self.config.storage_cluster) + LOG.info(msg) + else: + msg = MSG_NO_CLUSTER.format( + size=self.config.data_size_gb, c_name=self.config.storage_cluster) + LOG.warn(msg) if not ds_to_use: ds_to_use = self.select_simple_data_store() @@ -444,16 +450,21 @@ class CrTplHandler(BaseHandler): podsel = vim.storageDrs.PodSelectionSpec() podsel.storagePod = pod + folder_obj = self.vsphere.get_vm_folder(self.config.folder) + storagespec = vim.storageDrs.StoragePlacementSpec() storagespec.podSelectionSpec = podsel storagespec.type = 'create' - storagespec.folder = self.config.folder + storagespec.folder = folder_obj storagespec.resourcePool = self.cluster.resource_pool storagespec.configSpec = vmconf LOG.debug(_( "Trying to get a recommendation for a datastore from " "VSphere storageResourceManager ...")) + if self.verbose > 2: + msg = "storagespec:\n" + pp(storagespec) + LOG.debug(msg) content = self.vsphere.service_instance.RetrieveContent() try: rec = content.storageResourceManager.RecommendDatastores(storageSpec=storagespec) @@ -475,7 +486,7 @@ class CrTplHandler(BaseHandler): def _get_storage_pod_obj(self, used_c_name): content = self.vsphere.service_instance.RetrieveContent() - dc = self.config.get_obj(content, [vim.Datacenter], self.config.dc) + dc = self.vsphere.get_obj(content, [vim.Datacenter], self.config.dc) if not dc: raise VSphereDatacenterNotFoundError(self.config.dc) -- 2.39.5