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,93 @@
1
+ module Fog
2
+ module Network
3
+ class AzureRM
4
+ # VirtualNetworkGatewayConnection model class for Network Service
5
+ class VirtualNetworkGatewayConnection < Fog::Model
6
+ identity :name
7
+ attribute :id
8
+ attribute :location
9
+ attribute :resource_group
10
+ attribute :tags
11
+ attribute :virtual_network_gateway1
12
+ attribute :virtual_network_gateway2
13
+ attribute :local_network_gateway2
14
+ attribute :connection_type
15
+ attribute :connection_status
16
+ attribute :authorization_key
17
+ attribute :routing_weight
18
+ attribute :shared_key
19
+ attribute :egress_bytes_transferred
20
+ attribute :ingress_bytes_transferred
21
+ attribute :peer
22
+ attribute :enable_bgp
23
+ attribute :resource_guid
24
+ attribute :provisioning_state
25
+
26
+ def self.parse(gateway_connection)
27
+ connection = {}
28
+ connection['id'] = gateway_connection.id
29
+ connection['name'] = gateway_connection.name
30
+ connection['location'] = gateway_connection.location
31
+ connection['resource_group'] = get_resource_group_from_id(gateway_connection.id)
32
+ connection['tags'] = gateway_connection.tags
33
+
34
+ unless gateway_connection.virtual_network_gateway1.nil?
35
+ gateway1 = VirtualNetworkGateway.new
36
+ connection['virtual_network_gateway1'] = gateway1.merge_attributes(VirtualNetworkGateway.parse(gateway_connection.virtual_network_gateway1))
37
+ end
38
+
39
+ unless gateway_connection.virtual_network_gateway2.nil?
40
+ gateway2 = VirtualNetworkGateway.new
41
+ connection['virtual_network_gateway2'] = gateway2.merge_attributes(VirtualNetworkGateway.parse(gateway_connection.virtual_network_gateway2))
42
+ end
43
+
44
+ connection['connection_type'] = gateway_connection.connection_type
45
+ connection['connection_status'] = gateway_connection.connection_status
46
+ connection['authorization_key'] = gateway_connection.authorization_key
47
+ connection['routing_weight'] = gateway_connection.routing_weight
48
+ connection['shared_key'] = gateway_connection.shared_key
49
+ connection['egress_bytes_transferred'] = gateway_connection.egress_bytes_transferred
50
+ connection['ingress_bytes_transferred'] = gateway_connection.ingress_bytes_transferred
51
+ connection['peer'] = gateway_connection.peer
52
+ connection['enable_bgp'] = gateway_connection.enable_bgp
53
+ connection['provisioning_state'] = gateway_connection.provisioning_state
54
+
55
+ connection
56
+ end
57
+
58
+ def save
59
+ requires :name, :location, :resource_group, :connection_type
60
+ gateway_connection_params = gateway_connection_parameters
61
+ gateway_connection = service.create_or_update_virtual_network_gateway_connection(gateway_connection_params)
62
+ merge_attributes(VirtualNetworkGatewayConnection.parse(gateway_connection))
63
+ end
64
+
65
+ def destroy
66
+ service.delete_virtual_network_gateway_connection(resource_group, name)
67
+ end
68
+
69
+ private
70
+
71
+ def gateway_connection_parameters
72
+ {
73
+ resource_group_name: resource_group,
74
+ name: name,
75
+ location: location,
76
+ tags: tags,
77
+ virtual_network_gateway1: virtual_network_gateway1,
78
+ virtual_network_gateway2: virtual_network_gateway2,
79
+ local_network_gateway2: local_network_gateway2,
80
+ enable_bgp: enable_bgp,
81
+ connection_type: connection_type,
82
+ authorization_key: authorization_key,
83
+ routing_weight: routing_weight,
84
+ shared_key: shared_key,
85
+ egress_bytes_transferred: egress_bytes_transferred,
86
+ ingress_bytes_transferred: ingress_bytes_transferred,
87
+ peer: peer
88
+ }
89
+ end
90
+ end
91
+ end
92
+ end
93
+ end
@@ -0,0 +1,29 @@
1
+ require 'fog/core/collection'
2
+ require 'fog/azurerm/models/network/virtual_network_gateway_connection'
3
+
4
+ module Fog
5
+ module Network
6
+ class AzureRM
7
+ # VirtualNetworkGatewayConnections collection class for Network Service
8
+ class VirtualNetworkGatewayConnections < Fog::Collection
9
+ model VirtualNetworkGatewayConnection
10
+ attribute :resource_group
11
+
12
+ def all
13
+ requires :resource_group
14
+ gateway_connections = []
15
+ service.list_virtual_network_gateway_connections(resource_group).each do |connection|
16
+ gateway_connections << VirtualNetworkGatewayConnection.parse(connection)
17
+ end
18
+ load(gateway_connections)
19
+ end
20
+
21
+ def get(resource_group_name, name)
22
+ connection = service.get_virtual_network_gateway_connection(resource_group_name, name)
23
+ gateway_connection = VirtualNetworkGatewayConnection.new(service: service)
24
+ gateway_connection.merge_attributes(VirtualNetworkGatewayConnection.parse(connection))
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
@@ -1,5 +1,5 @@
1
1
  require 'fog/core/collection'
