From: Frank Brehm Date: Wed, 6 Nov 2019 14:22:03 +0000 (+0100) Subject: Fixing lib/cr_tf/handler.py X-Git-Tag: 1.3.4~3 X-Git-Url: https://git.uhu-banane.de/?a=commitdiff_plain;h=d79356d12740694e70a9130047a66a50cc9cb311;p=pixelpark%2Fcreate-terraform.git Fixing lib/cr_tf/handler.py --- diff --git a/lib/cr_tf/handler.py b/lib/cr_tf/handler.py index ea970dd..431c543 100644 --- a/lib/cr_tf/handler.py +++ b/lib/cr_tf/handler.py @@ -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 + '"'