forked from juju/juju
/
instance.go
72 lines (58 loc) · 1.69 KB
/
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
// Copyright 2013 Canonical Ltd.
// Licensed under the AGPLv3, see LICENCE file for details.
package local
import (
"fmt"
"github.com/juju/errors"
"github.com/juju/juju/instance"
"github.com/juju/juju/network"
)
type localInstance struct {
id instance.Id
env *localEnviron
}
var _ instance.Instance = (*localInstance)(nil)
// Id implements instance.Instance.Id.
func (inst *localInstance) Id() instance.Id {
return inst.id
}
// Status implements instance.Instance.Status.
func (inst *localInstance) Status() string {
return ""
}
func (*localInstance) Refresh() error {
return nil
}
func (inst *localInstance) Addresses() ([]network.Address, error) {
if inst.id == bootstrapInstanceId {
addrs := []network.Address{{
Scope: network.ScopePublic,
Type: network.HostName,
Value: "localhost",
}, {
Scope: network.ScopeCloudLocal,
Type: network.IPv4Address,
Value: inst.env.bridgeAddress,
}}
return addrs, nil
}
return nil, errors.NotImplementedf("localInstance.Addresses")
}
// OpenPorts implements instance.Instance.OpenPorts.
func (inst *localInstance) OpenPorts(machineId string, ports []network.Port) error {
logger.Infof("OpenPorts called for %s:%v", machineId, ports)
return nil
}
// ClosePorts implements instance.Instance.ClosePorts.
func (inst *localInstance) ClosePorts(machineId string, ports []network.Port) error {
logger.Infof("ClosePorts called for %s:%v", machineId, ports)
return nil
}
// Ports implements instance.Instance.Ports.
func (inst *localInstance) Ports(machineId string) ([]network.Port, error) {
return nil, nil
}
// Add a string representation of the id.
func (inst *localInstance) String() string {
return fmt.Sprintf("inst:%v", inst.id)
}