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


Python response.success函数代码示例

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


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

示例1: test_unregister_missing

 def test_unregister_missing(self):
     existing_sec = make_secret()
     secret.register([existing_sec])
     missing_sec = make_secret()
     res = secret.unregister([missing_sec["uuid"], existing_sec["uuid"]])
     self.assertEqual(res, response.success())
     self.assertEqual({}, self.connection.secrets)
开发者ID:EdDev,项目名称:vdsm,代码行数:7,代码来源:vmsecret_test.py

示例2: unregister

def unregister(uuids):
    try:
        uuids = [str(uuid.UUID(s)) for s in uuids]
    except ValueError as e:
        logging.warning("Attempt to unregister invalid uuid %s: %s" %
                        (uuids, e))
        return response.error("secretBadRequestErr")

    con = libvirtconnection.get()
    try:
        for sec_uuid in uuids:
            logging.info("Unregistering secret %r", sec_uuid)
            try:
                virsecret = con.secretLookupByUUIDString(sec_uuid)
            except libvirt.libvirtError as e:
                if e.get_error_code() != libvirt.VIR_ERR_NO_SECRET:
                    raise
                logging.debug("No such secret %r", sec_uuid)
            else:
                virsecret.undefine()
    except libvirt.libvirtError as e:
        logging.error("Could not unregister secrets: %s", e)
        return response.error("secretUnregisterErr")

    return response.success()
开发者ID:nirs,项目名称:vdsm,代码行数:25,代码来源:secret.py

示例3: test_unregister_existing

 def test_unregister_existing(self):
     sec1 = make_secret(password="sec1 password")
     sec2 = make_secret(password="sec2 password")
     secret.register([sec1, sec2])
     res = secret.unregister([sec1["uuid"]])
     self.assertEqual(res, response.success())
     self.assertNotIn(sec1["uuid"], self.connection.secrets)
     self.assertIn(sec2["uuid"], self.connection.secrets)
开发者ID:EdDev,项目名称:vdsm,代码行数:8,代码来源:vmsecret_test.py

示例4: test_register_new

 def test_register_new(self):
     sec1 = make_secret(password="sec1 password")
     sec2 = make_secret(password="sec2 password")
     res = secret.register([sec1, sec2])
     self.assertEqual(res, response.success())
     virsec1 = self.connection.secrets[sec1["uuid"]]
     self.assertEqual("sec1 password", virsec1.value)
     virsec2 = self.connection.secrets[sec2["uuid"]]
     self.assertEqual("sec2 password", virsec2.value)
开发者ID:EdDev,项目名称:vdsm,代码行数:9,代码来源:vmsecret_test.py

示例5: test_register_change_usage_id

 def test_register_change_usage_id(self):
     sec = make_secret(usage_id="ovirt/provider_uuid/secert_uuid")
     secret.register([sec])
     # Change usage id
     sec["usageID"] = "ovirt/domain_uuid/secret_uuid"
     res = secret.register([sec])
     self.assertEqual(res, response.success())
     virsec = self.connection.secrets[sec["uuid"]]
     self.assertEqual("ovirt/domain_uuid/secret_uuid", virsec.usage_id)
开发者ID:EdDev,项目名称:vdsm,代码行数:9,代码来源:vmsecret_test.py

示例6: teardownImage

    def teardownImage(self, domainId, poolId, imageId):
        if imageId == TEARDOWN_ERROR_IMAGE_ID:
            return response.error('teardownError')

        imagepath = _vol_path(self._image_path_base, domainId, poolId, imageId)
        resultpath = _vol_path(self._image_path_base, domainId, poolId,
                               imageId, ext='.res')
        os.rename(imagepath, resultpath)
        return response.success()
开发者ID:EdDev,项目名称:vdsm,代码行数:9,代码来源:seal_job_test.py

示例7: test_register_replace

 def test_register_replace(self):
     # Register 2 secrets
     sec1 = make_secret(password="sec1 password")
     sec2 = make_secret(password="sec2 password")
     secret.register([sec1, sec2])
     # Replace existing secret value
     sec2["password"] = make_password("sec2 new password")
     res = secret.register([sec2])
     self.assertEqual(res, response.success())
     virsec1 = self.connection.secrets[sec1["uuid"]]
     self.assertEqual("sec1 password", virsec1.value)
     virsec2 = self.connection.secrets[sec2["uuid"]]
     self.assertEqual("sec2 new password", virsec2.value)
