fleshing out steps

This commit is contained in:
Megan Marsh 2018-01-12 16:18:55 -08:00 committed by Matthew Hooker
parent 75ee66f934
commit 4fe89be32a
No known key found for this signature in database
GPG Key ID: 7B5F933D9CE8C6A1
2 changed files with 35 additions and 27 deletions

View File

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

View File

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