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


Python storage.StorageManagementClient方法代码示例

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


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

示例1: create_storage_account

# 需要导入模块: from azure.mgmt import storage [as 别名]
# 或者: from azure.mgmt.storage import StorageManagementClient [as 别名]
def create_storage_account(credentials, subscription_id, **kwargs):
    """
        Create a Storage account
        :param credentials: msrestazure.azure_active_directory.AdalAuthentication
        :param subscription_id: str
        :param **resource_group: str
        :param **storage_account: str
        :param **region: str
    """
    storage_management_client = StorageManagementClient(credentials, subscription_id)
    storage_account = storage_management_client.storage_accounts.create(
        resource_group_name=kwargs.get("resource_group", DefaultSettings.resource_group),
        account_name=kwargs.get("storage_account", DefaultSettings.storage_account),
        parameters=StorageAccountCreateParameters(
            sku=Sku(SkuName.standard_lrs), kind=Kind.storage, location=kwargs.get('region', DefaultSettings.region)))
    return storage_account.result().id 
开发者ID:Azure,项目名称:aztk,代码行数:18,代码来源:account_setup.py

示例2: get_blob_client

# 需要导入模块: from azure.mgmt import storage [as 别名]
# 或者: from azure.mgmt.storage import StorageManagementClient [as 别名]
def get_blob_client() -> blob.BlockBlobService:
    if not storage_resource_id:
        return blob.BlockBlobService(
            account_name=storage_account_name, account_key=storage_account_key, endpoint_suffix=storage_account_suffix)
    else:
        credentials = ServicePrincipalCredentials(
            client_id=client_id, secret=credential, tenant=tenant_id, resource="https://management.core.windows.net/")
        m = RESOURCE_ID_PATTERN.match(storage_resource_id)
        accountname = m.group("account")
        subscription = m.group("subscription")
        resourcegroup = m.group("resourcegroup")
        mgmt_client = StorageManagementClient(credentials, subscription)
        key = (mgmt_client.storage_accounts.list_keys(resource_group_name=resourcegroup, account_name=accountname)
               .keys[0].value)
        storage_client = CloudStorageAccount(accountname, key)
        return storage_client.create_block_blob_service() 
开发者ID:Azure,项目名称:aztk,代码行数:18,代码来源:config.py

示例3: storage_client

# 需要导入模块: from azure.mgmt import storage [as 别名]
# 或者: from azure.mgmt.storage import StorageManagementClient [as 别名]
def storage_client(self):
        """
        Uses client from cli so that users can use az login to get their credentials

        Returns:
             Storage Client
        """
        if not self.client:
            resource_group = self.desired_state_definition.get("resource_group")
            storage_account = self.desired_state_definition.get("storage_account")
            if resource_group and storage_account:
                client = get_client_from_cli_profile(StorageManagementClient)
                storage_keys = client.storage_accounts.list_keys(resource_group, storage_account)
                storage_keys = {v.key_name: v.value for v in storage_keys.keys}

                self.client = CloudStorageAccount(storage_account, storage_keys['key1'])
            else:
                raise Exception("azure_resource.resource_group and azure_resource.storage_account must be defined")
        return self.client 
开发者ID:capitalone,项目名称:Particle-Cloud-Framework,代码行数:21,代码来源:azure_resource.py

示例4: create_azure_session

# 需要导入模块: from azure.mgmt import storage [as 别名]
# 或者: from azure.mgmt.storage import StorageManagementClient [as 别名]
def create_azure_session(token, service):
    assert service in ['compute', 'network', 'security', 'storage', 'resource']
    assert isinstance(token, ServicePrincipalCredentials)
    platform = config.profile.get('platform')
    if 'subscription' in platform and platform['subscription']:
        sub_id = platform['subscription']
    else:
        raise ValueError("Subscription ID not in Azure Platform Definition")
    if service == 'compute':
        from azure.mgmt.compute import ComputeManagementClient
        return ComputeManagementClient(token, sub_id)
    if service == 'network':
        from azure.mgmt.network import NetworkManagementClient
        return NetworkManagementClient(token, sub_id)
    if service == 'storage':
        from azure.mgmt.storage import StorageManagementClient
        return StorageManagementClient(token, sub_id)
    if service == 'resource':
        from azure.mgmt.resource import ResourceManagementClient
        return ResourceManagementClient(token, sub_id) 
开发者ID:Chaffelson,项目名称:whoville,代码行数:22,代码来源:infra.py

示例5: get_storage_account

# 需要导入模块: from azure.mgmt import storage [as 别名]
# 或者: from azure.mgmt.storage import StorageManagementClient [as 别名]
def get_storage_account(group_name, storage_name, credentials, subscription_id):
        """
        Get the Storage Account named storage_name in group_name, if it not exists return None
        """
        try:
            storage_client = StorageManagementClient(credentials, subscription_id)
            return storage_client.storage_accounts.get_properties(group_name, storage_name)
        except CloudError as cex:
            if cex.status_code == 404:
                return None
            else:
                raise cex 
