def test_domain_xml_filesystem(self): """LXC XML with filesystem.""" config = """<domain></domain>""" expected = """<domain><name>foo</name><uuid>foo</uuid><devices><filesystem type="mount">""" +\ """<source dir="foo" /><target dir="bar" /></filesystem></devices></domain>""" results = lxc.domain_xml('foo', config, [('foo', 'bar')]) self.assertEqual(results, expected, compare(results, expected))
def test_domain_xml_modifies(self): """Fields are modified if existing.""" config = """<domain><name>bar</name><uuid>bar</uuid></domain>""" expected = """<domain><name>foo</name><uuid>foo</uuid><devices><filesystem type="mount">""" +\ """<source dir="foo" /><target dir="bar" /></filesystem></devices></domain>""" results = lxc.domain_xml('foo', config, [('foo', 'bar')]) self.assertEqual(results, expected, compare(results, expected))
def test_domain_xml_network(self): """XML with network fields are modified if existing.""" config = """<domain></domain>""" expected = """<domain><name>foo</name><uuid>foo</uuid><devices><filesystem type="mount">""" +\ """<source dir="foo" /><target dir="bar" /></filesystem><interface type="network">""" +\ """<source network="foo" /></interface></devices></domain>""" results = lxc.domain_xml('foo', config, [('foo', 'bar')], network_name='foo') self.assertEqual(results, expected, compare(results, expected))
def test_domain_xml(self): """XML with no network and no filesystem.""" config = """<domain></domain>""" expected = """<domain><name>foo</name><uuid>foo</uuid><devices /></domain>""" results = lxc.domain_xml('foo', config, []) self.assertEqual(results, expected, compare(results, expected))