github.com/mwhudson/juju@v0.0.0-20160512215208-90ff01f3497f/container/lxc/instance.go (about) 1 // Copyright 2013 Canonical Ltd. 2 // Licensed under the AGPLv3, see LICENCE file for details. 3 4 package lxc 5 6 import ( 7 "fmt" 8 9 "github.com/juju/errors" 10 "launchpad.net/golxc" 11 12 "github.com/juju/juju/instance" 13 "github.com/juju/juju/network" 14 "github.com/juju/juju/status" 15 ) 16 17 type lxcInstance struct { 18 golxc.Container 19 id string 20 } 21 22 var _ instance.Instance = (*lxcInstance)(nil) 23 24 // Id implements instance.Instance.Id. 25 func (lxc *lxcInstance) Id() instance.Id { 26 return instance.Id(lxc.id) 27 } 28 29 // Status implements instance.Instance.Status. 30 func (lxc *lxcInstance) Status() instance.InstanceStatus { 31 // On error, the state will be "unknown". 32 state, _, _ := lxc.Info() 33 return instance.InstanceStatus{ 34 Status: status.StatusUnknown, 35 Message: string(state), 36 } 37 } 38 39 func (*lxcInstance) Refresh() error { 40 return nil 41 } 42 43 func (lxc *lxcInstance) Addresses() ([]network.Address, error) { 44 return nil, errors.NotImplementedf("lxcInstance.Addresses") 45 } 46 47 // OpenPorts implements instance.Instance.OpenPorts. 48 func (lxc *lxcInstance) OpenPorts(machineId string, ports []network.PortRange) error { 49 return fmt.Errorf("not implemented") 50 } 51 52 // ClosePorts implements instance.Instance.ClosePorts. 53 func (lxc *lxcInstance) ClosePorts(machineId string, ports []network.PortRange) error { 54 return fmt.Errorf("not implemented") 55 } 56 57 // Ports implements instance.Instance.Ports. 58 func (lxc *lxcInstance) Ports(machineId string) ([]network.PortRange, error) { 59 return nil, fmt.Errorf("not implemented") 60 } 61 62 // Add a string representation of the id. 63 func (lxc *lxcInstance) String() string { 64 return fmt.Sprintf("lxc:%s", lxc.id) 65 }