from .xlate import XLATOR
-__version__ = '2.9.7'
+__version__ = '2.9.8'
LOG = logging.getLogger(__name__)
_ = XLATOR.gettext
self.vsphere_folders = []
self.used_networks = []
- self.used_dc_clusters = []
+ self.used_dc_clusters = {}
self.used_datastores = []
self.project_dir = None
self.project_name = None
def validate_storages(self):
self._validate_ds_clusters()
- self._validate_datastores()
+ # self._validate_datastores()
if self.verbose:
if self.used_dc_clusters:
- out = '\n'.join(map(lambda x: ' * {}'.format(x), self.used_dc_clusters))
+ out_lines = []
+ for vs_name in self.used_dc_clusters:
+ for cluster in self.used_dc_clusters[vs_name]:
+ out_lines.append(' * VSphere {v!r}: {c}'.format(
+ v=vs_name, c=cluster))
+ out = '\n'.join(out_lines)
LOG.debug(_("Used datastore clusters:") + "\n" + out)
else:
LOG.debug(_("No datastore clusters are used."))
disk = vm.disks[unit_number]
needed_gb += disk.size_gb
+ vs_name = vm.vsphere
+ vsphere = self.vsphere[vs_name]
+
found = False
- for cluster_name in self.vsphere.ds_clusters.keys():
+ for cluster_name in vsphere.ds_clusters.keys():
if cluster_name.lower() == vm.ds_cluster.lower():
if self.verbose > 2:
- LOG.debug(_("Found datastore cluster {c!r} for VM {n!r}.").format(
- n=vm.name, c=vm.ds_cluster))
+ LOG.debug(_(
+ "Found datastore cluster {c!r} in VSphere {v!r} for VM {n!r}.").format(
+ n=vm.name, v=vs_name, c=vm.ds_cluster))
if vm.ds_cluster != cluster_name:
LOG.debug(_("Setting datastore cluster for VM {n!r} to {c!r} ...").format(
n=vm.name, c=cluster_name))
vm.ds_cluster = cluster_name
- ds_cluster = self.vsphere.ds_clusters[cluster_name]
+ ds_cluster = vsphere.ds_clusters[cluster_name]
if self.verbose > 2:
LOG.debug(_(
- "Free space in cluster {c!r} before provisioning: "
+ "Free space of cluster {c!r} in VSphere {v!r} before provisioning: "
"{a:0.1f} GiB.").format(
- c=cluster_name, a=ds_cluster.avail_space_gb))
+ c=cluster_name, v=vs_name, a=ds_cluster.avail_space_gb))
if ds_cluster.avail_space_gb < needed_gb:
LOG.error(_(
- "Datastore cluster {d!r} has not sufficient space for storage of VM "
- "{v!r} (needed {n:0.1f} GiB, available {a:0.1f} GiB).").format(
- d=cluster_name, v=vm.name, n=needed_gb, a=ds_cluster.avail_space_gb))
+ "Datastore cluster {d!r} in VSphere {v!r} has not sufficient space for "
+ "storage of VM {vm!r} (needed {n:0.1f} GiB, available {a:0.1f} "
+ "GiB).").format(
+ d=cluster_name, v=vs_name, vm=vm.name, n=needed_gb,
+ a=ds_cluster.avail_space_gb))
self.eval_errors += 1
else:
ds_cluster.calculated_usage += needed_gb
if self.verbose > 1:
LOG.debug(_(
- "Free space in cluster {c!r} after provisioning: "
+ "Free space in cluster {c!r} in VSphere {v!r} after provisioning: "
"{a:0.1f} GiB.").format(
- c=cluster_name, a=ds_cluster.avail_space_gb))
+ c=cluster_name, v=vs_name, a=ds_cluster.avail_space_gb))
found = True
- if cluster_name not in self.used_dc_clusters:
- self.used_dc_clusters.append(cluster_name)
+ if vs_name not in self.used_dc_clusters:
+ self.used_dc_clusters[vs_name] = []
+ if cluster_name not in self.used_dc_clusters[vs_name]:
+ self.used_dc_clusters[vs_name].append(cluster_name)
break
if not found:
- LOG.error(_("Datastore cluster {c!r} of VM {n!r} not found.").format(
- n=vm.name, c=vm.ds_cluster))
+ LOG.error(_("Datastore cluster {c!r} of VM {n!r} not found in VSphere {v!r}.").format(
+ n=vm.name, c=vm.ds_cluster, v=vs_name))
self.eval_errors += 1
# -------------------------------------------------------------------------ยท