]> Frank Brehm's Git Trees - pixelpark/create-terraform.git/commitdiff
Error if no valif VMs found in YAML file
authorFrank Brehm <frank.brehm@pixelpark.com>
Tue, 9 Jan 2024 12:05:18 +0000 (13:05 +0100)
committerFrank Brehm <frank.brehm@pixelpark.com>
Tue, 9 Jan 2024 12:05:18 +0000 (13:05 +0100)
lib/cr_tf/app.py
lib/cr_tf/handler/read.py
lib/cr_tf/handler/vmware.py

index 87832c63117c35dbea1668e9d2fcb88bc2c13b1d..999319b05f9295721144029549eadaea29bdad2e 100644 (file)
@@ -42,7 +42,7 @@ from .xlate import __base_dir__ as __xlate_base_dir__
 from .xlate import __mo_file__ as __xlate_mo_file__
 from .xlate import XLATOR, LOCALE_DIR, DOMAIN
 
-__version__ = '1.3.2'
+__version__ = '1.3.3'
 LOG = logging.getLogger(__name__)
 
 SIGNAL_NAMES = {
@@ -540,6 +540,12 @@ class CrTfApplication(BaseApplication):
 
         if not self.handler.vsphere_password:
 
+            # Get the name of the first (and hopefully only) VSphere
+            vname = None
+            for vn in self.handler.vsphere.keys():
+                vname = vn
+                break
+
             if need_nl:
                 print('')
             prompt = self.colored(_("User password of {!r}").format(
index 3cf9ff43011c0bbbd642abd404cd5b24b7c1c065..cb4f6671e032aecb862279e306c9aa92da217a05 100644 (file)
@@ -25,7 +25,7 @@ from ..terraform.vm import TerraformVm
 
 from ..xlate import XLATOR
 
-__version__ = '0.1.0'
+__version__ = '0.1.1'
 LOG = logging.getLogger(__name__)
 
 _ = XLATOR.gettext
@@ -51,6 +51,10 @@ class CrTfHandlerReadMixin():
                 self.eval_errors).format(n=self.eval_errors, f=str(yaml_file))
             raise ExpectedHandlerError(msg)
 
+        if not self.vms:
+            msg = _("Did not found any VMs to deploy in file {!r}.").format(str(yaml_file))
+            raise ExpectedHandlerError(msg)
+
         LOG.info(_("Finished step {!r}.").format('read-yaml'))
         if self.stop_at_step == 'read-yaml':
             raise AbortExecution('read-yaml')
index 979a6ace5a889581801b4dc9046c7efbecf8be6b..da1d59ed9bfedb0f338c9f44784274f81b10d90a 100644 (file)
@@ -31,7 +31,7 @@ from ..errors import AbortExecution
 
 from ..xlate import XLATOR
 
-__version__ = '0.1.2'
+__version__ = '0.1.3'
 LOG = logging.getLogger(__name__)
 
 _ = XLATOR.gettext
@@ -102,6 +102,7 @@ class CrTfHandlerVmwMixin():
         if self.stop_at_step == 'vmw-init':
             self.incr_verbosity()
 
+        LOG.debug(_("Initialize VSPhere ..."))
         # Test for multiple VSphere references
         found_vspheres = []
         for vm in self.vms:
@@ -131,13 +132,17 @@ class CrTfHandlerVmwMixin():
             if vm.vsphere in self.vsphere:
                 continue
             vname = vm.vsphere
+            LOG.debug(_("Initializing VSphere {!r} ...").format(vname))
             if vname not in self.config.vsphere:
                 msg = _("VSPhere {!r} not defined in configuration.").format(vname)
                 raise ExpectedHandlerError(msg)
 
             if not self.vsphere_user and self.config.vsphere[vname].user:
+                LOG.debug(_("Setting {st} to {what!r}.").format(
+                    st='handler.vsphere_user', what=self.config.vsphere[vname].user))
                 self.vsphere_user = self.config.vsphere[vname].user
             if not self.vsphere_password and self.config.vsphere[vname].password:
+                LOG.debug(_("Setting {}.").format('handler.vsphere_password'))
                 self.vsphere_password = self.config.vsphere[vname].password
 
             try: