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