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,29 @@
1
+ module Fog
2
+ module ApplicationGateway
3
+ class AzureRM
4
+ # Real class for Application Gateway Request
5
+ class Real
6
+ def update_subnet_id_in_gateway_ip_configuration(gateway_params, subnet_id)
7
+ msg = 'Updating Subnet id of IP Configuration'
8
+ Fog::Logger.debug msg
9
+ gateway_params[:gateway_ip_configurations].each do |ip_configuration|
10
+ ip_configuration[:subnet_id] = subnet_id
11
+ end
12
+ begin
13
+ gateway = create_or_update_application_gateway(gateway_params)
14
+ rescue MsRestAzure::AzureOperationError => e
15
+ raise_azure_exception(e, msg)
16
+ end
17
+ Fog::Logger.debug 'IP Configuration updated Successfully'
18
+ gateway
19
+ end
20
+ end
21
+
22
+ # Mock class for Application Gateway Request
23
+ class Mock
24
+ def update_subnet_id_in_gateway_ip_configuration(*)
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
@@ -1,3 +1,6 @@
1
+ require 'base64'
2
+ WHITE_SPACE = ' '.freeze
3
+
1
4
  module Fog
2
5
  module Compute
3
6
  class AzureRM
@@ -14,27 +17,32 @@ module Fog
14
17
  virtual_machine.availability_set = sub_resource
15
18
  end
16
19
 
20
+ string_data = vm_hash[:custom_data]
21
+ string_data = WHITE_SPACE if string_data.nil?
22
+ encoded_data = Base64.strict_encode64(string_data)
17
23
  virtual_machine.hardware_profile = define_hardware_profile(vm_hash[:vm_size])
18
24
  virtual_machine.storage_profile = define_storage_profile(vm_hash[:name],
19
- vm_hash[:storage_account_name],
20
- vm_hash[:publisher],
21
- vm_hash[:offer],
22
- vm_hash[:sku],
23
- vm_hash[:version])
24
- virtual_machine.os_profile = if vm_hash[:platform].casecmp(WINDOWS) == 0
25
- define_windows_os_profile(vm_hash[:name],
25
+ vm_hash[:storage_account_name],
26
+ vm_hash[:publisher],
27
+ vm_hash[:offer],
28
+ vm_hash[:sku],
29
+ vm_hash[:version])
30
+ virtual_machine.os_profile = if vm_hash[:platform].casecmp(WINDOWS).zero?
31
+ define_windows_os_profile(vm_hash[:name],
32
+ vm_hash[:username],
33
+ vm_hash[:password],
34
+ vm_hash[:provision_vm_agent],
35
+ vm_hash[:enable_automatic_updates],
36
+ encoded_data)
37
+ else
38
+ define_linux_os_profile(vm_hash[:name],
26
39
  vm_hash[:username],
27
40
  vm_hash[:password],
28
- vm_hash[:provision_vm_agent],
29
- vm_hash[:enable_automatic_updates])
30
- else
31
- define_linux_os_profile(vm_hash[:name],
32
- vm_hash[:username],
33
- vm_hash[:password],
34
- vm_hash[:disable_password_authentication],
35
- vm_hash[:ssh_key_path],
36
- vm_hash[:ssh_key_data])
37
- end
41
+ vm_hash[:disable_password_authentication],
42
+ vm_hash[:ssh_key_path],
43
+ vm_hash[:ssh_key_data],
44
+ encoded_data)
45
+ end
38
46
  virtual_machine.network_profile = define_network_profile(vm_hash[:network_interface_card_id])
39
47
  virtual_machine.location = vm_hash[:location]
40
48
  begin
@@ -73,7 +81,7 @@ module Fog
73
81
  storage_profile
74
82
  end
75
83
 
76
- def define_windows_os_profile(vm_name, username, password, provision_vm_agent, enable_automatic_updates)
84
+ def define_windows_os_profile(vm_name, username, password, provision_vm_agent, enable_automatic_updates, encoded_data)
77
85
  os_profile = Azure::ARM::Compute::Models::OSProfile.new
78
86
  windows_config = Azure::ARM::Compute::Models::WindowsConfiguration.new
79
87
  windows_config.provision_vmagent = provision_vm_agent
@@ -83,10 +91,11 @@ module Fog
83
91
  os_profile.computer_name = vm_name
