def test_lxc_start(self): self.addCleanup(self.clean_container, DEFAULT_CONTAINER) _lxc_create(DEFAULT_CONTAINER, config_file=self.config) _lxc_start(DEFAULT_CONTAINER) _lxc_stop(DEFAULT_CONTAINER)
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)
def clean_container(self, container_name): if os.path.exists("/var/lib/lxc/%s" % container_name): _lxc_stop(container_name) _lxc_destroy(container_name)