packer-cn/builder/oracle/classic/step_create_IP_reservation.go

36 lines
969 B
Go
Raw Normal View History

2018-01-12 19:06:03 -05:00
package classic
import (
"log"
"github.com/hashicorp/go-oracle-terraform/compute"
2018-01-12 19:06:03 -05:00
"github.com/hashicorp/packer/packer"
"github.com/mitchellh/multistep"
)
type stepCreateIPReservation struct{}
func (s *stepCreateIPReservation) Run(state multistep.StateBag) multistep.StepAction {
ui := state.Get("ui").(packer.Ui)
ui.Say("Creating IP reservation...")
2018-01-17 16:07:41 -05:00
client := state.Get("client").(*compute.ComputeClient)
iprClient := client.IPReservations()
// TODO: add optional Name and Tags
2018-01-17 16:07:41 -05:00
IPInput := &compute.CreateIPReservationInput{
ParentPool: compute.PublicReservationPool,
Permanent: true,
}
2018-01-17 16:07:41 -05:00
ipRes, err := iprClient.CreateIPReservation(IPInput)
if err != nil {
log.Printf("Error creating IP Reservation: %s", err)
return multistep.ActionHalt
}
2018-01-16 19:55:39 -05:00
state.Put("instance_ip", ipRes.IP)
log.Printf("debug: ipRes is %#v", ipRes)
return multistep.ActionContinue
2018-01-12 19:06:03 -05:00
}
2018-01-17 16:07:41 -05:00
func (s *stepCreateIPReservation) Cleanup(state multistep.StateBag) {
// Nothing to do
}