fog-azure-rm 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (160) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +2 -0
  3. data/.travis.yml +13 -8
  4. data/CHANGELOG.md +23 -10
  5. data/CONTRIBUTORS.md +2 -0
  6. data/lib/fog/azurerm/application_gateway.rb +4 -3
  7. data/lib/fog/azurerm/compute.rb +0 -1
  8. data/lib/fog/azurerm/dns.rb +0 -3
  9. data/lib/fog/azurerm/docs/application_gateway.md +72 -2
  10. data/lib/fog/azurerm/docs/compute.md +8 -5
  11. data/lib/fog/azurerm/docs/network.md +185 -6
  12. data/lib/fog/azurerm/docs/resources.md +2 -2
  13. data/lib/fog/azurerm/docs/storage.md +2 -2
  14. data/lib/fog/azurerm/docs/traffic_manager.md +23 -0
  15. data/lib/fog/azurerm/models/application_gateway/gateway.rb +180 -22
  16. data/lib/fog/azurerm/models/application_gateway/gateways.rb +4 -2
  17. data/lib/fog/azurerm/models/application_gateway/ip_configuration.rb +7 -2
  18. data/lib/fog/azurerm/models/compute/server.rb +5 -2
  19. data/lib/fog/azurerm/models/compute/servers.rb +4 -8
  20. data/lib/fog/azurerm/models/network/express_route_circuit_authorization.rb +58 -0
  21. data/lib/fog/azurerm/models/network/express_route_circuit_authorizations.rb +31 -0
  22. data/lib/fog/azurerm/models/network/load_balancers.rb +4 -2
  23. data/lib/fog/azurerm/models/network/local_network_gateway.rb +68 -0
  24. data/lib/fog/azurerm/models/network/local_network_gateways.rb +29 -0
  25. data/lib/fog/azurerm/models/network/public_ip.rb +16 -1
  26. data/lib/fog/azurerm/models/network/virtual_network_gateway_connection.rb +93 -0
  27. data/lib/fog/azurerm/models/network/virtual_network_gateway_connections.rb +29 -0
  28. data/lib/fog/azurerm/models/network/virtual_network_gateways.rb +1 -1
  29. data/lib/fog/azurerm/models/resources/deployments.rb +4 -2
  30. data/lib/fog/azurerm/models/resources/resource_groups.rb +4 -2
  31. data/lib/fog/azurerm/models/storage/storage_accounts.rb +4 -2
  32. data/lib/fog/azurerm/models/traffic_manager/traffic_manager_end_point.rb +23 -6
  33. data/lib/fog/azurerm/models/traffic_manager/traffic_manager_profile.rb +29 -3
  34. data/lib/fog/azurerm/network.rb +23 -3
  35. data/lib/fog/azurerm/requests/application_gateway/{create_application_gateway.rb → create_or_update_application_gateway.rb} +23 -63
  36. data/lib/fog/azurerm/requests/application_gateway/get_application_gateway.rb +159 -0
  37. data/lib/fog/azurerm/requests/application_gateway/update_sku_attributes.rb +28 -0
  38. data/lib/fog/azurerm/requests/application_gateway/update_subnet_id_in_gateway_ip_configuration.rb +29 -0
  39. data/lib/fog/azurerm/requests/compute/create_virtual_machine.rb +31 -20
  40. data/lib/fog/azurerm/requests/compute/get_virtual_machine.rb +1 -1
  41. data/lib/fog/azurerm/requests/network/create_or_update_express_route_circuit.rb +1 -1
  42. data/lib/fog/azurerm/requests/network/create_or_update_express_route_circuit_authorization.rb +49 -0
  43. data/lib/fog/azurerm/requests/network/create_or_update_local_network_gateway.rb +78 -0
  44. data/lib/fog/azurerm/requests/network/{create_public_ip.rb → create_or_update_public_ip.rb} +22 -8
  45. data/lib/fog/azurerm/requests/network/create_or_update_virtual_network_gateway_connection.rb +81 -0
  46. data/lib/fog/azurerm/requests/network/delete_express_route_circuit_authorization.rb +28 -0
  47. data/lib/fog/azurerm/requests/network/delete_local_network_gateway.rb +28 -0
  48. data/lib/fog/azurerm/requests/network/delete_virtual_network_gateway_connection.rb +28 -0
  49. data/lib/fog/azurerm/requests/network/get_connection_shared_key.rb +25 -0
  50. data/lib/fog/azurerm/requests/network/get_express_route_circuit_authorization.rb +34 -0
  51. data/lib/fog/azurerm/requests/network/get_load_balancer.rb +169 -0
  52. data/lib/fog/azurerm/requests/network/get_local_network_gateway.rb +46 -0
  53. data/lib/fog/azurerm/requests/network/get_virtual_network_gateway_connection.rb +46 -0
  54. data/lib/fog/azurerm/requests/network/list_express_route_circuit_authorizations.rb +36 -0
  55. data/lib/fog/azurerm/requests/network/list_local_network_gateways.rb +49 -0
  56. data/lib/fog/azurerm/requests/network/list_virtual_network_gateway_connections.rb +49 -0
  57. data/lib/fog/azurerm/requests/network/reset_connection_shared_key.rb +36 -0
  58. data/lib/fog/azurerm/requests/network/set_connection_shared_key.rb +36 -0
  59. data/lib/fog/azurerm/requests/resources/create_deployment.rb +5 -4
  60. data/lib/fog/azurerm/requests/resources/create_resource_group.rb +5 -4
  61. data/lib/fog/azurerm/requests/resources/delete_deployment.rb +5 -4
  62. data/lib/fog/azurerm/requests/resources/delete_resource_group.rb +5 -4
  63. data/lib/fog/azurerm/requests/resources/delete_resource_tag.rb +6 -4
  64. data/lib/fog/azurerm/requests/resources/get_deployment.rb +81 -0
  65. data/lib/fog/azurerm/requests/resources/get_resource_group.rb +47 -0
  66. data/lib/fog/azurerm/requests/resources/list_deployments.rb +5 -4
  67. data/lib/fog/azurerm/requests/resources/list_resource_groups.rb +6 -5
  68. data/lib/fog/azurerm/requests/resources/list_tagged_resources.rb +5 -4
  69. data/lib/fog/azurerm/requests/resources/tag_resource.rb +6 -4
  70. data/lib/fog/azurerm/requests/storage/get_storage_account.rb +36 -0
  71. data/lib/fog/azurerm/requests/traffic_manager/{create_traffic_manager_endpoint.rb → create_or_update_traffic_manager_endpoint.rb} +2 -2
  72. data/lib/fog/azurerm/requests/traffic_manager/{create_traffic_manager_profile.rb → create_or_update_traffic_manager_profile.rb} +6 -6
  73. data/lib/fog/azurerm/requests/traffic_manager/list_traffic_manager_profiles.rb +1 -1
  74. data/lib/fog/azurerm/resources.rb +2 -3
  75. data/lib/fog/azurerm/storage.rb +1 -1
  76. data/lib/fog/azurerm/traffic_manager.rb +2 -3
  77. data/lib/fog/azurerm/utilities/general.rb +5 -0
  78. data/lib/fog/azurerm/version.rb +1 -1
  79. data/lib/fog/azurerm.rb +34 -32
  80. data/test/api_stub/models/application_gateway/gateway.rb +29 -0
  81. data/test/api_stub/models/network/express_route_circuit_authorization.rb +22 -0
  82. data/test/api_stub/models/network/local_network_gateway.rb +31 -0
  83. data/test/api_stub/models/network/virtual_network_gateway_connection.rb +31 -0
  84. data/test/api_stub/requests/application_gateway/gateway.rb +30 -0
  85. data/test/api_stub/requests/compute/virtual_machine.rb +129 -2
  86. data/test/api_stub/requests/network/express_route_circuit_authorization.rb +31 -0
  87. data/test/api_stub/requests/network/local_network_gateway.rb +62 -0
  88. data/test/api_stub/requests/network/virtual_network_gateway_connection.rb +68 -0
  89. data/test/api_stub/requests/traffic_manager/traffic_manager_profile.rb +13 -0
  90. data/test/api_stub.rb +97 -48
  91. data/test/integration/Virtual_network_gateway_connection.rb +212 -0
  92. data/test/integration/application_gateway.rb +125 -54
  93. data/test/integration/deployment.rb +1 -1
  94. data/test/integration/express_route_circuit.rb +43 -4
  95. data/test/integration/external_load_balancer.rb +4 -4
  96. data/test/integration/internal_load_balancer.rb +4 -4
  97. data/test/integration/local_network_gateway.rb +76 -0
  98. data/test/integration/public_ip.rb +7 -0
  99. data/test/integration/server.rb +5 -4
  100. data/test/integration/storage_account.rb +5 -5
  101. data/test/integration/traffic_manager.rb +21 -0
  102. data/test/integration/virtual_network_gateway.rb +51 -22
  103. data/test/models/application_gateway/test_gateway.rb +56 -1
  104. data/test/models/application_gateway/test_gateways.rb +5 -5
  105. data/test/models/compute/test_servers.rb +6 -14
  106. data/test/models/network/test_express_route_circuit_authorization.rb +50 -0
  107. data/test/models/network/test_express_route_circuit_authorizations.rb +43 -0
  108. data/test/models/network/test_load_balancers.rb +6 -6
  109. data/test/models/network/test_local_network_gateway.rb +53 -0
  110. data/test/models/network/test_local_network_gateways.rb +42 -0
  111. data/test/models/network/test_public_ip.rb +16 -12
  112. data/test/models/network/test_virtual_network_gateway_connection.rb +59 -0
  113. data/test/models/network/test_virtual_network_gateway_connections.rb +42 -0
  114. data/test/models/resources/test_deployments.rb +5 -5
  115. data/test/models/resources/test_resource_groups.rb +5 -5
  116. data/test/models/storage/test_storage_accounts.rb +3 -3
  117. data/test/models/traffic_manager/test_traffic_manager_end_point.rb +1 -1
  118. data/test/models/traffic_manager/test_traffic_manager_profile.rb +11 -4
  119. data/test/requests/application_gateway/test_create_or_update_application_gateway.rb +35 -0
  120. data/test/requests/application_gateway/test_get_application_gateway.rb +24 -0
  121. data/test/requests/compute/test_create_virtual_machine.rb +17 -2
  122. data/test/requests/network/test_create_express_route_circuit_authorization.rb +35 -0
  123. data/test/requests/network/test_create_or_update_local_network_gateway.rb +36 -0
  124. data/test/requests/network/test_create_public_ip.rb +3 -3
  125. data/test/requests/network/test_create_virtual_network_gateway_connection.rb +36 -0
  126. data/test/requests/network/test_delete_express_route_circuit_authorization.rb +23 -0
  127. data/test/requests/network/test_delete_local_network_gateway.rb +23 -0
  128. data/test/requests/network/test_delete_virtual_network_gateway.rb +2 -2
  129. data/test/requests/network/test_delete_virtual_network_gateway_connection.rb +23 -0
  130. data/test/requests/network/test_get_connection_shared_key.rb +24 -0
  131. data/test/requests/network/test_get_express_route_circuit_authorization.rb +24 -0
  132. data/test/requests/network/test_get_load_balancer.rb +24 -0
  133. data/test/requests/network/test_get_local_network_gateway.rb +24 -0
  134. data/test/requests/network/test_get_virtual_network_gateway_connection.rb +24 -0
  135. data/test/requests/network/test_list_express_route_circuit_authorizations.rb +24 -0
  136. data/test/requests/network/test_list_local_network_gateways.rb +24 -0
  137. data/test/requests/network/test_list_virtual_network_gateway_connections.rb +24 -0
  138. data/test/requests/network/test_reset_connection_shared_key.rb +23 -0
  139. data/test/requests/network/test_set_connection_shared_key.rb +23 -0
  140. data/test/requests/network/test_update_public_ip.rb +34 -0
  141. data/test/requests/resources/test_create_deployment.rb +1 -1
  142. data/test/requests/resources/test_create_resource_group.rb +1 -1
  143. data/test/requests/resources/test_delete_deployment.rb +1 -1
  144. data/test/requests/resources/test_delete_resource_group.rb +1 -1
  145. data/test/requests/resources/test_delete_resource_tag.rb +1 -1
  146. data/test/requests/resources/test_get_deployment.rb +24 -0
  147. data/test/requests/resources/test_get_resource_group.rb +24 -0
  148. data/test/requests/resources/test_list_deployments.rb +1 -1
  149. data/test/requests/resources/test_list_resource_groups.rb +1 -1
  150. data/test/requests/resources/test_list_tagged_resources.rb +1 -1
  151. data/test/requests/resources/test_tag_resource.rb +1 -1
  152. data/test/requests/storage/test_get_storage_account.rb +25 -0
  153. data/test/requests/traffic_manager/test_create_traffic_manager_endpoint.rb +2 -2
  154. data/test/requests/traffic_manager/test_create_traffic_manager_profile.rb +3 -3
  155. data/test/requests/traffic_manager/test_update_traffic_manager_endpoint.rb +27 -0
  156. data/test/requests/traffic_manager/test_update_traffic_manager_profile.rb +27 -0
  157. data/test/test_helper.rb +52 -0
  158. metadata +73 -9
  159. data/lib/fog/azurerm/core.rb +0 -14
  160. data/test/requests/application_gateway/test_create_application_gateway.rb +0 -51
