当前位置: 首页>>代码示例>>Python>>正文


Python response.is_error函数代码示例

本文整理汇总了Python中vdsm.common.response.is_error函数的典型用法代码示例。如果您正苦于以下问题:Python is_error函数的具体用法?Python is_error怎么用?Python is_error使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了is_error函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _startUnderlyingMigration

    def _startUnderlyingMigration(self, startTime, migrationParams,
                                  machineParams):
        if self.hibernating:
            self._started = True
            self._vm.hibernate(self._dst)
        else:
            self._vm.prepare_migration()

            # Do not measure the time spent for creating the VM on the
            # destination. In some cases some expensive operations can cause
            # the migration to get cancelled right after the transfer started.
            destCreateStartTime = time.time()
            result = self._destServer.migrationCreate(machineParams,
                                                      self._incomingLimit)
            destCreationTime = time.time() - destCreateStartTime
            startTime += destCreationTime
            self.log.info('Creation of destination VM took: %d seconds',
                          destCreationTime)

            if response.is_error(result):
                self.status = result
                if response.is_error(result, 'migrateLimit'):
                    raise MigrationLimitExceeded()
                else:
                    raise MigrationDestinationSetupError(
                        'migration destination error: ' +
                        result['status']['message'])

            self._started = True

            if config.getboolean('vars', 'ssl'):
                transport = 'tls'
            else:
                transport = 'tcp'
            duri = 'qemu+{}://{}/system'.format(
                transport, normalize_literal_addr(self.remoteHost))

            dstqemu = migrationParams['dstqemu']
            if dstqemu:
                muri = 'tcp://{}'.format(
                    normalize_literal_addr(dstqemu))
            else:
                muri = 'tcp://{}'.format(
                    normalize_literal_addr(self.remoteHost))

            self._vm.log.info('starting migration to %s '
                              'with miguri %s', duri, muri)

            self._monitorThread = MonitorThread(self._vm, startTime,
                                                self._convergence_schedule,
                                                self._use_convergence_schedule)

            if self._use_convergence_schedule:
                self._perform_with_conv_schedule(duri, muri)
            else:
                self._perform_with_downtime_thread(duri, muri)

            self.log.info("migration took %d seconds to complete",
                          (time.time() - startTime) + destCreationTime)
开发者ID:nirs,项目名称:vdsm,代码行数:59,代码来源:migration.py

示例2: _recover

 def _recover(self, message):
     if not response.is_error(self.status):
         self.status = response.error('migrateErr')
     self.log.error(message)
     if not self.hibernating and self._destServer is not None:
         if self._vm.post_copy == PostCopyPhase.RUNNING:
             # We can't recover a VM after a failed post-copy migration.
             # And the destination takes care of the situation itself.
             self._vm.handle_failed_post_copy(clean_vm=True)
             return
         try:
             self._destServer.destroy(self._vm.id)
         except Exception:
             self.log.exception("Failed to destroy remote VM")
     # if the guest was stopped before migration, we need to cont it
     if self.hibernating:
         self._vm.cont(ignoreStatus=True)
         if self._enableGuestEvents:
             self._vm.guestAgent.events.after_hibernation_failure()
     elif self._enableGuestEvents:
         self._vm.guestAgent.events.after_migration_failure()
     # either way, migration has finished
     if self._recovery:
         self._vm.set_last_status(vmstatus.UP, vmstatus.MIGRATION_SOURCE)
         self._recovery = False
     else:
         self._vm.lastStatus = vmstatus.UP
     self._started = False
     self._vm.send_status_event()
开发者ID:EdDev,项目名称:vdsm,代码行数:29,代码来源:migration.py

示例3: test_interface_update

 def test_interface_update(self):
     devices = [{'nicModel': 'virtio', 'network': 'ovirtmgmt',
                 'macAddr': '52:54:00:59:F5:3F',
                 'device': 'bridge', 'type': 'interface',
                 'alias': 'net1', 'name': 'net1',
                 'linkActive': 'true',
                 'specParams': {'inbound': {'average': 1000, 'peak': 5000,
                                            'burst': 1024},
                                'outbound': {'average': 128, 'burst': 256}},
                 }]
     params = {'linkActive': 'true', 'alias': 'net1',
               'deviceType': 'interface', 'network': 'ovirtmgmt2',
               'specParams': {'inbound': {}, 'outbound': {}}}
     updated_xml = '''
         <interface type="bridge">
           <mac address="52:54:00:59:F5:3F"/>
           <model type="virtio"/>
           <source bridge="ovirtmgmt2"/>
           <virtualport type="openvswitch"/>
           <link state="up"/>
           <bandwidth/>
         </interface>
     '''
     with fake.VM(devices=devices, create_device_objects=True) as testvm:
         testvm._dom = fake.Domain()
         res = testvm.updateDevice(params)
         self.assertFalse(response.is_error(res))
         self.assertXMLEqual(testvm._dom.devXml, updated_xml)
开发者ID:EdDev,项目名称:vdsm,代码行数:28,代码来源:device_test.py

示例4: test_create_with_missing_boot_disk

 def test_create_with_missing_boot_disk(self):
     res = self.vm.create({
         'vmId': self.uuid,
         'memSize': 0,
         'boot': 'c',
     })
     self.assertTrue(response.is_error(res, 'MissParam'))
开发者ID:EdDev,项目名称:vdsm,代码行数:7,代码来源:API_test.py

