Example #1
0
	"github.com/juju/juju/cloudconfig/instancecfg"
	"github.com/juju/juju/container"
	"github.com/juju/juju/container/lxc/lxcutils"
	"github.com/juju/juju/instance"
	"github.com/juju/juju/juju/arch"
	"github.com/juju/juju/storage/looputil"
	"github.com/juju/juju/version"
)

var logger = loggo.GetLogger("juju.container.lxc")

var (
	defaultTemplate  = "ubuntu-cloud"
	LxcContainerDir  = golxc.GetDefaultLXCContainerDir()
	LxcRestartDir    = "/etc/lxc/auto"
	LxcObjectFactory = golxc.Factory()
	runtimeGOOS      = runtime.GOOS
	runningInsideLXC = lxcutils.RunningInsideLXC
	writeWgetTmpFile = ioutil.WriteFile
)

const (
	// DefaultLxcBridge is the package created container bridge
	DefaultLxcBridge = "lxcbr0"
	// Btrfs is special as we treat it differently for create and clone.
	Btrfs = "btrfs"

	// etcNetworkInterfaces here is the path (inside the container's
	// rootfs) where the network config is stored.
	etcNetworkInterfaces = "/etc/network/interfaces"
)
Example #2
0
	c.Assert(running, Equals, false)
}

func (s *NetworkSuite) TestNotExistingNetworkAttributes(c *C) {
	// Test reading of network attributes from a not existing environment.
	defer golxc.SetConfPath(golxc.SetConfPath(filepath.Join(c.MkDir(), "foo")))

	_, _, err := golxc.NetworkAttributes()
	c.Assert(err, ErrorMatches, "open .*: no such file or directory")
}

type LXCSuite struct {
	factory golxc.ContainerFactory
}

var _ = Suite(&LXCSuite{golxc.Factory()})

func (s *LXCSuite) SetUpSuite(c *C) {
	u, err := user.Current()
	c.Assert(err, IsNil)
	if u.Uid != "0" {
		// Has to be run as root!
		c.Skip("tests must run as root")
	}
}

func (s *LXCSuite) TestCreateDestroy(c *C) {
	// Test clean creation and destroying of a container.
	lc := s.factory.New("golxc")
	c.Assert(lc.IsConstructed(), Equals, false)
	home := golxc.ContainerHome(lc)