forked from askholme/packer-builder-vultr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstep_serverinfo.go
34 lines (28 loc) · 925 Bytes
/
step_serverinfo.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package main
import (
"fmt"
"github.com/DarkDNA/vultr"
"github.com/mitchellh/multistep"
"github.com/mitchellh/packer/packer"
)
type stepServerInfo struct{}
func (s *stepServerInfo) Run(state multistep.StateBag) multistep.StepAction {
client := state.Get("client").(*vultr.Client)
ui := state.Get("ui").(packer.Ui)
c := state.Get("config").(Config)
serverId := state.Get("server_id").(string)
ui.Say("Waiting for server to be powered on...")
serverInfo, err := waitForServerState("active", "running", serverId, client, c.stateTimeout)
if err != nil {
err := fmt.Errorf("Error waiting for server to be running: %s", err)
state.Put("error", err)
ui.Error(err.Error())
return multistep.ActionHalt
}
state.Put("server_ip", serverInfo.Ip)
state.Put("default_password", serverInfo.Password)
return multistep.ActionContinue
}
func (s *stepServerInfo) Cleanup(state multistep.StateBag) {
// no cleanup
}