开发者ID:grycap,项目名称:im,代码行数:14,代码来源:Azure.py

示例6: get_client

# 需要导入模块: from azure.mgmt import storage [as 别名]
# 或者: from azure.mgmt.storage import StorageManagementClient [as 别名]
def get_client(self, subscription_id: str):
        return StorageManagementClient(self.credentials.get_credentials('arm'),
                                       subscription_id=subscription_id) 
开发者ID:nccgroup,项目名称:ScoutSuite,代码行数:5,代码来源:storageaccounts.py

示例7: storage_client

# 需要导入模块: from azure.mgmt import storage [as 别名]
# 或者: from azure.mgmt.storage import StorageManagementClient [as 别名]
def storage_client(self):
        """Get storage client with subscription and credentials."""
        return StorageManagementClient(self.credentials, self.subscription_id) 
开发者ID:project-koku,项目名称:koku,代码行数:5,代码来源:client.py

示例8: test_storage_client

# 需要导入模块: from azure.mgmt import storage [as 别名]
# 或者: from azure.mgmt.storage import StorageManagementClient [as 别名]
def test_storage_client(self, _):
        """Test the storage_client property."""
        obj = AzureClientFactory(
            subscription_id=FAKE.uuid4(),
            tenant_id=FAKE.uuid4(),
            client_id=FAKE.uuid4(),
            client_secret=FAKE.word(),
            cloud=random.choice(self.clouds),
        )
        self.assertTrue(isinstance(obj.storage_client, StorageManagementClient)) 
开发者ID:project-koku,项目名称:koku,代码行数:12,代码来源:tests_client.py

示例9: test_cloud_storage_account

# 需要导入模块: from azure.mgmt import storage [as 别名]
# 或者: from azure.mgmt.storage import StorageManagementClient [as 别名]
def test_cloud_storage_account(self, _):
        """Test the cloud_storage_account method."""
        subscription_id = FAKE.uuid4()
        resource_group_name = FAKE.word()
        storage_account_name = FAKE.word()
        obj = AzureClientFactory(
            subscription_id=subscription_id,
            tenant_id=FAKE.uuid4(),
            client_id=FAKE.uuid4(),
            client_secret=FAKE.word(),
            cloud=random.choice(self.clouds),
        )
        with patch.object(StorageManagementClient, "storage_accounts", return_value=None):
            cloud_account = obj.cloud_storage_account(resource_group_name, storage_account_name)
            self.assertTrue(isinstance(cloud_account, BlobServiceClient)) 
开发者ID:project-koku,项目名称:koku,代码行数:17,代码来源:tests_client.py

示例10: __init__

# 需要导入模块: from azure.mgmt import storage [as 别名]
# 或者: from azure.mgmt.storage import StorageManagementClient [as 别名]
def __init__(self):
        os.environ['AZURE_AUTH_LOCATION'] = '/root/azure_auth.json'
        self.compute_client = get_client_from_auth_file(ComputeManagementClient)
        self.resource_client = get_client_from_auth_file(ResourceManagementClient)
        self.network_client = get_client_from_auth_file(NetworkManagementClient)
        self.storage_client = get_client_from_auth_file(StorageManagementClient)
        self.datalake_client = get_client_from_auth_file(DataLakeStoreAccountManagementClient)
        self.authorization_client = get_client_from_auth_file(AuthorizationManagementClient)
        self.sp_creds = json.loads(open(os.environ['AZURE_AUTH_LOCATION']).read())
        self.dl_filesystem_creds = lib.auth(tenant_id=json.dumps(self.sp_creds['tenantId']).replace('"', ''),
                                            client_secret=json.dumps(self.sp_creds['clientSecret']).replace('"', ''),
                                            client_id=json.dumps(self.sp_creds['clientId']).replace('"', ''),
                                            resource='https://datalake.azure.net/') 
开发者ID:apache,项目名称:incubator-dlab,代码行数:15,代码来源:actions_lib.py

示例11: make_blob_client

# 需要导入模块: from azure.mgmt import storage [as 别名]
# 或者: from azure.mgmt.storage import StorageManagementClient [as 别名]
def make_blob_client(secrets):
    """
        Creates a blob client object
        :param str storage_account_key: storage account key
        :param str storage_account_name: storage account name
        :param str storage_account_suffix: storage account suffix
    """

    if secrets.shared_key:
        # Set up SharedKeyCredentials
        blob_client = blob.BlockBlobService(
            account_name=secrets.shared_key.storage_account_name,
            account_key=secrets.shared_key.storage_account_key,
            endpoint_suffix=secrets.shared_key.storage_account_suffix,
        )
    else:
        # Set up ServicePrincipalCredentials
        arm_credentials = ServicePrincipalCredentials(
            client_id=secrets.service_principal.client_id,
            secret=secrets.service_principal.credential,
            tenant=secrets.service_principal.tenant_id,
            resource="https://management.core.windows.net/",
        )
        match = RESOURCE_ID_PATTERN.match(secrets.service_principal.storage_account_resource_id)
        accountname = match.group("account")
        subscription = match.group("subscription")
        resourcegroup = match.group("resourcegroup")
        mgmt_client = StorageManagementClient(arm_credentials, subscription)
        key = (retry_function(
            mgmt_client.storage_accounts.list_keys,
            10,
            1,
            Exception,
            resource_group_name=resourcegroup,
            account_name=accountname,
        ).keys[0].value)
        storage_client = CloudStorageAccount(accountname, key)
        blob_client = storage_client.create_block_blob_service()

    return blob_client 