@@ -0,0 +1,81 @@
1
+ module Fog
2
+ module Resources
3
+ class AzureRM
4
+ # This class provides the actual implemention for service calls.
5
+ class Real
6
+ def get_deployment(resource_group, deployment_name)
7
+ msg = "Getting Deployment #{deployment_name} in Resource Group: #{resource_group}"
8
+ Fog::Logger.debug msg
9
+ begin
10
+ deployment = @rmc.deployments.get(resource_group, deployment_name)
11
+ rescue MsRestAzure::AzureOperationError => e
12
+ raise_azure_exception(e, msg)
13
+ end
14
+ Fog::Logger.debug "Getting deployment #{deployment_name} successfully in Resource Group: #{resource_group}"
15
+ deployment
16
+ end
17
+ end
18
+
19
+ # This class provides the mock implementation
20
+ class Mock
21
+ def get_deployment(*)
22
+ deployments = {
23
+ id: "/subscriptions/########-####-####-####-############/resourceGroups/fog-test-rg/providers/microsoft.resources/deployments/testdeployment",
24
+ name: 'testdeployment',
25
+ properties: {
26
+ templateLink: {
27
+ uri: 'https://test.com/template.json',
28
+ contentVersion: '1.0.0.0'
29
+ },
30
+ parametersLink: {
31
+ uri: 'https://test.com/parameters.json',
32
+ contentVersion: '1.0.0.0'
33
+ },
34
+ parameters: {
35
+ parameter1: {
36
+ type: 'string',
37
+ value: 'parameter1'
38
+ }
39
+ },
40
+ mode: 'Incremental',
41
+ provisioningState: 'Accepted',
42
+ timestamp: '2015-01-01T18:26:20.6229141Z',
43
+ correlationId: 'd5062e45-6e9f-4fd3-a0a0-6b2c56b15757',
44
+ outputs: {
45
+ key1: {
46
+ type: 'string',
47
+ value: 'output1'
48
+ }
49
+ },
50
+ providers: [{
51
+ namespace: 'namespace1',
52
+ resourceTypes: [
53
+ {
54
+ resourceType: 'resourceType1',
55
+ locations: ['westus']
56
+ }
57
+ ]
58
+ }],
59
+ dependencies: [
60
+ {
61
+ dependsOn: [
62
+ {
63
+ id: 'resourceid1',
64
+ resourceType: 'namespace1/resourcetype1',
65
+ resourceName: 'resourcename1'
66
+ }
67
+ ],
68
+ id: 'resourceid2',
69
+ resourceType: 'namespace1/resourcetype2',
70
+ resourceName: 'resourcename2'
71
+ }
72
+ ]
73
+ }
74
+ }
75
+ result_mapper = Azure::ARM::Resources::Models::Deployment.mapper
76
+ @rmc.deserialize(result_mapper, deployments, 'result.body')
77
+ end
78
+ end
79
+ end
80
+ end
81
+ end
@@ -0,0 +1,47 @@
1
+ module Fog
2
+ module Resources
3
+ class AzureRM
4
+ # This class provides the actual implemention for service calls.
5
+ class Real
6
+ def get_resource_group(resource_group_name)
7
+ msg = "Getting Resource Group #{resource_group_name}"
8
+ Fog::Logger.debug msg
9
+ begin
10
+ resource_group = @rmc.resource_groups.get(resource_group_name)
11
+ rescue MsRestAzure::AzureOperationError => e
12
+ raise_azure_exception(e, msg)
13
+ end
14
+ Fog::Logger.debug "Getting Resource Group #{resource_group_name} successfully"
15
+ resource_group
16
+ end
17
+ end
18
+
19
+ # This class provides the mock implementation for unit tests.
20
+ class Mock
21
+ def get_resource_group(*)
22
+ resource_group =
23
+ {
24
+ 'location' => 'westus',
25
+ 'id' => '/subscriptions/########-####-####-####-############/resourceGroups/Fog_test_rg',
26
+ 'name' => 'Fog_test_rg',
27
+ 'properties' =>
28
+ {
29
+ 'provisioningState' => 'Succeeded'
30
+ }
31
+ },
32
+ {
33
+ 'location' => 'westus',
34
+ 'id' => '/subscriptions/########-####-####-####-############/resourceGroups/Fog_test_rg1',
35
+ 'name' => 'Fog_test_rg1',
36
+ 'properties' =>
37
+ {
38
+ 'provisioningState' => 'Succeeded'
39
+ }
40
+ }
41
+ result_mapper = Azure::ARM::Resources::Models::ResourceGroup.mapper
42
+ @rmc.deserialize(result_mapper, resource_group, 'result.body')
43
+ end
44
+ end
45
+ end
46
+ end
47
+ end
@@ -4,14 +4,15 @@ module Fog
4
4
  # This class provides the actual implemention for service calls.
