kitchen-azurerm 0.8.1 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 43e31b997eaad24c664c720fd6e499f04021940c
4
- data.tar.gz: 3c92979c97988e1d7af0d84111362c501e577b62
3
+ metadata.gz: 05ef22eeb440f66a0bffd98b1176b0016fd3d05e
4
+ data.tar.gz: a891f93f0ea8296aace68d6efdbb111aafcc0400
5
5
  SHA512:
6
- metadata.gz: 1a3a8b0de1fbf6c832c2fa065515552ec17d7042d9a86ebefc9c22ec5d1a653153111ec19b7c4eb71f0a51078d9ea4d6952707b55d76ce19554cf984d42476cd
7
- data.tar.gz: 7ac4c11589b995f3d8c3262d5372015a58420c079547559ad0e93261a218d13db8141935ba35e06d61dd1f89d92b4f5ee0471d5c0d6fac1fed69a3259de2ea9e
6
+ metadata.gz: 19892e32f4c756c90ddd3b7fe9e5dc00cf9ec8e5b722b73ec98006cab9402537a95fd93b8ab868f6ef2d0bcce704dced603e8226b63d6e53e74ef52d64967e88
7
+ data.tar.gz: 018ce70d5e518dae8759b0a6e5ff6a5daeb77f2d66712e0dca3a0c234b8bd76dfd8f04035ab10a6e707edfa7985ec26fbcc4d4d60d9bb840e863708d07cb0c27
@@ -56,8 +56,8 @@ module Kitchen
56
56
  false
57
57
  end
58
58
 
59
- default_config(:azure_management_url) do |_config|
60
- 'https://management.azure.com'
59
+ default_config(:azure_environment) do |_config|
60
+ 'Azure'
61
61
  end
62
62
 
63
63
  default_config(:pre_deployment_template) do |_config|
@@ -95,8 +95,10 @@ module Kitchen
95
95
  vmName: state[:vm_name]
96
96
  }
97
97
 
98
- credentials = Kitchen::Driver::Credentials.new.azure_credentials_for_subscription(config[:subscription_id])
99
- @resource_management_client = ::Azure::ARM::Resources::ResourceManagementClient.new(credentials)
98
+ credentials = Kitchen::Driver::Credentials.new.azure_credentials_for_subscription(config[:subscription_id], config[:azure_environment])
99
+ management_endpoint = resource_manager_endpoint_url(config[:azure_environment])
100
+ info "Azure environment: #{config[:azure_environment]}"
101
+ @resource_management_client = ::Azure::ARM::Resources::ResourceManagementClient.new(credentials, management_endpoint)
100
102
  @resource_management_client.subscription_id = config[:subscription_id]
101
103
 
102
104
  # Create Resource Group
@@ -136,7 +138,7 @@ module Kitchen
136
138
  # Monitor all operations until completion
137
139
  follow_deployment_until_end_state(state[:azure_resource_group_name], deployment_name)
138
140
 
139
- network_management_client = ::Azure::ARM::Network::NetworkManagementClient.new(credentials)
141
+ network_management_client = ::Azure::ARM::Network::NetworkManagementClient.new(credentials, management_endpoint)
140
142
  network_management_client.subscription_id = config[:subscription_id]
141
143
 
142
144
  if config[:vnet_id] == '' || config[:public_ip]
@@ -161,7 +163,7 @@ module Kitchen
161
163
  state[:uuid] = SecureRandom.hex(8) unless existing_state_value?(state, :uuid)
162
164
  state[:server_id] = "vm#{state[:uuid]}" unless existing_state_value?(state, :server_id)
163
165
  state[:azure_resource_group_name] = azure_resource_group_name unless existing_state_value?(state, :azure_resource_group_name)
164
- [:subscription_id, :username, :password, :vm_name, :azure_management_url].each do |config_element|
166
+ [:subscription_id, :username, :password, :vm_name, :azure_environment].each do |config_element|
165
167
  state[config_element] = config[config_element] unless existing_state_value?(state, config_element)
