示例#1
0
 def test_featuresElement(self):
     """Testing OvfLibvirt.featuresElement"""
     self.assertEqual(Ovf.xmlString(OvfLibvirt.featuresElement(True, True, True, True)),
                      '<features><pae/><nonpae/><acpi/><apic/></features>')
     self.assertEqual(Ovf.xmlString(OvfLibvirt.featuresElement(pae=True)),
                      '<features><pae/></features>')
     self.assertEqual(Ovf.xmlString(OvfLibvirt.featuresElement(nonpae=True)),
                      '<features><nonpae/></features>')
     self.assertEqual(Ovf.xmlString(OvfLibvirt.featuresElement(acpi=True)),
                      '<features><acpi/></features>')
     self.assertEqual(Ovf.xmlString(OvfLibvirt.featuresElement(apic=True)),
                      '<features><apic/></features>')
示例#2
0
    def test_libvirtDocument(self):
        """Testing OvfLibvirt.libvirtDocument"""
        domain = self.testDocument.createElement('domain')
        domain.setAttribute('type', 'xen')

        elem = self.testDocument.createElement('name')
        elem.appendChild(self.testDocument.createTextNode('test'))
        domain.appendChild(elem)

        # no sections
        testDoc = OvfLibvirt.libvirtDocument(domain)
        testStr = self.docTag + '<domain type="xen"><name>test</name></domain>'
        self.assertEqual(Ovf.xmlString(testDoc), testStr)

        # new section
        clockSection = self.testDocument.createElement('clock')
        clockSection.setAttribute('sync','utc')

        testDoc = OvfLibvirt.libvirtDocument(domain, clockSection)
        testStr = self.docTag + '<domain type="xen"><name>test</name>' + \
                  '<clock sync="utc"/></domain>'
        self.assertEqual(Ovf.xmlString(testDoc), testStr)

        # replace section
        domain.appendChild(clockSection)
        newClockSection = self.testDocument.createElement('clock')
        newClockSection.setAttribute('sync','localtime')

        testDoc = OvfLibvirt.libvirtDocument(domain, newClockSection)
        testStr = self.docTag + '<domain type="xen"><name>test</name>' + \
                  '<clock sync="localtime"/></domain>'
        self.assertEqual(Ovf.xmlString(testDoc), testStr)

        # multiple sections (new and old)
        newNameSection = self.testDocument.createElement('name')
        nameNode = self.testDocument.createTextNode('test_completed')
        newNameSection.appendChild(nameNode)

        testDoc = OvfLibvirt.libvirtDocument(domain, newNameSection,
                                                   newClockSection)
        testStr = self.docTag + '<domain type="xen">' + \
                  '<name>test_completed</name>' + \
                  '<clock sync="localtime"/></domain>'
        self.assertEqual(Ovf.xmlString(testDoc), testStr)
示例#3
0
 def test_uuidElement(self):
     """Testing OvfLibvirt.uuidElement"""
     testStr = '4dea22b31d52d8f32516782e98ab3fa0'
     self.assertEqual(Ovf.xmlString(OvfLibvirt.uuidElement(testStr)),
                      '<uuid>' + testStr + '</uuid>')
示例#4
0
 def test_nameElement(self):
     """Testing OvfLibvirt.nameElement"""
     self.assertEqual(Ovf.xmlString(OvfLibvirt.nameElement('test')),
                      '<name>test</name>')
示例#5
0
 def test_domainElement(self):
     """Testing OvfLibvirt.domainElement"""
     testElem = OvfLibvirt.domainElement('kqemu')
     self.assertEqual(Ovf.xmlString(testElem),
                      '<domain type="kqemu"/>')
示例#6
0
 def test_graphicsElement(self):
     """Testing OvfLibvirt.graphicsElement"""
     self.assertEqual(Ovf.xmlString(OvfLibvirt.graphicsElement('vnc', '192.168.1.1', '6522')),
                      '<graphics listen="192.168.1.1" port="6522" type="vnc"/>')
     self.assertEqual(Ovf.xmlString(OvfLibvirt.graphicsElement('sdl')),
                      '<graphics type="sdl"/>')
示例#7
0
 def test_inputElement(self):
     """Testing OvfLibvirt.inputElement"""
     self.assertEqual(Ovf.xmlString(OvfLibvirt.inputElement('mouse', 'usb')),
                      '<input bus="usb" type="mouse"/>')
     self.assertEqual(Ovf.xmlString(OvfLibvirt.inputElement('tablet')),
                      '<input type="tablet"/>')
示例#8
0
 def test_emulatorElement(self):
     """Testing OvfLibvirt.emulatorElement"""
     testElem = OvfLibvirt.emulatorElement('/usr/bin/qemu')
     self.assertEqual(Ovf.xmlString(testElem),
                      '<emulator>/usr/bin/qemu</emulator>')
示例#9
0
 def test_clockElement(self):
     """Testing OvfLibvirt.clockElement"""
     self.assertEqual(Ovf.xmlString(OvfLibvirt.clockElement('localtime')),
                      '<clock sync="localtime"/>')
示例#10
0
 def test_onCrashElement(self):
     """Testing OvfLibvirt.onCrashElement"""
     self.assertEqual(Ovf.xmlString(OvfLibvirt.onCrashElement('restart')),
                      '<on_crash>restart</on_crash>')
示例#11
0
 def test_onRebootElement(self):
     """Testing OvfLibvirt.onRebootElement"""
     self.assertEqual(Ovf.xmlString(OvfLibvirt.onRebootElement('restart')),
                      '<on_reboot>restart</on_reboot>')
示例#12
0
 def test_onPowerOffElement(self):
     """Testing OvfLibvirt.onPowerOffElement"""
     self.assertEqual(Ovf.xmlString(OvfLibvirt.onPowerOffElement('destroy')),
                      '<on_poweroff>destroy</on_poweroff>')
示例#13
0
 def test_vcpuElement(self):
     """Testing OvfLibvirt.vcpuElement"""
     self.assertEqual(Ovf.xmlString(OvfLibvirt.vcpuElement('1')),
                      '<vcpu>1</vcpu>')
示例#14
0
 def test_currentMemoryElement(self):
     """Testing OvfLibvirt.currentMemoryElement"""
     self.assertEqual(Ovf.xmlString(OvfLibvirt.currentMemoryElement('262144')),
                      '<currentMemory>262144</currentMemory>')
示例#15
0
 def test_memoryElement(self):
     """Testing OvfLibvirt.memoryElement"""
     self.assertEqual(Ovf.xmlString(OvfLibvirt.memoryElement('262144')),
                      '<memory>262144</memory>')