def _Create(self): """Creates an Azure Files share. For Standard Files, see https://docs.microsoft.com/en-us/azure/storage/files/storage-how-to-create-file-share#create-file-share-through-command-line-interface-cli and for Premium Files, see https://docs.microsoft.com/en-us/azure/storage/files/storage-how-to-create-premium-fileshare#create-a-premium-file-share-using-azure-cli """ logging.info('Creating SMB server %s', self.name) if FLAGS.smb_tier == 'Standard_LRS': storage_account_number = azure_network.AzureStorageAccount.total_storage_accounts - 1 self.storage_account_name = 'pkb%s' % FLAGS.run_uri + 'storage' + str( storage_account_number) elif FLAGS.smb_tier == 'Premium_LRS': storage_account_number = ( azure_network.AzureStorageAccount.total_storage_accounts) self.storage_account_name = 'pkb%s' % FLAGS.run_uri + 'filestorage' + str( storage_account_number) # Premium Files uses a different storage account kind from Standard Files. # See links in description for more details. self.storage_account = azure_network.AzureStorageAccount( storage_type='Premium_LRS', region=FLAGS.zone[0] or 'westus2', name=self.storage_account_name, kind='FileStorage', resource_group=self.resource_group, use_existing=False) self.storage_account.Create() self.connection_args = util.GetAzureStorageConnectionArgs( self.storage_account_name, self.resource_group.args) self.storage_account_key = util.GetAzureStorageAccountKey( self.storage_account_name, self.resource_group.args) self._AzureSmbCommand('create')
def PrepareService(self, location, existing_storage_account_and_resource_group=None): # abs is "Azure Blob Storage" prefix = 'pkb%sabs' % FLAGS.run_uri # Maybe extract existing storage account and resource group names existing_storage_account, existing_resource_group = None, None if existing_storage_account_and_resource_group: existing_storage_account, existing_resource_group = \ existing_storage_account_and_resource_group assert existing_storage_account is not None assert existing_resource_group is not None storage_account_name = existing_storage_account or prefix + 'storage' resource_group_name = existing_resource_group or prefix + '-resource-group' # We use a separate resource group so that our buckets can optionally stick # around after PKB runs. This is useful for things like cold reads tests self.resource_group = \ azure_network.AzureResourceGroup(resource_group_name, existing_resource_group is not None) self.resource_group.Create() # We use a different Azure storage account than the VM account # because a) we need to be able to set the storage class # separately, including using a blob-specific storage account and # b) this account might be in a different location than any # VM-related account. self.storage_account = azure_network.AzureStorageAccount( FLAGS.azure_storage_type, location or DEFAULT_AZURE_REGION, storage_account_name, kind=FLAGS.azure_blob_account_kind, resource_group=self.resource_group, use_existing=existing_storage_account is not None) self.storage_account.Create()
def PrepareService(self, location): # abs is "Azure Blob Storage" prefix = 'pkb%sabs' % FLAGS.run_uri self.resource_group = azure_network.GetResourceGroup() # We use a different Azure storage account than the VM account # because a) we need to be able to set the storage class # separately, including using a blob-specific storage account and # b) this account might be in a different location than any # VM-related account. self.storage_account = azure_network.AzureStorageAccount( FLAGS.azure_storage_type, location or DEFAULT_AZURE_REGION, prefix + 'storage', kind=FLAGS.azure_blob_account_kind) self.storage_account.Create()
def PrepareService(self, location, existing_storage_account_and_resource_group=None, try_to_create_storage_account_and_resource_group=False): """See base class (without additional args). TODO(deitz): We should use the same interface across the clouds without additional arguments. Args: location: where to place our data. existing_storage_account_and_resource_group: An existing storage account and resource group for reading objects that may have already been created. try_to_create_storage_account_and_resource_group: Whether to try to create the storage account and resource group in case it does not exist yet. This supports invoking the object_storage_service_benchmark multiple times on the same bucket name and creating the resource group the first time. While this defaults to False, if there is no existing storage account and resource group passed to this function via existing_storage_account_and_resource_group, then one will be created. """ # abs is "Azure Blob Storage" prefix = 'pkb%sabs' % FLAGS.run_uri # Maybe extract existing storage account and resource group names existing_storage_account, existing_resource_group = None, None if existing_storage_account_and_resource_group: existing_storage_account, existing_resource_group = \ existing_storage_account_and_resource_group assert existing_storage_account is not None assert existing_resource_group is not None else: # We don't have an existing storage account or resource group so we better # create one. try_to_create_storage_account_and_resource_group = True storage_account_name = existing_storage_account or prefix + 'storage' resource_group_name = existing_resource_group or prefix + '-resource-group' # If we have an existing storage account and resource, we typically would # not try to create it. If try_to_create_storage_account_and_resource_group # is True, however, then we do try to create it. In this case, we shouldn't # raise on a failure since it may already exist. raise_on_create_failure = not ( existing_storage_account_and_resource_group and try_to_create_storage_account_and_resource_group) # We use a separate resource group so that our buckets can optionally stick # around after PKB runs. This is useful for things like cold reads tests self.resource_group = \ azure_network.AzureResourceGroup( resource_group_name, use_existing=not try_to_create_storage_account_and_resource_group, timeout_minutes=max(FLAGS.timeout_minutes, FLAGS.persistent_timeout_minutes), raise_on_create_failure=raise_on_create_failure) self.resource_group.Create() # We use a different Azure storage account than the VM account # because a) we need to be able to set the storage class # separately, including using a blob-specific storage account and # b) this account might be in a different location than any # VM-related account. self.storage_account = azure_network.AzureStorageAccount( FLAGS.azure_storage_type, location or DEFAULT_AZURE_REGION, storage_account_name, kind=FLAGS.azure_blob_account_kind, resource_group=self.resource_group, use_existing=not try_to_create_storage_account_and_resource_group, raise_on_create_failure=raise_on_create_failure) self.storage_account.Create()