5
5
  class Real
6
6
  def list_deployments(resource_group)
7
- Fog::Logger.debug "Listing Deployments in Resource Group: #{resource_group}"
7
+ msg = "Listing Deployments in Resource Group: #{resource_group}"
8
+ Fog::Logger.debug msg
8
9
  begin
9
10
  deployments = @rmc.deployments.list_as_lazy(resource_group)
10
- Fog::Logger.debug "Deployments listed successfully in Resource Group: #{resource_group}"
11
- deployments.value
12
11
  rescue MsRestAzure::AzureOperationError => e
13
- raise Fog::AzureRm::OperationError.new(e)
12
+ raise_azure_exception(e, msg)
14
13
  end
14
+ Fog::Logger.debug "Deployments listed successfully in Resource Group: #{resource_group}"
15
+ deployments.value
15
16
  end
16
17
  end
17
18
 
@@ -4,15 +4,16 @@ module Fog
4
4
  # This class provides the actual implemention for service calls.
5
5
  class Real
6
6
  def list_resource_groups
7
- Fog::Logger.debug 'Listing Resource Groups'
7
+ msg = 'Listing Resource Groups'
8
+ Fog::Logger.debug msg
8
9
  begin
9
10
  resource_groups = @rmc.resource_groups.list_as_lazy