2
- require 'fog/azurerm/models/network/network_interface'
2
+ require 'fog/azurerm/models/network/virtual_network_gateway'
3
3
 
4
4
  module Fog
5
5
  module Network
@@ -18,8 +18,10 @@ module Fog
18
18
  load(deployments)
19
19
  end
20
20
 
21
- def get(identity)
22
- all.find { |deployment| deployment.name == identity }
21
+ def get(resource_group_name, deployment_name)
22
+ deployment = service.get_deployment(resource_group_name, deployment_name)
23
+ deployment_object = Fog::Resources::AzureRM::Deployment.new(service: service)
24
+ deployment_object.merge_attributes(Fog::Resources::AzureRM::Deployment.parse(deployment))
23
25
  end
24
26
  end
25
27
  end
@@ -17,8 +17,10 @@ module Fog
17
17
  load(resource_groups)
18
18
  end
19
19
 
20
- def get(identity)
21
- all.find { |f| f.name == identity }
20
+ def get(resource_group_name)
21
+ resource_group = service.get_resource_group(resource_group_name)
22
+ resource_group_object = Fog::Resources::AzureRM::ResourceGroup.new(service: service)
23
+ resource_group_object.merge_attributes(Fog::Resources::AzureRM::ResourceGroup.parse(resource_group))
22
24
  end
23
25
  end
24
26
  end
@@ -23,8 +23,10 @@ module Fog
23
23
  load(accounts)
24
24
  end
25
25
 
26
- def get(identity)
27
- all.find { |f| f.name == identity }
26
+ def get(resource_group_name, storage_account_name)
27
+ storage_account = service.get_storage_account(resource_group_name, storage_account_name)
28
+ storage_account_object = Fog::Storage::AzureRM::StorageAccount.new(service: service)
29
+ storage_account_object.merge_attributes(Fog::Storage::AzureRM::StorageAccount.parse(storage_account))
28
30
  end
29
31
 
30
32
  def check_name_availability(name)
@@ -41,20 +41,31 @@ module Fog
41
41
  requires :target, :endpoint_location if type.eql?(EXTERNAL_ENDPOINTS)
42
42
  requires :target_resource_id, :endpoint_location, :min_child_endpoints if type.eql?(NESTED_ENDPOINTS)
43
43
 
44
- if %w(azureEndpoints externalEndpoints nestedEndpoints).select { |type| type if type.eql?(type) }.any?
45
- traffic_manager_endpoint = service.create_traffic_manager_endpoint(traffic_manager_endpoint_hash)
46
- merge_attributes(Fog::TrafficManager::AzureRM::TrafficManagerEndPoint.parse(traffic_manager_endpoint))
47
- else
48
- raise(ArgumentError, ":type should be '#{AZURE_ENDPOINTS}', '#{EXTERNAL_ENDPOINTS}' or '#{NESTED_ENDPOINTS}'")
49
- end
44
+ create_or_update
50
45
  end
