Esempio n. 1
0
 def test_disk_cow(self):
     """XML with COW."""
     pool_config = """<pool><target><path>/poolpath</path></target></pool>"""
     disk_config = """<volume><target><path>/path/volume.qcow2</path></target><capacity>10</capacity></volume>"""
     expected = """<volume type="file"><name>foo</name><uuid>foo</uuid><target>""" +\
                """<path>/poolpath/foo.qcow2</path><format type="qcow2" />""" +\
                """</target><capacity>10</capacity><backingStore><path>/path/volume.qcow2</path>""" +\
                """<format type="qcow2" /></backingStore></volume>"""
     results = qemu.disk_xml('foo', pool_config, disk_config, True)
     results = results.replace('\n', '').replace('\t', '').replace('  ', '')
     self.assertEqual(results, expected, compare(results, expected))
Esempio n. 2
0
 def test_disk_cow(self):
     """XML with COW."""
     pool_config = """<pool><target><path>/poolpath</path></target></pool>"""
     disk_config = """<volume><target><path>/path/volume.qcow2</path></target><capacity>10</capacity></volume>"""
     expected = """<volume type="file"><name>foo</name><uuid>foo</uuid><target>""" +\
                """<path>/poolpath/foo.qcow2</path><format type="qcow2" />""" +\
                """</target><capacity>10</capacity><backingStore><path>/path/volume.qcow2</path>""" +\
                """<format type="qcow2" /></backingStore></volume>"""
     results = qemu.disk_xml('foo', pool_config, disk_config, True)
     results = results.replace('\n', '').replace('\t', '').replace('  ', '')
     self.assertEqual(results, expected, compare(results, expected))
Esempio n. 3
0
    def test_disk_xml(self):
        """XML without COW."""
        pool_config = """<pool><target><path>/poolpath</path></target></pool>"""
        disk_config = """<volume><target><path>/path/volume.qcow2</path></target><capacity>10</capacity></volume>"""
        expected = """<volume type="file">
  <name>foo</name>
  <uuid>foo</uuid>
  <target>
    <path>/poolpath/foo.qcow2</path>
    <format type="qcow2" />
  </target>
<capacity>10</capacity></volume>"""
        results = qemu.disk_xml('foo', pool_config, disk_config, False)
        self.assertEqual(results, expected, compare(results, expected))
Esempio n. 4
0
    def test_disk_xml(self):
        """XML without COW."""
        pool_config = """<pool><target><path>/poolpath</path></target></pool>"""
        disk_config = """<volume><target><path>/path/volume.qcow2</path></target><capacity>10</capacity></volume>"""
        expected = """<volume type="file">
  <name>foo</name>
  <uuid>foo</uuid>
  <target>
    <path>/poolpath/foo.qcow2</path>
    <format type="qcow2" />
  </target>
<capacity>10</capacity></volume>"""
        results = qemu.disk_xml('foo', pool_config, disk_config, False)
        self.assertEqual(results, expected, compare(results, expected))
Esempio n. 5
0
    def test_disk_xml_modifies(self):
        """QEMU XML without COW fields are modified if existing."""
        pool_config = """<pool><target><path>/poolpath</path></target></pool>"""
        disk_config = """<volume><target><path>/path/volume.qcow2</path></target><name>bar</name>""" +\
                      """<capacity>10</capacity></volume>"""
        expected = """<volume type="file">
  <name>foo</name>
  <uuid>foo</uuid>
  <target>
    <path>/poolpath/foo.qcow2</path>
    <permissions>
      <mode>0644</mode>
    </permissions>
    <format type="qcow2" />
  </target>
<capacity>10</capacity></volume>"""
        results = qemu.disk_xml('foo', pool_config, disk_config, False)
        self.assertEqual(results, expected, compare(results, expected))