update to support power management discovery for virtual box environment
diff --git a/automation/node.go b/automation/node.go
index fe61add..a414820 100644
--- a/automation/node.go
+++ b/automation/node.go
@@ -2,8 +2,10 @@
import (
"fmt"
+ "log"
maas "github.com/juju/gomaasapi"
+ "net/url"
)
// MaasNodeStatus MAAS lifecycle status for nodes
@@ -69,11 +71,28 @@
return id
}
+func (n *MaasNode) PowerType() string {
+ ptype, _ := n.GetString("power_type")
+ return ptype
+}
+
func (n *MaasNode) PowerState() string {
state, _ := n.GetString("power_state")
return state
}
+func (n *MaasNode) UpdatePowerParameters(ptype string, params map[string]string) {
+ values := url.Values{}
+ values.Add("power_type", ptype)
+ for k, v := range params {
+ values.Add("power_parameters_"+k, v)
+ }
+ _, err := n.Update(values)
+ if err != nil {
+ log.Printf("[error] error updating power settings : %s", err.Error())
+ }
+}
+
// Hostname get the hostname
func (n *MaasNode) Hostname() string {
hn, _ := n.GetString("hostname")