Exemplo n.º 1
0
    def test_specified_graphics(self):
        # Test specified listen
        graphics = {'type': 'vnc', 'listen': '127.0.0.1'}
        args = {
            'name': 'test',
            'disks': [{
                'size': 10
            }, {
                'size': 20
            }],
            'graphics': graphics,
            'cdrom': self.iso
        }
        t = VMTemplate(args)
        self.assertEquals(graphics, t.info['graphics'])

        # Test specified type
        graphics = {'type': 'spice', 'listen': '127.0.0.1'}
        args['graphics'] = graphics
        t = VMTemplate(args)
        self.assertEquals(graphics, t.info['graphics'])

        # If no listen specified, test the default listen
        graphics = {'type': 'vnc'}
        args['graphics'] = graphics
        t = VMTemplate(args)
        self.assertEquals(graphics['type'], t.info['graphics']['type'])
        self.assertEquals('127.0.0.1', t.info['graphics']['listen'])
Exemplo n.º 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])
Exemplo n.º 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])
Exemplo n.º 4
0
 def test_construct_overrides(self):
     graphics = {'type': 'spice', 'listen': '127.0.0.1'}
     args = {'name': 'test', 'disks': [{'size': 10}, {'size': 20}],
             'graphics': graphics, "cdrom": self.iso}
     t = VMTemplate(args)
     self.assertEquals(2, len(t.info['disks']))
     self.assertEquals(graphics, t.info['graphics'])
Exemplo n.º 5
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])
Exemplo n.º 6
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])
Exemplo n.º 7
0
    def test_minimal_construct(self):
        fields = (('name', 'test'), ('os_distro', 'unknown'), ('os_version',
                                                               'unknown'),
                  ('cpus', 1), ('memory', 1024), ('networks', ['default']),
                  ('disk_bus', 'ide'), ('nic_model', 'e1000'), ('graphics', {
                      'type':
                      'vnc',
                      'listen':
                      '127.0.0.1'
                  }), ('cdrom', self.iso))

        args = {'name': 'test', 'cdrom': self.iso}
        t = VMTemplate(args)
        for name, val in fields:
            self.assertEquals(val, t.info.get(name))
Exemplo n.º 8
0
 def test_arg_merging(self):
     """
     Make sure that default parameters from osinfo do not override user-
     provided parameters.
     """
     graphics = {'type': 'vnc', 'listen': '127.0.0.1'}
     args = {'name': 'test', 'os_distro': 'opensuse', 'os_version': '12.3',
             'cpus': 2, 'memory': 2048, 'networks': ['foo'],
             'cdrom': self.iso, 'graphics': graphics}
     t = VMTemplate(args)
     self.assertEquals(2, t.info.get('cpus'))
     self.assertEquals(2048, t.info.get('memory'))
     self.assertEquals(['foo'], t.info.get('networks'))
     self.assertEquals(self.iso, t.info.get('cdrom'))
     self.assertEquals(graphics, t.info.get('graphics'))
Exemplo n.º 9
0
 def __init__(self, args, scan=False, conn=None):
     VMTemplate.__init__(self, args, scan)
     self.conn = conn
Exemplo n.º 10
0
 def __init__(self, args, scan=False, conn=None):
     VMTemplate.__init__(self, args, scan)
     self.conn = conn
Exemplo n.º 11
0
 def __init__(self, args, mockmodel_inst=None):
     VMTemplate.__init__(self, args)
     self.model = mockmodel_inst
Exemplo n.º 12
0
 def __init__(self, args, mockmodel_inst=None):
     VMTemplate.__init__(self, args)
     self.model = mockmodel_inst