From 9edd98f7b0fda9d791e9944c6a06dd0a896f70e7 Mon Sep 17 00:00:00 2001 From: Matthew Hooker Date: Fri, 26 Jan 2018 13:43:19 -0800 Subject: [PATCH] Use more uuids and make messaging consistent. --- builder/oracle/classic/step_add_keys.go | 9 ++------- builder/oracle/classic/step_create_instance.go | 4 ++-- builder/oracle/classic/step_create_ip_reservation.go | 5 +++-- builder/oracle/classic/step_security.go | 2 +- builder/oracle/classic/step_snapshot.go | 2 +- 5 files changed, 9 insertions(+), 13 deletions(-) diff --git a/builder/oracle/classic/step_add_keys.go b/builder/oracle/classic/step_add_keys.go index b8331eb94..544c35bf2 100644 --- a/builder/oracle/classic/step_add_keys.go +++ b/builder/oracle/classic/step_add_keys.go @@ -6,7 +6,7 @@ import ( "strings" "github.com/hashicorp/go-oracle-terraform/compute" - uuid "github.com/hashicorp/go-uuid" + "github.com/hashicorp/packer/common/uuid" "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" ) @@ -23,13 +23,8 @@ func (s *stepAddKeysToAPI) Run(_ context.Context, state multistep.StateBag) mult sshPublicKey := strings.TrimSpace(state.Get("publicKey").(string)) // form API call to add key to compute cloud - uuid_string, err := uuid.GenerateUUID() - if err != nil { - ui.Error(fmt.Sprintf("Error creating unique SSH key name: %s", err.Error())) - return multistep.ActionHalt - } sshKeyName := fmt.Sprintf("/Compute-%s/%s/packer_generated_key_%s", - config.IdentityDomain, config.Username, uuid_string) + config.IdentityDomain, config.Username, uuid.TimeOrderedUUID()) ui.Say(fmt.Sprintf("Creating temporary key: %s", sshKeyName)) diff --git a/builder/oracle/classic/step_create_instance.go b/builder/oracle/classic/step_create_instance.go index fd70c6afa..ea840cb22 100644 --- a/builder/oracle/classic/step_create_instance.go +++ b/builder/oracle/classic/step_create_instance.go @@ -49,7 +49,7 @@ func (s *stepCreateInstance) Run(_ context.Context, state multistep.StateBag) mu } state.Put("instance_id", instanceInfo.ID) - ui.Say(fmt.Sprintf("Created instance (%s).", instanceInfo.ID)) + ui.Message(fmt.Sprintf("Created instance: %s.", instanceInfo.ID)) return multistep.ActionContinue } @@ -60,7 +60,7 @@ func (s *stepCreateInstance) Cleanup(state multistep.StateBag) { config := state.Get("config").(*Config) imID := state.Get("instance_id").(string) - ui.Say(fmt.Sprintf("Terminating instance (%s)...", imID)) + ui.Say("Terminating source instance...") instanceClient := client.Instances() input := &compute.DeleteInstanceInput{ diff --git a/builder/oracle/classic/step_create_ip_reservation.go b/builder/oracle/classic/step_create_ip_reservation.go index 8e23be785..cee4a62e8 100644 --- a/builder/oracle/classic/step_create_ip_reservation.go +++ b/builder/oracle/classic/step_create_ip_reservation.go @@ -5,6 +5,7 @@ import ( "fmt" "github.com/hashicorp/go-oracle-terraform/compute" + "github.com/hashicorp/packer/common/uuid" "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" ) @@ -19,8 +20,8 @@ func (s *stepCreateIPReservation) Run(_ context.Context, state multistep.StateBa iprClient := client.IPReservations() // TODO: add optional Name and Tags - ipresName := fmt.Sprintf("ipres_%s", config.ImageName) - ui.Say(fmt.Sprintf("Creating IP reservation: %s", ipresName)) + ipresName := fmt.Sprintf("ipres_%s_%s", config.ImageName, uuid.TimeOrderedUUID()) + ui.Say(fmt.Sprintf("Creating temporary IP reservation: %s", ipresName)) IPInput := &compute.CreateIPReservationInput{ ParentPool: compute.PublicReservationPool, diff --git a/builder/oracle/classic/step_security.go b/builder/oracle/classic/step_security.go index dae341ba6..22d74de08 100644 --- a/builder/oracle/classic/step_security.go +++ b/builder/oracle/classic/step_security.go @@ -71,7 +71,7 @@ func (s *stepSecurity) Run(_ context.Context, state multistep.StateBag) multiste func (s *stepSecurity) Cleanup(state multistep.StateBag) { client := state.Get("client").(*compute.ComputeClient) ui := state.Get("ui").(packer.Ui) - ui.Say("Deleting the packer-generated security rules and lists...") + ui.Say("Deleting temporary rules and lists...") // delete security rules that Packer generated secRuleName := state.Get("security_rule_name").(string) diff --git a/builder/oracle/classic/step_snapshot.go b/builder/oracle/classic/step_snapshot.go index 30a7d32c8..602ebd1ad 100644 --- a/builder/oracle/classic/step_snapshot.go +++ b/builder/oracle/classic/step_snapshot.go @@ -37,7 +37,7 @@ func (s *stepSnapshot) Run(_ context.Context, state multistep.StateBag) multiste } state.Put("snapshot", snap) - ui.Say(fmt.Sprintf("Created snapshot (%s).", snap.Name)) + ui.Message(fmt.Sprintf("Created snapshot: %s.", snap.Name)) return multistep.ActionContinue }