-
Notifications
You must be signed in to change notification settings - Fork 0
/
instance.go
44 lines (34 loc) · 1002 Bytes
/
instance.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
35
36
37
38
39
40
41
42
43
44
// Copyright 2013 Joyent Inc.
// Licensed under the AGPLv3, see LICENCE file for details.
package joyent
import (
"github.com/joyent/gosdc/cloudapi"
"github.com/juju/juju/instance"
)
type joyentInstance struct {
machine *cloudapi.Machine
env *joyentEnviron
}
var _ instance.Instance = (*joyentInstance)(nil)
func (inst *joyentInstance) Id() instance.Id {
return instance.Id(inst.machine.Id)
}
func (inst *joyentInstance) Status() string {
return inst.machine.State
}
func (inst *joyentInstance) Refresh() error {
return nil
}
func (inst *joyentInstance) Addresses() ([]instance.Address, error) {
addresses := make([]instance.Address, len(inst.machine.IPs))
for _, ip := range inst.machine.IPs {
address := instance.NewAddress(ip, instance.NetworkUnknown)
if ip == inst.machine.PrimaryIP {
address.NetworkScope = instance.NetworkPublic
} else {
address.NetworkScope = instance.NetworkCloudLocal
}
addresses = append(addresses, address)
}
return addresses, nil
}