fog-azure-rm 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (97) hide show
  1. checksums.yaml +4 -4
  2. data/CONTRIBUTING.md +19 -8
  3. data/LICENSE.md +1 -1
  4. data/README.md +9 -8
  5. data/lib/fog/azurerm/models/compute/availability_set.rb +17 -3
  6. data/lib/fog/azurerm/models/compute/availability_sets.rb +2 -6
  7. data/lib/fog/azurerm/models/compute/server.rb +1 -1
  8. data/lib/fog/azurerm/models/compute/servers.rb +3 -1
  9. data/lib/fog/azurerm/models/dns/record_set.rb +31 -3
  10. data/lib/fog/azurerm/models/dns/record_sets.rb +7 -17
  11. data/lib/fog/azurerm/models/dns/zone.rb +26 -3
  12. data/lib/fog/azurerm/models/dns/zones.rb +8 -6
  13. data/lib/fog/azurerm/models/network/frontend_ip_configuration.rb +32 -0
  14. data/lib/fog/azurerm/models/network/inbound_nat_pool.rb +27 -0
  15. data/lib/fog/azurerm/models/network/inbound_nat_rule.rb +29 -0
  16. data/lib/fog/azurerm/models/network/load_balancer.rb +249 -0
  17. data/lib/fog/azurerm/models/network/load_balancers.rb +27 -0
  18. data/lib/fog/azurerm/models/network/load_balancing_rule.rb +42 -0
  19. data/lib/fog/azurerm/models/network/network_interface.rb +46 -7
  20. data/lib/fog/azurerm/models/network/network_interfaces.rb +2 -8
  21. data/lib/fog/azurerm/models/network/network_security_group.rb +89 -0
  22. data/lib/fog/azurerm/models/network/network_security_groups.rb +27 -0
  23. data/lib/fog/azurerm/models/network/network_security_rule.rb +40 -0
  24. data/lib/fog/azurerm/models/network/probe.rb +29 -0
  25. data/lib/fog/azurerm/models/network/public_ip.rb +32 -4
  26. data/lib/fog/azurerm/models/network/public_ips.rb +2 -8
  27. data/lib/fog/azurerm/models/network/subnet.rb +20 -12
  28. data/lib/fog/azurerm/models/network/subnets.rb +1 -7
  29. data/lib/fog/azurerm/models/network/traffic_manager_end_point.rb +63 -0
  30. data/lib/fog/azurerm/models/network/traffic_manager_end_points.rb +29 -0
  31. data/lib/fog/azurerm/models/network/traffic_manager_profile.rb +59 -0
  32. data/lib/fog/azurerm/models/network/traffic_manager_profiles.rb +24 -0
  33. data/lib/fog/azurerm/models/network/virtual_network.rb +19 -6
  34. data/lib/fog/azurerm/models/network/virtual_networks.rb +4 -9
  35. data/lib/fog/azurerm/models/resources/resource_group.rb +2 -1
  36. data/lib/fog/azurerm/models/resources/resource_groups.rb +1 -9
  37. data/lib/fog/azurerm/models/storage/storage_account.rb +5 -7
  38. data/lib/fog/azurerm/models/storage/storage_accounts.rb +5 -6
  39. data/lib/fog/azurerm/network.rb +30 -0
  40. data/lib/fog/azurerm/requests/compute/create_availability_set.rb +13 -2
  41. data/lib/fog/azurerm/requests/compute/create_virtual_machine.rb +60 -2
  42. data/lib/fog/azurerm/requests/compute/deallocate_virtual_machine.rb +4 -2
  43. data/lib/fog/azurerm/requests/compute/delete_availability_set.rb +4 -2
  44. data/lib/fog/azurerm/requests/compute/delete_virtual_machine.rb +4 -2
  45. data/lib/fog/azurerm/requests/compute/generalize_virtual_machine.rb +4 -2
  46. data/lib/fog/azurerm/requests/compute/get_virtual_machine.rb +57 -1
  47. data/lib/fog/azurerm/requests/compute/list_availability_sets.rb +16 -1
  48. data/lib/fog/azurerm/requests/compute/list_available_sizes_for_virtual_machine.rb +27 -1
  49. data/lib/fog/azurerm/requests/compute/power_off_virtual_machine.rb +4 -2
  50. data/lib/fog/azurerm/requests/compute/redeploy_virtual_machine.rb +4 -2
  51. data/lib/fog/azurerm/requests/compute/restart_virtual_machine.rb +4 -2
  52. data/lib/fog/azurerm/requests/compute/start_virtual_machine.rb +4 -2
  53. data/lib/fog/azurerm/requests/dns/check_for_zone.rb +16 -17
  54. data/lib/fog/azurerm/requests/dns/create_record_set.rb +80 -37
  55. data/lib/fog/azurerm/requests/dns/create_zone.rb +43 -27
  56. data/lib/fog/azurerm/requests/dns/delete_record_set.rb +17 -19
  57. data/lib/fog/azurerm/requests/dns/delete_zone.rb +16 -19
  58. data/lib/fog/azurerm/requests/dns/get_records_from_record_set.rb +29 -28
  59. data/lib/fog/azurerm/requests/dns/list_record_sets.rb +49 -23
  60. data/lib/fog/azurerm/requests/dns/list_zones.rb +57 -23
  61. data/lib/fog/azurerm/requests/network/check_for_public_ip.rb +3 -1
  62. data/lib/fog/azurerm/requests/network/check_for_virtual_network.rb +4 -2
  63. data/lib/fog/azurerm/requests/network/create_load_balancer.rb +208 -0
  64. data/lib/fog/azurerm/requests/network/create_network_interface.rb +42 -4
  65. data/lib/fog/azurerm/requests/network/create_network_security_group.rb +200 -0
  66. data/lib/fog/azurerm/requests/network/create_public_ip.rb +19 -5
  67. data/lib/fog/azurerm/requests/network/create_subnet.rb +19 -6
  68. data/lib/fog/azurerm/requests/network/create_traffic_manager_endpoint.rb +78 -0
  69. data/lib/fog/azurerm/requests/network/create_traffic_manager_profile.rb +127 -0
  70. data/lib/fog/azurerm/requests/network/create_virtual_network.rb +40 -5
  71. data/lib/fog/azurerm/requests/network/delete_load_balancer.rb +27 -0
  72. data/lib/fog/azurerm/requests/network/delete_network_interface.rb +5 -3
  73. data/lib/fog/azurerm/requests/network/delete_network_security_group.rb +29 -0
  74. data/lib/fog/azurerm/requests/network/delete_public_ip.rb +4 -2
  75. data/lib/fog/azurerm/requests/network/delete_subnet.rb +10 -8
  76. data/lib/fog/azurerm/requests/network/delete_traffic_manager_endpoint.rb +37 -0
  77. data/lib/fog/azurerm/requests/network/delete_traffic_manager_profile.rb +37 -0
  78. data/lib/fog/azurerm/requests/network/delete_virtual_network.rb +8 -6
  79. data/lib/fog/azurerm/requests/network/get_traffic_manager_profile.rb +96 -0
  80. data/lib/fog/azurerm/requests/network/list_load_balancers.rb +31 -0
  81. data/lib/fog/azurerm/requests/network/list_network_interfaces.rb +41 -9
  82. data/lib/fog/azurerm/requests/network/list_network_security_groups.rb +171 -0
  83. data/lib/fog/azurerm/requests/network/list_public_ips.rb +21 -9
  84. data/lib/fog/azurerm/requests/network/list_subnets.rb +34 -11
  85. data/lib/fog/azurerm/requests/network/list_traffic_manager_profiles.rb +98 -0
  86. data/lib/fog/azurerm/requests/network/list_virtual_networks.rb +53 -8
  87. data/lib/fog/azurerm/requests/resources/create_resource_group.rb +11 -2
  88. data/lib/fog/azurerm/requests/resources/delete_resource_group.rb +4 -2
  89. data/lib/fog/azurerm/requests/resources/list_resource_groups.rb +23 -7
  90. data/lib/fog/azurerm/requests/storage/check_storage_account_name_availability.rb +2 -0
  91. data/lib/fog/azurerm/requests/storage/create_storage_account.rb +14 -8
  92. data/lib/fog/azurerm/requests/storage/delete_storage_account.rb +4 -3
  93. data/lib/fog/azurerm/requests/storage/list_storage_account_for_rg.rb +33 -2
  94. data/lib/fog/azurerm/requests/storage/list_storage_accounts.rb +32 -5
  95. data/lib/fog/azurerm/storage.rb +0 -1
  96. data/lib/fog/azurerm/version.rb +1 -1
  97. metadata +35 -10
