From 007e8f7c14203ef81b23e82f0ead74e4f185a187 Mon Sep 17 00:00:00 2001 From: Megan Marsh Date: Tue, 16 Jan 2018 14:28:24 -0800 Subject: [PATCH] finish stubbing out step_create_IP_reservation --- builder/oracle/classic/builder.go | 3 +- .../classic/step_create_IP_reservation.go | 32 ++++++++++++------- 2 files changed, 22 insertions(+), 13 deletions(-) diff --git a/builder/oracle/classic/builder.go b/builder/oracle/classic/builder.go index b8af96345..4867ff34e 100644 --- a/builder/oracle/classic/builder.go +++ b/builder/oracle/classic/builder.go @@ -8,6 +8,7 @@ import ( "github.com/hashicorp/go-oracle-terraform/compute" "github.com/hashicorp/go-oracle-terraform/opc" "github.com/hashicorp/packer/common" + "github.com/hashicorp/packer/helper/communicator" "github.com/hashicorp/packer/packer" "github.com/mitchellh/multistep" ) @@ -58,7 +59,6 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe // Build the steps steps := []multistep.Step{ - /* &ocommon.StepKeyPair{ Debug: b.config.PackerDebug, DebugKeyPath: fmt.Sprintf("oci_classic_%s.pem", b.config.PackerBuildName), @@ -75,7 +75,6 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe }, &common.StepProvision{}, &stepSnapshot{}, - */ } // Run the steps diff --git a/builder/oracle/classic/step_create_IP_reservation.go b/builder/oracle/classic/step_create_IP_reservation.go index a719999dd..415b3ddac 100644 --- a/builder/oracle/classic/step_create_IP_reservation.go +++ b/builder/oracle/classic/step_create_IP_reservation.go @@ -1,6 +1,9 @@ package classic import ( + "log" + + "github.com/hashicorp/go-oracle-terraform/compute" "github.com/hashicorp/packer/packer" "github.com/mitchellh/multistep" ) @@ -10,15 +13,22 @@ type stepCreateIPReservation struct{} func (s *stepCreateIPReservation) Run(state multistep.StateBag) multistep.StepAction { ui := state.Get("ui").(packer.Ui) ui.Say("Creating IP reservation...") - const endpoint_path = "/ip/reservation/" // POST - - // $ opc compute ip-reservations add \ - // /Compute-mydomain/user@example.com/master-instance-ip \ - // /oracle/public/ippool - - // account /Compute-mydomain/default - // ip 129.144.27.172 - // name /Compute-mydomain/user@example.com/master-instance-ip - // ... - + client := state.Get("client", client).(*compute.ComputeClient) + iprClient := client.IPReservations() + if err != nil { + log.Printf("Error getting IPReservations Client: %s", err) + return multistep.ActionHalt + } + // TODO: add optional Name and Tags + IPInput := &iprClient.CreateIPReservationInput{ + ParentPool: compute.PublicReservationPool, + Permanent: true, + } + ipRes, err := iprClient.CreateIPReservation(createIPReservation) + if err != nil { + log.Printf("Error creating IP Reservation: %s", err) + return multistep.ActionHalt + } + log.Printf("debug: ipRes is %#v", ipRes) + return multistep.ActionContinue }