github.com/mattyw/juju@v0.0.0-20140610034352-732aecd63861/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 ) 14 15 type lxcInstance struct { 16 golxc.Container 17 id string 18 } 19 20 var _ instance.Instance = (*lxcInstance)(nil) 21 22 // Id implements instance.Instance.Id. 23 func (lxc *lxcInstance) Id() instance.Id { 24 return instance.Id(lxc.id) 25 } 26 27 // Status implements instance.Instance.Status. 28 func (lxc *lxcInstance) Status() string { 29 // On error, the state will be "unknown". 30 state, _, _ := lxc.Info() 31 return string(state) 32 } 33 34 func (*lxcInstance) Refresh() error { 35 return nil 36 } 37 38 func (lxc *lxcInstance) Addresses() ([]instance.Address, error) { 39 return nil, errors.NotImplementedf("lxcInstance.Addresses") 40 } 41 42 // OpenPorts implements instance.Instance.OpenPorts. 43 func (lxc *lxcInstance) OpenPorts(machineId string, ports []instance.Port) error { 44 return fmt.Errorf("not implemented") 45 } 46 47 // ClosePorts implements instance.Instance.ClosePorts. 48 func (lxc *lxcInstance) ClosePorts(machineId string, ports []instance.Port) error { 49 return fmt.Errorf("not implemented") 50 } 51 52 // Ports implements instance.Instance.Ports. 53 func (lxc *lxcInstance) Ports(machineId string) ([]instance.Port, error) { 54 return nil, fmt.Errorf("not implemented") 55 } 56 57 // Add a string representation of the id. 58 func (lxc *lxcInstance) String() string { 59 return fmt.Sprintf("lxc:%s", lxc.id) 60 }