10
- resource_groups.next_link = '' if resource_groups.next_link.nil?
11
- Fog::Logger.debug 'Resource Groups listed successfully'
12
- resource_groups.value
13
11
  rescue MsRestAzure::AzureOperationError => e
14
- raise Fog::AzureRm::OperationError.new(e)
12
+ raise_azure_exception(e, msg)
15
13
  end
14
+ resource_groups.next_link = '' if resource_groups.next_link.nil?
15
+ Fog::Logger.debug 'Resource Groups listed successfully'
16
+ resource_groups.value
16
17
  end
17
18
  end
18
19
 
@@ -4,17 +4,18 @@ module Fog
4
4
  # This class provides the actual implemention for service calls.
5
5
  class Real
6
6
  def list_tagged_resources(tag_name, tag_value = nil)
7
- Fog::Logger.debug "Listing Resources with tagname: #{tag_name}"
7
+ msg = "Listing Resources with tagname: #{tag_name}"
8
+ Fog::Logger.debug msg
8
9
  unless tag_name.nil?
9
10
  query_filter = "tagname eq '#{tag_name}' "
10
11
  query_filter += tag_value.nil? ? '' : "and tagvalue eq '#{tag_value}'"
11
12
  begin
12
13
  resources = @rmc.resources.list_as_lazy(query_filter)