51
46
 
52
47
  def destroy
53
48
  service.delete_traffic_manager_endpoint(resource_group, name, traffic_manager_profile_name, type)
54
49
  end
55
50
 
51
+ def update(endpoint_params)
52
+ validate_input(endpoint_params)
53
+ merge_attributes(endpoint_params)
54
+
55
+ create_or_update
56
+ end
57
+
56
58
  private
57
59
 
60
+ def create_or_update
61
+ if %w(azureEndpoints externalEndpoints nestedEndpoints).select { |type| type if type.eql?(type) }.any?
62
+ traffic_manager_endpoint = service.create_or_update_traffic_manager_endpoint(traffic_manager_endpoint_hash)
63
+ merge_attributes(Fog::TrafficManager::AzureRM::TrafficManagerEndPoint.parse(traffic_manager_endpoint))
64
+ else
65
+ raise(ArgumentError, ":type should be '#{AZURE_ENDPOINTS}', '#{EXTERNAL_ENDPOINTS}' or '#{NESTED_ENDPOINTS}'")
66
+ end
67
+ end
68
+
58
69
  def traffic_manager_endpoint_hash
59
70
  {
60
71
  resource_group: resource_group,
@@ -69,6 +80,12 @@ module Fog
69
80
  min_child_endpoints: min_child_endpoints
70
81
  }
71
82
  end
83
+
84
+ def validate_input(attr_hash)
85
+ invalid_attr = [:resource_group, :name, :traffic_manager_profile_name, :id]
86
+ result = invalid_attr & attr_hash.keys
87
+ raise 'Cannot modify the given attribute' unless result.empty?
88
+ end
72
89
  end
73
90
  end
74
91
  end
@@ -44,15 +44,41 @@ module Fog
44
44
  def save
45
45
  requires :name, :resource_group, :traffic_routing_method, :relative_name, :ttl,
46
46
  :protocol, :port, :path
47
- traffic_manager_profile = service.create_traffic_manager_profile(resource_group, name,
48
- traffic_routing_method, relative_name, ttl,
49
- protocol, port, path)
47
+ traffic_manager_profile = service.create_or_update_traffic_manager_profile(traffic_manager_profile_hash)
50
48
  merge_attributes(Fog::TrafficManager::AzureRM::TrafficManagerProfile.parse(traffic_manager_profile))
51
49
  end
52
50
 
53
51
  def destroy
54
52
  service.delete_traffic_manager_profile(resource_group, name)
55
53
  end
54
+
55
+ def update(profile_params)
56
+ validate_input(profile_params)
57
+ merge_attributes(profile_params)
58
+ profile = service.create_or_update_traffic_manager_profile(traffic_manager_profile_hash)
59
+ merge_attributes(Fog::TrafficManager::AzureRM::TrafficManagerProfile.parse(profile))
60
+ end
61
+
62
+ private
63
+
64
+ def validate_input(attr_hash)
65
+ invalid_attr = [:resource_group, :name, :relative_name, :id]
66
+ result = invalid_attr & attr_hash.keys
67
+ raise 'Cannot modify the given attribute' unless result.empty?
68
+ end
69
+
70
+ def traffic_manager_profile_hash
71
+ {
72
+ resource_group: resource_group,
73
+ name: name,
74
+ traffic_routing_method: traffic_routing_method,
75
+ relative_name: relative_name,
76
+ ttl: ttl,
77
+ protocol: protocol,
78
+ port: port,
79
+ path: path
80
+ }
81
+ end
56
82
  end
57
83
  end
58
84
  end
@@ -1,5 +1,3 @@
1
- require 'fog/azurerm/core'
2
-
3
1
  module Fog
4
2
  module Network
5
3
  # Fog Service Class for AzureRM
@@ -21,7 +19,7 @@ module Fog
21
19
  request :delete_virtual_network
22
20
  request :list_virtual_networks
23
21
  request :check_for_virtual_network
