from .xlate import XLATOR
-__version__ = '3.0.1'
+__version__ = '3.0.2'
LOG = logging.getLogger(__name__)
_ = XLATOR.gettext
print()
LOG.info(_("Initialising VSPhere handlers."))
- self.init_vspheres()
+ self.init_vspheres(yaml_file)
self.exec_collect_folders(yaml_file)
self.assign_default_vmw_values()
raise AbortExecution('pdns-zones')
# -------------------------------------------------------------------------ยท
- def init_vspheres(self):
+ def init_vspheres(self, yaml_file):
if self.stop_at_step == 'vmw-init':
self.incr_verbosity()
+ # Test for multiple VSphere references
+ found_vspheres = []
+ for vm in self.vms:
+ vname = vm.vsphere
+ if vname not in found_vspheres:
+ found_vspheres.append(vname)
+ if len(found_vspheres) > 1:
+ msg = _(
+ "There is only one, unique VSPhere definition allowed in a project file. "
+ "In {f!r} were found {nr} different VSPhere definitions:").format(
+ f=yaml_file, nr=len(found_vspheres))
+ msg += '\n'
+ for vname in sorted(found_vspheres, key=string.lower):
+ msg += ' * {!r}'.format(vname)
+ raise ExpectedHandlerError(msg)
+
self._init_vspheres()
LOG.info(_("Finished step {!r}.").format('vmw-init'))