Use more uuids and make messaging consistent.

This commit is contained in:
Matthew Hooker 2018-01-26 13:43:19 -08:00
parent c6b43ce6e9
commit 9edd98f7b0
No known key found for this signature in database
GPG Key ID: 7B5F933D9CE8C6A1
5 changed files with 9 additions and 13 deletions

View File

@ -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))

View File

@ -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{

View File

@ -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,

View File

@ -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)

View File

@ -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
}