예제 #1
0
 def test_with_vms(self):
     cif = FakeClientIF()
     with fake.VM(params={'vmId': 'testvm1'}, cif=cif) as testvm1:
         with fake.VM(params={'vmId': 'testvm2'}, cif=cif) as testvm2:
             vms = cif.getVMs()
             self.assertEqual(len(vms), 2)
             self.assertIn(testvm1.id, vms)
             self.assertIn(testvm2.id, vms)
예제 #2
0
    def test_sriov_vm(self):
        params = {
            'name': 'SRiovVm',
            'displaySecurePort': '-1',
            'memSize': '256',
            'displayPort': '-1',
            'display': 'qxl'
        }

        devices = [
            {
                'device': 'bridge',
                'nicModel': 'virtio',
                'macAddr': '52:54:00:59:FF:FF',
                'type': 'interface',
                'network': ''
            },
        ]

        test_path = os.path.realpath(__file__)
        dir_name = os.path.split(test_path)[0]
        api_path = os.path.join(dir_name, '..', 'data', 'testSRiovVm.xml')

        domain = None
        with open(api_path, 'r') as domxml:
            domain = domxml.read()
        with fake.VM(params=params,
                     devices=devices,
                     create_device_objects=True) as vm:
            vm._domain = domain_descriptor.DomainDescriptor(domain)
            vm._getUnderlyingVmDevicesInfo()
            self.verifyDevicesConf(vm.conf['devices'])
            self._assert_guest_device_adress_is_reported(vm)
예제 #3
0
    def testAllVmStats(self):
        with fake.VM(_VM_PARAMS) as testvm:
            with MonkeyPatchScope([(clientIF, 'getInstance',
                                    lambda _: testvm.cif)]):
                api = API.Global()

                # here is where clientIF will be used.
                response = api.getAllVmStats()

                self.assertEqual(response['status']['code'], 0)

                for stat in response['statsList']:
                    self.assertVmStatsSchemaCompliancy('RunningVmStats', stat)
예제 #4
0
 def testRunningStats(self):
     with fake.VM(_VM_PARAMS) as testvm:
         self.assertVmStatsSchemaCompliancy('RunningVmStats',
                                            testvm.getStats())
예제 #5
0
 def testDownStats(self):
     with fake.VM() as testvm:
         testvm.setDownStatus(define.ERROR, vmexitreason.GENERIC_ERROR)
         self.assertVmStatsSchemaCompliancy('ExitedVmStats',
                                            testvm.getStats())
예제 #6
0
 def test_nr_hugepages(self, hugepages, memory, expected):
     with mock.patch.object(vm.Vm, 'mem_size_mb', lambda _: memory):
         metadata = _VM_HUGEPAGES_METADATA.format(hugepages=hugepages)
         with fake.VM(metadata=metadata) as fakevm:
             self.assertEqual(fakevm.nr_hugepages, expected)
예제 #7
0
 def test_hugepagesz(self, hugepages, expected):
     metadata = _VM_HUGEPAGES_METADATA.format(hugepages=hugepages)
     with fake.VM(metadata=metadata) as vm:
         self.assertEqual(vm.hugepagesz, expected)