4
"launchpad.net/gomaasapi"
5
"launchpad.net/juju-core/environs"
6
"launchpad.net/juju-core/log"
7
"launchpad.net/juju-core/state"
8
"launchpad.net/juju-core/state/api/params"
11
type maasInstance struct {
12
maasObject *gomaasapi.MAASObject
16
var _ environs.Instance = (*maasInstance)(nil)
18
func (instance *maasInstance) Id() state.InstanceId {
19
// Use the node's 'resource_uri' value.
20
return state.InstanceId((*instance.maasObject).URI().String())
23
// refreshInstance refreshes the instance with the most up-to-date information
24
// from the MAAS server.
25
func (instance *maasInstance) refreshInstance() error {
26
insts, err := instance.environ.Instances([]state.InstanceId{instance.Id()})
30
newMaasObject := insts[0].(*maasInstance).maasObject
31
instance.maasObject = newMaasObject
35
func (instance *maasInstance) DNSName() (string, error) {
36
hostname, err := (*instance.maasObject).GetField("hostname")
43
func (instance *maasInstance) WaitDNSName() (string, error) {
44
// A MAAS nodes gets his DNS name when it's created. WaitDNSName,
45
// (same as DNSName) just returns the hostname of the node.
46
return instance.DNSName()
49
// MAAS does not do firewalling so these port methods do nothing.
50
func (instance *maasInstance) OpenPorts(machineId string, ports []params.Port) error {
51
log.Debugf("environs/maas: unimplemented OpenPorts() called")
55
func (instance *maasInstance) ClosePorts(machineId string, ports []params.Port) error {
56
log.Debugf("environs/maas: unimplemented ClosePorts() called")
60
func (instance *maasInstance) Ports(machineId string) ([]params.Port, error) {
61
log.Debugf("environs/maas: unimplemented Ports() called")
62
return []params.Port{}, nil