13
- resources.next_link = '' if resources.next_link.nil?
14
- resources.value
15
14
  rescue MsRestAzure::AzureOperationError => e
16
- raise Fog::AzureRm::OperationError.new(e)
15
+ raise_azure_exception(e, msg)
17
16
  end
17
+ resources.next_link = '' if resources.next_link.nil?
18
+ resources.value
18
19
  end
19
20
  end
20
21
  end
@@ -15,17 +15,19 @@ module Fog
15
15
  resource_name = get_resource_from_resource_id(resource_id, RESOURCE_NAME)
16
16
  parent_resource_id = ''
17
17
 
18
- Fog::Logger.debug "Creating Tag #{tag_name} for Resource #{resource_name}"
18
+ msg = "Creating Tag #{tag_name} for Resource #{resource_name}"
19
+ Fog::Logger.debug msg
20
+
19
21
  begin
20
22
  resource = @rmc.resources.get(resource_group_name, resource_provider_namespace, parent_resource_id, resource_type, resource_name, API_VERSION)
21
23
  resource.tags = {} if resource.tags.nil?
22
24
  resource.tags[tag_name] = tag_value
23
25
  @rmc.resources.create_or_update(resource_group_name, resource_provider_namespace, parent_resource_id, resource_type, resource_name, API_VERSION, resource)
24
- Fog::Logger.debug "Tag #{tag_name} created successfully for Resource #{resource_name}"
25
- true
26
26
  rescue MsRestAzure::AzureOperationError => e
27
- raise Fog::AzureRm::OperationError.new(e)
27
+ raise_azure_exception(e, msg)
28
28
  end
29
+ Fog::Logger.debug "Tag #{tag_name} created successfully for Resource #{resource_name}"
30
+ true
29
31
  end
30
32
  end
31
33
 
@@ -0,0 +1,36 @@
1
+ module Fog
2
+ module Storage
3
+ class AzureRM
4
+ # This class provides the actual implementation for service calls.
5
+ class Real
6
+ def get_storage_account(resource_group_name, storage_account_name)
7
+ msg = "Getting storage account: #{storage_account_name}."
8
+ Fog::Logger.debug msg
9
+ begin
10
+ storage_account = @storage_mgmt_client.storage_accounts.get_properties(resource_group_name, storage_account_name)
11
+ rescue MsRestAzure::AzureOperationError => e
12
+ raise_azure_exception(e, msg)
13
+ end
14
+ Fog::Logger.debug "Getting storage account: #{storage_account_name} successfully."
15
+ storage_account
16
+ end
17
+ end
18
+ # This class provides the mock implementation.
19
+ class Mock
20
+ def get_storage_account(*)
21
+ storage_account_hash = {
22
+ 'id' => '/subscriptions/67f2116d-4ea2-4c6c-b20a-f92183dbe3cb/resourceGroups/fog_test_rg/providers/Microsoft.Storage/storageAccounts/fogtestsasecond',
23
+ 'name' => 'fog-test-storage-account',
24
+ 'location' => 'west us',
25
+ 'sku' =>
26
+ {
27
+ 'name' => 'Standard_LRS'
28
+ }
29
+ }
30
+ storage_account_mapper = Azure::ARM::Storage::Models::StorageAccount.mapper
31
+ storage_mgmt_client.deserialize(storage_account_mapper, storage_account_hash, 'hash')
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
@@ -3,7 +3,7 @@ module Fog
3
3
  class AzureRM
4
4
  # Real class for Traffic Manager Request
5
5
  class Real
6
- def create_traffic_manager_endpoint(endpoint_hash)
6
+ def create_or_update_traffic_manager_endpoint(endpoint_hash)
7
7
  msg = "Creating Traffic Manager Endpoint: #{endpoint_hash[:name]}."
8
8
  Fog::Logger.debug msg
9
9
  endpoint_parameters = get_endpoint_object(endpoint_hash[:target_resource_id], endpoint_hash[:target], endpoint_hash[:weight], endpoint_hash[:priority], endpoint_hash[:endpoint_location], endpoint_hash[:min_child_endpoints])
@@ -33,7 +33,7 @@ module Fog
33
33
 
34
34
  # Mock class for TrafficManager Request
35
35
  class Mock