84
92
  os_profile.admin_username = username
85
93
  os_profile.admin_password = password
94
+ os_profile.custom_data = encoded_data
86
95
  os_profile
87
96
  end
88
97
 
89
- def define_linux_os_profile(vm_name, username, password, disable_password_authentication, ssh_key_path, ssh_key_data)
98
+ def define_linux_os_profile(vm_name, username, password, disable_password_authentication, ssh_key_path, ssh_key_data, encoded_data)
90
99
  os_profile = Azure::ARM::Compute::Models::OSProfile.new
91
100
  linux_config = Azure::ARM::Compute::Models::LinuxConfiguration.new
92
101
 
@@ -104,6 +113,7 @@ module Fog
104
113
  os_profile.computer_name = vm_name
105
114
  os_profile.admin_username = username
106
115
  os_profile.admin_password = password
116
+ os_profile.custom_data = encoded_data
107
117
  os_profile
108
118
  end
109
119
 
@@ -159,7 +169,8 @@ module Fog
159
169
  {
160
170
  'disablePasswordAuthentication' => true
161
171
  },
162
- 'secrets' => []
172
+ 'secrets' => [],
173
+ 'customData' => 'ZWNobyBjdXN0b21EYXRh'
163
174
  },
164
175
  'networkProfile' =>
165
176
  {
@@ -40,7 +40,7 @@ module Fog
40
40
  },
41
41
  'osDisk' =>
