From 71acccc1ed4afa077d0a1d65c8efba628f7077f2 Mon Sep 17 00:00:00 2001 From: Matthew Hooker Date: Fri, 26 Jan 2018 13:12:35 -0800 Subject: [PATCH] add UI output with resource names --- builder/oracle/classic/step_add_keys.go | 3 ++- builder/oracle/classic/step_create_instance.go | 4 ++-- builder/oracle/classic/step_create_ip_reservation.go | 9 +++++++-- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/builder/oracle/classic/step_add_keys.go b/builder/oracle/classic/step_add_keys.go index 8a6025977..b8331eb94 100644 --- a/builder/oracle/classic/step_add_keys.go +++ b/builder/oracle/classic/step_add_keys.go @@ -16,7 +16,6 @@ type stepAddKeysToAPI struct{} func (s *stepAddKeysToAPI) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { // get variables from state ui := state.Get("ui").(packer.Ui) - ui.Say("Adding SSH keys to API...") config := state.Get("config").(*Config) client := state.Get("client").(*compute.ComputeClient) @@ -32,6 +31,8 @@ func (s *stepAddKeysToAPI) Run(_ context.Context, state multistep.StateBag) mult sshKeyName := fmt.Sprintf("/Compute-%s/%s/packer_generated_key_%s", config.IdentityDomain, config.Username, uuid_string) + ui.Say(fmt.Sprintf("Creating temporary key: %s", sshKeyName)) + sshKeysClient := client.SSHKeys() sshKeysInput := compute.CreateSSHKeyInput{ Name: sshKeyName, diff --git a/builder/oracle/classic/step_create_instance.go b/builder/oracle/classic/step_create_instance.go index 2f8493fd1..fd70c6afa 100644 --- a/builder/oracle/classic/step_create_instance.go +++ b/builder/oracle/classic/step_create_instance.go @@ -16,11 +16,11 @@ func (s *stepCreateInstance) Run(_ context.Context, state multistep.StateBag) mu // get variables from state ui := state.Get("ui").(packer.Ui) ui.Say("Creating Instance...") + config := state.Get("config").(*Config) client := state.Get("client").(*compute.ComputeClient) keyName := state.Get("key_name").(string) - - ipAddName := fmt.Sprintf("ipres_%s", config.ImageName) + ipAddName := state.Get("ipres_name").(string) secListName := state.Get("security_list").(string) netInfo := compute.NetworkingInfo{ diff --git a/builder/oracle/classic/step_create_ip_reservation.go b/builder/oracle/classic/step_create_ip_reservation.go index 84154631b..8e23be785 100644 --- a/builder/oracle/classic/step_create_ip_reservation.go +++ b/builder/oracle/classic/step_create_ip_reservation.go @@ -13,15 +13,19 @@ type stepCreateIPReservation struct{} func (s *stepCreateIPReservation) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { ui := state.Get("ui").(packer.Ui) - ui.Say("Creating IP reservation...") + config := state.Get("config").(*Config) client := state.Get("client").(*compute.ComputeClient) 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)) + IPInput := &compute.CreateIPReservationInput{ ParentPool: compute.PublicReservationPool, Permanent: true, - Name: fmt.Sprintf("ipres_%s", config.ImageName), + Name: ipresName, } ipRes, err := iprClient.CreateIPReservation(IPInput) @@ -32,6 +36,7 @@ func (s *stepCreateIPReservation) Run(_ context.Context, state multistep.StateBa return multistep.ActionHalt } state.Put("instance_ip", ipRes.IP) + state.Put("ipres_name", ipresName) return multistep.ActionContinue }