示例5: test_migrate_from_status

 def test_migrate_from_status(self, vm_status):
         with MonkeyPatchScope([
             (migration, 'SourceThread', fake.MigrationSourceThread)
         ]):
             with fake.VM(status=vm_status, cif=self.cif) as testvm:
                 res = testvm.migrate({})  # no params needed
                 self.assertFalse(response.is_error(res))
开发者ID:EdDev,项目名称:vdsm,代码行数:7,代码来源:vmmigration_test.py

示例6: test_create_fix_param_vmName

 def test_create_fix_param_vmName(self):
     vmParams = {
         'vmId': self.uuid,
         'memSize': 8 * 1024,
     }
     res = self.vm.create(vmParams)
     self.assertFalse(response.is_error(res))
     self.assertEqual(vmParams.get('vmName'), 'n%s' % self.uuid)
开发者ID:EdDev,项目名称:vdsm,代码行数:8,代码来源:API_test.py

示例7: test_no_callbacks

 def test_no_callbacks(self):
     vm = FakeVM(
         self.dom,
         FakeGuestAgent(responsive=False),
         acpiEnable='false'
     )
     obj = make_powerdown(vm, self.event)
     res = obj.start()
     self.assertTrue(response.is_error(res, 'exist'))
开发者ID:EdDev,项目名称:vdsm,代码行数:9,代码来源:powerdown_test.py

示例8: testGetConvertedVMErrorFlow

    def testGetConvertedVMErrorFlow(self, exc):
        def _raise_error(*args, **kwargs):
            raise exc()

        # we monkeypatch the very first utility function called
        with MonkeyPatchScope([(v2v, '_get_job', _raise_error)]):
            # we use uuid to fill the API contract, but it is unused
            res = v2v.get_converted_vm(str(uuid.uuid4()))
        self.assertTrue(response.is_error(res))
开发者ID:nirs,项目名称:vdsm,代码行数:9,代码来源:v2v_test.py

示例9: test_hibernation_params_map_memory_dump

    def test_hibernation_params_map_memory_dump(self):
        vmParams = {'hiberVolHandle': self._hibernation_volume_old_format}
        vmParams.update(self.vmParams)

        res = self.vm.create(vmParams)
        self.assertFalse(response.is_error(res))
        expected_memory_dump = {'device': 'disk', 'domainID': '0',
                                'poolID': '1', 'imageID': '2', 'volumeID': '3'}
        self.assertEqual(expected_memory_dump, vmParams['restoreState'])
开发者ID:nirs,项目名称:vdsm,代码行数:9,代码来源:API_test.py

示例10: test_create_unsupported_graphics

 def test_create_unsupported_graphics(self):
     vmParams = {
         'vmId': self.uuid,
         'memSize': 8 * 1024,
         'vmType': 'kvm',
         'display': 'unsupported',
     }
     res = self.vm.create(vmParams)
     self.assertTrue(response.is_error(res, 'createErr'))
开发者ID:EdDev,项目名称:vdsm,代码行数:9,代码来源:API_test.py

示例11: test_create_fix_param_kvmEnable

 def test_create_fix_param_kvmEnable(self):
     vmParams = {
         'vmId': self.uuid,
         'memSize': 8 * 1024,
         'vmType': 'kvm',
     }
     res = self.vm.create(vmParams)
     self.assertFalse(response.is_error(res))
     self.assertTrue(conv.tobool(vmParams.get('kvmEnable')))
开发者ID:EdDev,项目名称:vdsm,代码行数:9,代码来源:API_test.py

示例12: test_with_default_callbacks

 def test_with_default_callbacks(self):
     vm = FakeVM(
         self.dom,
         FakeGuestAgent(responsive=True),
         acpiEnable='true'
     )
     obj = make_powerdown(vm, self.event)
     # no actual callback will be called now!
     res = obj.start()
     self.assertFalse(response.is_error(res))
开发者ID:EdDev,项目名称:vdsm,代码行数:10,代码来源:powerdown_test.py

示例13: createVm

 def createVm(self, vmParams, vmRecover=False):
     with self.vmContainerLock:
         if not vmRecover:
             if vmParams['vmId'] in self.vmContainer:
                 return errCode['exist']
         vm = Vm(self, vmParams, vmRecover)
         ret = vm.run()
         if not response.is_error(ret):
             self.vmContainer[vmParams['vmId']] = vm
         return ret
开发者ID:EdDev,项目名称:vdsm,代码行数:10,代码来源:clientIF.py

示例14: test_create_twice

 def test_create_twice(self):
     vmParams = {
         'vmId': self.uuid,
     }
     vm = FakeVM(self.cif, vmParams)
     self.cif.vmContainer[vm.id] = vm
     try:
         res = self.vm.create({})
         self.assertTrue(response.is_error(res, 'exist'))
     finally:
         del self.cif.vmContainer[vm.id]
     self.assertEqual(self.cif.vmContainer, {})
开发者ID:EdDev,项目名称:vdsm,代码行数:12,代码来源:API_test.py

示例15: test_hibernation_params_requested_but_missing

    def test_hibernation_params_requested_but_missing(self):
        vmParams = {
            'hiberVolHandle': '/this/path/does/not/exist/'
        }
        vmParams.update(self.vmParams)

        refParams = copy.deepcopy(vmParams)
        del refParams['hiberVolHandle']  # must go away
        refParams['restoreState'] = True  # to be added BY TESTS

        res = self.vm.create(vmParams)
        self.assertFalse(response.is_error(res))
        self.assertEqual(refParams, vmParams)
开发者ID:EdDev,项目名称:vdsm,代码行数:13,代码来源:API_test.py


注:本文中的vdsm.common.response.is_error函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。