42
42
  {
43
- 'name' => "fog-test-server_os_disk",
43
+ 'name' => 'fog-test-server_os_disk',
44
44
  'vhd' =>
45
45
  {
46
46
  'uri' => 'http://fogtestsafirst.blob.core.windows.net/vhds/fog-test-server_os_disk.vhd'
@@ -4,7 +4,7 @@ module Fog
4
4
  # Real class for Network Request
5
5
  class Real
6
6
  def create_or_update_express_route_circuit(circuit_parameters)
7
- msg = "Exception creating/updating Express Route Circuit #{circuit_parameters[:circuit_name]} in Resource Group: #{circuit_parameters[:resource_group_name]}."
7
+ msg = "Creating/updating Express Route Circuit #{circuit_parameters[:circuit_name]} in Resource Group: #{circuit_parameters[:resource_group_name]}."
8
8
  Fog::Logger.debug msg
9
9
  circuit = get_express_route_circuit_object(circuit_parameters)
10
10
  begin
@@ -0,0 +1,49 @@
1
+ module Fog
2
+ module Network
3
+ class AzureRM
4
+ # Real class for Express Route Circuit Authorization Request
5
+ class Real
6
+ def create_or_update_express_route_circuit_authorization(circuit_authorization_params)
7
+ msg = "Creating/updating Express Route Circuit Authorization #{circuit_authorization_params[:authorization_name]} in Resource Group: #{circuit_authorization_params[:resource_group]}."
8
+ Fog::Logger.debug msg
9
+ circuit_authorization = get_circuit_authorization_object(circuit_authorization_params)
10
+ begin
11
+ authorization = @network_client.express_route_circuit_authorizations.create_or_update(circuit_authorization_params[:resource_group], circuit_authorization_params[:circuit_name], circuit_authorization_params[:authorization_name], circuit_authorization)
12
+ rescue MsRestAzure::AzureOperationError => e
13
+ raise_azure_exception(e, msg)
14
+ end
15
+ Fog::Logger.debug "Express Route Circuit Authorization #{circuit_authorization_params[:authorization_name]} created/updated successfully."
16
+ authorization
17
+ end
18
+
19
+ private
20
+
21
+ def get_circuit_authorization_object(circuit_authorization_params)
22
+ circuit_authorization = Azure::ARM::Network::Models::ExpressRouteCircuitAuthorization.new
23
+ circuit_authorization.name = circuit_authorization_params[:authorization_name]
24
+ circuit_authorization.authorization_key = circuit_authorization_params[:authorization_key]
25
+ circuit_authorization.authorization_use_status = circuit_authorization_params[:authorization_status]
26
+ circuit_authorization.provisioning_state = circuit_authorization_params[:provisioning_state]
27
+ circuit_authorization.etag = circuit_authorization_params[:etag]
28
+
29
+ circuit_authorization
30
+ end
31
+ end
32
+
33
+ # Mock class for Express Route Circuit Authorization Request
34
+ class Mock
35
+ def create_or_update_express_route_circuit_authorization(*)
36
+ authorization = {
37
+ 'name' => 'authorization-name',
38
+ 'properties' => {
39
+ 'authorizationKey' => 'authorization-key',
40
+ 'authorizationUseStatus' => 'Available'
41
+ }
42
+ }
43
+ authorization_mapper = Azure::ARM::Network::Models::ExpressRouteCircuitAuthorization.mapper
44
+ @network_client.deserialize(authorization_mapper, authorization, 'result.body')
45
+ end
46
+ end
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,78 @@
1
+ module Fog
2
+ module Network
3
+ class AzureRM
4
+ # Real class for Local Network Gateway Request
5
+ class Real
6
+ def create_or_update_local_network_gateway(local_network_gateway_params)
7
+ msg = "Creating/Updating Local Network Gateway: #{local_network_gateway_params[:name]} in Resource Group: #{local_network_gateway_params[:resource_group]}."
8
+ Fog::Logger.debug msg
9
+ local_network_gateway = get_local_network_gateway_object(local_network_gateway_params)
10
+ begin
11
+ local_network_gateway = @network_client.local_network_gateways.create_or_update(local_network_gateway_params[:resource_group], local_network_gateway.name, local_network_gateway)
12
+ rescue MsRestAzure::AzureOperationError => e
13
+ raise_azure_exception(e, msg)
14
+ end
15
+ Fog::Logger.debug "Local Network Gateway #{local_network_gateway_params[:name]} created/updated successfully."
16
+ local_network_gateway
17
+ end
18
+
19
+ private
20
+
21
+ def get_local_network_gateway_object(local_network_gateway_params)
22
+ local_network_gateway = Azure::ARM::Network::Models::LocalNetworkGateway.new
23
+ local_network_gateway.local_network_address_space = get_local_network_address_space_object(local_network_gateway_params[:local_network_address_space_prefixes]) if local_network_gateway_params[:local_network_address_space_prefixes]
24
+ local_network_gateway.gateway_ip_address = local_network_gateway_params[:gateway_ip_address] if local_network_gateway_params[:gateway_ip_address]
25
+ local_network_gateway.bgp_settings = get_bgp_settings_object(local_network_gateway_params)
26
+
27
+ local_network_gateway.name = local_network_gateway_params[:name]
28
+ local_network_gateway.type = local_network_gateway_params[:type]
29
+ local_network_gateway.location = local_network_gateway_params[:location]
30
+ local_network_gateway.tags = local_network_gateway_params[:tags] if local_network_gateway.tags.nil?
31
+ local_network_gateway.provisioning_state = local_network_gateway_params[:provisioning_state]
32
+
33
+ local_network_gateway
34
+ end
35
+
36
+ def get_local_network_address_space_object(local_network_address_space_prefixes)
37
+ address_space = Azure::ARM::Network::Models::AddressSpace.new
38
+ address_space.address_prefixes = local_network_address_space_prefixes
39
+ address_space
40
+ end
41
+
42
+ def get_bgp_settings_object(local_network_gateway_params)
43
+ bgp_settings = Azure::ARM::Network::Models::BgpSettings.new
44
+ bgp_settings.asn = local_network_gateway_params[:asn]
45
+ bgp_settings.bgp_peering_address = local_network_gateway_params[:bgp_peering_address]
46
+ bgp_settings.peer_weight = local_network_gateway_params[:peer_weight]
47
+ bgp_settings
48
+ end
49
+ end
50
+
51
+ # Mock class for Local Network Gateway Request
52
+ class Mock
53
+ def create_or_update_virtual_network_gateway(*)
54
+ local_network_gateway = {
55
+ 'id' => '/subscriptions/<Subscription_id>/resourceGroups/learn_fog/providers/Microsoft.Network/localNetworkGateways/testLocalNetworkGateway',
56
+ 'name' => 'testLocalNetworkGateway',
57
+ 'type' => 'Microsoft.Network/localNetworkGateways',
58
+ 'location' => 'eastus',
59
+ 'properties' =>
60
+ {
61
+ 'local_network_address_space' => {
62
+ 'address_prefixes' => []
63
+ },
64
+ 'gateway_ip_address' => '192.168.1.1',
65
+ 'bgp_settings' => {
66
+ 'asn' => 100,
67
+ 'bgp_peering_address' => '192.168.1.2',
68
+ 'peer_weight' => 3
69
+ }
70
+ }
71
+ }
72
+ local_network_gateway_mapper = Azure::ARM::Network::Models::LocalNetworkGateway.mapper
73
+ @network_client.deserialize(local_network_gateway_mapper, local_network_gateway, 'result.body')
74
+ end
75
+ end
76
+ end
77
+ end
78
+ end
@@ -3,18 +3,32 @@ module Fog
3
3
  class AzureRM
4
4
  # Real class for Network Request
5
5
  class Real
6
- def create_public_ip(resource_group, name, location, public_ip_allocation_method)
7
- Fog::Logger.debug "Creating PublicIP #{name} in Resource Group #{resource_group}."
8
- public_ip = Azure::ARM::Network::Models::PublicIPAddress.new
9
- public_ip.name = name
10
- public_ip.location = location
11
- public_ip.public_ipallocation_method = public_ip_allocation_method
6
+ def create_or_update_public_ip(resource_group, name, location, public_ip_allocation_method, idle_timeout_in_minutes, domain_name_label)
7
+ msg = "Creating/Updating PublicIP #{name} in Resource Group #{resource_group}."
8
+ Fog::Logger.debug msg
9
+ public_ip = get_public_ip_object(name, location, public_ip_allocation_method, idle_timeout_in_minutes, domain_name_label)
12
10
  begin
13
- public_ip = @network_client.public_ipaddresses.create_or_update(resource_group, name, public_ip)
11
+ public_ip_obj = @network_client.public_ipaddresses.create_or_update(resource_group, name, public_ip)
14
12
  rescue MsRestAzure::AzureOperationError => e
15
- raise_azure_exception(e, "Creating PublicIP #{name} in Resource Group #{resource_group}")
13
+ raise_azure_exception(e, msg)
16
14
  end
17
15
  Fog::Logger.debug "PublicIP #{name} Created Successfully!"
16
+ public_ip_obj
17
+ end
18
+
19
+ private
20
+
21
+ def get_public_ip_object(name, location, public_ip_allocation_method, idle_timeout_in_minutes, domain_name_label)
22
+ public_ip = Azure::ARM::Network::Models::PublicIPAddress.new
23
+ public_ip.name = name
24
+ public_ip.location = location
25
+ public_ip.public_ipallocation_method = public_ip_allocation_method unless public_ip_allocation_method.nil?
26
+ public_ip.idle_timeout_in_minutes = idle_timeout_in_minutes unless idle_timeout_in_minutes.nil?
27
+ unless domain_name_label.nil?
28
+ public_ip.dns_settings = Azure::ARM::Network::Models::PublicIPAddressDnsSettings.new
29
+ public_ip.dns_settings.domain_name_label = domain_name_label
30
+ end
31
+
18
32
  public_ip
19
33
  end
20
34
  end
@@ -0,0 +1,81 @@
1
+
2
+ module Fog
3
+ module Network
4
+ class AzureRM
5
+ # Real class for Network Request
6
+ class Real
7
+ def create_or_update_virtual_network_gateway_connection(gateway_connection_params)
8
+ msg = "Creating/Updating Virtual Network Gateway Connection: #{gateway_connection_params[:name]} in Resource Group: #{gateway_connection_params[:resource_group_name]}."
9
+ Fog::Logger.debug msg
10
+ gateway_connection = get_network_gateway_connection_object(gateway_connection_params)
11
+ begin
12
+ network_gateway_connection = @network_client.virtual_network_gateway_connections.create_or_update(gateway_connection_params[:resource_group_name], gateway_connection_params[:name], gateway_connection)
13
+ rescue MsRestAzure::AzureOperationError => e
14
+ raise_azure_exception(e, msg)
15
+ end
16
+ Fog::Logger.debug "Virtual Network Gateway Connection #{gateway_connection_params[:name]} created/updated successfully."
17
+ network_gateway_connection
18
+ end
19
+
20
+ private
21
+
22
+ def get_network_gateway_connection_object(gateway_connection_params)
23
+ gateway_connection = Azure::ARM::Network::Models::VirtualNetworkGatewayConnection.new
24
+
25
+ gateway_connection.name = gateway_connection_params[:name]
26
+ gateway_connection.location = gateway_connection_params[:location]
27
+ gateway_connection.tags = gateway_connection_params[:tags] if gateway_connection.tags.nil?
28
+
29
+ if gateway_connection_params[:virtual_network_gateway1]
30
+ gateway_connection.virtual_network_gateway1 = get_virtual_network_gateway(gateway_connection_params[:virtual_network_gateway1][:resource_group], gateway_connection_params[:virtual_network_gateway1][:name])
31
+ end
32
+
33
+ if gateway_connection_params[:virtual_network_gateway2]
34
+ gateway_connection.virtual_network_gateway2 = get_virtual_network_gateway(gateway_connection_params[:virtual_network_gateway2][:resource_group], gateway_connection_params[:virtual_network_gateway2][:name])
35
+ end
36
+
37
+ gateway_connection.authorization_key = gateway_connection_params[:authorization_key]
38
+ gateway_connection.connection_type = gateway_connection_params[:connection_type]
39
+ gateway_connection.routing_weight = gateway_connection_params[:routing_weight]
40
+ gateway_connection.shared_key = gateway_connection_params[:shared_key]
41
+ gateway_connection.connection_status = gateway_connection_params[:connection_status]
42
+ gateway_connection.egress_bytes_transferred = gateway_connection_params[:egress_bytes_transferred]
43
+ gateway_connection.ingress_bytes_transferred = gateway_connection_params[:ingress_bytes_transferred]
44
+ if gateway_connection_params[:peer]
45
+ peer = MsRestAzure::SubResource.new
46
+ peer.id = gateway_connection_params[:peer]
47
+ gateway_connection.peer = peer
48
+ end
49
+ gateway_connection.resource_guid = gateway_connection_params[:resource_guid]
50
+ gateway_connection.enable_bgp = gateway_connection_params[:enable_bgp]
51
+ gateway_connection.provisioning_state = gateway_connection_params[:provisioning_state]
52
+
53
+ gateway_connection
54
+ end
55
+ end
56
+
57
+ # Mock class for Network Request
58
+ class Mock
59
+ def create_or_update_virtual_network_gateway_connection(*)
60
+ connection = {
61
+ 'name' => 'cn1',
62
+ 'location' => 'West US',
63
+ 'tags' => { 'key1' => 'value1' },
64
+ 'properties' => {
65
+ 'virtualNetworkGateway1' => {
66
+ 'name' => 'firstgateway'
67
+ },
68
+ 'virtualNetworkGateway2' => {
69
+ 'name' => 'secondgateway'
70
+ },
71
+ 'connectionType' => 'SiteToSite',
72
+ 'connectivityState' => 'Connected'
73
+ }
74
+ }
75
+ connection_mapper = Azure::ARM::Network::Models::VirtualNetworkGatewayConnection.mapper
76
+ @network_client.deserialize(connection_mapper, connection, 'result.body')
77
+ end
78
+ end
79
+ end
80
+ end
81
+ end
@@ -0,0 +1,28 @@
1
+ module Fog
2
+ module Network
3
+ class AzureRM
4
+ # Real class for Express Route Circuit Authorization Request
5
+ class Real
6
+ def delete_express_route_circuit_authorization(resource_group_name, circuit_name, authorization_name)
7
+ msg = "Deleting Express Route Circuit Authorization #{authorization_name} from Resource Group #{resource_group_name}."
8
+ Fog::Logger.debug msg
9
+ begin
10
+ @network_client.express_route_circuit_authorizations.delete(resource_group_name, circuit_name, authorization_name)
11
+ rescue MsRestAzure::AzureOperationError => e
12
+ raise_azure_exception(e, msg)
13
+ end
14
+ Fog::Logger.debug "Express Route Circuit Authorization #{authorization_name} Deleted Successfully."
15
+ true
16
+ end
17
+ end
18
+
19
+ # Mock class for Express Route Circuit Authorization Request
20
+ class Mock
21
+ def delete_express_route_circuit_authorization(*)
22
+ Fog::Logger.debug 'Express Route Circuit Authorization {authorization_name} from Resource group {resource_group_name} deleted successfully.'
23
+ true
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,28 @@
1
+ module Fog
2
+ module Network
3
+ class AzureRM
4
+ # Real class for Local Network Gateway Request
5
+ class Real
6
+ def delete_local_network_gateway(resource_group_name, local_network_gateway_name)
7
+ msg = "Deleting Local Network Gateway: #{local_network_gateway_name}"
8
+ Fog::Logger.debug msg
9
+ begin
10
+ @network_client.local_network_gateways.delete(resource_group_name, local_network_gateway_name)
11
+ rescue MsRestAzure::AzureOperationError => e
12
+ raise_azure_exception(e, msg)
13
+ end
14
+ Fog::Logger.debug "Local Network Gateway #{local_network_gateway_name} from Resource group #{resource_group_name} deleted successfully."
15
+ true
16
+ end
17
+ end
18
+
19
+ # Mock class for Local Network Gateway Request
20
+ class Mock
21
+ def delete_local_network_gateway(*)
22
+ Fog::Logger.debug 'Local Network Gateway testLocalNetworkGateway from Resource group learn_fog deleted successfully.'
23
+ true
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,28 @@
1
+ module Fog
2
+ module Network
3
+ class AzureRM
4
+ # Real class for Network Request
5
+ class Real
6
+ def delete_virtual_network_gateway_connection(resource_group_name, gateway_connection_name)
7
+ msg = "Deleting Virtual Network Gateway Connection #{gateway_connection_name} from Resource Group #{resource_group_name}."
8
+ Fog::Logger.debug msg
9
+ begin
10
+ @network_client.virtual_network_gateway_connections.delete(resource_group_name, gateway_connection_name)
11
+ rescue MsRestAzure::AzureOperationError => e
12
+ raise_azure_exception(e, msg)
13
+ end
14
+ Fog::Logger.debug "Virtual Network Gateway Connection #{gateway_connection_name} Deleted Successfully."
15
+ true
16
+ end
17
+ end
18
+
19
+ # Mock class for Network Request
20
+ class Mock
21
+ def delete_virtual_network_gateway_connection(*)
22
+ Fog::Logger.debug 'Virtual Network Gateway Connection deleted successfully.'
23
+ true
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,25 @@
1
+ module Fog
2
+ module Network
3
+ class AzureRM
4
+ # Real class for Network Request
5
+ class Real
6
+ def get_connection_shared_key(resource_group_name, connection_shared_key_name)
7
+ msg = "Getting the shared key of Connection #{connection_shared_key_name} from Resource Group #{resource_group_name}."
8
+ Fog::Logger.debug msg
9
+ begin
10
+ @network_client.virtual_network_gateway_connections.get_shared_key(resource_group_name, connection_shared_key_name).value
11
+ rescue MsRestAzure::AzureOperationError => e
12
+ raise_azure_exception(e, msg)
13
+ end
14
+ end
15
+ end
16
+
17
+ # Mock class for Network Request
18
+ class Mock
19
+ def get_connection_shared_key(*)
20
+ Fog::Logger.debug 'Get the shared key of Connection successfully.'
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,34 @@
1
+ module Fog
2
+ module Network
3
+ class AzureRM
4
+ # Real class for Express Route Circuit Authorization Request
5
+ class Real
6
+ def get_express_route_circuit_authorization(resource_group_name, circuit_name, authorization_name)
7
+ msg = "Getting Express Route Circuit Authorization #{authorization_name} from Resource Group #{resource_group_name}."
8
+ Fog::Logger.debug msg
9
+ begin
10
+ circuit_authorization = @network_client.express_route_circuit_authorizations.get(resource_group_name, circuit_name, authorization_name)
11
+ rescue MsRestAzure::AzureOperationError => e
12
+ raise_azure_exception(e, msg)
13
+ end
14
+ circuit_authorization
15
+ end
16
+ end
17
+
18
+ # Mock class for Express Route Circuit Authorization Request
19
+ class Mock
20
+ def get_express_route_circuit_authorization(*)
21
+ authorization = {
22
+ 'name' => 'authorization-name',
23
+ 'properties' => {
24
+ 'authorizationKey' => 'authorization-key',
25
+ 'authorizationUseStatus' => 'Available'
26
+ }
27
+ }
28
+ authorization_mapper = Azure::ARM::Network::Models::ExpressRouteCircuitAuthorization.mapper
29
+ @network_client.deserialize(authorization_mapper, authorization, 'result.body')
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end