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


Python BlobService.delete_container方法代码示例

本文整理汇总了Python中azure.storage.BlobService.delete_container方法的典型用法代码示例。如果您正苦于以下问题:Python BlobService.delete_container方法的具体用法?Python BlobService.delete_container怎么用?Python BlobService.delete_container使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在azure.storage.BlobService的用法示例。


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

示例1: deprovision

# 需要导入模块: from azure.storage import BlobService [as 别名]
# 或者: from azure.storage.BlobService import delete_container [as 别名]
def deprovision(instance_id):
    """
    Deprovision an existing instance of this service

    DELETE /v2/service_instances/<instance_id>:
        <instance_id> is the Cloud Controller provided
          value used to provision the instance

    return:
        As of API 2.3, an empty JSON document
        is expected
    """
    global subscription_id
    global cert
    global account_name
    global account_key

    if account_name and account_key:
        blob_service = BlobService(account_name, account_key)
        container_name = '{0}-{1}'.format(CONTAINER_NAME_PREFIX, instance_id)
        blob_service.delete_container(container_name)

        if account_name.startswith(STORAGE_ACCOUNT_NAME_PREFIX):
            sms = ServiceManagementService(subscription_id, cert_file)
            sms.delete_storage_account(account_name)

    return jsonify({})
开发者ID:bingosummer,项目名称:azure-storage-service-broker,代码行数:29,代码来源:azurestorageservicebroker.py

示例2: delete

# 需要导入模块: from azure.storage import BlobService [as 别名]
# 或者: from azure.storage.BlobService import delete_container [as 别名]
    def delete(self):

        properties = self.__SMS.get_deployment_by_name(self.name, self.name)
        media_link = properties.role_list.roles[0].os_virtual_hard_disk.media_link
        storage_name = media_link[media_link.find("//") + 2:media_link.find(".blob")]

        from Azure.AzureVolumes.AzureVolumes import AzureVolumescls
        volume_service = AzureVolumescls(credentials=self._credentials)
        volumes = volume_service.list_volumes()
        volume_to_be_deleted = None
        for volume in volumes:
            if volume.instance_id == self.name:
                volume_to_be_deleted = volume
                break

        self.__SMS.delete_deployment(self.name, self.name)
        self.__SMS.delete_hosted_service(self.name)
        volume_to_be_deleted.delete()
        # delete image from storge
        from azure.storage import BlobService

        keys = self.__SMS.get_storage_account_keys(storage_name)
        blob_service = BlobService(account_name=storage_name, account_key=keys.storage_service_keys.primary)

        blob_service.delete_container(self.name, fail_not_exist=True)
开发者ID:Hawkgirl,项目名称:ext_cloud,代码行数:27,代码来源:AzureInstance.py

示例3: test_azure_call

# 需要导入模块: from azure.storage import BlobService [as 别名]
# 或者: from azure.storage.BlobService import delete_container [as 别名]
def test_azure_call(request):
    import os
    try:
        from azure.storage import BlobService
        bs = BlobService(os.environ["AZURE_STORAGE_ACCOUNT"], os.environ["AZURE_STORAGE_ACCESS_KEY"])
        import random
        container_name = hex(int(random.random() * 1000000000))

        bs.create_container(container_name)
        bs.put_blob(container_name, 'testblob', 'hello world\n', 'BlockBlob')
        blob = bs.get_blob(container_name, 'testblob')
        if blob != 'hello world\n':
            return HttpResponse("Failed!", status = '404')
        
        bs.delete_blob(container_name, 'testblob')
        bs.delete_container(container_name)

        return HttpResponse("Succeeded!")
    except:
        try:
            import traceback
        
            return HttpResponse(traceback.format_exc() + str(os.environ.keys()))
        except:
            import traceback
            return HttpResponse(traceback.format_exc())
开发者ID:KuduApps,项目名称:PythonApp,代码行数:28,代码来源:test_urls.py

示例4: do_step

# 需要导入模块: from azure.storage import BlobService [as 别名]
# 或者: from azure.storage.BlobService import delete_container [as 别名]