24
- request :create_public_ip
22
+ request :create_or_update_public_ip
25
23
  request :delete_public_ip
26
24
  request :get_public_ip
27
25
  request :list_public_ips
@@ -43,6 +41,7 @@ module Fog
43
41
  request :create_load_balancer
44
42
  request :delete_load_balancer
45
43
  request :list_load_balancers
44
+ request :get_load_balancer
46
45
  request :create_or_update_network_security_group
47
46
  request :delete_network_security_group
48
47
  request :list_network_security_groups
@@ -61,7 +60,22 @@ module Fog
61
60
  request :delete_express_route_circuit_peering
62
61
  request :get_express_route_circuit_peering
63
62
  request :list_express_route_circuit_peerings
63
+ request :create_or_update_express_route_circuit_authorization
64
+ request :delete_express_route_circuit_authorization
65
+ request :get_express_route_circuit_authorization
66
+ request :list_express_route_circuit_authorizations
64
67
  request :list_express_route_service_providers
68
+ request :create_or_update_local_network_gateway
69
+ request :delete_local_network_gateway
70
+ request :get_local_network_gateway
71
+ request :list_local_network_gateways
72
+ request :create_or_update_virtual_network_gateway_connection
73
+ request :delete_virtual_network_gateway_connection
74
+ request :get_virtual_network_gateway_connection
75
+ request :list_virtual_network_gateway_connections
76
+ request :get_connection_shared_key
77
+ request :reset_connection_shared_key
78
+ request :set_connection_shared_key
65
79
 
66
80
  model_path 'fog/azurerm/models/network'
67
81
  model :virtual_network
@@ -92,8 +106,14 @@ module Fog
92
106
  collection :express_route_circuits
93
107
  model :express_route_circuit_peering
94
108
  collection :express_route_circuit_peerings
109
+ model :express_route_circuit_authorization
110
+ collection :express_route_circuit_authorizations
95
111
  model :express_route_service_provider
96
112
  collection :express_route_service_providers
113
+ model :local_network_gateway
114
+ collection :local_network_gateways
115
+ model :virtual_network_gateway_connection
116
+ collection :virtual_network_gateway_connections
97
117
 
98
118
  # Mock class for Network Service
99
119
  class Mock
@@ -3,80 +3,41 @@ module Fog
3
3
  class AzureRM
4
4
  # Real class for Application Gateway Request
5
5
  class Real
6
- def create_application_gateway(name, location, resource_group, sku_name, sku_tier, sku_capacity, gateway_ip_configurations, ssl_certificates, frontend_ip_configurations, frontend_ports, probes, backend_address_pools, backend_http_settings_list, http_listeners, url_path_maps, request_routing_rules)
7
- msg = "Creating Application Gateway: #{name} in Resource Group: #{resource_group}."
6
+ def create_or_update_application_gateway(gateway_params)
7
+ msg = "Creating/Updated Application Gateway: #{gateway_params[:name]} in Resource Group: #{gateway_params[:resource_group]}."
8
8
  Fog::Logger.debug msg
9
- gateway = define_application_gateway(name, location, sku_name, sku_tier, sku_capacity, gateway_ip_configurations, ssl_certificates, frontend_ip_configurations, frontend_ports, probes, backend_address_pools, backend_http_settings_list, http_listeners, url_path_maps, request_routing_rules)
9
+ gateway = define_application_gateway(gateway_params)
10
10
  begin
11
- gateway_obj = @network_client.application_gateways.create_or_update(resource_group, name, gateway)
11
+ gateway_obj = @network_client.application_gateways.create_or_update(gateway_params[:resource_group], gateway_params[:name], gateway)
12
12
  rescue MsRestAzure::AzureOperationError => e
13
13
  raise_azure_exception(e, msg)
14
14
  end
15
- Fog::Logger.debug "Application Gateway #{name} created successfully."
15
+ Fog::Logger.debug "Application Gateway #{gateway_params[:name]} created/updated successfully."
16
16
  gateway_obj
17
17
  end
18
18
 
19
19
  private
20
20
 
