github.com/mattyw/juju@v0.0.0-20140610034352-732aecd63861/provider/local/instance.go (about) 1 // Copyright 2013 Canonical Ltd. 2 // Licensed under the AGPLv3, see LICENCE file for details. 3 4 package local 5 6 import ( 7 "fmt" 8 9 "github.com/juju/errors" 10 11 "github.com/juju/juju/instance" 12 ) 13 14 type localInstance struct { 15 id instance.Id 16 env *localEnviron 17 } 18 19 var _ instance.Instance = (*localInstance)(nil) 20 21 // Id implements instance.Instance.Id. 22 func (inst *localInstance) Id() instance.Id { 23 return inst.id 24 } 25 26 // Status implements instance.Instance.Status. 27 func (inst *localInstance) Status() string { 28 return "" 29 } 30 31 func (*localInstance) Refresh() error { 32 return nil 33 } 34 35 func (inst *localInstance) Addresses() ([]instance.Address, error) { 36 if inst.id == bootstrapInstanceId { 37 addrs := []instance.Address{{ 38 NetworkScope: instance.NetworkPublic, 39 Type: instance.HostName, 40 Value: "localhost", 41 }, { 42 NetworkScope: instance.NetworkCloudLocal, 43 Type: instance.Ipv4Address, 44 Value: inst.env.bridgeAddress, 45 }} 46 return addrs, nil 47 } 48 return nil, errors.NotImplementedf("localInstance.Addresses") 49 } 50 51 // OpenPorts implements instance.Instance.OpenPorts. 52 func (inst *localInstance) OpenPorts(machineId string, ports []instance.Port) error { 53 logger.Infof("OpenPorts called for %s:%v", machineId, ports) 54 return nil 55 } 56 57 // ClosePorts implements instance.Instance.ClosePorts. 58 func (inst *localInstance) ClosePorts(machineId string, ports []instance.Port) error { 59 logger.Infof("ClosePorts called for %s:%v", machineId, ports) 60 return nil 61 } 62 63 // Ports implements instance.Instance.Ports. 64 func (inst *localInstance) Ports(machineId string) ([]instance.Port, error) { 65 return nil, nil 66 } 67 68 // Add a string representation of the id. 69 func (inst *localInstance) String() string { 70 return fmt.Sprintf("inst:%v", inst.id) 71 }