本文整理汇总了Python中swiftclient.Connection.post_account方法的典型用法代码示例。如果您正苦于以下问题:Python Connection.post_account方法的具体用法?Python Connection.post_account怎么用?Python Connection.post_account使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类swiftclient.Connection
的用法示例。
在下文中一共展示了Connection.post_account方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from swiftclient import Connection [as 别名]
# 或者: from swiftclient.Connection import post_account [as 别名]
#.........这里部分代码省略.........
try:
self.success = True
self.cdn_containers[self.enabled_container]['cdn_enabled'] = False
# This would take some time to be propagated
# We will keep checking until it's disabled.
self.timer = 0
while self.cdn_containers[
self.enabled_container]['cdn_enabled'] is True:
if self.timer > 90:
break
sleep(1)
self.timer = self.timer + 1
continue
self.logger.warning("Deleting Container: %s", self.container['name'])
self.swift_client.delete_container(self.container_name)
self.cdn_client.delete_container(self.container_name)
except Exception as e:
self.success, self.overall_success = False, False
self.failure = e
self.logger.error(
"Delete CDN Container Failed %s", sys.exc_info()[1])
@monitoring.timeit
def update_metadata(self):
"""
Update the metadata of the account
"""
try:
self.success = True
headers = {"X-Account-Meta-Temp-User": "updatemetadata-user"}
self.swift_client.post_account(headers)
self.logger.warning(
"Posting Metadata to Account succeeded: %s", headers)
except Exception as e:
self.success, self.overall_success = False, False
self.failure = e
self.logger.error(
"Updating MetaData for CDN Container Failed %s",
sys.exc_info()[1])
@monitoring.timeit
def retrieve_metadata(self):
"""
Retrieve the metadata of the account
"""
try:
self.success = True
account_info = self.swift_client.head_account()
self.logger.warning(
"Getting Account Head succeeded: %s", account_info)
except Exception as e:
self.success, self.overall_success = False, False
self.failure = e
self.logger.error(
"Retrieve MetaData from CDN Container Failed %s",
sys.exc_info()[1])
def run(self):
"""
This is a driver function that runs all the other methods in the Class
"""
self.create_cdn_enabled_container()
self.list_containers()
self.select_container()
# Uploading metadata and retrieving it
self.update_metadata()
self.retrieve_metadata()
# First create a test object. Next, test the presence of it, using
# bot a http and hppts url. Then delete the object.
self.upload_object()
self.check_http_url()
self.check_https_url()
if hasattr(self, 'object'):
self.delete_object()
self.delete_container()
if self.overall_success is True:
exit(0)
else:
exit(1)
示例2: __init__
# 需要导入模块: from swiftclient import Connection [as 别名]
# 或者: from swiftclient.Connection import post_account [as 别名]
#.........这里部分代码省略.........
except Exception as e:
self.success, self.overall_success = False, False
self.failure = e
self.logger.error(
"Retrieving Account Head failed %s", sys.exc_info()[1])
@monitoring.timeit
def retrieve_metadata_container(self):
"""
Retrieve the metadata of the container
"""
try:
self.success = True
container_info = self.swift_client.head_container(self.container)
self.logger.warning(
"Getting Container Head succeeded: %s", container_info)
except Exception as e:
self.success, self.overall_success = False, False
self.failure = e
self.logger.error(
"Getting Container Head failed: %s", sys.exc_info()[1])
@monitoring.timeit
def update_metadata_account(self):
"""
Update the metadata of the account
"""
try:
self.success = True
headers = {"X-Account-Meta-Temp-User": "testuser"}
self.swift_client.post_account(headers)
self.logger.warning(
"Posting Metadata to Account succeeded: %s", headers)
except Exception as e:
self.success, self.overall_success = False, False
self.failure = e
self.logger.error(
"Posting Metadata to Account failed %s", sys.exc_info()[1])
@monitoring.timeit
def update_metadata_container(self):
"""
Update the metadata of the container
"""
try:
self.success = True
headers = {"X-Container-Meta-Temp-User": "testuser"}
self.swift_client.post_container(self.container, headers)
self.logger.warning(
"Posting Metadata to Container succeeded: %s", headers)
except Exception as e:
self.success, self.overall_success = False, False
self.failure = e
self.logger.error(
"Posting Metadata to Container failed %s", sys.exc_info()[1])
@monitoring.timeit
def update_metadata_object(self):
"""
Update the metadata of the object