@@ -0,0 +1,27 @@
1
+ require 'fog/core/collection'
2
+ require 'fog/azurerm/models/network/network_security_group'
3
+
4
+ module Fog
5
+ module Network
6
+ class AzureRM
7
+ # collection class for Network Security Group
8
+ class NetworkSecurityGroups < Fog::Collection
9
+ model Fog::Network::AzureRM::NetworkSecurityGroup
10
+ attribute :resource_group
11
+
12
+ def all
13
+ requires :resource_group
14
+ network_security_groups = []
15
+ service.list_network_security_groups(resource_group).each do |nsg|
16
+ network_security_groups << Fog::Network::AzureRM::NetworkSecurityGroup.parse(nsg)
17
+ end
18
+ load(network_security_groups)
19
+ end
20
+
21
+ def get(identity)
22
+ all.find { |f| f.name == identity }
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,40 @@
1
+ module Fog
2
+ module Network
3
+ class AzureRM
4
+ # Subnet model for Network Service
5
+ class NetworkSecurityRule < Fog::Model
6
+ identity :name
7
+ attribute :id
8
+ attribute :resource_group
9
+ attribute :network_security_group_name
10
+ attribute :description
11
+ attribute :protocol
12
+ attribute :source_port_range
13
+ attribute :destination_port_range
14
+ attribute :source_address_prefix
15
+ attribute :destination_address_prefix
16
+ attribute :access
17
+ attribute :priority
18
+ attribute :direction
19
+
20
+ def self.parse(nsr)
21
+ hash = {}
22
+ hash['id'] = nsr['id']
23
+ hash['name'] = nsr['name']
24
+ hash['resource_group'] = nsr['id'].split('/')[4]
25
+ hash['network_security_group_name'] = nsr['id'].split('/')[8]
26
+ hash['description'] = nsr['properties']['description']
27
+ hash['protocol'] = nsr['properties']['protocol']
28
+ hash['source_port_range'] = nsr['properties']['sourcePortRange']
29
+ hash['destination_port_range'] = nsr['properties']['destinationPortRange']
30
+ hash['source_address_prefix'] = nsr['properties']['sourceAddressPrefix']
31
+ hash['destination_address_prefix'] = nsr['properties']['destinationAddressPrefix']
32
+ hash['access'] = nsr['properties']['access']
33
+ hash['priority'] = nsr['properties']['priority']
34
+ hash['direction'] = nsr['properties']['direction']
35
+ hash
36
+ end
37
+ end
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,29 @@
1
+ module Fog
2
+ module Network
3
+ class AzureRM
4
+ # Probe model for Network Service
5
+ class Probe < Fog::Model
6
+ identity :name
7
+ attribute :id
8
+ attribute :protocol
9
+ attribute :port
10
+ attribute :request_path
11
+ attribute :interval_in_seconds
12
+ attribute :number_of_probes
13
+
14
+ def self.parse(probe)
15
+ probe_prop = probe['properties']
16
+ hash = {}
17
+ hash['id'] = probe['id']
18
+ hash['name'] = probe['name']
19
+ hash['protocol'] = probe_prop['protocol']
20
+ hash['port'] = probe_prop['port']
21
+ hash['request_path'] = probe_prop['requestPath']
22
+ hash['interval_in_seconds'] = probe_prop['intervalInSeconds']
23
+ hash['number_of_probes'] = probe_prop['numberOfProbes']
24
+ hash
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
@@ -4,17 +4,45 @@ module Fog
4
4
  # PublicIP model class for Network Service