36
- def create_traffic_manager_endpoint(*)
36
+ def create_or_update_traffic_manager_endpoint(*)
37
37
  endpoint = {
38
38
  'name' => '{endpoint-name}',
39
39
  'type' => 'Microsoft.Network/trafficManagerProfiles/externalEndpoints',
@@ -3,16 +3,16 @@ module Fog
3
3
  class AzureRM
4
4
  # This class provides the actual implementation for service call.
5
5
  class Real
6
- def create_traffic_manager_profile(resource_group, name, traffic_routing_method, relative_name, ttl, protocol, port, path)
7
- msg = "Creating Traffic Manager Profile: #{name}."
6
+ def create_or_update_traffic_manager_profile(profile_hash)
7
+ msg = "Creating Traffic Manager Profile: #{profile_hash[:name]}."
8
8
  Fog::Logger.debug msg
9
- profile_parameters = get_profile_object(traffic_routing_method, relative_name, ttl, protocol, port, path)
9
+ profile_parameters = get_profile_object(profile_hash[:traffic_routing_method], profile_hash[:relative_name], profile_hash[:ttl], profile_hash[:protocol], profile_hash[:port], profile_hash[:path])
10
10
  begin
11
- traffic_manager_profile = @traffic_mgmt_client.profiles.create_or_update(resource_group, name, profile_parameters)
11
+ traffic_manager_profile = @traffic_mgmt_client.profiles.create_or_update(profile_hash[:resource_group], profile_hash[:name], profile_parameters)
12
12
  rescue MsRestAzure::AzureOperationError => e
13
13
  raise_azure_exception(e, msg)
14
14
  end
15
- Fog::Logger.debug "Traffic Manager Profile: #{name} created successfully."
15
+ Fog::Logger.debug "Traffic Manager Profile: #{profile_hash[:name]} created successfully."
16
16
  traffic_manager_profile
17
17
  end
18
18
 
@@ -45,7 +45,7 @@ module Fog
45
45
  end
46
46
  # This class provides the mock implementation for unit tests.
47
47
  class Mock
48
- def create_traffic_manager_profile(*)
48
+ def create_or_update_traffic_manager_profile(*)
49
49
  profile = {
50
50
  'location' => 'global',
51
51
  'tags' => {},
@@ -73,7 +73,7 @@ module Fog
73
73
  }
74
74
  }
75
75
  ]
76
- profiles_mapper = Azure::ARM::TrafficManager::Models::Profile.mapper
76
+ profiles_mapper = Azure::ARM::TrafficManager::Models::ProfileListResult.mapper
77
77
  @traffic_mgmt_client.deserialize(profiles_mapper, profiles, 'result.body')
78
78
  end
79
79
  end
@@ -1,6 +1,3 @@
1
- require 'fog/azurerm/core'
2
- require 'fog/azurerm/credentials'
3
-
4
1
  module Fog
5
2
  module Resources
6
3
  # This class registers models, requests and collections
@@ -14,9 +11,11 @@ module Fog
14
11
  request :create_resource_group
15
12
  request :list_resource_groups
16
13
  request :delete_resource_group
14
+ request :get_resource_group
17
15
  request :create_deployment
18
16
  request :delete_deployment
19
17
  request :list_deployments
18
+ request :get_deployment
20
19
  request :delete_resource_tag
21
20
  request :list_tagged_resources
22
21
  request :tag_resource
@@ -1,4 +1,3 @@
1
- require 'fog/azurerm/core'
2
1
  module Fog
3
2
  module Storage
4
3
  # This class registers models, requests and collections
@@ -19,6 +18,7 @@ module Fog
19
18
  request :create_storage_account
20
19
  request :list_storage_accounts
21
20
  request :delete_storage_account
21
+ request :get_storage_account
22
22
  request :list_storage_account_for_rg
23
23
  request :check_storage_account_name_availability
24
24
  request :get_storage_access_keys
@@ -1,4 +1,3 @@
1
- require 'fog/azurerm/core'
2
1
  module Fog
3
2
  module TrafficManager
4
3
  # This class registers models, requests and collections
@@ -9,12 +8,12 @@ module Fog
9
8
  requires :subscription_id
10
9
 
11
10
  request_path 'fog/azurerm/requests/traffic_manager'
12
- request :create_traffic_manager_profile
11
+ request :create_or_update_traffic_manager_profile
13
12
  request :delete_traffic_manager_profile
14
13
  request :get_traffic_manager_profile
15
14
  request :list_traffic_manager_profiles
16
15
 
17
- request :create_traffic_manager_endpoint
16
+ request :create_or_update_traffic_manager_endpoint
18
17
  request :delete_traffic_manager_endpoint
19
18
  request :get_traffic_manager_endpoint
20
19
 
@@ -18,6 +18,11 @@ def get_traffic_manager_profile_name_from_endpoint_id(endpoint_id)
18
18
  endpoint_id.split('/')[8]
19
19
  end
20
20
 
21
+ # Pick Express Route Circuit name from Id(String)
22
+ def get_circuit_name_from_id(circuit_id)
23
+ circuit_id.split('/')[8]
24
+ end
25
+
21
26
  def get_record_type(type)
22
27
  type.split('/').last
23
28
  end
@@ -1,5 +1,5 @@
1
1
  module Fog
2
2
  module AzureRM
3
- VERSION = '0.0.5'.freeze
3
+ VERSION = '0.0.6'.freeze
4
4
  end
5
5
  end
data/lib/fog/azurerm.rb CHANGED
@@ -4,41 +4,43 @@ require 'erb'
4
4
  require 'fog/azurerm/config'
5
5
  require 'fog/azurerm/utilities/general'
6
6
  require 'fog/azurerm/version'