21
- def define_application_gateway(name, location, sku_name, sku_tier, sku_capacity, gateway_ip_configurations, ssl_certificates, frontend_ip_configurations, frontend_ports, probes, backend_address_pools, backend_http_settings_list, http_listeners, url_path_maps, request_routing_rules)
21
+ def define_application_gateway(gateway_params)
22
22
  application_gateway = Azure::ARM::Network::Models::ApplicationGateway.new
23
- application_gateway.name = name
24
- application_gateway.location = location
25
-
26
- if gateway_ip_configurations
27
- gateway_ip_configuration_arr = define_gateway_ip_configuration(gateway_ip_configurations)
28
- application_gateway.gateway_ipconfigurations = gateway_ip_configuration_arr
29
- end
30
-
31
- if ssl_certificates
32
- ssl_certificate_arr = define_ssl_certificate(ssl_certificates)
33
- application_gateway.ssl_certificates = ssl_certificate_arr
34
- end
35
-
36
- if frontend_ip_configurations
37
- frontend_ip_configuration_arr = define_frontend_ip_configurations(frontend_ip_configurations)
38
- application_gateway.frontend_ipconfigurations = frontend_ip_configuration_arr
39
- end
40
-
41
- if frontend_ports
42
- frontend_port_arr = define_frontend_ports(frontend_ports)
43
- application_gateway.frontend_ports = frontend_port_arr
44
- end
45
-
46
- if probes
47
- probe_arr = define_probes(probes)
48
- application_gateway.probes = probe_arr
49
- end
50
-
51
- if backend_address_pools
52
- backend_address_pool_arr = define_backend_address_pools(backend_address_pools)
53
- application_gateway.backend_address_pools = backend_address_pool_arr
54
- end
55
-
56
- if backend_http_settings_list
57
- backend_http_setting_arr = define_backend_http_settings(backend_http_settings_list)
58
- application_gateway.backend_http_settings_collection = backend_http_setting_arr
59
- end
60
-
61
- if http_listeners
62
- http_listener_arr = define_http_listeners(http_listeners)
63
- application_gateway.http_listeners = http_listener_arr
64
- end
65
-
66
- if url_path_maps
67
- url_path_maps_arr = define_url_path_maps(url_path_maps)
68
- application_gateway.url_path_maps = url_path_maps_arr
69
- end
70
-
71
- if request_routing_rules
72
- request_routing_rule_arr = define_request_routing_rules(request_routing_rules)
73
- application_gateway.request_routing_rules = request_routing_rule_arr
74
- end
23
+ application_gateway.name = gateway_params[:name]
24
+ application_gateway.location = gateway_params[:location]
25
+
26
+ application_gateway.gateway_ipconfigurations = define_gateway_ip_configuration(gateway_params[:gateway_ip_configurations]) if gateway_params[:gateway_ip_configurations]
27
+ application_gateway.ssl_certificates = define_ssl_certificate(gateway_params[:ssl_certificates]) if gateway_params[:ssl_certificates]
28
+ application_gateway.frontend_ipconfigurations = define_frontend_ip_configurations(gateway_params[:frontend_ip_configurations]) if gateway_params[:frontend_ip_configurations]
29
+ application_gateway.frontend_ports = define_frontend_ports(gateway_params[:frontend_ports]) if gateway_params[:frontend_ports]
30
+ application_gateway.probes = define_probes(gateway_params[:probes]) if gateway_params[:probes]
31
+ application_gateway.backend_address_pools = define_backend_address_pools(gateway_params[:backend_address_pools]) if gateway_params[:backend_address_pools]
32
+ application_gateway.backend_http_settings_collection = define_backend_http_settings(gateway_params[:backend_http_settings_list]) if gateway_params[:backend_http_settings_list]
33
+ application_gateway.http_listeners = define_http_listeners(gateway_params[:http_listeners]) if gateway_params[:http_listeners]
34
+ application_gateway.url_path_maps = define_url_path_maps(gateway_params[:url_path_maps]) if gateway_params[:url_path_maps]
35
+ application_gateway.request_routing_rules = define_request_routing_rules(gateway_params[:request_routing_rules]) if gateway_params[:request_routing_rules]
75
36
 
76
37
  gateway_sku = Azure::ARM::Network::Models::ApplicationGatewaySku.new
77
- gateway_sku.name = sku_name
78
- gateway_sku.tier = sku_tier
79
- gateway_sku.capacity = sku_capacity
38
+ gateway_sku.name = gateway_params[:sku_name]
39
+ gateway_sku.tier = gateway_params[:sku_tier]
40
+ gateway_sku.capacity = gateway_params[:sku_capacity]
80
41
  application_gateway.sku = gateway_sku
81
42
 
82
43
  application_gateway
@@ -171,7 +132,6 @@ module Fog
171
132
  backend_pool = Azure::ARM::Network::Models::ApplicationGatewayBackendAddressPool.new
172
133
 
173
134
  backend_addresses1 = bap[:ip_addresses]
174
-
175
135
  addresses = []
176
136
  backend_addresses1.each do |address|
177
137
  backend_add = Azure::ARM::Network::Models::ApplicationGatewayBackendAddress.new
@@ -327,7 +287,7 @@ module Fog
327
287
 
328
288
  # Mock class for Network Request
329
289
  class Mock
330
- def create_application_gateway(_name, _location, _resource_group, _sku_name, _sku_tier, _sku_capacity, _gateway_ip_configurations, _ssl_certificates, _frontend_ip_configurations, _frontend_ports, _probes, _backend_address_pools, _backend_http_settings_list, _http_listeners, _url_path_maps, _request_routing_rules)
290
+ def create_or_update_application_gateway(*)
331
291
  end
332
292
  end
333
293
  end
