finish stubbing out step_create_IP_reservation

This commit is contained in:
Megan Marsh 2018-01-16 14:28:24 -08:00 committed by Matthew Hooker
parent 7d72870179
commit 007e8f7c14
No known key found for this signature in database
GPG Key ID: 7B5F933D9CE8C6A1
2 changed files with 22 additions and 13 deletions

View File

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

View File

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