fmt step_wait, interruptible_wait

This commit is contained in:
Cheng Sun 2014-12-09 11:17:35 +00:00
parent cadf3a5d6a
commit efbc365b6d
2 changed files with 9 additions and 7 deletions

View File

@ -6,24 +6,26 @@ import (
)
type InterruptibleWait struct {
Predicate func () (result bool, err error)
Predicate func() (result bool, err error)
PredicateInterval time.Duration
Timeout time.Duration
Timeout time.Duration
}
type TimeoutError struct { }
type TimeoutError struct{}
func (err TimeoutError) Error() string {
return "Timed out"
}
type InterruptedError struct { }
type InterruptedError struct{}
func (err InterruptedError) Error() string {
return "Interrupted"
}
type PredicateResult struct {
complete bool
err error
err error
}
func (wait InterruptibleWait) Wait(state multistep.StateBag) error {

View File

@ -20,12 +20,12 @@ func (self *stepWait) Run(state multistep.StateBag) multistep.StepAction {
//Expect install to be configured to shutdown on completion
err := InterruptibleWait{
Predicate: func () (bool, error) {
Predicate: func() (bool, error) {
power_state, err := instance.GetPowerState()
return power_state == "Halted", err
},
PredicateInterval: 30 * time.Second,
Timeout: config.InstallTimeout,
Timeout: config.InstallTimeout,
}.Wait(state)
if err != nil {