finish stubbing out step_create_IP_reservation
This commit is contained in:
parent
7d72870179
commit
007e8f7c14
|
@ -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
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue