github.com/cloud-green/juju@v0.0.0-20151002100041-a00291338d3d/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 "github.com/juju/juju/network" 13 ) 14 15 type localInstance struct { 16 id instance.Id 17 env *localEnviron 18 } 19 20 var _ instance.Instance = (*localInstance)(nil) 21 22 // Id implements instance.Instance.Id. 23 func (inst *localInstance) Id() instance.Id { 24 return inst.id 25 } 26 27 // Status implements instance.Instance.Status. 28 func (inst *localInstance) Status() string { 29 return "" 30 } 31 32 func (inst *localInstance) Addresses() ([]network.Address, error) { 33 if inst.id == bootstrapInstanceId { 34 addrs := []network.Address{{ 35 Scope: network.ScopePublic, 36 Type: network.HostName, 37 Value: "localhost", 38 }, { 39 Scope: network.ScopeCloudLocal, 40 Type: network.IPv4Address, 41 Value: inst.env.bridgeAddress, 42 }} 43 return addrs, nil 44 } 45 return nil, errors.NotImplementedf("localInstance.Addresses") 46 } 47 48 // OpenPorts implements instance.Instance.OpenPorts. 49 func (inst *localInstance) OpenPorts(machineId string, ports []network.PortRange) error { 50 logger.Infof("OpenPorts called for %s:%v", machineId, ports) 51 return nil 52 } 53 54 // ClosePorts implements instance.Instance.ClosePorts. 55 func (inst *localInstance) ClosePorts(machineId string, ports []network.PortRange) error { 56 logger.Infof("ClosePorts called for %s:%v", machineId, ports) 57 return nil 58 } 59 60 // Ports implements instance.Instance.Ports. 61 func (inst *localInstance) Ports(machineId string) ([]network.PortRange, error) { 62 return nil, nil 63 } 64 65 // Add a string representation of the id. 66 func (inst *localInstance) String() string { 67 return fmt.Sprintf("inst:%v", inst.id) 68 }