from ..xlate import XLATOR
-__version__ = '0.3.0'
+__version__ = '0.3.1'
LOG = logging.getLogger(__name__)
_ = XLATOR.gettext
self.eval_errors).format(n=self.eval_errors)
raise ExpectedHandlerError(msg)
- self.get_all_vms()
self.validate_vms()
LOG.info(_("Finished step {!r}.").format('validate-yaml'))
total_vms = 0
slim_vms = []
- slim_verbose = 2
+ slim_verbose = 3
for vsphere_name in self.vsphere:
re_vm = re.compile(pat_vm, re.IGNORECASE)
for vm in self.vsphere_vm_cache[vsphere_name]:
- if self.verbose >= 2:
+ if self.verbose >= 3:
LOG.debug(_('Checking VM {n!r} against pattern {p!r} ...').format(
n=vm.name, p=pat_vm))
if re_vm.match(vm.name):
vsphere_name = vm.vsphere
vsphere = self.vsphere[vsphere_name]
- vm_paths = None
- if vsphere_name in self.all_vms:
- if vm.fqdn in self.all_vms[vsphere_name]:
- vm_paths = self.all_vms[vsphere_name][vm.fqdn]
+ existing_vm = None
+
+ if vsphere_name in self.vsphere_vm_cache:
+ for this_vm in self.vsphere_vm_cache[vsphere_name]:
+ if this_vm.name == vm.fqdn:
+ existing_vm = this_vm
+ break
+
+ if existing_vm:
- if vm_paths:
msg = _('[{m}] - VM is already existing in VSphere {v!r}, path {p!r}.').format(
- m=self.colored('Existing', 'YELLOW'), v=vsphere_name, p=pp(vm_paths))
+ m=self.colored('Existing', 'YELLOW'), v=vsphere_name, p=pp(existing_vm.path))
print(msg, end='', flush=True)
if self.verbose:
print()
- vm_info = vsphere.get_vm(vm.fqdn, vsphere_name=vsphere_name, as_obj=True)
if self.verbose > 2:
- LOG.debug(_("VM info:") + "\n" + pp(vm_info.as_dict(bare=True)))
- ds = vm_info.config_path_storage
+ LOG.debug(_("VM info:") + "\n" + pp(existing_vm.as_dict(bare=True)))
+ ds = existing_vm.config_path_storage
LOG.debug(_("Datastore of VM {vm!r}: {ds!r}.").format(vm=vm.name, ds=ds))
vm.datastore = ds
vm.already_existing = True
- self.existing_vms.append(vm_info)
+ self.existing_vms.append(existing_vm)
else: