Class: Fog::Storage::AzureRM::Real
- Inherits:
-
Object
- Object
- Fog::Storage::AzureRM::Real
- Defined in:
- lib/fog/azurerm/storage.rb,
lib/fog/azurerm/requests/storage/list_storage_accounts.rb,
lib/fog/azurerm/requests/storage/create_storage_account.rb,
lib/fog/azurerm/requests/storage/delete_storage_account.rb,
lib/fog/azurerm/requests/storage/list_storage_account_for_rg.rb,
lib/fog/azurerm/requests/storage/check_storage_account_name_availability.rb
Overview
This class provides the actual implemention for service calls.
Instance Method Summary collapse
- #check_storage_account_name_availability(params) ⇒ Object
- #create_storage_account(resource_group, name, params) ⇒ Object
- #delete_storage_account(resource_group, name) ⇒ Object
-
#initialize(options) ⇒ Real
constructor
A new instance of Real.
- #list_storage_account_for_rg(resource_group) ⇒ Object
- #list_storage_accounts ⇒ Object
Constructor Details
#initialize(options) ⇒ Real
Returns a new instance of Real.
36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/fog/azurerm/storage.rb', line 36 def initialize() begin require 'azure_mgmt_storage' rescue LoadError => e retry if require('rubygems') raise e. end credentials = Fog::Credentials::AzureRM.get_credentials([:tenant_id], [:client_id], [:client_secret]) @storage_mgmt_client = ::Azure::ARM::Storage::StorageManagementClient.new(credentials) @storage_mgmt_client.subscription_id = [:subscription_id] end |
Instance Method Details
#check_storage_account_name_availability(params) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/fog/azurerm/requests/storage/check_storage_account_name_availability.rb', line 6 def check_storage_account_name_availability(params) Fog::Logger.debug "Checking Name availability: #{params.name}." begin promise = @storage_mgmt_client.storage_accounts.check_name_availability(params) result = promise.value! name_available_obj = Azure::ARM::Storage::Models::CheckNameAvailabilityResult.serialize_object(result.body) if name_available_obj['nameAvailable'] == true Fog::Logger.debug "Name: #{params.name} is available." return true else Fog::Logger.debug "Name: #{params.name} is not available." Fog::Logger.debug "Reason: #{name_available_obj['reason']}." return false end rescue MsRestAzure::AzureOperationError => e msg = "Exception checking name availability: #{e.body['error']['message']}" raise msg if e.body['error']['code'] == 'ResourceGroupNotFound' end end |
#create_storage_account(resource_group, name, params) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/fog/azurerm/requests/storage/create_storage_account.rb', line 7 def create_storage_account(resource_group, name, params) Fog::Logger.debug "Creating Storage Account: #{name}." begin promise = @storage_mgmt_client.storage_accounts.create(resource_group, name, params) response = promise.value! Fog::Logger.debug "Storage Account created successfully." response rescue MsRestAzure::AzureOperationError => e msg = "Exception creating Storage Account #{name} in Resource Group #{resource_group}. #{e.body['error']['message']}" raise msg end end |
#delete_storage_account(resource_group, name) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/fog/azurerm/requests/storage/delete_storage_account.rb', line 7 def delete_storage_account(resource_group, name) Fog::Logger.debug "Deleting Storage Account: #{name}." begin promise = @storage_mgmt_client.storage_accounts.delete(resource_group, name) response = promise.value! Fog::Logger.debug "Storage Account #{name} deleted successfully." response rescue MsRestAzure::AzureOperationError => e msg = "Exception deleting Storage Account #{name} in Resource Group #{resource_group}. #{e.body['error']['message']}" raise msg end end |
#list_storage_account_for_rg(resource_group) ⇒ Object
7 8 9 10 11 12 13 14 15 16 |
# File 'lib/fog/azurerm/requests/storage/list_storage_account_for_rg.rb', line 7 def list_storage_account_for_rg(resource_group) begin promise = @storage_mgmt_client.storage_accounts.list_by_resource_group(resource_group) response = promise.value! response.body.value rescue MsRestAzure::AzureOperationError => e msg = "Exception listing Storage Accounts in Resource Group #{resource_group}. #{e.body['error']['message']}" raise msg end end |
#list_storage_accounts ⇒ Object
6 7 8 9 10 11 12 13 14 15 |
# File 'lib/fog/azurerm/requests/storage/list_storage_accounts.rb', line 6 def list_storage_accounts begin promise = @storage_mgmt_client.storage_accounts.list response = promise.value! response.body.value rescue MsRestAzure::AzureOperationError => e msg = "Exception listing Storage Accounts. #{e.body['error']['message']}" raise msg end end |