From dfa9d63097a43335b74ac8dc33c7fe783feaec73 Mon Sep 17 00:00:00 2001 From: Cheng Sun Date: Mon, 15 Dec 2014 11:18:57 +0000 Subject: [PATCH] Always fetch a new VM instance from UUID for consistency --- builder/xenserver/step_create_instance.go | 1 - builder/xenserver/step_start_on_himn.go | 7 ++++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/builder/xenserver/step_create_instance.go b/builder/xenserver/step_create_instance.go index 85645ab..8870755 100644 --- a/builder/xenserver/step_create_instance.go +++ b/builder/xenserver/step_create_instance.go @@ -207,7 +207,6 @@ func (self *stepCreateInstance) Run(state multistep.StateBag) multistep.StepActi } state.Put("instance_uuid", instanceId) - state.Put("instance", instance) ui.Say(fmt.Sprintf("Created instance '%s'", instanceId)) return multistep.ActionContinue diff --git a/builder/xenserver/step_start_on_himn.go b/builder/xenserver/step_start_on_himn.go index 4e17807..8999cc9 100644 --- a/builder/xenserver/step_start_on_himn.go +++ b/builder/xenserver/step_start_on_himn.go @@ -27,7 +27,12 @@ func (self *stepStartOnHIMN) Run(state multistep.StateBag) multistep.StepAction ui.Say("Step: Start VM on the Host Internal Mangement Network") - instance := state.Get("instance").(*VM) + uuid := state.Get("instance_uuid").(string) + instance, err := client.GetVMByUuid(uuid) + if err != nil { + ui.Error(fmt.Sprintf("Unable to get VM from UUID '%s': %s", uuid, err.Error())) + return multistep.ActionHalt + } // Find the HIMN Ref networks, err := client.GetNetworkByNameLabel("Host internal management network")