#.........这里部分代码省略.........
            res = authorizedPost(url, pivnetAPIToken)
            code = res.getcode()

    # releases
    is_release_file = re.compile("^releases\/.+")
    if not os.path.exists("/tmp/releases"):
        os.makedirs("/tmp/releases")

    client = bosh_client.BoshClient("https://10.0.0.4:25555", "admin", "admin")
    storage_account_name = settings["STORAGE-ACCOUNT-NAME"]
    storage_access_key = settings["STORAGE-ACCESS-KEY"]

    blob_service = BlobService(storage_account_name, storage_access_key)
    blob_service.create_container(
        container_name='tempreleases',
        x_ms_blob_public_access='container')

    print "Processing releases."
    for url in release_urls:

        print "Downloading {0}.".format(url)

        if "concourse" in url:
            release_url = "https://s3-us-west-2.amazonaws.com/bosh-azure-releases/concourse.zip"
            res = urllib2.urlopen(release_url)
        else:
            res = authorizedPost(url, pivnetAPIToken)

        code = res.getcode()

        length = int(res.headers["Content-Length"])

        # content-length
        if code is 200:

            total = 0
            pcent = 0.0
            CHUNK = 16 * 1024

            with tempfile.TemporaryFile() as temp:
                while True:
                    chunk = res.read(CHUNK)
                    total += CHUNK
                    pcent = (float(total) / float(length)) * 100

                    sys.stdout.write(
                        "Download progress: %.2f%% (%.2fM)\r" %
                        (pcent, total / 1000000.0))
                    sys.stdout.flush()

                    if not chunk:
                        break

                    temp.write(chunk)

                print "Download complete."

                z = zipfile.ZipFile(temp)
                for name in z.namelist():
                    
                    # is this a release?
                    if is_release_file.match(name):

                        release_filename = "/tmp/{0}".format(name)

                        print "Unpacking {0}.".format(name)
                        z.extract(name, "/tmp")

                        print "Uploading {0} to Azure blob store".format(name)

                        blob_service.put_block_blob_from_path(
                            'tempreleases',
                            name,
                            "/tmp/{0}".format(name),
                            x_ms_blob_content_type='application/x-compressed'
                        )

                        os.unlink(release_filename)
                        blob_url = "http://{0}.blob.core.windows.net/{1}/{2}".format(
                            storage_account_name, 'tempreleases', name)

                        print "Uploading release {0} to BOSH director.".format(name)

                        task_id = client.upload_release(blob_url)
                        client.wait_for_task(task_id)

                z.close()
                temp.close()

    blob_service.delete_container("tempreleases")

    # stemcells
    print "Processing stemcells."

    for url in stemcell_urls:
        print "Processing stemcell {0}".format(url)
        task_id = client.upload_stemcell(url)
        client.wait_for_task(task_id)

    return context
开发者ID:ooha-m,项目名称:test-base,代码行数:104,代码来源:download_from_pivnet_upload_to_bosh.py

示例5: AzureFS

# 需要导入模块: from azure.storage import BlobService [as 别名]
# 或者: from azure.storage.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)
开发者ID:QuasarSE,项目名称:azurefs,代码行数:70,代码来源:azurefs.py

示例6: apathetic_container_delete

# 需要导入模块: from azure.storage import BlobService [as 别名]
# 或者: from azure.storage.BlobService import delete_container [as 别名]
def apathetic_container_delete(container_name, *args, **kwargs):
    conn = BlobService(*args, **kwargs)
    conn.delete_container(container_name)

    return conn
开发者ID:DataDog,项目名称:wal-e,代码行数:7,代码来源:wabs_integration_help.py

示例7: BlobService

# 需要导入模块: from azure.storage import BlobService [as 别名]
# 或者: from azure.storage.BlobService import delete_container [as 别名]
blob_service = BlobService(account_name, account_key)

for container in blob_service.list_containers():
    c = container.name
    if c == "heartbeat": continue
    if options.date and not ( c == "processed-"+options.date ): continue
    if debug: sys.stderr.write("Processing container: "+str(c)+"\n")
    for b in blob_service.list_blobs(c):
        if debug: sys.stderr.write("Processing blob: "+str(b.name)+"\n")
        data = blob_service.get_blob(c, b.name)
        cs = StringIO.StringIO(data)
        gzipstream = gzip.GzipFile(fileobj=cs)
        if output_format == "txt":
            print gzipstream.read()
        elif output_format == "json":
            d = {}
            i = 0
            ds = gzipstream.read()
            # some DCU entries contains more than 28 values (outside the
            # definition of the headers)
            for x in ds.strip().split("\t")[:27]:
                d[headers[i]] = x
                i=i+1
            print (json.dumps(d, sort_keys=True))
        if options.clear:
            if debug: sys.stderr.write("Deleting blob: "+str(b.name)+"\n")
            blob_service.delete_blob(c, b.name)
    if options.clear:
        if debug: sys.stderr.write("Deleting container: "+str(c)+"\n")
        blob_service.delete_container(c)
开发者ID:adulau,项目名称:dcu-tools,代码行数:32,代码来源:dcu-fetch.py

示例8: delete_blobs

# 需要导入模块: from azure.storage import BlobService [as 别名]
# 或者: from azure.storage.BlobService import delete_container [as 别名]
def delete_blobs():
    print "deleting blobs: " + ", ".join(BLOB_CONTAINERS)
    for i in range(len(ACCOUNT)):
        bs = BlobService(ACCOUNT[i], KEY[i])
        for container in BLOB_CONTAINERS:
            bs.delete_container(container)
开发者ID:CICS525,项目名称:DBLikeProject,代码行数:8,代码来源:AzureCleaner.py


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