7
- require 'fog/azurerm/core'
8
- require 'fog/azurerm/dns'
9
- require 'fog/azurerm/fog_azure_rm_exception'
10
- require 'fog/azurerm/resources'
11
- require 'fog/azurerm/storage'
12
- require 'fog/azurerm/network'
13
- require 'fog/azurerm/compute'
14
- require 'fog/azurerm/application_gateway'
15
- require 'fog/azurerm/traffic_manager'
7
+ require 'fog/core'
16
8
 
17
9
  module Fog
10
+ module Credentials
11
+ autoload :AzureRM, File.expand_path('azurerm/credentials', __dir__)
12
+ end
13
+ module Compute
14
+ autoload :AzureRM, File.expand_path('azurerm/compute', __dir__)
15
+ end
16
+ module DNS
17
+ autoload :AzureRM, File.expand_path('azurerm/dns', __dir__)
18
+ end
19
+ module Network
20
+ autoload :AzureRM, File.expand_path('azurerm/network', __dir__)
21
+ end
22
+ module Resources
23
+ autoload :AzureRM, File.expand_path('azurerm/resources', __dir__)
24
+ end
25
+ module TrafficManager
26
+ autoload :AzureRM, File.expand_path('azurerm/traffic_manager', __dir__)
27
+ end
28
+ module Storage
29
+ autoload :AzureRM, File.expand_path('azurerm/storage', __dir__)
30
+ end
31
+ module ApplicationGateway
32
+ autoload :AzureRM, File.expand_path('azurerm/application_gateway', __dir__)
33
+ end
34
+
18
35
  # Main AzureRM fog Provider Module
19
36
  module AzureRM
20
- def self.services
21
- begin
22
- array_of_services = []
23
- ENV['BUNDLE_GEM'] = File.expand_path('../../lib', File.dirname(__FILE__))
24
- gem_path = ENV['BUNDLE_GEM']
25
- files = Dir.entries(File.join(gem_path, '/fog/azurerm')).select { |f| !File.directory? f }
26
- files.each do |file|
27
- next if file == 'config.rb'
28
- next if file == 'core.rb'
29
- next if file == 'credentials.rb'
30
- next if file == 'docs'
31
- next if file == 'models'
32
- next if file == 'requests'
33
- next if file == 'version.rb'
34
- array_of_services.push(file.split('.').first.upcase)
35
- end
36
- array_of_services
37
- rescue => e
38
- Fog::Logger.warning(e.message)
39
- raise e.message
40
- # typically occurs if folder_to_count does not exist
41
- end
42
- end
37
+ extend Fog::Provider
38
+ service(:resources, 'Resources')
39
+ service(:dns, 'DNS')
40
+ service(:storage, 'Storage')
41
+ service(:network, 'Network')
42
+ service(:compute, 'Compute')
43
+ service(:application_gateway, 'ApplicationGateway')
44
+ service(:traffic_manager, 'TrafficManager')
43
45
  end
44
46
  end
@@ -1,6 +1,7 @@
1
1
  module ApiStub
2
2
  module Models
3
3
  module ApplicationGateway
4
+ # Mock class for Application Gateway Model
4
5
  class Gateway
5
6
  def self.create_application_gateway_response(gateway_client)
6
7
  gateway = '{
@@ -130,6 +131,34 @@ module ApiStub
130
131
  gateway_mapper = Azure::ARM::Network::Models::ApplicationGateway.mapper
131
132
  gateway_client.deserialize(gateway_mapper, JSON.load(gateway), 'result.body')
132
133
  end
134
+
135
+ def self.ssl_certifcate
136
+ {
137
+ name: '<SSL Certificate name>',
138
+ data: 'Base-64 encoded pfx certificate',
139
+ password: 'azure',
140
+ public_cert_data: 'Base-64 encoded Public cert data corresponding to pfx specified in data.'
141
+ }
142
+ end
143
+
144
+ def self.frontend_port
145
+ {
146
+ name: '<Frontend port name>',
147
+ port: 80
148
+ }
149
+ end
150
+
151
+ def self.probe
152
+ {
153
+ name: '<Probe name>',
154
+ protocol: 'http',
155
+ host: 'localhost',
156
+ path: '/fog-test',
157
+ interval: 60,
158
+ timeout: 300,
159
+ unhealthy_threshold: 5
160
+ }
161
+ end
133
162
  end
134
163
  end
135
164
  end
