Class: Chef::Provisioning::AzureRM::AzureProvider
- Inherits:
-
Chef::Provider::LWRPBase
- Object
- Chef::Provider::LWRPBase
- Chef::Provisioning::AzureRM::AzureProvider
show all
- Defined in:
- lib/chef/provisioning/azurerm/azure_provider.rb
Instance Method Summary
collapse
Instance Method Details
#action_handler ⇒ Object
11
12
13
|
# File 'lib/chef/provisioning/azurerm/azure_provider.rb', line 11
def action_handler
@action_handler ||= Chef::Provisioning::ChefProviderActionHandler.new(self)
end
|
#compute_management_client ⇒ Object
29
30
31
32
33
34
|
# 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 ⇒ Object
36
37
38
39
40
41
|
# 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 ⇒ Object
15
16
17
18
19
20
|
# 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) ⇒ Object
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
# 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::AzureChina.resource_manager_endpoint_url
when 'azuregermancloud'
MsRestAzure::AzureEnvironments::AzureGermanCloud.resource_manager_endpoint_url
when 'azurerm'
MsRestAzure::AzureEnvironments::Azure.resource_manager_endpoint_url
when 'azure'
MsRestAzure::AzureEnvironments::Azure.resource_manager_endpoint_url
end
end
|
#storage_management_client ⇒ Object
22
23
24
25
26
27
|
# 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) ⇒ Object
58
59
60
61
62
63
64
65
66
67
68
69
70
|
# 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
|