5
5
  class PublicIp < Fog::Model
6
6
  identity :name
7
- attribute :type
7
+ attribute :id
8
8
  attribute :location
9
9
  attribute :resource_group
10
+ attribute :ip_address
11
+ attribute :public_ip_allocation_method
12
+ attribute :idle_timeout_in_minutes
13
+ attribute :ip_configuration_id
14
+ attribute :domain_name_label
15
+ attribute :fqdn
16
+ attribute :reverse_fqdn
17
+
18
+ def self.parse(pip)
19
+ pip_properties = pip['properties']
20
+ hash = {}
21
+ hash['id'] = pip['id']
22
+ hash['name'] = pip['name']
23
+ hash['location'] = pip['location']
24
+ hash['resource_group'] = pip['id'].split('/')[4]
25
+ hash['public_ip_allocation_method'] = pip_properties['publicIPAllocationMethod']
26
+ hash['ip_address'] = pip_properties['ipAddress']
27
+ hash['idle_timeout_in_minutes'] = pip_properties['idleTimeoutInMinutes']
28
+ hash['ip_configuration_id'] = pip_properties['ipConfiguration']['id'] unless pip_properties['ipConfiguration'].nil?
29
+
30
+ unless pip_properties['dnsSettings'].nil?
31
+ hash['domain_name_label'] = pip_properties['dnsSettings']['domainNameLabel']
32
+ hash['fqdn'] = pip_properties['dnsSettings']['fqdn']
33
+ hash['reverse_fqdn'] = pip_properties['dnsSettings']['reverseFqdn']
34
+ end
35
+
36
+ hash
37
+ end
10
38
 
11
39
  def save
12
40
  requires :name
13
- requires :type
41
+ requires :public_ip_allocation_method
14
42
  requires :location
15
43
  requires :resource_group
16
-
17
- service.create_public_ip(resource_group, name, location, type)
44
+ pip = service.create_public_ip(resource_group, name, location, public_ip_allocation_method)
45
+ merge_attributes(Fog::Network::AzureRM::PublicIp.parse(pip))
18
46
  end
19
47
 
20
48
  def destroy
@@ -12,14 +12,8 @@ module Fog
12
12
  def all
13
13
  requires :resource_group
14
14
  public_ips = []
15
- pubip_list = service.list_public_ips(resource_group)
16
- pubip_list.each do |pip|
17
- hash = {}
18
- pip.instance_variables.each do |var|
19
- hash[var.to_s.delete('@')] = pip.instance_variable_get(var)
20
- end
21
- hash['resource_group'] = resource_group
22
- public_ips << hash
15
+ service.list_public_ips(resource_group).each do |pip|
16
+ public_ips << Fog::Network::AzureRM::PublicIp.parse(pip)
23
17
  end
24
18
  load(public_ips)
25
19
  end
@@ -7,26 +7,34 @@ module Fog
7
7
  attribute :id
8
8
  attribute :resource_group
9
9
  attribute :virtual_network_name
10
- attribute :properties
11
- attribute :addressPrefix
12
- attribute :networkSecurityGroupId
13
- attribute :routeTableId
14
- attribute :ipConfigurations
10
+ attribute :address_prefix
11
+ attribute :network_security_group_id
12
+ attribute :route_table_id
13
+ attribute :ip_configurations_ids
14
+
15
+ def self.parse(subnet)
16
+ hash = {}
17
+ hash['id'] = subnet['id']
18
+ hash['name'] = subnet['name']
19
+ hash['resource_group'] = subnet['id'].split('/')[4]
20
+ hash['virtual_network_name'] = subnet['id'].split('/')[8]
21
+ hash['address_prefix'] = subnet['properties']['addressPrefix']
22
+ hash['network_security_group_id'] = subnet['properties']['networkSecurityGroup']['id'] unless subnet['properties']['networkSecurityGroup'].nil?
23
+ hash['route_table_id'] = subnet['properties']['routeTable']['id'] unless subnet['properties']['routeTable'].nil?
24
+ hash['ip_configurations_ids'] = subnet['properties']['ipConfigurations'].map{ |item| item['id'] } unless subnet['properties']['ipConfigurations'].nil?
25
+ hash
26
+ end
15
27
 
16
28
  def save
17
29
  requires :name
18
30
  requires :resource_group
19
31
  requires :virtual_network_name
20
- Fog::Logger.debug "Creating Subnet: #{name}..."
21
- #puts "Creating Subnet: #{name}..."
22
- subnet = service.create_subnet(resource_group, virtual_network_name, name, addressPrefix)
23
- Fog::Logger.debug "Subnet #{name} created successfully."
24
- #puts "Subnet #{name} created successfully."
25
- subnet
32
+ subnet = service.create_subnet(resource_group, name, virtual_network_name, address_prefix)
33
+ merge_attributes(Fog::Network::AzureRM::Subnet.parse(subnet))
26
34
  end
27
35
 
28
36
  def destroy
29
- service.delete_subnet(resource_group, virtual_network_name, name)
37
+ service.delete_subnet(resource_group, name, virtual_network_name)
30
38
  end
31
39
  end
32
40
  end
@@ -15,13 +15,7 @@ module Fog
15
15
  requires :virtual_network_name
16
16
  subnets = []
17
17
  service.list_subnets(resource_group, virtual_network_name).each do |subnet|
18
- hash = {}
19
- subnet.instance_variables.each do |var|
20
- hash[var.to_s.delete('@')] = subnet.instance_variable_get(var)
21
- end
22
- hash['resource_group'] = subnet.instance_variable_get('@id').split('/')[4]
23
- hash['virtual_network_name'] = subnet.instance_variable_get('@id').split('/')[8]
24
- subnets << hash
18
+ subnets << Fog::Network::AzureRM::Subnet.parse(subnet)
25
19
  end
26
20
  load(subnets)
27
21
  end
