mirror of https://github.com/hashicorp/packer
This adds two config options that we need in order to successfully build our Rackspace images. First, a boolean `rackconnect_wait` option which waits for the RackConnect metadata to appear. Second, an `ssh_interface` option, for rackconnect users who have more prohibitive firewalls on the 'public' interface and want to ensure all traffic to the server goes over the 'private' one. Finishes #952.pull/1925/head
parent
f1970370ef
commit
6e92e60eef
@ -0,0 +1,45 @@
|
||||
package openstack
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/mitchellh/multistep"
|
||||
"github.com/mitchellh/packer/packer"
|
||||
"time"
|
||||
|
||||
"github.com/mitchellh/gophercloud-fork-40444fb"
|
||||
)
|
||||
|
||||
type StepWaitForRackConnect struct {
|
||||
Wait bool
|
||||
}
|
||||
|
||||
func (s *StepWaitForRackConnect) Run(state multistep.StateBag) multistep.StepAction {
|
||||
if !s.Wait {
|
||||
return multistep.ActionContinue
|
||||
}
|
||||
|
||||
csp := state.Get("csp").(gophercloud.CloudServersProvider)
|
||||
server := state.Get("server").(*gophercloud.Server)
|
||||
ui := state.Get("ui").(packer.Ui)
|
||||
fmt.Printf("%s", server)
|
||||
|
||||
ui.Say(fmt.Sprintf("Waiting for server (%s) to become RackConnect ready...", server.Id))
|
||||
|
||||
for {
|
||||
server, err := csp.ServerById(server.Id)
|
||||
if err != nil {
|
||||
return multistep.ActionHalt
|
||||
}
|
||||
|
||||
if server.Metadata["rackconnect_automation_status"] == "DEPLOYED" {
|
||||
break
|
||||
}
|
||||
|
||||
time.Sleep(2 * time.Second)
|
||||
}
|
||||
|
||||
return multistep.ActionContinue
|
||||
}
|
||||
|
||||
func (s *StepWaitForRackConnect) Cleanup(state multistep.StateBag) {
|
||||
}
|
||||
Loading…
Reference in new issue