@@ -0,0 +1,22 @@
1
+ module ApiStub
2
+ module Models
3
+ module Network
4
+ # Mock class for Express Route Circuit Authorization Model
5
+ class ExpressRouteCircuitAuthorization
6
+ def self.create_express_route_circuit_authorization_response(network_client)
7
+ authorization = '{
8
+ "name": "MicrosoftAuthorization",
9
+ "id": "/subscriptions/{guid}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/expressRouteCircuits/{circuitName}/authorizations/{authorizationName}",
10
+ "properties": {
11
+ "authorizationKey": "authorization-key",
12
+ "authorizationUseStatus": "Available"
13
+ }
14
+ }'
15
+
16
+ express_route_circuit_authorization_mapper = Azure::ARM::Network::Models::ExpressRouteCircuitAuthorization.mapper
17
+ network_client.deserialize(express_route_circuit_authorization_mapper, JSON.load(authorization), 'result.body')
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,31 @@
1
+ module ApiStub
2
+ module Models
3
+ module Network
4
+ # Mock class for Local Network Gateway Model
5
+ class LocalNetworkGateway
6
+ def self.create_local_network_gateway_response(network_client)
7
+ local_network_gateway = {
8
+ 'id' => '/subscriptions/<Subscription_id>/resourceGroups/learn_fog/providers/Microsoft.Network/localNetworkGateways/testLocalNetworkGateway',
9
+ 'name' => 'testLocalNetworkGateway',
10
+ 'type' => 'Microsoft.Network/localNetworkGateways',
11
+ 'location' => 'eastus',
12
+ 'properties' =>
13
+ {
14
+ 'local_network_address_space' => {
15
+ 'address_prefixes' => []
16
+ },
17
+ 'gateway_ip_address' => '192.168.1.1',
18
+ 'bgp_settings' => {
19
+ 'asn' => 100,
20
+ 'bgp_peering_address' => '192.168.1.2',
21
+ 'peer_weight' => 3
22
+ }
23
+ }
24
+ }
25
+ local_network_gateway_mapper = Azure::ARM::Network::Models::LocalNetworkGateway.mapper
26
+ network_client.deserialize(local_network_gateway_mapper, local_network_gateway, 'result.body')
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,31 @@
1
+ module ApiStub
2
+ module Models
3
+ module Network
4
+ # Mock class for Virtual Network Gateway Connection Models
5
+ class VirtualNetworkGatewayConnection
6
+ def self.create_virtual_network_gateway_connection_response(network_client)
7
+ gateway_connection = '{
8
+ "name": "cn1",
9
+ "id": "/subscriptions/{subscription-id}/resourceGroups/{resource_group_name}/providers/microsoft.network/connections/connection1",
10
+ "location": "West US",
11
+ "tags": { "key1": "value1" },
12
+ "properties": {
13
+ "virtualNetworkGateway1": {
14
+ "name": "firstgateway",
15
+ "id": "/subscriptions/{subscription-id}/resourceGroups/{resource_group_name}/providers/microsoft.network/SiteToSite/firstgateway"
16
+ },
17
+ "virtualNetworkGateway2": {
18
+ "name": "secondgateway",
19
+ "id": "/subscriptions/{subscription-id}/resourceGroups/{resource_group_name}/providers/microsoft.network/SiteToSite/secondgateway"
20
+ },
21
+ "connectionType": "SiteToSite",
22
+ "connectivityState": "Connected"
23
+ }
24
+ }'
25
+ connection_mapper = Azure::ARM::Network::Models::VirtualNetworkGatewayConnection.mapper
26
+ network_client.deserialize(connection_mapper, JSON.load(gateway_connection), 'result.body')
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
@@ -1,6 +1,7 @@
1
1
  module ApiStub
2
2
  module Requests
3
3
  module ApplicationGateway
4
+ # Mock class for Application Gateway Requests
4
5
  class Gateway
5
6
  def self.create_application_gateway_response(gateway_client)
6
7
  response = '{
@@ -138,6 +139,35 @@ module ApiStub
138
139
  gateway_client.deserialize(gateway_mapper, JSON.load(response), 'result.body')
139
140
  end
140
141
 
142
+ def self.gateway_params
143
+ gateway_ip_configurations = ApiStub::Requests::ApplicationGateway::Gateway.gateway_ip_configurations
144
+ frontend_ip_configurations = ApiStub::Requests::ApplicationGateway::Gateway.frontend_ip_configurations
145
+ frontend_ports = ApiStub::Requests::ApplicationGateway::Gateway.frontend_ports
146
+ backend_address_pools = ApiStub::Requests::ApplicationGateway::Gateway.backend_address_pools
147
+ backend_http_settings_list = ApiStub::Requests::ApplicationGateway::Gateway.backend_http_settings_list
148
+ http_listeners = ApiStub::Requests::ApplicationGateway::Gateway.http_listeners
149
+ request_routing_rules = ApiStub::Requests::ApplicationGateway::Gateway.request_routing_rules
150
+ params = {
151
+ name: 'gateway',
152
+ location: 'East US',
153
+ resource_group: 'fogRM-rg',
154
+ sku_name: 'Standard_Medium',
155
+ sku_tier: 'Standard',
156
+ sku_capacity: 2,
157
+ gateway_ip_configurations: gateway_ip_configurations,
158
+ ssl_certificates: ssl_certificates,
159
+ frontend_ip_configurations: frontend_ip_configurations,
160
+ frontend_ports: frontend_ports,
161
+ probes: probes,
162
+ backend_address_pools: backend_address_pools,
163
+ backend_http_settings_list: backend_http_settings_list,
164
+ http_listeners: http_listeners,
165
+ url_path_maps: url_path_maps,
166
+ request_routing_rules: request_routing_rules
167
+ }
168
+ params
169
+ end
170
+
141
171
  def self.list_application_gateway_response(gateway_client)
142
172
  response = '{
143
173
  "value": [{