166
168
  end
167
169
  state.delete(:password) unless instance.transport[:ssh_key].nil?
@@ -305,8 +307,10 @@ module Kitchen
305
307
 
306
308
  def destroy(state)
307
309
  return if state[:server_id].nil?
308
- credentials = Kitchen::Driver::Credentials.new.azure_credentials_for_subscription(state[:subscription_id])
309
- resource_management_client = ::Azure::ARM::Resources::ResourceManagementClient.new(credentials, state[:azure_management_url])
310
+ credentials = Kitchen::Driver::Credentials.new.azure_credentials_for_subscription(state[:subscription_id], state[:azure_environment])
311
+ management_endpoint = resource_manager_endpoint_url(state[:azure_environment])
312
+ info "Azure environment: #{state[:azure_environment]}"
313
+ resource_management_client = ::Azure::ARM::Resources::ResourceManagementClient.new(credentials, management_endpoint)
310
314
  resource_management_client.subscription_id = state[:subscription_id]
311
315
  begin
312
316
  info "Destroying Resource Group: #{state[:azure_resource_group_name]}"
@@ -385,6 +389,19 @@ logoff
385
389
  data.each { |key, value| render_binding.local_variable_set(key.to_sym, value) }
386
390
  ERB.new(template, nil, '-').result(render_binding)
387
391
  end
392
+
393
+ def resource_manager_endpoint_url(azure_environment)
394
+ case azure_environment.downcase
395
+ when 'azureusgovernment'
396
+ MsRestAzure::AzureEnvironments::AzureUSGovernment.resource_manager_endpoint_url
397
+ when 'azurechina'
398
+ MsRestAzure::AzureEnvironments::AzureChina.resource_manager_endpoint_url
399
+ when 'azuregermancloud'
400
+ MsRestAzure::AzureEnvironments::AzureGermanCloud.resource_manager_endpoint_url
401
+ when 'azure'
402
+ MsRestAzure::AzureEnvironments::Azure.resource_manager_endpoint_url
403
+ end
404
+ end
388
405
  end
389
406
  end
390
407
  end
@@ -26,14 +26,33 @@ module Kitchen
26
26
  #
27
27
  # @return [MsRest::TokenCredentials] TokenCredentials object to be passed in with each subsequent request.
28
28
  #
29
- def azure_credentials_for_subscription(subscription_id)
29
+ def azure_credentials_for_subscription(subscription_id, azure_environment)
30
30
  tenant_id = ENV['AZURE_TENANT_ID'] || @credentials[subscription_id]['tenant_id']
31
31
  client_id = ENV['AZURE_CLIENT_ID'] || @credentials[subscription_id]['client_id']
32
32
  client_secret = ENV['AZURE_CLIENT_SECRET'] || @credentials[subscription_id]['client_secret']
33
- token_provider = ::MsRestAzure::ApplicationTokenProvider.new(tenant_id, client_id, client_secret)
33
+ token_provider = ::MsRestAzure::ApplicationTokenProvider.new(tenant_id, client_id, client_secret, settings_for_azure_environment(azure_environment))
34
34
  ::MsRest::TokenCredentials.new(token_provider)
35
35
  end
36
36
 
37
+ #
38
+ # Retrieves a [MsRestAzure::ActiveDirectoryServiceSettings] object representing the settings for the given cloud.
39
+ # @param azure_environment [String] The Azure environment to retrieve settings for.
40
+ #
41
+ # @return [MsRestAzure::ActiveDirectoryServiceSettings] Settings to be used for subsequent requests
42
+ #
43
+ def settings_for_azure_environment(azure_environment)
44
+ case azure_environment.downcase
45
+ when 'azureusgovernment'
46
+ ::MsRestAzure::ActiveDirectoryServiceSettings.get_azure_us_government_settings
47
+ when 'azurechina'
48
+ ::MsRestAzure::ActiveDirectoryServiceSettings.get_azure_china_settings
49
+ when 'azuregermancloud'
50
+ ::MsRestAzure::ActiveDirectoryServiceSettings.get_azure_germany_settings
51
+ when 'azure'
52
+ ::MsRestAzure::ActiveDirectoryServiceSettings.get_azure_settings
53
+ end
54
+ end
55
+
37
56
  def self.singleton