开发者ID:EdDev,项目名称:vdsm,代码行数:13,代码来源:vmsecret_test.py

示例8: start

    def start(self):
        # are there any available methods for power-down?
        if self.chain.callbacks:
            # flag for successful power-down event detection
            # this flag is common for both shutdown and reboot workflows
            # because we want to exit the CallbackChain in case either
            # of them happens
            self.event.clear()

            self.chain.start()
            return response.success(message=self.returnMsg)
        else:
            # No tools, no ACPI
            return response.error(
                'exist',
                message='VM without ACPI or active oVirt guest agent. '
                        'Try Forced Shutdown.')
开发者ID:EdDev,项目名称:vdsm,代码行数:17,代码来源:vmpowerdown.py

示例9: test_register_clear

 def test_register_clear(self):
     self.connection.secrets = {
         "uuid1": vmfakecon.Secret(self.connection, "uuid1", "ceph",
                                   "ovirt/name1", None),
         "uuid2": vmfakecon.Secret(self.connection, "uuid2", "ceph",
                                   "name2", None),
     }
     sec = make_secret()
     res = secret.register([sec], clear=True)
     # Should succeed
     self.assertEqual(res, response.success())
     # Should remove existing ovirt secrets
     self.assertNotIn("uuid1", self.connection.secrets)
     # Should keep non-ovirt secrets
     self.assertIn("uuid2", self.connection.secrets)
     # Should register new secret
     virsec = self.connection.secrets[sec["uuid"]]
     self.assertEqual(sec["password"].value, virsec.value)
开发者ID:EdDev,项目名称:vdsm,代码行数:18,代码来源:vmsecret_test.py

示例10: register

def register(secrets, clear=False):
    try:
        secrets = [Secret(params) for params in secrets]
    except ValueError as e:
        logging.warning("Attempt to register invalid secret: %s", e)
        return response.error("secretBadRequestErr")

    con = libvirtconnection.get()
    try:
        for secret in secrets:
            logging.info("Registering secret %s", secret)
            secret.register(con)
        if clear:
            uuids = frozenset(sec.uuid for sec in secrets)
            for virsecret in con.listAllSecrets():
                if virsecret.UUIDString() not in uuids and _is_ovirt_secret(virsecret):
                    virsecret.undefine()
    except libvirt.libvirtError as e:
        logging.error("Could not register secret %s: %s", secret, e)
        return response.error("secretRegisterErr")

    return response.success()
开发者ID:nirs,项目名称:vdsm,代码行数:22,代码来源:secret.py

示例11: prepareImage

 def prepareImage(self, domainId, poolId, imageId, volumeId,
                  allowIllegal=False):
     imagepath = _vol_path(self._image_path_base, domainId, poolId, imageId)
     with io.open(imagepath, 'w'):
         pass
     return response.success(path=imagepath)
开发者ID:EdDev,项目名称:vdsm,代码行数:6,代码来源:seal_job_test.py

示例12: lease_info

 def lease_info(self, lease):
     key = (lease["sd_id"], lease["lease_id"])
     if key not in self.leases:
         return exception.GeneralException().response()
     return response.success(result=self.leases[key])
开发者ID:EdDev,项目名称:vdsm,代码行数:5,代码来源:vmlease_test.py

示例13: createVm

 def createVm(self, vmParams, vmRecover=False):
     self.vmRequests[vmParams['vmId']] = (vmParams, vmRecover)
     return response.success(vmList={})
开发者ID:EdDev,项目名称:vdsm,代码行数:3,代码来源:clientif_test.py

示例14: createVm

 def createVm(self, vmParams):
     return response.success(vmList=[self])
开发者ID:EdDev,项目名称:vdsm,代码行数:2,代码来源:API_test.py

示例15: succeed_passthrough

 def succeed_passthrough(self, foo):
     return response.success(foo=foo)
开发者ID:nirs,项目名称:vdsm,代码行数:2,代码来源:api_response_test.py


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