本文整理汇总了Python中azure.storage.blob.BlobService.delete_container方法的典型用法代码示例。如果您正苦于以下问题:Python BlobService.delete_container方法的具体用法?Python BlobService.delete_container怎么用?Python BlobService.delete_container使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类azure.storage.blob.BlobService
的用法示例。
在下文中一共展示了BlobService.delete_container方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: module_impl
# 需要导入模块: from azure.storage.blob import BlobService [as 别名]
# 或者: from azure.storage.blob.BlobService import delete_container [as 别名]
#.........这里部分代码省略.........
results['changed'] = True
results['msg'] = 'Container meta data updated successfully.'
if x_ms_blob_public_access:
access = x_ms_blob_public_access
if x_ms_blob_public_access == 'private':
access = None
if not check_mode:
log('Set access to %s for container %s' % (access, container_name))
bs.set_container_acl(container_name=container_name, x_ms_blob_public_access=access)
results['changed'] = True
results['msg'] = 'Container ACL updated successfully.'
if permissions:
if hours == 0 and days == 0:
raise Exception("Parameter error: expecting hours > 0 or days > 0")
id = "%s-%s" % (container_name, permissions)
si = get_identifier(id, hours, days, permissions)
identifiers = SignedIdentifiers()
identifiers.signed_identifiers.append(si)
if not check_mode:
log('Set permissions to %s for container %s' % (permissions, container_name))
bs.set_container_acl(container_name=container_name,signed_identifiers=identifiers)
results['changed'] = True
results['msg'] = 'Container ACL updated successfully.'
results['container'] = get_container_facts(bs, container_name)
return results
if mode == 'delete':
container = get_container_facts(bs, container_name)
if container is None:
results['msg'] = "Container %s could not be found." % container_name
return results
if not check_mode:
log('Deleting container %s' % container_name)
bs.delete_container(container_name)
results['changed'] = True
results['msg'] = 'Container deleted successfully.'
return results
if mode == 'delete_blob':
if blob_name is None:
raise Exception("Parameter error: blob_name cannot be None.")
container = container_check(bs, container_name)
blob = get_blob_facts(bs, container_name, blob_name)
if not blob:
results['msg'] = 'Blob %s could not be found in container %s.' % (blob_name, container_name)
return results
if not check_mode:
log('Deleteing %s from container %s.' % (blob_name, container_name))
bs.delete_blob(container_name, blob_name)
results['changed'] = True
results['msg'] = 'Blob successfully deleted.'
return results
if mode == 'put':
if not blob_name:
raise Exception("Parameter error: blob_name cannot be None.")
if not file_path :
raise Exception("Parameter error: file_path cannot be None.")
if not path_check(file_path):
raise Exception("File %s does not exist." % file_path)
示例2: AzureFS
# 需要导入模块: from azure.storage.blob import BlobService [as 别名]
# 或者: from azure.storage.blob.BlobService import delete_container [as 别名]
#.........这里部分代码省略.........
def mkdir(self, path, mode):
if path.count('/') <= 1: # create on root
name = path[1:]
if not 3 <= len(name) <= 63:
log.error("Container names can be 3 through 63 chars long.")
raise FuseOSError(ENAMETOOLONG)
if name is not name.lower():
log.error("Container names cannot contain uppercase \
characters.")
raise FuseOSError(EACCES)
if name.count('--') > 0:
log.error('Container names cannot contain consecutive \
dashes (-).')
raise FuseOSError(EAGAIN)
#TODO handle all "-"s must be preceded by letter or numbers
#TODO starts with only letter or number, can contain letter, nr,'-'
resp = self.blobs.create_container(name)
if resp:
self.rebuild_container_list()
log.info("CONTAINER %s CREATED" % name)
else:
raise FuseOSError(EACCES)
log.error("Invalid container name or container already \
exists.")
else:
raise FuseOSError(ENOSYS) # TODO support 2nd+ level mkdirs
def rmdir(self, path):
if path.count('/') == 1:
c_name = path[1:]
resp = self.blobs.delete_container(c_name)
if resp:
if path in self.containers:
del self.containers[path]
else:
raise FuseOSError(EACCES)
else:
raise FuseOSError(ENOSYS) # TODO support 2nd+ level mkdirs
def create(self, path, mode):
node = dict(st_mode=(S_IFREG | mode), st_size=0, st_nlink=1,
st_uid=getuid(), st_mtime=time.time())
d, f = self._parse_path(path)
if not f:
log.error("Cannot create files on root level: /")
raise FuseOSError(ENOSYS)
dir = self._get_dir(d, True)
if not dir:
raise FuseOSError(EIO)
dir['files'][f] = node
return self.open(path, data='') # reusing handler provider
def open(self, path, flags=0, data=None):
if data == None: # download contents
c_name = self.parse_container(path)
f_name = path[path.find('/', 1) + 1:]
try:
data = self.blobs.get_blob(c_name, f_name)
示例3: _cleanUpExternalStore
# 需要导入模块: from azure.storage.blob import BlobService [as 别名]
# 或者: from azure.storage.blob.BlobService import delete_container [as 别名]
def _cleanUpExternalStore(self, containerName):
from toil.jobStores.azureJobStore import _fetchAzureAccountKey
from azure.storage.blob import BlobService
blobService = BlobService(account_key=_fetchAzureAccountKey(self.accountName),
account_name=self.accountName)
blobService.delete_container(containerName)
示例4: AzureFS
# 需要导入模块: from azure.storage.blob import BlobService [as 别名]
# 或者: from azure.storage.blob.BlobService import delete_container [as 别名]
#.........这里部分代码省略.........
else:
file_obj = self._get_file(path)
if file_obj:
return file_obj
log.warning("getattr: no such file: %s", path)
raise FuseOSError(errno.ENOENT)
def mkdir(self, path, mode):
if path.count('/') <= 1: # create on root
name = path[1:]
if not 3 <= len(name) <= 63:
log.error("Container names can be 3 through 63 chars long")
raise FuseOSError(errno.ENAMETOOLONG)
if not re.match(RE_CONTAINER_NAME, name):
log.error("Invalid container name: '%s'", name)
raise FuseOSError(errno.EACCES)
resp = self.blobs.create_container(name)
if resp:
self._rebuild_container_list()
log.info("CONTAINER %s CREATED", name)
else:
log.error("Invalid container name or container already exists")
raise FuseOSError(errno.EACCES)
else:
# TODO: Support 2nd+ level directory creation
raise FuseOSError(errno.ENOSYS)
def rmdir(self, path):
if path.count('/') == 1:
c_name = path[1:]
resp = self.blobs.delete_container(c_name)
if resp:
if path in self.containers:
del self.containers[path]
else:
raise FuseOSError(errno.EACCES)
else:
# TODO: Support 2nd+ level directories
raise FuseOSError(errno.ENOSYS)
def create(self, path, mode, fi=None):
node = make_stat(stat.S_IFREG | mode)
d, f = self._parse_path(path)
if not f:
log.error("Cannot create files on root level: /")
raise FuseOSError(errno.ENOSYS)
if f == ".__refresh_cache__":
log.info("Refresh cache forced (%s)" % f)
self._get_dir(path, True, True)
return self.open(path, data='')
directory = self._get_dir(d, True)
if not directory:
raise FuseOSError(errno.EIO)
directory['files'][f] = node
return self.open(path, data='') # reusing handler provider
def open(self, path, flags=0, data=None):
log.info("open: path=%s; flags=%s", path, flags)