38
57
  @credentials ||= Credentials.new
39
58
  end
@@ -196,7 +196,7 @@
196
196
  "osDisk": {
197
197
  "name": "osdisk",
198
198
  "vhd": {
199
- "uri": "[concat('http://',parameters('newStorageAccountName'),'.blob.core.windows.net/',variables('vmStorageAccountContainerName'),'/',variables('OSDiskName'),'.vhd')]"
199
+ "uri": "[concat(reference(concat('Microsoft.Storage/storageAccounts/', parameters('newStorageAccountName')), '2015-06-15').primaryEndpoints.blob, variables('vmStorageAccountContainerName'), '/',variables('OSDiskName'),'.vhd')]"
200
200
  },
201
201
  "caching": "ReadWrite",
202
202
  "createOption": "FromImage"
@@ -212,7 +212,7 @@
212
212
  "diagnosticsProfile": {
213
213
  "bootDiagnostics": {
214
214
  "enabled": "[parameters('bootDiagnosticsEnabled')]",
215
- "storageUri": "[concat('http://',parameters('newStorageAccountName'),'.blob.core.windows.net')]"
215
+ "storageUri": "[reference(concat('Microsoft.Storage/storageAccounts/', parameters('newStorageAccountName')), '2015-06-15').primaryEndpoints.blob]"
216
216
  }
217
217
  }
218
218
  },
@@ -215,7 +215,7 @@
215
215
  "osDisk": {
216
216
  "name": "osdisk",
217
217
  "vhd": {
218
- "uri": "[concat('http://',parameters('newStorageAccountName'),'.blob.core.windows.net/',variables('vmStorageAccountContainerName'),'/',variables('OSDiskName'),'.vhd')]"
218
+ "uri": "[concat(reference(concat('Microsoft.Storage/storageAccounts/', parameters('newStorageAccountName')), '2015-06-15').primaryEndpoints.blob, variables('vmStorageAccountContainerName'), '/',variables('OSDiskName'),'.vhd')]"
219
219
  },
220
220
  "caching": "ReadWrite",
221
221
  "createOption": "FromImage"
@@ -231,7 +231,7 @@
231
231
  "diagnosticsProfile": {
232
232
  "bootDiagnostics": {
233
233
  "enabled": "[parameters('bootDiagnosticsEnabled')]",
234
- "storageUri": "[concat('http://',parameters('newStorageAccountName'),'.blob.core.windows.net')]"
234
+ "storageUri": "[reference(concat('Microsoft.Storage/storageAccounts/', parameters('newStorageAccountName')), '2015-06-15').primaryEndpoints.blob]"
235
235
  }
236
236
  }
237
237
  },
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kitchen-azurerm
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.1
4
+ version: 0.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stuart Preston
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-02-28 00:00:00.000000000 Z
11
+ date: 2017-04-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: inifile
@@ -148,7 +148,7 @@ dependencies:
148
148
  version: '0'
149
149
  description: Test Kitchen driver for the Microsoft Azure Resource Manager (ARM) API
150
150
  email:
151
- - stuart@pendrica.com
151
+ - stuart@chef.io
152
152
  executables: []
153
153
  extensions: []
154
154
  extra_rdoc_files: []
@@ -160,7 +160,7 @@ files:
160
160
  - lib/kitchen/driver/credentials.rb
161
161
  - templates/internal.erb
162
162
  - templates/public.erb
163
- homepage: https://github.com/pendrica/kitchen-azurerm
163
+ homepage: https://github.com/test-kitchen/kitchen-azurerm
164
164
  licenses:
165
165
  - Apache-2.0
166
166
  metadata: {}