From 2ecf5cc9aa9b182dd7cf7c0d1fca11c519a5dffb Mon Sep 17 00:00:00 2001 From: James Griffith Date: Tue, 15 Sep 2020 09:56:36 -0400 Subject: [PATCH] Communicator is not needed unless shutdown_command is populated --- builder/vsphere/common/step_shutdown.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/builder/vsphere/common/step_shutdown.go b/builder/vsphere/common/step_shutdown.go index f85749f40..78319fd4d 100644 --- a/builder/vsphere/common/step_shutdown.go +++ b/builder/vsphere/common/step_shutdown.go @@ -47,7 +47,6 @@ type StepShutdown struct { func (s *StepShutdown) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { ui := state.Get("ui").(packer.Ui) - comm := state.Get("communicator").(packer.Communicator) vm := state.Get("vm").(*driver.VirtualMachineDriver) if off, _ := vm.IsPoweredOff(); off { @@ -59,6 +58,9 @@ func (s *StepShutdown) Run(ctx context.Context, state multistep.StateBag) multis if s.Config.DisableShutdown { ui.Say("Automatic shutdown disabled. Please shutdown virtual machine.") } else if s.Config.Command != "" { + // Communicator is not needed unless shutdown_command is populated + comm := state.Get("communicator").(packer.Communicator) + ui.Say("Executing shutdown command...") log.Printf("Shutdown command: %s", s.Config.Command)