本文整理汇总了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)
示例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()
示例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)
示例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)
示例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)
示例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()
示例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)
示例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.')
示例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)
示例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()
示例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)
示例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])
示例13: createVm
def createVm(self, vmParams, vmRecover=False):
self.vmRequests[vmParams['vmId']] = (vmParams, vmRecover)
return response.success(vmList={})
示例14: createVm
def createVm(self, vmParams):
return response.success(vmList=[self])
示例15: succeed_passthrough
def succeed_passthrough(self, foo):
return response.success(foo=foo)