Example #1
0
    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)
Example #2
0
    def test_lxc_wait(self):
        self.addCleanup(self.clean_container, DEFAULT_CONTAINER)

        _lxc_create(DEFAULT_CONTAINER, config_file=self.config)

        _lxc_start(DEFAULT_CONTAINER)

        def waitForState(result):
            self.assertEqual(result, True)

        d = _lxc_wait(DEFAULT_CONTAINER, "RUNNING")
        d.addCallback(waitForState)
        yield d

        _lxc_stop(DEFAULT_CONTAINER)
        yield _lxc_wait(DEFAULT_CONTAINER, "STOPPED")
        _lxc_destroy(DEFAULT_CONTAINER)
Example #3
0
 def clean_container(self, container_name):
     if os.path.exists("/var/lib/lxc/%s" % container_name):
         _lxc_stop(container_name)
         _lxc_destroy(container_name)