Beispiel #1
0
    def test_to_xml(self):
        graphics = {'type': 'spice', 'listen': '127.0.0.1'}
        vm_uuid = str(uuid.uuid4()).replace('-', '')
        t = VMTemplate({'name': 'test-template', 'cdrom': self.iso})
        xml = t.to_vm_xml('test-vm', vm_uuid, graphics=graphics)
        self.assertEquals(vm_uuid, xpath_get_text(xml, "/domain/uuid")[0])
        self.assertEquals('test-vm', xpath_get_text(xml, "/domain/name")[0])
        expr = "/domain/devices/graphics/@type"
        self.assertEquals(graphics['type'], xpath_get_text(xml, expr)[0])
        expr = "/domain/devices/graphics/@listen"
        self.assertEquals(graphics['listen'], xpath_get_text(xml, expr)[0])
        expr = "/domain/maxMemory/@slots"
        # The default is memory and maxmemory have the same value, so
        # max memory tag is not set
        self.assertEquals(0, len(xpath_get_text(xml, expr)))
        expr = "/domain/memory"
        self.assertEquals(str(1024), xpath_get_text(xml, expr)[0])

        if hasattr(psutil, 'virtual_memory'):
            host_memory = psutil.virtual_memory().total >> 10
        else:
            host_memory = psutil.TOTAL_PHYMEM >> 10
        t = VMTemplate({'name': 'test-template', 'cdrom': self.iso,
                        'memory': {'current': (host_memory >> 10) - 512}})
        try:
            xml = t.to_vm_xml('test-vm', vm_uuid, graphics=graphics)
        except Exception as e:
            # Test current memory greater than maxmemory (1024/default)
            self.assertTrue('KCHVM0041E' in e.message)
Beispiel #2
0
    def test_to_xml(self):
        graphics = {'type': 'spice', 'listen': '127.0.0.1'}
        vm_uuid = str(uuid.uuid4()).replace('-', '')
        t = VMTemplate({'name': 'test-template', 'cdrom': self.iso})
        xml = t.to_vm_xml('test-vm', vm_uuid, graphics=graphics)
        self.assertEquals(vm_uuid, xpath_get_text(xml, "/domain/uuid")[0])
        self.assertEquals('test-vm', xpath_get_text(xml, "/domain/name")[0])
        expr = "/domain/devices/graphics/@type"
        self.assertEquals(graphics['type'], xpath_get_text(xml, expr)[0])
        expr = "/domain/devices/graphics/@listen"
        self.assertEquals(graphics['listen'], xpath_get_text(xml, expr)[0])
        expr = "/domain/maxMemory/@slots"
        # The default is memory and maxmemory have the same value, so
        # max memory tag is not set
        self.assertEquals(0, len(xpath_get_text(xml, expr)))
        expr = "/domain/memory"
        self.assertEquals(str(1024), xpath_get_text(xml, expr)[0])

        if hasattr(psutil, 'virtual_memory'):
            host_memory = psutil.virtual_memory().total >> 10
        else:
            host_memory = psutil.TOTAL_PHYMEM >> 10
        t = VMTemplate({'name': 'test-template', 'cdrom': self.iso,
                        'memory': {'current': (host_memory >> 10) - 512}})
        try:
            xml = t.to_vm_xml('test-vm', vm_uuid, graphics=graphics)
        except Exception as e:
            # Test current memory greater than maxmemory (1024/default)
            self.assertTrue('KCHVM0041E' in e.message)