@@ -0,0 +1,63 @@
1
+ module Fog
2
+ module Network
3
+ class AzureRM
4
+ # Traffic Manager End Point model for Network Service
5
+ class TrafficManagerEndPoint < Fog::Model
6
+ identity :name
7
+ attribute :traffic_manager_profile_name
8
+ attribute :id
9
+ attribute :resource_group
10
+ attribute :type
11
+ attribute :target_resource_id
12
+ attribute :target
13
+ attribute :endpoint_status
14
+ attribute :endpoint_monitor_status
15
+ attribute :weight
16
+ attribute :priority
17
+ attribute :endpoint_location
18
+ attribute :min_child_endpoints
19
+
20
+ def self.parse(endpoint)
21
+ hash = {}
22
+ hash['id'] = endpoint['id']
23
+ hash['name'] = endpoint['name']
24
+ hash['resource_group'] = endpoint['id'].split('/')[4]
25
+ type = endpoint['type'].split('/')[2]
26
+ type.slice!('Endpoints')
27
+ hash['type'] = type
28
+ hash['target_resource_id'] = endpoint['properties']['targetResourceId']
29
+ hash['target'] = endpoint['properties']['target']
30
+ hash['endpoint_status'] = endpoint['properties']['endpointStatus']
31
+ hash['endpoint_monitor_status'] = endpoint['properties']['endpointMonitorStatus']
32
+ hash['weight'] = endpoint['properties']['weight']
33
+ hash['priority'] = endpoint['properties']['priority']
34
+ hash['endpoint_location'] = endpoint['properties']['endpointLocation']
35
+ hash['min_child_endpoints'] = endpoint['properties']['minChildEndpoints']
36
+ hash
37
+ end
38
+
39
+ def save
40
+ requires :name, :traffic_manager_profile_name, :resource_group, :type
41
+ requires :target_resource_id if type.eql?('azure')
42
+ requires :target, :endpoint_location if type.eql?('external')
43
+ requires :target_resource_id, :endpoint_location, :min_child_endpoints if type.eql?('nested')
44
+
45
+ if %w(azure external nested).select { |type| type if type.eql?(type) }.any?
46
+ traffic_manager_endpoint = service.create_traffic_manager_endpoint(resource_group, name,
47
+ traffic_manager_profile_name, type,
48
+ target_resource_id, target, weight,
49
+ priority, endpoint_location,
50
+ min_child_endpoints)
51
+ merge_attributes(Fog::Network::AzureRM::TrafficManagerEndPoint.parse(traffic_manager_endpoint))
52
+ else
53
+ raise(ArgumentError, ':type should be "azure", "external" or "nested"')
54
+ end
55
+ end
56
+
57
+ def destroy
58
+ service.delete_traffic_manager_endpoint(resource_group, name, traffic_manager_profile_name, type)
59
+ end
60
+ end
61
+ end
62
+ end
63
+ end
@@ -0,0 +1,29 @@
1
+ module Fog
2
+ module Network
3
+ class AzureRM
4
+ # Traffic Manager End Point Collection for Network Service
5
+ class TrafficManagerEndPoints < Fog::Collection
6
+ attribute :resource_group
7
+ attribute :traffic_manager_profile_name
8
+ model Fog::Network::AzureRM::TrafficManagerEndPoint
9
+
10
+ def all
11
+ requires :resource_group
12
+ requires :traffic_manager_profile_name
13
+
14
+ traffic_manager_endpoints = []
15
+ profile = service.get_traffic_manager_profile(resource_group, traffic_manager_profile_name)
16
+ end_points = profile['properties']['endpoints']
17
+ end_points.each do |endpoint|
18
+ traffic_manager_endpoints << Fog::Network::AzureRM::TrafficManagerEndPoint.parse(endpoint)
19
+ end
20
+ load(traffic_manager_endpoints)
21
+ end
22
+
23
+ def get(identity)
24
+ all.find { |endpoint| endpoint.name == identity }
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,59 @@
1
+ module Fog
2
+ module Network
3
+ class AzureRM
4
+ # Traffic Manager Profile model for Network Service
5
+ class TrafficManagerProfile < Fog::Model
6
+ identity :name
7
+ attribute :id
8
+ attribute :resource_group
9
+ attribute :location
10
+ attribute :profile_status
11
+ attribute :traffic_routing_method
12
+ attribute :relative_name
13
+ attribute :fqdn
14
+ attribute :ttl
15
+ attribute :profile_monitor_status
16
+ attribute :protocol
17
+ attribute :port
18
+ attribute :path
19
+ attribute :endpoints
20
+
21
+ def self.parse(profile)
22
+ hash = {}
23
+ hash['id'] = profile['id']
24
+ hash['name'] = profile['name']
25
+ hash['resource_group'] = profile['id'].split('/')[4]
26
+ hash['location'] = profile['location']
27
+ hash['profile_status'] = profile['properties']['profileStatus']
28
+ hash['traffic_routing_method'] = profile['properties']['trafficRoutingMethod']
29
+ hash['relative_name'] = profile['properties']['dnsConfig']['relativeName']
30
+ hash['fqdn'] = profile['properties']['dnsConfig']['fqdn']
31
+ hash['ttl'] = profile['properties']['dnsConfig']['ttl']
32
+ hash['profile_monitor_status'] = profile['properties']['monitorConfig']['profileMonitorStatus']
33
+ hash['protocol'] = profile['properties']['monitorConfig']['protocol']
34
+ hash['port'] = profile['properties']['monitorConfig']['port']
35
+ hash['path'] = profile['properties']['monitorConfig']['path']
36
+ hash['endpoints'] = []
37
+ profile['properties']['endpoints'].each do |endpoint|
38
+ end_point = Fog::Network::AzureRM::TrafficManagerEndPoint.new
39
+ hash['endpoints'] << end_point.merge_attributes(Fog::Network::AzureRM::TrafficManagerEndPoint.parse(endpoint))
40
+ end
41
+ hash
42
+ end
43
+
44
+ def save
45
+ requires :name, :resource_group, :traffic_routing_method, :relative_name, :ttl,
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)
50
+ merge_attributes(Fog::Network::AzureRM::TrafficManagerProfile.parse(traffic_manager_profile))
51
+ end
52
+
53
+ def destroy
54
+ service.delete_traffic_manager_profile(resource_group, name)
55
+ end
56
+ end
57
+ end
58
+ end
59
+ end
@@ -0,0 +1,24 @@
1
+ module Fog
2
+ module Network
3
+ class AzureRM
4
+ # Traffic Manager Profile Collection for Network Service
5
+ class TrafficManagerProfiles < Fog::Collection
6
+ attribute :resource_group
7
+ model Fog::Network::AzureRM::TrafficManagerProfile
8
+
9
+ def all
10
+ requires :resource_group
11
+ traffic_manager_profiles = []
12
+ service.list_traffic_manager_profiles(resource_group).each do |profile|
13
+ traffic_manager_profiles << Fog::Network::AzureRM::TrafficManagerProfile.parse(profile)
14
+ end
15
+ load(traffic_manager_profiles)
16
+ end
17
+
18
+ def get(identity)
19
+ all.find { |profile| profile.name == identity }
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
@@ -5,20 +5,33 @@ module Fog
5
5
  identity :name
