fleshing out steps
This commit is contained in:
parent
75ee66f934
commit
4fe89be32a
|
@ -1,34 +1,48 @@
|
|||
package classic
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/hashicorp/packer/packer"
|
||||
"github.com/mitchellh/multistep"
|
||||
)
|
||||
|
||||
type stepCreateIPReservation struct{}
|
||||
type stepCreateInstance struct{}
|
||||
|
||||
func (s *stepCreateIPReservation) Run(state multistep.StateBag) multistep.StepAction {
|
||||
ui := state.Get("ui").(packer.Ui)
|
||||
ui.Say("Creating Instance...")
|
||||
const endpoint_path = "/launchplan/" // POST
|
||||
// master-instance.json
|
||||
|
||||
// {
|
||||
// "instances": [{
|
||||
// "shape": "oc3",
|
||||
// "sshkeys": ["/Compute-mydomain/user@example.com/my_sshkey"],
|
||||
// "name": "Compute-mydomain/user@example.com/master-instance",
|
||||
// "label": "master-instance",
|
||||
// "imagelist": "/Compute-mydomain/user@example.com/Ubuntu.16.04-LTS.amd64.20170330",
|
||||
// "networking": {
|
||||
// "eth0": {
|
||||
// "nat": "ipreservation:/Compute-mydomain/user@example.com/master-instance-ip"
|
||||
// }
|
||||
// }
|
||||
// }]
|
||||
// }
|
||||
`
|
||||
{
|
||||
"instances": [{
|
||||
"shape": "oc3",
|
||||
"sshkeys": ["/Compute-mydomain/user@example.com/my_sshkey"],
|
||||
"name": "Compute-mydomain/user@example.com/master-instance",
|
||||
"label": "master-instance",
|
||||
"imagelist": "/Compute-mydomain/user@example.com/Ubuntu.16.04-LTS.amd64.20170330",
|
||||
"networking": {
|
||||
"eth0": {
|
||||
"nat": "ipreservation:/Compute-mydomain/user@example.com/master-instance-ip"
|
||||
}
|
||||
}
|
||||
}]
|
||||
}
|
||||
`
|
||||
// command line call
|
||||
// $ opc compute launch-plans add --request-body=./master-instance.json
|
||||
// ...
|
||||
|
||||
instanceID, err := client.CreateInstance(publicKey)
|
||||
if err != nil {
|
||||
err = fmt.Errorf("Problem creating instance: %s", err)
|
||||
ui.Error(err.Error())
|
||||
state.Put("error", err)
|
||||
return multistep.ActionHalt
|
||||
}
|
||||
|
||||
state.Put("instance_id", instanceID)
|
||||
|
||||
ui.Say(fmt.Sprintf("Created instance (%s).", instanceID))
|
||||
}
|
||||
|
|
|
@ -5,20 +5,14 @@ import (
|
|||
"github.com/mitchellh/multistep"
|
||||
)
|
||||
|
||||
type stepCreateIPReservation struct{}
|
||||
type stepInstanceInfo struct{}
|
||||
|
||||
func (s *stepInstanceInfo) Run(state multistep.StateBag) multistep.StepAction {
|
||||
ui := state.Get("ui").(packer.Ui)
|
||||
ui.Say("Getting Instance Info...")
|
||||
endpoint_path := "/instance/%s", instanceName // GET
|
||||
ui := state.Get("ui").(packer.Ui)
|
||||
instanceID := state.Get("instance_id").(string)
|
||||
endpoint_path := "/instance/%s", instanceID // GET
|
||||
|
||||
// $ 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
|
||||
// ...
|
||||
// https://docs.oracle.com/en/cloud/iaas/compute-iaas-cloud/stcsa/op-instance-%7Bname%7D-get.html
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue