]> Frank Brehm's Git Trees - pixelpark/create-terraform.git/commitdiff
Fixing lib/cr_tf/handler.py
authorFrank Brehm <frank.brehm@pixelpark.com>
Wed, 6 Nov 2019 14:22:03 +0000 (15:22 +0100)
committerFrank Brehm <frank.brehm@pixelpark.com>
Wed, 6 Nov 2019 14:22:03 +0000 (15:22 +0100)
lib/cr_tf/handler.py

index ea970dd89dafc3515e53c3a319bf404b88ee5307..431c543c5c4574cac2b57b8356afea59c011cc87 100644 (file)
@@ -61,7 +61,7 @@ from .terraform.disk import TerraformDisk
 
 from .xlate import XLATOR
 
-__version__ = '3.1.6'
+__version__ = '3.1.7'
 LOG = logging.getLogger(__name__)
 
 _ = XLATOR.gettext
@@ -2387,6 +2387,9 @@ class CreateTerraformHandler(BaseHandler):
     # --------------------------------------------------------------------------
     def create_instance_file(self, vm):
 
+        vs_name = vm.vsphere
+        vsphere = self.vsphere[vs_name]
+
         fname = 'instance.' + vm.name + '.tf'
         LOG.debug(_("Creating file {f!r} for VM instance {n!r}.").format(
             f=fname, n=vm.name))
@@ -2394,11 +2397,10 @@ class CreateTerraformHandler(BaseHandler):
         guest_id = self.config.guest_id
         tpl_vm = None
         if vm.vm_template:
-            tpl_vm = self.vsphere_templates[vm.vm_template]
+            tpl_vm = self.vsphere_templates[vs_name][vm.vm_template]
             if self.verbose > 3:
                 LOG.debug(_("Using template:") + "\n" + pp(tpl_vm))
-            guest_id = 'data.vsphere_virtual_machine.{}.guest_id'.format(
-                tpl_vm['tf_name'])
+            guest_id = 'data.vsphere_virtual_machine.{}.guest_id'.format(tpl_vm.tf_name)
         else:
             guest_id = '"' + guest_id + '"'