开发者ID:Azure,项目名称:aztk,代码行数:42,代码来源:azure_api.py

示例12: make_table_service

# 需要导入模块: from azure.mgmt import storage [as 别名]
# 或者: from azure.mgmt.storage import StorageManagementClient [as 别名]
def make_table_service(secrets):
    if secrets.shared_key:
        table_service = TableService(
            account_name=secrets.shared_key.storage_account_name,
            account_key=secrets.shared_key.storage_account_key,
            endpoint_suffix=secrets.shared_key.storage_account_suffix,
        )
    else:
        arm_credentials = ServicePrincipalCredentials(
            client_id=secrets.service_principal.client_id,
            secret=secrets.service_principal.credential,
            tenant=secrets.service_principal.tenant_id,
            resource="https://management.core.windows.net/",
        )
        match = RESOURCE_ID_PATTERN.match(secrets.service_principal.storage_account_resource_id)
        accountname = match.group("account")
        subscription = match.group("subscription")
        resourcegroup = match.group("resourcegroup")
        mgmt_client = StorageManagementClient(arm_credentials, subscription)
        key = (retry_function(
            mgmt_client.storage_accounts.list_keys,
            10,
            1,
            Exception,
            resource_group_name=resourcegroup,
            account_name=accountname,
        ).keys[0].value)
        table_service = TableService(account_name=accountname, account_key=key)

    return table_service 
开发者ID:Azure,项目名称:aztk,代码行数:32,代码来源:azure_api.py

示例13: storage_client

# 需要导入模块: from azure.mgmt import storage [as 别名]
# 或者: from azure.mgmt.storage import StorageManagementClient [as 别名]
def storage_client(self):
        return StorageManagementClient(self.credentials, self.subscription_id) 
开发者ID:RedHatQE,项目名称:wrapanapi,代码行数:4,代码来源:msazure.py

示例14: __init__

# 需要导入模块: from azure.mgmt import storage [as 别名]
# 或者: from azure.mgmt.storage import StorageManagementClient [as 别名]
def __init__(self, cred, subs_id, my_storage_rg, vmss_rg_name, vmss_name, storage, pan_handle, logger=None):
        self.credentials = cred
        self.subscription_id = subs_id
        self.logger = logger
        self.hub_name = vmss_rg_name
        self.storage_name = storage
        self.panorama_handler = pan_handle
        self.vmss_table_name = re.sub(self.ALPHANUM, '', vmss_name + 'vmsstable')
        self.vmss_rg_name = vmss_rg_name

        try:
            self.resource_client = ResourceManagementClient(cred, subs_id)
            self.compute_client = ComputeManagementClient(cred, subs_id)
            self.network_client = NetworkManagementClient(cred, subs_id)
            self.store_client = StorageManagementClient(cred, subs_id)
            store_keys = self.store_client.storage_accounts.list_keys(my_storage_rg, storage).keys[0].value
            self.table_service = TableService(account_name=storage,
                                              account_key=store_keys)
        except Exception as e:
            self.logger.error("Getting Azure Infra handlers failed %s" % str(e))
            raise e


        rg_list = self.resource_client.resource_groups.list()
        self.managed_spokes = []
        self.managed_spokes.append(vmss_rg_name)
        self.new_spokes = [] 
开发者ID:PaloAltoNetworks,项目名称:pan-fca,代码行数:29,代码来源:monitor.py

示例15: generate_options_for_storage_account

# 需要导入模块: from azure.mgmt import storage [as 别名]
# 或者: from azure.mgmt.storage import StorageManagementClient [as 别名]
def generate_options_for_storage_account(server=None, **kwargs):
    discovered_az_stores = []
    for handler in AzureARMHandler.objects.all():
        set_progress('Connecting to Azure Storage \
        for handler: {}'.format(handler))
        credentials = ServicePrincipalCredentials(
            client_id=handler.client_id,
            secret=handler.secret,
            tenant=handler.tenant_id
        )
        azure_client = storage.StorageManagementClient(credentials, handler.serviceaccount)
        set_progress("Connection to Azure established")
        for st in azure_client.storage_accounts.list():
            discovered_az_stores.append(st.name)
    return discovered_az_stores 
开发者ID:CloudBoltSoftware,项目名称:cloudbolt-forge,代码行数:17,代码来源:create.py


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