-
Notifications
You must be signed in to change notification settings - Fork 1
/
instance_linux.go
executable file
·85 lines (70 loc) · 2.17 KB
/
instance_linux.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
73
74
75
76
77
78
79
80
81
82
83
84
85
// Copyright 2013 Canonical Ltd.
// Licensed under the AGPLv3, see LICENCE file for details.
package local
import (
"fmt"
"launchpad.net/juju-core/errors"
"launchpad.net/juju-core/instance"
"launchpad.net/juju-core/provider/common"
)
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() ([]instance.Address, error) {
if inst.id == bootstrapInstanceId {
addrs := []instance.Address{{
NetworkScope: instance.NetworkPublic,
Type: instance.HostName,
Value: "localhost",
}, {
NetworkScope: instance.NetworkCloudLocal,
Type: instance.Ipv4Address,
Value: inst.env.bridgeAddress,
}}
return addrs, nil
}
return nil, errors.NewNotImplementedError("localInstance.Addresses")
}
// DNSName implements instance.Instance.DNSName.
func (inst *localInstance) DNSName() (string, error) {
if inst.id == bootstrapInstanceId {
return inst.env.bridgeAddress, nil
}
// Get the IPv4 address from eth0
return getAddressForInterface("eth0")
}
// WaitDNSName implements instance.Instance.WaitDNSName.
func (inst *localInstance) WaitDNSName() (string, error) {
return common.WaitDNSName(inst)
}
// OpenPorts implements instance.Instance.OpenPorts.
func (inst *localInstance) OpenPorts(machineId string, ports []instance.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 []instance.Port) error {
logger.Infof("ClosePorts called for %s:%v", machineId, ports)
return nil
}
// Ports implements instance.Instance.Ports.
func (inst *localInstance) Ports(machineId string) ([]instance.Port, error) {
return nil, nil
}
// Add a string representation of the id.
func (inst *localInstance) String() string {
return fmt.Sprintf("inst:%v", inst.id)
}