def test_create_filesystems(self): """Create with multiple filesystem.""" xml = """<domain></domain>""" expected = """<domain><name>foo</name><uuid>foo</uuid><devices><filesystem type="mount">""" +\ """<source dir="/bar/foo" /><target dir="/baz" /></filesystem><filesystem type="mount">""" +\ """<source dir="/dead/foo" /><target dir="/beef" /></filesystem></devices></domain>""" hypervisor = mock.Mock() hypervisor.listNetworks.return_value = [] with mock.patch('see.context.resources.lxc.open', mock.mock_open(read_data=xml), create=True): with mock.patch('see.context.resources.lxc.os.makedirs'): lxc.domain_create( hypervisor, 'foo', { 'configuration': '/foo', 'filesystem': [{ 'source_path': '/bar', 'target_path': '/baz' }, { 'source_path': '/dead', 'target_path': '/beef' }] }) results = hypervisor.defineXML.call_args_list[0][0][0] self.assertEqual(results, expected, compare(results, expected))
def test_create(self): """Create with no network and no filesystem.""" xml = """<domain></domain>""" expected = """<domain><name>foo</name><uuid>foo</uuid><devices /></domain>""" hypervisor = mock.Mock() hypervisor.listNetworks.return_value = [] with mock.patch('see.context.resources.lxc.open', mock.mock_open(read_data=xml), create=True): lxc.domain_create(hypervisor, 'foo', {'configuration': '/foo'}) results = hypervisor.defineXML.call_args_list[0][0][0] self.assertEqual(results, expected, compare(results, expected))
def test_create_filesystem(self): """Create with single filesystem.""" xml = """<domain></domain>""" expected = """<domain><name>foo</name><uuid>foo</uuid><devices><filesystem type="mount">""" +\ """<source dir="/bar/foo" /><target dir="/baz" /></filesystem></devices></domain>""" hypervisor = mock.Mock() hypervisor.listNetworks.return_value = [] with mock.patch('see.context.resources.lxc.open', mock.mock_open(read_data=xml), create=True): with mock.patch('see.context.resources.lxc.os.makedirs'): lxc.domain_create(hypervisor, 'foo', {'configuration': '/foo', 'filesystem': {'source_path': '/bar', 'target_path': '/baz'}}) results = hypervisor.defineXML.call_args_list[0][0][0] self.assertEqual(results, expected, compare(results, expected))