@@ -0,0 +1,159 @@
1
+ module Fog
2
+ module ApplicationGateway
3
+ class AzureRM
4
+ # Real class for Application Gateway Request
5
+ class Real
6
+ def get_application_gateway(resource_group_name, application_gateway_name)
7
+ msg = "Getting Application Gateway: #{application_gateway_name} in Resource group: #{resource_group_name}"
8
+ Fog::Logger.debug msg
9
+ begin
10
+ application_gateway = @network_client.application_gateways.get(resource_group_name, application_gateway_name)
11
+ rescue MsRestAzure::AzureOperationError => e
12
+ raise_azure_exception(e, msg)
13
+ end
14
+ Fog::Logger.debug "Getting application gateway #{application_gateway_name} successfully in Resource Group: #{resource_group_name}"
15
+ application_gateway
16
+ end
17
+ end
18
+
19
+ # Mock class for Application Gateway Request
20
+ class Mock
21
+ def get_application_gateway(*)
22
+ response = '{
23
+ "id": "/subscriptions/{guid}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/applicationGateways/gateway",
24
+ "name": "gateway",
25
+ "type": "Microsoft.Network/applicationGateways",
26
+ "location": "eastus",
27
+ "properties": {
28
+ "sku": {
29
+ "name": "Standard_Medium",
30
+ "tier": "Standard",
31
+ "capacity": 2
32
+ },
33
+ "gatewayIPConfigurations": [
34
+ {
35
+ "id": "/subscriptions/{guid}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/applicationGateways/gateway/gatewayIPConfigurations/ag-GatewayIP",
36
+ "properties": {
37
+ "subnet": {
38
+ "id": "/subscriptions/{guid}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworks/vnet/subnets/GatewaySubnet"
39
+ },
40
+ "provisioningState": "Succeeded"
41
+ },
42
+ "name": "ag-GatewayIP"
43
+ }
44
+ ],
45
+ "sslCertificates": [
46
+ {
47
+ "id": "/subscriptions/{guid}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/applicationGateways/gateway/sslCertificates/ssl_certificate",
48
+ "properties": {
49
+ "publicCertData": "MIIDiDCCAnACCQCwYkR0Mxy+QTANBgkqhkiG9w0BAQUFADCBhTELMAkGA1UEBhMCUEsxDzANBgNVBAgTBlB1bmphYjEPMA0GA1UEBxMGTGFob3JlMQ8wDQYDVQQKEwZDb25maXoxDDAKBgNVBAsTA0RldjEPMA0GA1UEAxMGaGFpZGVyMSQwIgYJKoZIhvcNAQkBFhVoYWlkZXIuYWxpQGNvbmZpei5jb20wHhcNMTYwMzAyMTE0NTM2WhcNMTcwMzAyMTE0NTM2WjCBhTELMAkGA1UEBhMCUEsxDzANBgNVBAgTBlB1bmphYjEPMA0GA1UEBxMGTGFob3JlMQ8wDQYDVQQKEwZDb25maXoxDDAKBgNVBAsTA0RldjEPMA0GA1UEAxMGaGFpZGVyMSQwIgYJKoZIhvcNAQkBFhVoYWlkZXIuYWxpQGNvbmZpei5jb20wggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCuJrPbvOG+4oXQRamkOALlpdK98m+atJue9zOcCCagY8IJI4quYL13d8VItmrZf7erA+siqpYlWEuk1+lmmUY7T4AWAL8mXeR2vc7hWF601WDUjeVPK19+IcC8emMLOlBpvjXC9nbvADLQuR0PGitfjCqFoG66EOqJmLDNBsyHWmy+qhb8J4WXitruNAJDPe/20h6L23vD6z4tvwBjh4zkrfskGlKCNcAuvG1NI0FAS8261Jvs3lf+8oFyI+oSXGtknrkeQv3PbXyeEe3KO5a/M61Uebo04Uwd4yCvdu6H0sF+YYA4bfFdanuFmrZvf9cZSwknQid+vOdzyGkTHTPFAgMBAAEwDQYJKoZIhvcNAQEFBQADggEBAKtPhYpfvn5OxP+BcChsWaQA4KZQj0THGdiAjHsvfjsgteFvhkzqZBkhKYtsAWV5tB5/GDl+o4c6PQJ2/TXhOJn3pSNaUzrCJIGtKS5DknbqTQxCwVlxyBtPHLAYWqKcPMlH282rw3VY0OYTL96XOgZ/WZjcN6A7ku+uWsNCql443FoWL+N3Gpaab45OyIluFUOH+yc0ToHNlP3iOpI3rVpi2xwmGrSyUKsGUma3nrBq7TWjkDE1E+oJoybaMNZzgXGIPSJC1HYIF1U8GSoFkZpAFxXecD0FinXWDRwUP6K54iti3i6a/Ox73WhwfI4mVCqsOy1WYWtKYhMVe6Kj4Nw=",
50
+ "provisioningState": "Succeeded"
51
+ },
52
+ "name": "ssl_certificate"
53
+ }
54
+ ],
55
+ "frontendIPConfigurations": [
56
+ {
57
+ "id": "/subscriptions/{guid}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/applicationGateways/gateway/frontendIPConfigurations/frontend_ip_config",
58
+ "properties": {
59
+ "privateIPAllocationMethod": "Dynamic",
60
+ "publicIPAddress": {
61
+ "id": "/subscriptions/{guid}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/publicIPAddresses/ag_publicip-672835"
62
+ },
63
+ "provisioningState": "Succeeded"
64
+ },
65
+ "name": "frontend_ip_config"
66
+ }
67
+ ],
68
+ "frontendPorts": [
69
+ {
70
+ "id": "/subscriptions/{guid}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/applicationGateways/gateway/frontendPorts/gateway_front_port",
71
+ "properties": {
72
+ "port": 443,
73
+ "provisioningState": "Succeeded"
74
+ },
75
+ "name": "gateway_front_port"
76
+ }
77
+ ],
78
+ "probes": [],
79
+ "backendAddressPools": [
80
+ {
81
+ "id": "/subscriptions/{guid}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/applicationGateways/gateway/backendAddressPools/AG-BackEndAddressPool",
82
+ "properties": {
83
+ "backendAddresses": [
84
+ {
85
+ "ipAddress": "10.0.0.4"
86
+ },
87
+ {
88
+ "ipAddress": "10.0.0.5"
89
+ }
90
+ ],
91
+ "provisioningState": "Succeeded"
92
+ },
93
+ "name": "AG-BackEndAddressPool"
94
+ }
95
+ ],
96
+ "backendHttpSettingsCollection": [
97
+ {
98
+ "id": "/subscriptions/{guid}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/applicationGateways/gateway/backendHttpSettingsCollection/gateway_settings",
99
+ "properties": {
100
+ "port": 80,
101
+ "protocol": "Http",
102
+ "cookieBasedAffinity": "Enabled",
103
+ "requestTimeout": 30,
104
+ "provisioningState": "Succeeded"
105
+ },
106
+ "name": "gateway_settings"
107
+ }
108
+ ],
109
+ "httpListeners": [
110
+ {
111
+ "id": "/subscriptions/{guid}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/applicationGateways/gateway/httpListeners/gateway_listener",
112
+ "properties": {
113
+ "frontendIPConfiguration": {
114
+ "id": "/subscriptions/{guid}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/applicationGateways/gateway/frontendIPConfigurations/frontend_ip_config"
115
+ },
116
+ "frontendPort": {
117
+ "id": "/subscriptions/{guid}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/applicationGateways/gateway/frontendPorts/gateway_front_port"
118
+ },
119
+ "protocol": "Https",
120
+ "sslCertificate": {
121
+ "id": "/subscriptions/{guid}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/applicationGateways/gateway/sslCertificates/ssl_certificate"
122
+ },
123
+ "requireServerNameIndication": false,
124
+ "provisioningState": "Succeeded"
125
+ },
126
+ "name": "gateway_listener"
127
+ }
128
+ ],
129
+ "urlPathMaps": [],
130
+ "requestRoutingRules": [
131
+ {
132
+ "id": "/subscriptions/{guid}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/applicationGateways/gateway/requestRoutingRules/gateway_request_route_rule",
133
+ "properties": {
134
+ "ruleType": "Basic",
135
+ "backendAddressPool": {
136
+ "id": "/subscriptions/{guid}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/applicationGateways/gateway/backendAddressPools/AG-BackEndAddressPool"
137
+ },
138
+ "backendHttpSettings": {
139
+ "id": "/subscriptions/{guid}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/applicationGateways/gateway/backendHttpSettingsCollection/gateway_settings"
140
+ },
141
+ "httpListener": {
142
+ "id": "/subscriptions/{guid}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/applicationGateways/gateway/httpListeners/gateway_listener"
143
+ },
144
+ "provisioningState": "Succeeded"
145
+ },
146
+ "name": "gateway_request_route_rule"
147
+ }
148
+ ],
149
+ "resourceGuid": "b3db5ebf-10f8-4666-9596-d1459530f64b",
150
+ "provisioningState": "Succeeded"
151
+ }
152
+ }'
153
+ gateway_mapper = Azure::ARM::Network::Models::ApplicationGateway.mapper
154
+ @network_client.deserialize(gateway_mapper, JSON.load(response), 'result.body')
155
+ end
156
+ end
157
+ end
158
+ end
159
+ end
@@ -0,0 +1,28 @@
1
+ module Fog
2
+ module ApplicationGateway
3
+ class AzureRM
4
+ # Real class for Application Gateway Request
5
+ class Real
6
+ def update_sku_attributes(gateway_params, sku_name, sku_capacity)
7
+ msg = "Updating sku attributes for #{sku_name}"
8
+ Fog::Logger.debug msg
9
+ gateway_params[:sku_name] = sku_name if sku_name
10
+ gateway_params[:sku_capacity] = sku_capacity if sku_capacity
11
+ begin
12
+ gateway = create_or_update_application_gateway(gateway_params)
13
+ rescue MsRestAzure::AzureOperationError => e
14
+ raise_azure_exception(e, msg)
15
+ end
16
+ Fog::Logger.debug "Sku #{sku_name} updated Successfully"
17
+ gateway
18
+ end
19
+ end
20
+
21
+ # Mock class for Application Gateway Request
22
+ class Mock
23
+ def update_sku_attributes(*)
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end