6
6
  attribute :id
7
7
  attribute :location
8
+ attribute :resource_group
8
9
  attribute :dns_list
9
10
  attribute :subnet_address_list
10
11
  attribute :network_address_list
11
- attribute :resource_group
12
- attribute :properties
12
+
13
+ def self.parse(vnet)
14
+ hash = {}
15
+ hash['id'] = vnet['id']
16
+ hash['name'] = vnet['name']
17
+ hash['resource_group'] = vnet['id'].split('/')[4]
18
+ hash['location'] = vnet['location']
19
+ hash['dns_list'] = vnet['properties']['dhcpOptions']['dnsServers'].join(',') unless vnet['properties']['dhcpOptions'].nil?
20
+ hash['network_address_list'] = vnet['properties']['addressSpace']['addressPrefixes'].join(',') unless vnet['properties']['addressSpace']['addressPrefixes'].nil?
21
+ subnet_address_list = []
22
+ vnet['properties']['subnets'].each do |subnet|
23
+ subnet_address_list << subnet['properties']['addressPrefix']
24
+ end
25
+ hash['subnet_address_list'] = subnet_address_list.join(',')
26
+ hash
27
+ end
13
28
 
14
29
  def save
15
30
  requires :name
16
31
  requires :location
17
32
  requires :resource_group
18
- Fog::Logger.debug "Creating Virtual Network: #{name}..."
19
- virtual_network = service.create_virtual_network(name, location, resource_group, dns_list, subnet_address_list, network_address_list)
20
- Fog::Logger.debug "Virtual Network #{name} created successfully."
21
- virtual_network
33
+ vnet = service.create_virtual_network(resource_group, name, location, dns_list, subnet_address_list, network_address_list)
34
+ merge_attributes(Fog::Network::AzureRM::VirtualNetwork.parse(vnet))
22
35
  end
23
36
 
24
37
  def destroy