Beispiel #3
0
    def test_to_xml(self):
        graphics = {"type": "spice", "listen": "127.0.0.1"}
        vm_uuid = str(uuid.uuid4()).replace("-", "")
        t = VMTemplate({"name": "test-template", "cdrom": self.iso})
        xml = t.to_vm_xml("test-vm", vm_uuid, graphics=graphics)
        self.assertEquals(vm_uuid, xpath_get_text(xml, "/domain/uuid")[0])
        self.assertEquals("test-vm", xpath_get_text(xml, "/domain/name")[0])
        expr = "/domain/devices/graphics/@type"
        self.assertEquals(graphics["type"], xpath_get_text(xml, expr)[0])
        expr = "/domain/devices/graphics/@listen"
        self.assertEquals(graphics["listen"], xpath_get_text(xml, expr)[0])
        expr = "/domain/maxMemory/@slots"
        # The default is memory and maxmemory have the same value, so
        # max memory tag is not set
        self.assertEquals(0, len(xpath_get_text(xml, expr)))
        expr = "/domain/memory"
        self.assertEquals(str(1024), xpath_get_text(xml, expr)[0])

        if hasattr(psutil, "virtual_memory"):
            host_memory = psutil.virtual_memory().total >> 10
        else:
            host_memory = psutil.TOTAL_PHYMEM >> 10
        t = VMTemplate({"name": "test-template", "cdrom": self.iso, "memory": {"current": (host_memory >> 10) - 512}})
        try:
            xml = t.to_vm_xml("test-vm", vm_uuid, graphics=graphics)
        except Exception as e:
            # Test current memory greater than maxmemory (1024/default)
            self.assertTrue("KCHVM0041E" in e.message)
Beispiel #4
0
    def test_to_xml(self):
        graphics = {'type': 'spice', 'listen': '127.0.0.1'}
        vm_uuid = str(uuid.uuid4()).replace('-', '')
        t = VMTemplate({'name': 'test-template', 'cdrom': self.iso})
        xml = t.to_vm_xml('test-vm', vm_uuid, graphics=graphics)
        self.assertEquals(vm_uuid, xpath_get_text(xml, "/domain/uuid")[0])
        self.assertEquals('test-vm', xpath_get_text(xml, "/domain/name")[0])
        expr = "/domain/devices/graphics/@type"
        self.assertEquals(graphics['type'], xpath_get_text(xml, expr)[0])
        expr = "/domain/devices/graphics/@listen"
        self.assertEquals(graphics['listen'], xpath_get_text(xml, expr)[0])
        expr = "/domain/maxMemory/@slots"
        self.assertEquals('3', xpath_get_text(xml, expr)[0])
        expr = "/domain/maxMemory"
        self.assertEquals(str((1024 * 4) << 10), xpath_get_text(xml, expr)[0])

        if hasattr(psutil, 'virtual_memory'):
            host_memory = psutil.virtual_memory().total >> 10
        else:
            host_memory = psutil.TOTAL_PHYMEM >> 10
        t = VMTemplate({'name': 'test-template', 'cdrom': self.iso,
                        'memory': (host_memory >> 10) - 512})
        xml = t.to_vm_xml('test-vm', vm_uuid, graphics=graphics)
        expr = "/domain/maxMemory"
        self.assertEquals(str(host_memory), xpath_get_text(xml, expr)[0])
        expr = "/domain/maxMemory/@slots"
        self.assertEquals('1', xpath_get_text(xml, expr)[0])
Beispiel #5
0
    def test_to_xml(self):
        graphics = {'type': 'spice', 'listen': '127.0.0.1'}
        vm_uuid = str(uuid.uuid4()).replace('-', '')
        t = VMTemplate({'name': 'test-template', 'cdrom': self.iso})
        xml = t.to_vm_xml('test-vm', vm_uuid, graphics=graphics)
        self.assertEquals(vm_uuid, xpath_get_text(xml, "/domain/uuid")[0])
        self.assertEquals('test-vm', xpath_get_text(xml, "/domain/name")[0])
        expr = "/domain/devices/graphics/@type"
        self.assertEquals(graphics['type'], xpath_get_text(xml, expr)[0])
        expr = "/domain/devices/graphics/@listen"
        self.assertEquals(graphics['listen'], xpath_get_text(xml, expr)[0])
        expr = "/domain/maxMemory/@slots"
        self.assertEquals('3', xpath_get_text(xml, expr)[0])
        expr = "/domain/maxMemory"
        self.assertEquals(str((1024 * 4) << 10), xpath_get_text(xml, expr)[0])

        if hasattr(psutil, 'virtual_memory'):
            host_memory = psutil.virtual_memory().total >> 10
        else:
            host_memory = psutil.TOTAL_PHYMEM >> 10
        t = VMTemplate({
            'name': 'test-template',
            'cdrom': self.iso,
            'memory': (host_memory >> 10) - 512
        })
        xml = t.to_vm_xml('test-vm', vm_uuid, graphics=graphics)
        expr = "/domain/maxMemory"
        self.assertEquals(str(host_memory), xpath_get_text(xml, expr)[0])
        expr = "/domain/maxMemory/@slots"
        self.assertEquals('1', xpath_get_text(xml, expr)[0])
