예제 #1
0
    def test_lxc_container(self):
        self.addCleanup(self.clean_container, DEFAULT_CONTAINER)
        customize_log = self.makeFile()
        c = LXCContainer(DEFAULT_CONTAINER,
                         "dsa...",
                         "precise",
                         "ppa",
                         customize_log=customize_log)
        running = yield c.is_running()
        self.assertFalse(running)
        self.assertFalse(c.is_constructed())

        # verify we can't run a non-constructed container
        failure = c.run()
        yield self.assertFailure(failure, LXCError)

        yield c.create()

        self.assertFalse(running)
        self.assertTrue(c.is_constructed())
        yield c.run()

        running = yield c.is_running()
        self.assertTrue(running)
        self.assertTrue(c.is_constructed())

        output = _lxc_ls()
        self.assertIn(DEFAULT_CONTAINER, output)

        # Verify we have a path into the container
        self.assertTrue(os.path.exists(c.rootfs))
        self.assertTrue(c.is_constructed())

        self.verify_container(c, "dsa...", "precise", "ppa")

        # Verify that we are in containers
        containers = yield get_containers(None)
        self.assertEqual(containers[DEFAULT_CONTAINER], True)

        # tear it down
        yield c.destroy()
        running = yield c.is_running()
        self.assertFalse(running)

        containers = yield get_containers(None)
        self.assertNotIn(DEFAULT_CONTAINER, containers)

        # Verify the customize log file.
        self.assertTrue(os.path.exists(customize_log))

        # and its gone
        output = _lxc_ls()
        self.assertNotIn(DEFAULT_CONTAINER, output)
예제 #2
0
파일: test_lxc.py 프로젝트: mcclurmc/juju
    def test_lxc_create(self):
        self.addCleanup(self.clean_container, DEFAULT_CONTAINER)

        _lxc_create(DEFAULT_CONTAINER, config_file=self.config)

        # verify we can find the container
        output = _lxc_ls()
        self.assertIn(DEFAULT_CONTAINER, output)

        # remove and verify the container was removed
        _lxc_destroy(DEFAULT_CONTAINER)
        output = _lxc_ls()
        self.assertNotIn(DEFAULT_CONTAINER, output)
예제 #3
0
파일: test_lxc.py 프로젝트: mcclurmc/juju
    def test_lxc_container(self):
        self.addCleanup(self.clean_container, DEFAULT_CONTAINER)
        customize_log = self.makeFile()
        c = LXCContainer(
            DEFAULT_CONTAINER, "dsa...", "ppa", customize_log=customize_log)

        running = yield c.is_running()
        self.assertFalse(running)
        self.assertFalse(c.is_constructed())
        # verify we can't run a non-constructed container
        failure = c.run()
        yield self.assertFailure(failure, LXCError)

        yield c.create()

        self.assertFalse(running)
        self.assertTrue(c.is_constructed())
        yield c.run()

        running = yield c.is_running()
        self.assertTrue(running)
        self.assertTrue(c.is_constructed())

        output = _lxc_ls()
        self.assertIn(DEFAULT_CONTAINER, output)

        # verify we have a path into the container
        self.assertTrue(os.path.exists(c.rootfs))
        self.assertTrue(c.is_constructed())

        self.verify_container(c, "dsa...", "ppa")

        # verify that we are in containers
        containers = yield get_containers(None)
        self.assertEqual(containers[DEFAULT_CONTAINER], True)

        # tear it down
        yield c.destroy()
        running = yield c.is_running()
        self.assertFalse(running)

        containers = yield get_containers(None)
        self.assertNotIn(DEFAULT_CONTAINER, containers)

        # Verify the customize log file.
        self.assertTrue(os.path.exists(customize_log))

        # and its gone
        output = _lxc_ls()
        self.assertNotIn(DEFAULT_CONTAINER, output)
예제 #4
0
    def test_container_clone(self):
        self.addCleanup(self.clean_container, DEFAULT_CONTAINER)
        self.addCleanup(self.clean_container, DEFAULT_CONTAINER + "_child")

        master_container = LXCContainer(DEFAULT_CONTAINER,
                                        origin="ppa",
                                        public_key="dsa...",
                                        series="oneiric")

        # verify that we cannot clone an unconstructed container
        failure = master_container.clone("test_lxc_fail")
        yield self.assertFailure(failure, LXCError)

        yield master_container.create()

        # Clone a child container from the template
        child_name = DEFAULT_CONTAINER + "_child"
        c = yield master_container.clone(child_name)

        self.assertEqual(c.container_name, child_name)

        running = yield c.is_running()
        self.assertFalse(running)
        yield c.run()

        running = yield c.is_running()
        self.assertTrue(running)

        output = _lxc_ls()
        self.assertIn(DEFAULT_CONTAINER, output)

        self.verify_container(c, "dsa...", "oneiric", "ppa")

        # verify that we are in containers
        containers = yield get_containers(None)
        self.assertEqual(containers[child_name], True)

        # tear it down
        yield c.destroy()
        running = yield c.is_running()
        self.assertFalse(running)

        containers = yield get_containers(None)
        self.assertNotIn(child_name, containers)

        # and its gone
        output = _lxc_ls()
        self.assertNotIn(child_name, output)

        yield master_container.destroy()
예제 #5
0
파일: test_lxc.py 프로젝트: mcclurmc/juju
    def test_container_clone(self):
        self.addCleanup(self.clean_container, DEFAULT_CONTAINER)
        self.addCleanup(self.clean_container, DEFAULT_CONTAINER + "_child")

        master_container = LXCContainer(DEFAULT_CONTAINER,
                                        origin="ppa",
                                        public_key="dsa...")

        # verify that we cannot clone an unconstructed container
        failure = master_container.clone("test_lxc_fail")
        yield self.assertFailure(failure, LXCError)

        yield master_container.create()

        # Clone a child container from the template
        child_name = DEFAULT_CONTAINER + "_child"
        c = yield master_container.clone(child_name)

        self.assertEqual(c.container_name, child_name)

        running = yield c.is_running()
        self.assertFalse(running)
        yield c.run()

        running = yield c.is_running()
        self.assertTrue(running)

        output = _lxc_ls()
        self.assertIn(DEFAULT_CONTAINER, output)

        self.verify_container(c, "dsa...", "ppa")

        # verify that we are in containers
        containers = yield get_containers(None)
        self.assertEqual(containers[child_name], True)

        # tear it down
        yield c.destroy()
        running = yield c.is_running()
        self.assertFalse(running)

        containers = yield get_containers(None)
        self.assertNotIn(child_name, containers)

        # and its gone
        output = _lxc_ls()
        self.assertNotIn(child_name, output)

        yield master_container.destroy()