class Chef::Provisioning::AzureRM::AzureProvider

Public Instance Methods

action_handler() click to toggle source
# File lib/chef/provisioning/azurerm/azure_provider.rb, line 11
def action_handler
  @action_handler ||= Chef::Provisioning::ChefProviderActionHandler.new(self)
end
compute_management_client() click to toggle source
# File lib/chef/provisioning/azurerm/azure_provider.rb, line 29
def compute_management_client
  credentials = Credentials.new.azure_credentials_for_subscription(new_resource.subscription_id, new_resource.driver_name)
  client = Azure::ARM::Compute::ComputeManagementClient.new(credentials, resource_manager_endpoint_url(new_resource.driver_name))
  client.subscription_id = new_resource.subscription_id
  client
end
network_management_client() click to toggle source
# File lib/chef/provisioning/azurerm/azure_provider.rb, line 36
def network_management_client
  credentials = Credentials.new.azure_credentials_for_subscription(new_resource.subscription_id, new_resource.driver_name)
  client = Azure::ARM::Network::NetworkResourceProviderClient.new(credentials, resource_manager_endpoint_url(new_resource.driver_name))
  client.subscription_id = new_resource.subscription_id
  client
end
resource_management_client() click to toggle source
# File lib/chef/provisioning/azurerm/azure_provider.rb, line 15
def resource_management_client
  credentials = Credentials.new.azure_credentials_for_subscription(new_resource.subscription_id, new_resource.driver_name)
  client = Azure::ARM::Resources::ResourceManagementClient.new(credentials, resource_manager_endpoint_url(new_resource.driver_name))
  client.subscription_id = new_resource.subscription_id
  client
end
resource_manager_endpoint_url(azure_environment) click to toggle source
# File lib/chef/provisioning/azurerm/azure_provider.rb, line 43
def resource_manager_endpoint_url(azure_environment)
  case azure_environment.downcase
  when 'azureusgovernment'
    MsRestAzure::AzureEnvironments::AzureUSGovernment.resource_manager_endpoint_url
  when 'azurechina'
    MsRestAzure::AzureEnvironments::AzureChinaCloud.resource_manager_endpoint_url
  when 'azuregermancloud'
    MsRestAzure::AzureEnvironments::AzureGermanCloud.resource_manager_endpoint_url
  when 'azurerm'
    MsRestAzure::AzureEnvironments::AzureCloud.resource_manager_endpoint_url
  when 'azure'
    MsRestAzure::AzureEnvironments::AzureCloud.resource_manager_endpoint_url
  end
end
storage_management_client() click to toggle source
# File lib/chef/provisioning/azurerm/azure_provider.rb, line 22
def storage_management_client
  credentials = Credentials.new.azure_credentials_for_subscription(new_resource.subscription_id, new_resource.driver_name)
  client = Azure::ARM::Storage::StorageManagementClient.new(credentials, resource_manager_endpoint_url(new_resource.driver_name))
  client.subscription_id = new_resource.subscription_id
  client
end
try_azure_operation(description, silently_continue_on_error = false) { || ... } click to toggle source
# File lib/chef/provisioning/azurerm/azure_provider.rb, line 58
def try_azure_operation(description, silently_continue_on_error = false)
  begin
    result = yield
  rescue MsRestAzure::AzureOperationError => operation_error
    unless silently_continue_on_error
      error = operation_error.body['error']
      Chef::Log.error "ERROR #{description} - #{error}"
      raise operation_error
    end
  end

  result
end