mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Feature to Specify AZURE blob storage type (#30660)
* Feature to Specify AZURE blob storage type * Feature to Specify AZURE blob storage type * Feature to Specify AZURE blob storage type * Revert "Feature to Specify AZURE blob storage type" This reverts commit 1d33997769ef3763a2eb434404c918134761635f. modified: lib/ansible/module_utils/azure_rm_common.py * Feature to Specify AZURE blob storage type
This commit is contained in:
parent
cddff32792
commit
d122a693d1
2 changed files with 19 additions and 3 deletions
|
@ -548,7 +548,7 @@ class AzureRMModuleBase(object):
|
|||
self.fail("Error {0} has a provisioning state of {1}. Expecting state to be {2}.".format(
|
||||
azure_object.name, azure_object.provisioning_state, AZURE_SUCCESS_STATE))
|
||||
|
||||
def get_blob_client(self, resource_group_name, storage_account_name):
|
||||
def get_blob_client(self, resource_group_name, storage_account_name, storage_blob_type='block'):
|
||||
keys = dict()
|
||||
try:
|
||||
# Get keys from the storage account
|
||||
|
@ -559,7 +559,12 @@ class AzureRMModuleBase(object):
|
|||
|
||||
try:
|
||||
self.log('Create blob service')
|
||||
return CloudStorageAccount(storage_account_name, account_keys.keys[0].value).create_block_blob_service()
|
||||
if storage_blob_type == 'page':
|
||||
return CloudStorageAccount(storage_account_name, account_keys.keys[0].value).create_page_blob_service()
|
||||
elif storage_blob_type == 'block':
|
||||
return CloudStorageAccount(storage_account_name, account_keys.keys[0].value).create_block_blob_service()
|
||||
else:
|
||||
raise Exception("Invalid storage blob type defined.")
|
||||
except Exception as exc:
|
||||
self.fail("Error creating blob service client for storage account {0} - {1}".format(storage_account_name,
|
||||
str(exc)))
|
||||
|
|
|
@ -37,6 +37,15 @@ options:
|
|||
default: null
|
||||
aliases:
|
||||
- blob_name
|
||||
blob_type:
|
||||
description:
|
||||
- Type of Blob Object.
|
||||
required: false
|
||||
default: block
|
||||
choices:
|
||||
- block
|
||||
- page
|
||||
version_added: "2.5"
|
||||
container:
|
||||
description:
|
||||
- Name of a blob container within the storage account.
|
||||
|
@ -212,6 +221,7 @@ class AzureRMStorageBlob(AzureRMModuleBase):
|
|||
self.module_arg_spec = dict(
|
||||
storage_account_name=dict(required=True, type='str', aliases=['account_name', 'storage_account']),
|
||||
blob=dict(type='str', aliases=['blob_name']),
|
||||
blob_type=dict(type='str', default='block', choices=['block','page']),
|
||||
container=dict(required=True, type='str', aliases=['container_name']),
|
||||
dest=dict(type='str'),
|
||||
force=dict(type='bool', default=False),
|
||||
|
@ -234,6 +244,7 @@ class AzureRMStorageBlob(AzureRMModuleBase):
|
|||
self.storage_account_name = None
|
||||
self.blob = None
|
||||
self.blob_obj = None
|
||||
self.blob_type = None
|
||||
self.container = None
|
||||
self.container_obj = None
|
||||
self.dest = None
|
||||
|
@ -264,7 +275,7 @@ class AzureRMStorageBlob(AzureRMModuleBase):
|
|||
|
||||
# add file path validation
|
||||
|
||||
self.blob_client = self.get_blob_client(self.resource_group, self.storage_account_name)
|
||||
self.blob_client = self.get_blob_client(self.resource_group, self.storage_account_name, self.blob_type)
|
||||
self.container_obj = self.get_container()
|
||||
|
||||
if self.blob is not None:
|
||||
|
|
Loading…
Reference in a new issue