本文整理匯總了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