def validate_encryption(namespace): ''' Builds up the encryption object for storage account operations based on the list of services passed in. ''' if namespace.encryption: from azure.mgmt.storage.models import Encryption, EncryptionServices, EncryptionService services = {service: EncryptionService(True) for service in namespace.encryption} namespace.encryption = Encryption(EncryptionServices(**services))
def create_storage(self): """Function that creates a new storage account :raises: :class:`Exception` """ if not self._resource_management_integration_service\ .resource_group_exists( self._vdc_storage_account_resource_group): self._logger.info( 'No resource group: {} found, provisioning one.'.format( self._vdc_storage_account_resource_group)) self._resource_management_integration_service\ .create_or_update_resource_group( self._vdc_storage_account_resource_group, self._location) self._logger.info('Attempting authentication.') parameters: StorageAccountCreateParameters encryptionService = EncryptionService(enabled=True) encryptionServices = EncryptionServices(blob=encryptionService) encryption = Encryption(services=encryptionServices) parameters = StorageAccountCreateParameters( sku=Sku(name='Standard_LRS'), kind='BlobStorage', location=self._location, encryption=encryption, access_tier='Cool', enable_https_traffic_only=True) self._logger.info( 'creating storage account using rg: {} and account name: {}'. format(self._vdc_storage_account_resource_group, self._vdc_storage_account_name)) async_operation = self._storage_management_client.storage_accounts.create( self._vdc_storage_account_resource_group, self._vdc_storage_account_name, parameters) async_operation.wait() self._logger.info('vdc storage created')