Beispiel #6
0
 def test_mem_dev_slots(self):
     vm_uuid = str(uuid.uuid4()).replace('-', '')
     t = VMTemplate({'name': 'test-template', 'cdrom': self.iso,
                     'memory':  {'current': 2048, 'maxmemory': 3072}})
     xml = t.to_vm_xml('test-vm', vm_uuid)
     expr = "/domain/maxMemory/@slots"
     slots = str(MEM_DEV_SLOTS[os.uname()[4]])
     self.assertEquals(slots, xpath_get_text(xml, expr)[0])
 def test_mem_dev_slots(self):
     vm_uuid = str(uuid.uuid4()).replace('-', '')
     t = VMTemplate({'name': 'test-template', 'cdrom': self.iso,
                     'memory':  {'current': 2048, 'maxmemory': 3072}})
     xml = t.to_vm_xml('test-vm', vm_uuid)
     expr = "/domain/maxMemory/@slots"
     slots = str(MEM_DEV_SLOTS[os.uname()[4]])
     self.assertEquals(slots, xpath_get_text(xml, expr)[0])
Beispiel #8
0
 def test_to_xml(self):
     graphics = {'type': 'spice', 'listen': '127.0.0.1'}
     vm_uuid = str(uuid.uuid4()).replace('-', '')
     if os.uname()[4] in ['ppc', 'ppc64', 'ppc64le']:
         maxmem = 3328
     else:
         maxmem = 3072
     t = VMTemplate({'name': 'test-template', 'cdrom': self.iso,
                    'max_memory': maxmem << 10})
     xml = t.to_vm_xml('test-vm', vm_uuid, graphics=graphics)
     self.assertEquals(vm_uuid, xpath_get_text(xml, "/domain/uuid")[0])
     self.assertEquals('test-vm', xpath_get_text(xml, "/domain/name")[0])
     expr = "/domain/devices/graphics/@type"
     self.assertEquals(graphics['type'], xpath_get_text(xml, expr)[0])
     expr = "/domain/devices/graphics/@listen"
     self.assertEquals(graphics['listen'], xpath_get_text(xml, expr)[0])
     expr = "/domain/maxMemory/@slots"
     self.assertEquals('2', xpath_get_text(xml, expr)[0])
Beispiel #9
0
 def test_to_xml(self):
     graphics = {'type': 'spice', 'listen': '127.0.0.1'}
     vm_uuid = str(uuid.uuid4()).replace('-', '')
     if os.uname()[4] in ['ppc', 'ppc64', 'ppc64le']:
         maxmem = 3328
     else:
         maxmem = 3072
     t = VMTemplate({
         'name': 'test-template',
         'cdrom': self.iso,
         'max_memory': maxmem << 10
     })
     xml = t.to_vm_xml('test-vm', vm_uuid, graphics=graphics)
     self.assertEquals(vm_uuid, xpath_get_text(xml, "/domain/uuid")[0])
     self.assertEquals('test-vm', xpath_get_text(xml, "/domain/name")[0])
     expr = "/domain/devices/graphics/@type"
     self.assertEquals(graphics['type'], xpath_get_text(xml, expr)[0])
     expr = "/domain/devices/graphics/@listen"
     self.assertEquals(graphics['listen'], xpath_get_text(xml, expr)[0])
     expr = "/domain/maxMemory/@slots"
     self.assertEquals('2', xpath_get_text(xml, expr)[0])