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