github.com/cloudbase/juju-core@v0.0.0-20140504232958-a7271ac7912f/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 "launchpad.net/golxc" 10 11 "launchpad.net/juju-core/errors" 12 "launchpad.net/juju-core/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.NewNotImplementedError("lxcInstance.Addresses") 40 } 41 42 // DNSName implements instance.Instance.DNSName. 43 func (lxc *lxcInstance) DNSName() (string, error) { 44 return "", instance.ErrNoDNSName 45 } 46 47 // WaitDNSName implements instance.Instance.WaitDNSName. 48 func (lxc *lxcInstance) WaitDNSName() (string, error) { 49 return "", instance.ErrNoDNSName 50 } 51 52 // OpenPorts implements instance.Instance.OpenPorts. 53 func (lxc *lxcInstance) OpenPorts(machineId string, ports []instance.Port) error { 54 return fmt.Errorf("not implemented") 55 } 56 57 // ClosePorts implements instance.Instance.ClosePorts. 58 func (lxc *lxcInstance) ClosePorts(machineId string, ports []instance.Port) error { 59 return fmt.Errorf("not implemented") 60 } 61 62 // Ports implements instance.Instance.Ports. 63 func (lxc *lxcInstance) Ports(machineId string) ([]instance.Port, error) { 64 return nil, fmt.Errorf("not implemented") 65 } 66 67 // Add a string representation of the id. 68 func (lxc *lxcInstance) String() string { 69 return fmt.Sprintf("lxc:%s", lxc.id) 70 }