fog-azure-rm 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CONTRIBUTING.md +19 -8
- data/LICENSE.md +1 -1
- data/README.md +9 -8
- data/lib/fog/azurerm/models/compute/availability_set.rb +17 -3
- data/lib/fog/azurerm/models/compute/availability_sets.rb +2 -6
- data/lib/fog/azurerm/models/compute/server.rb +1 -1
- data/lib/fog/azurerm/models/compute/servers.rb +3 -1
- data/lib/fog/azurerm/models/dns/record_set.rb +31 -3
- data/lib/fog/azurerm/models/dns/record_sets.rb +7 -17
- data/lib/fog/azurerm/models/dns/zone.rb +26 -3
- data/lib/fog/azurerm/models/dns/zones.rb +8 -6
- data/lib/fog/azurerm/models/network/frontend_ip_configuration.rb +32 -0
- data/lib/fog/azurerm/models/network/inbound_nat_pool.rb +27 -0
- data/lib/fog/azurerm/models/network/inbound_nat_rule.rb +29 -0
- data/lib/fog/azurerm/models/network/load_balancer.rb +249 -0
- data/lib/fog/azurerm/models/network/load_balancers.rb +27 -0
- data/lib/fog/azurerm/models/network/load_balancing_rule.rb +42 -0
- data/lib/fog/azurerm/models/network/network_interface.rb +46 -7
- data/lib/fog/azurerm/models/network/network_interfaces.rb +2 -8
- data/lib/fog/azurerm/models/network/network_security_group.rb +89 -0
- data/lib/fog/azurerm/models/network/network_security_groups.rb +27 -0
- data/lib/fog/azurerm/models/network/network_security_rule.rb +40 -0
- data/lib/fog/azurerm/models/network/probe.rb +29 -0
- data/lib/fog/azurerm/models/network/public_ip.rb +32 -4
- data/lib/fog/azurerm/models/network/public_ips.rb +2 -8
- data/lib/fog/azurerm/models/network/subnet.rb +20 -12
- data/lib/fog/azurerm/models/network/subnets.rb +1 -7
- data/lib/fog/azurerm/models/network/traffic_manager_end_point.rb +63 -0
- data/lib/fog/azurerm/models/network/traffic_manager_end_points.rb +29 -0
- data/lib/fog/azurerm/models/network/traffic_manager_profile.rb +59 -0
- data/lib/fog/azurerm/models/network/traffic_manager_profiles.rb +24 -0
- data/lib/fog/azurerm/models/network/virtual_network.rb +19 -6
- data/lib/fog/azurerm/models/network/virtual_networks.rb +4 -9
- data/lib/fog/azurerm/models/resources/resource_group.rb +2 -1
- data/lib/fog/azurerm/models/resources/resource_groups.rb +1 -9
- data/lib/fog/azurerm/models/storage/storage_account.rb +5 -7
- data/lib/fog/azurerm/models/storage/storage_accounts.rb +5 -6
- data/lib/fog/azurerm/network.rb +30 -0
- data/lib/fog/azurerm/requests/compute/create_availability_set.rb +13 -2
- data/lib/fog/azurerm/requests/compute/create_virtual_machine.rb +60 -2
- data/lib/fog/azurerm/requests/compute/deallocate_virtual_machine.rb +4 -2
- data/lib/fog/azurerm/requests/compute/delete_availability_set.rb +4 -2
- data/lib/fog/azurerm/requests/compute/delete_virtual_machine.rb +4 -2
- data/lib/fog/azurerm/requests/compute/generalize_virtual_machine.rb +4 -2
- data/lib/fog/azurerm/requests/compute/get_virtual_machine.rb +57 -1
- data/lib/fog/azurerm/requests/compute/list_availability_sets.rb +16 -1
- data/lib/fog/azurerm/requests/compute/list_available_sizes_for_virtual_machine.rb +27 -1
- data/lib/fog/azurerm/requests/compute/power_off_virtual_machine.rb +4 -2
- data/lib/fog/azurerm/requests/compute/redeploy_virtual_machine.rb +4 -2
- data/lib/fog/azurerm/requests/compute/restart_virtual_machine.rb +4 -2
- data/lib/fog/azurerm/requests/compute/start_virtual_machine.rb +4 -2
- data/lib/fog/azurerm/requests/dns/check_for_zone.rb +16 -17
- data/lib/fog/azurerm/requests/dns/create_record_set.rb +80 -37
- data/lib/fog/azurerm/requests/dns/create_zone.rb +43 -27
- data/lib/fog/azurerm/requests/dns/delete_record_set.rb +17 -19
- data/lib/fog/azurerm/requests/dns/delete_zone.rb +16 -19
- data/lib/fog/azurerm/requests/dns/get_records_from_record_set.rb +29 -28
- data/lib/fog/azurerm/requests/dns/list_record_sets.rb +49 -23
- data/lib/fog/azurerm/requests/dns/list_zones.rb +57 -23
- data/lib/fog/azurerm/requests/network/check_for_public_ip.rb +3 -1
- data/lib/fog/azurerm/requests/network/check_for_virtual_network.rb +4 -2
- data/lib/fog/azurerm/requests/network/create_load_balancer.rb +208 -0
- data/lib/fog/azurerm/requests/network/create_network_interface.rb +42 -4
- data/lib/fog/azurerm/requests/network/create_network_security_group.rb +200 -0
- data/lib/fog/azurerm/requests/network/create_public_ip.rb +19 -5
- data/lib/fog/azurerm/requests/network/create_subnet.rb +19 -6
- data/lib/fog/azurerm/requests/network/create_traffic_manager_endpoint.rb +78 -0
- data/lib/fog/azurerm/requests/network/create_traffic_manager_profile.rb +127 -0
- data/lib/fog/azurerm/requests/network/create_virtual_network.rb +40 -5
- data/lib/fog/azurerm/requests/network/delete_load_balancer.rb +27 -0
- data/lib/fog/azurerm/requests/network/delete_network_interface.rb +5 -3
- data/lib/fog/azurerm/requests/network/delete_network_security_group.rb +29 -0
- data/lib/fog/azurerm/requests/network/delete_public_ip.rb +4 -2
- data/lib/fog/azurerm/requests/network/delete_subnet.rb +10 -8
- data/lib/fog/azurerm/requests/network/delete_traffic_manager_endpoint.rb +37 -0
- data/lib/fog/azurerm/requests/network/delete_traffic_manager_profile.rb +37 -0
- data/lib/fog/azurerm/requests/network/delete_virtual_network.rb +8 -6
- data/lib/fog/azurerm/requests/network/get_traffic_manager_profile.rb +96 -0
- data/lib/fog/azurerm/requests/network/list_load_balancers.rb +31 -0
- data/lib/fog/azurerm/requests/network/list_network_interfaces.rb +41 -9
- data/lib/fog/azurerm/requests/network/list_network_security_groups.rb +171 -0
- data/lib/fog/azurerm/requests/network/list_public_ips.rb +21 -9
- data/lib/fog/azurerm/requests/network/list_subnets.rb +34 -11
- data/lib/fog/azurerm/requests/network/list_traffic_manager_profiles.rb +98 -0
- data/lib/fog/azurerm/requests/network/list_virtual_networks.rb +53 -8
- data/lib/fog/azurerm/requests/resources/create_resource_group.rb +11 -2
- data/lib/fog/azurerm/requests/resources/delete_resource_group.rb +4 -2
- data/lib/fog/azurerm/requests/resources/list_resource_groups.rb +23 -7
- data/lib/fog/azurerm/requests/storage/check_storage_account_name_availability.rb +2 -0
- data/lib/fog/azurerm/requests/storage/create_storage_account.rb +14 -8
- data/lib/fog/azurerm/requests/storage/delete_storage_account.rb +4 -3
- data/lib/fog/azurerm/requests/storage/list_storage_account_for_rg.rb +33 -2
- data/lib/fog/azurerm/requests/storage/list_storage_accounts.rb +32 -5
- data/lib/fog/azurerm/storage.rb +0 -1
- data/lib/fog/azurerm/version.rb +1 -1
- metadata +35 -10
@@ -4,11 +4,14 @@ module Fog
|
|
4
4
|
class AzureRM
|
5
5
|
# Real class for Network Request
|
6
6
|
class Real
|
7
|
-
def create_network_interface(name, location,
|
7
|
+
def create_network_interface(resource_group, name, location, subnet_id, ip_config_name, prv_ip_alloc_method)
|
8
|
+
Fog::Logger.debug "Creating Network Interface Card: #{name}..."
|
8
9
|
network_interface = define_network_interface(name, location, subnet_id, ip_config_name, prv_ip_alloc_method)
|
9
10
|
begin
|
10
11
|
promise = @network_client.network_interfaces.create_or_update(resource_group, name, network_interface)
|
11
|
-
promise.value!
|
12
|
+
result = promise.value!
|
13
|
+
Fog::Logger.debug "Network Interface #{name} created successfully."
|
14
|
+
Azure::ARM::Network::Models::NetworkInterface.serialize_object(result.body)
|
12
15
|
rescue MsRestAzure::AzureOperationError => e
|
13
16
|
msg = "Exception creating Network Interface #{name} in Resource Group: #{resource_group}. #{e.body['error']['message']}"
|
14
17
|
raise msg
|
@@ -43,8 +46,43 @@ module Fog
|
|
43
46
|
|
44
47
|
# Mock class for Network Request
|
45
48
|
class Mock
|
46
|
-
def create_network_interface(name, location,
|
47
|
-
|
49
|
+
def create_network_interface(resource_group, name, location, subnet_id, ip_configs_name, prv_ip_alloc_method)
|
50
|
+
{
|
51
|
+
'id' => "/subscriptions/########-####-####-####-############/resourceGroups/#{resource_group}/providers/Microsoft.Network/networkInterfaces/#{name}",
|
52
|
+
'name' => name,
|
53
|
+
'type' => 'Microsoft.Network/networkInterfaces',
|
54
|
+
'location' => location,
|
55
|
+
'properties' =>
|
56
|
+
{
|
57
|
+
'ipConfigurations' =>
|
58
|
+
[
|
59
|
+
{
|
60
|
+
'id' => "/subscriptions/########-####-####-####-############/resourceGroups/#{resource_group}/providers/Microsoft.Network/networkInterfaces/#{name}/ipConfigurations/#{ip_configs_name}",
|
61
|
+
'properties' =>
|
62
|
+
{
|
63
|
+
'privateIPAddress' => '10.0.0.5',
|
64
|
+
'privateIPAllocationMethod' => prv_ip_alloc_method,
|
65
|
+
'subnet' =>
|
66
|
+
{
|
67
|
+
'id' => subnet_id
|
68
|
+
},
|
69
|
+
'provisioningState' => 'Succeeded'
|
70
|
+
},
|
71
|
+
'name' => ip_configs_name,
|
72
|
+
'etag' => "W/\"e6c8e5c3-f28d-44f3-babe-0e8e934a591e\""
|
73
|
+
}
|
74
|
+
],
|
75
|
+
'dnsSettings' =>
|
76
|
+
{
|
77
|
+
'dnsServers' => [],
|
78
|
+
'appliedDnsServers' => []
|
79
|
+
},
|
80
|
+
'enableIPForwarding' => false,
|
81
|
+
'resourceGuid' => '2bff0fad-623b-4773-82b8-dc875f3aacd2',
|
82
|
+
'provisioningState' => 'Succeeded'
|
83
|
+
},
|
84
|
+
'etag' => "W/\"e6c8e5c3-f28d-44f3-babe-0e8e934a591e\""
|
85
|
+
}
|
48
86
|
end
|
49
87
|
end
|
50
88
|
end
|
@@ -0,0 +1,200 @@
|
|
1
|
+
module Fog
|
2
|
+
module Network
|
3
|
+
class AzureRM
|
4
|
+
# Real class for Network Request
|
5
|
+
class Real
|
6
|
+
def create_network_security_group(resource_group, name, location, security_rules)
|
7
|
+
Fog::Logger.debug "Creating Network Security Group #{name} in Resource Group #{resource_group}."
|
8
|
+
properties = Azure::ARM::Network::Models::NetworkSecurityGroupPropertiesFormat.new
|
9
|
+
properties.security_rules = define_security_rules(security_rules)
|
10
|
+
|
11
|
+
params = Azure::ARM::Network::Models::NetworkSecurityGroup.new
|
12
|
+
params.location = location
|
13
|
+
params.properties = properties
|
14
|
+
begin
|
15
|
+
promise = @network_client.network_security_groups.begin_create_or_update(resource_group, name, params)
|
16
|
+
result = promise.value!
|
17
|
+
Fog::Logger.debug "Network Security Group #{name} Created Successfully!"
|
18
|
+
Azure::ARM::Network::Models::NetworkSecurityGroup.serialize_object(result.body)
|
19
|
+
rescue MsRestAzure::AzureOperationError => e
|
20
|
+
msg = "Exception creating Network Security Group #{name} in Resource Group: #{resource_group}. #{e.body['error']['message']}"
|
21
|
+
raise msg
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
def define_security_rules(security_rules)
|
28
|
+
rules = []
|
29
|
+
security_rules.each do |sr|
|
30
|
+
properties = Azure::ARM::Network::Models::SecurityRulePropertiesFormat.new
|
31
|
+
properties.description = sr[:description] unless sr[:description].nil?
|
32
|
+
properties.protocol = sr[:protocol]
|
33
|
+
properties.source_port_range = sr[:source_port_range]
|
34
|
+
properties.destination_port_range = sr[:destination_port_range]
|
35
|
+
properties.source_address_prefix = sr[:source_address_prefix]
|
36
|
+
properties.destination_address_prefix = sr[:destination_address_prefix]
|
37
|
+
properties.access = sr[:access]
|
38
|
+
properties.priority = sr[:priority]
|
39
|
+
properties.direction = sr[:direction]
|
40
|
+
|
41
|
+
security_rule = Azure::ARM::Network::Models::SecurityRule.new
|
42
|
+
security_rule.name = sr[:name]
|
43
|
+
security_rule.properties = properties
|
44
|
+
rules << security_rule
|
45
|
+
end unless security_rules.nil?
|
46
|
+
rules
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
# Mock class for Network Request
|
51
|
+
class Mock
|
52
|
+
def create_network_security_group(resource_group, name, location, security_rules)
|
53
|
+
{
|
54
|
+
'id' => "/subscriptions/########-####-####-####-############/resourceGroups/#{resource_group}/providers/Microsoft.Network/networkSecurityGroups/#{name}",
|
55
|
+
'name' => name,
|
56
|
+
'type' => 'Microsoft.Network/networkSecurityGroups',
|
57
|
+
'location' => location,
|
58
|
+
'properties' =>
|
59
|
+
{
|
60
|
+
'securityRules' =>
|
61
|
+
[
|
62
|
+
{
|
63
|
+
'id' => "/subscriptions/########-####-####-####-############/resourceGroups/#{resource_group}/providers/Microsoft.Network/networkSecurityGroups/#{name}/securityRules/testRule",
|
64
|
+
'properties' =>
|
65
|
+
{
|
66
|
+
'protocol' => 'tcp',
|
67
|
+
'sourceAddressPrefix' => '0.0.0.0/0',
|
68
|
+
'destinationAddressPrefix' => '0.0.0.0/0',
|
69
|
+
'access' => 'Allow',
|
70
|
+
'direction' => 'Inbound',
|
71
|
+
'sourcePortRange' => '22',
|
72
|
+
'destinationPortRange' => '22',
|
73
|
+
'priority' => 100,
|
74
|
+
'provisioningState' => 'Updating'
|
75
|
+
},
|
76
|
+
'name' => 'testRule',
|
77
|
+
'etag' => "W/\"0fded34d-08bb-4862-a766-f3ce67044920\""
|
78
|
+
}
|
79
|
+
],
|
80
|
+
'defaultSecurityRules' =>
|
81
|
+
[
|
82
|
+
{
|
83
|
+
'id' => "/subscriptions/########-####-####-####-############/resourceGroups/#{resource_group}/providers/Microsoft.Network/networkSecurityGroups/#{name}/defaultSecurityRules/AllowVnetInBound",
|
84
|
+
'properties' =>
|
85
|
+
{
|
86
|
+
'protocol' => '*',
|
87
|
+
'sourceAddressPrefix' => 'VirtualNetwork',
|
88
|
+
'destinationAddressPrefix' => 'VirtualNetwork',
|
89
|
+
'access' => 'Allow',
|
90
|
+
'direction' => 'Inbound',
|
91
|
+
'description' => 'Allow inbound traffic from all VMs in VNET',
|
92
|
+
'sourcePortRange' => '*',
|
93
|
+
'destinationPortRange' => '*',
|
94
|
+
'priority' => 65000,
|
95
|
+
'provisioningState' => 'Updating'
|
96
|
+
},
|
97
|
+
'name' => 'AllowVnetInBound',
|
98
|
+
'etag' => "W/\"0fded34d-08bb-4862-a766-f3ce67044920\""
|
99
|
+
},
|
100
|
+
{
|
101
|
+
'id' => "/subscriptions/########-####-####-####-############/resourceGroups/#{resource_group}/providers/Microsoft.Network/networkSecurityGroups/#{name}/defaultSecurityRules/AllowAzureLoadBalancerInBound",
|
102
|
+
'properties' =>
|
103
|
+
{
|
104
|
+
'protocol' => '*',
|
105
|
+
'sourceAddressPrefix' => 'AzureLoadBalancer',
|
106
|
+
'destinationAddressPrefix' => '*',
|
107
|
+
'access' => 'Allow',
|
108
|
+
'direction' => 'Inbound',
|
109
|
+
'description' => 'Allow inbound traffic from azure load balancer',
|
110
|
+
'sourcePortRange' => '*',
|
111
|
+
'destinationPortRange' => '*',
|
112
|
+
'priority' => 65001,
|
113
|
+
'provisioningState' => 'Updating'
|
114
|
+
},
|
115
|
+
'name' => 'AllowAzureLoadBalancerInBound',
|
116
|
+
'etag' => "W/\"0fded34d-08bb-4862-a766-f3ce67044920\""
|
117
|
+
},
|
118
|
+
{
|
119
|
+
'id' => "/subscriptions/########-####-####-####-############/resourceGroups/#{resource_group}/providers/Microsoft.Network/networkSecurityGroups/#{name}/defaultSecurityRules/DenyAllInBound",
|
120
|
+
'properties' =>
|
121
|
+
{
|
122
|
+
'protocol' => '*',
|
123
|
+
'sourceAddressPrefix' => '*',
|
124
|
+
'destinationAddressPrefix' => '*',
|
125
|
+
'access' => 'Deny',
|
126
|
+
'direction' => 'Inbound',
|
127
|
+
'description' => 'Deny all inbound traffic',
|
128
|
+
'sourcePortRange' => '*',
|
129
|
+
'destinationPortRange' => '*',
|
130
|
+
'priority' => 65500,
|
131
|
+
'provisioningState' => 'Updating'
|
132
|
+
},
|
133
|
+
'name' => 'DenyAllInBound',
|
134
|
+
'etag' => "W/\"0fded34d-08bb-4862-a766-f3ce67044920\""
|
135
|
+
},
|
136
|
+
{
|
137
|
+
'id' => "/subscriptions/########-####-####-####-############/resourceGroups/#{resource_group}/providers/Microsoft.Network/networkSecurityGroups/#{name}/defaultSecurityRules/AllowVnetOutBound",
|
138
|
+
'properties' =>
|
139
|
+
{
|
140
|
+
'protocol' => '*',
|
141
|
+
'sourceAddressPrefix' => 'VirtualNetwork',
|
142
|
+
'destinationAddressPrefix' => 'VirtualNetwork',
|
143
|
+
'access' => 'Allow',
|
144
|
+
'direction' => 'Outbound',
|
145
|
+
'description' => 'Allow outbound traffic from all VMs to all VMs in VNET',
|
146
|
+
'sourcePortRange' => '*',
|
147
|
+
'destinationPortRange' => '*',
|
148
|
+
'priority' => 65000,
|
149
|
+
'provisioningState' => 'Updating'
|
150
|
+
},
|
151
|
+
'name' => 'AllowVnetOutBound',
|
152
|
+
'etag' => "W/\"0fded34d-08bb-4862-a766-f3ce67044920\""
|
153
|
+
},
|
154
|
+
{
|
155
|
+
'id' => "/subscriptions/########-####-####-####-############/resourceGroups/#{resource_group}/providers/Microsoft.Network/networkSecurityGroups/#{name}/defaultSecurityRules/AllowInternetOutBound",
|
156
|
+
'properties' =>
|
157
|
+
{
|
158
|
+
'protocol' => '*',
|
159
|
+
'sourceAddressPrefix' => '*',
|
160
|
+
'destinationAddressPrefix' => 'Internet',
|
161
|
+
'access' => 'Allow',
|
162
|
+
'direction' => 'Outbound',
|
163
|
+
'description' => 'Allow outbound traffic from all VMs to Internet',
|
164
|
+
'sourcePortRange' => '*',
|
165
|
+
'destinationPortRange' => '*',
|
166
|
+
'priority' => 65001,
|
167
|
+
'provisioningState' => 'Updating'
|
168
|
+
},
|
169
|
+
'name' => 'AllowInternetOutBound',
|
170
|
+
'etag' => "W/\"0fded34d-08bb-4862-a766-f3ce67044920\""
|
171
|
+
},
|
172
|
+
{
|
173
|
+
'id' => "/subscriptions/########-####-####-####-############/resourceGroups/#{resource_group}/providers/Microsoft.Network/networkSecurityGroups/#{name}/defaultSecurityRules/DenyAllOutBound",
|
174
|
+
'properties' =>
|
175
|
+
{
|
176
|
+
'protocol' => '*',
|
177
|
+
'sourceAddressPrefix' => '*',
|
178
|
+
'destinationAddressPrefix' => '*',
|
179
|
+
'access' => 'Deny',
|
180
|
+
'direction' => 'Outbound',
|
181
|
+
'description' => 'Deny all outbound traffic',
|
182
|
+
'sourcePortRange' => '*',
|
183
|
+
'destinationPortRange' => '*',
|
184
|
+
'priority' => 65500,
|
185
|
+
'provisioningState' => 'Updating'
|
186
|
+
},
|
187
|
+
'name' => 'DenyAllOutBound',
|
188
|
+
'etag' => "W/\"0fded34d-08bb-4862-a766-f3ce67044920\""
|
189
|
+
}
|
190
|
+
],
|
191
|
+
'resourceGuid' => '9dca97e6-4789-4ebd-86e3-52b8b0da6cd4',
|
192
|
+
'provisioningState' => 'Updating'
|
193
|
+
},
|
194
|
+
'etag' => "W/\"0fded34d-08bb-4862-a766-f3ce67044920\""
|
195
|
+
}
|
196
|
+
end
|
197
|
+
end
|
198
|
+
end
|
199
|
+
end
|
200
|
+
end
|
@@ -3,11 +3,10 @@ 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,
|
6
|
+
def create_public_ip(resource_group, name, location, public_ip_allocation_method)
|
7
7
|
Fog::Logger.debug "Creating PublicIP #{name} in Resource Group #{resource_group}."
|
8
8
|
properties = Azure::ARM::Network::Models::PublicIPAddressPropertiesFormat.new
|
9
|
-
properties.public_ipallocation_method =
|
10
|
-
|
9
|
+
properties.public_ipallocation_method = public_ip_allocation_method
|
11
10
|
public_ip = Azure::ARM::Network::Models::PublicIPAddress.new
|
12
11
|
public_ip.name = name
|
13
12
|
public_ip.location = location
|
@@ -16,7 +15,7 @@ module Fog
|
|
16
15
|
promise = @network_client.public_ipaddresses.create_or_update(resource_group, name, public_ip)
|
17
16
|
result = promise.value!
|
18
17
|
Fog::Logger.debug "PublicIP #{name} Created Successfully!"
|
19
|
-
result
|
18
|
+
Azure::ARM::Network::Models::PublicIPAddress.serialize_object(result.body)
|
20
19
|
rescue MsRestAzure::AzureOperationError => e
|
21
20
|
msg = "Exception creating Public IP #{name} in Resource Group: #{resource_group}. #{e.body['error']['message']}"
|
22
21
|
raise msg
|
@@ -26,7 +25,22 @@ module Fog
|
|
26
25
|
|
27
26
|
# Mock class for Network Request
|
28
27
|
class Mock
|
29
|
-
def create_public_ip(resource_group, name,
|
28
|
+
def create_public_ip(resource_group, name, location, public_ip_allocation_method)
|
29
|
+
{
|
30
|
+
'id' => "/subscriptions/########-####-####-####-############/resourceGroups/#{resource_group}/providers/Microsoft.Network/publicIPAddresses/#{name}",
|
31
|
+
'name' => name,
|
32
|
+
'type' => 'Microsoft.Network/publicIPAddresses',
|
33
|
+
'location' => location,
|
34
|
+
'properties' =>
|
35
|
+
{
|
36
|
+
'publicIPAllocationMethod' => public_ip_allocation_method,
|
37
|
+
'ipAddress' => '13.91.253.67',
|
38
|
+
'idleTimeoutInMinutes' => 4,
|
39
|
+
'resourceGuid' => '767b1955-94de-433c-8e4a-ea0ad25e8d0c',
|
40
|
+
'provisioningState' => 'Succeeded'
|
41
|
+
},
|
42
|
+
'etag' => "W/\"450f3b58-92fb-4de1-bb91-2f5b47c1de96\""
|
43
|
+
}
|
30
44
|
end
|
31
45
|
end
|
32
46
|
end
|
@@ -3,18 +3,21 @@ module Fog
|
|
3
3
|
class AzureRM
|
4
4
|
# Real class for Network Request
|
5
5
|
class Real
|
6
|
-
def create_subnet(resource_group,
|
6
|
+
def create_subnet(resource_group, name, virtual_network_name, addressPrefix)
|
7
|
+
Fog::Logger.debug "Creating Subnet: #{name}..."
|
7
8
|
subnet_properties = Azure::ARM::Network::Models::SubnetPropertiesFormat.new
|
8
9
|
subnet_properties.address_prefix = addressPrefix unless addressPrefix.nil?
|
9
10
|
|
10
11
|
subnet = Azure::ARM::Network::Models::Subnet.new
|
11
|
-
subnet.name =
|
12
|
+
subnet.name = name
|
12
13
|
subnet.properties = subnet_properties
|
13
14
|
begin
|
14
|
-
promise = @network_client.subnets.create_or_update(resource_group, virtual_network_name,
|
15
|
-
promise.value!
|
15
|
+
promise = @network_client.subnets.create_or_update(resource_group, virtual_network_name, name, subnet)
|
16
|
+
result = promise.value!
|
17
|
+
Fog::Logger.debug "Subnet #{name} created successfully."
|
18
|
+
Azure::ARM::Network::Models::Subnet.serialize_object(result.body)
|
16
19
|
rescue MsRestAzure::AzureOperationError => e
|
17
|
-
msg = "Exception creating Subnet #{
|
20
|
+
msg = "Exception creating Subnet #{name} in Resource Group: #{resource_group}. #{e.body['error']['message']}"
|
18
21
|
raise msg
|
19
22
|
end
|
20
23
|
end
|
@@ -22,7 +25,17 @@ module Fog
|
|
22
25
|
|
23
26
|
# Mock class for Network Request
|
24
27
|
class Mock
|
25
|
-
def create_subnet(
|
28
|
+
def create_subnet(resource_group, name, virtual_network_name, addressPrefix)
|
29
|
+
{
|
30
|
+
'id' => "/subscriptions/########-####-####-####-############/resourceGroups/#{resource_group}/providers/Microsoft.Network/virtualNetworks/#{virtual_network_name}/subnets/#{name}",
|
31
|
+
'properties' =>
|
32
|
+
{
|
33
|
+
'addressPrefix' => addressPrefix,
|
34
|
+
'provisioningState' => 'Succeeded'
|
35
|
+
},
|
36
|
+
'name' => name,
|
37
|
+
'etag' => "W/\"88188301-2b72-4243-a734-996d4851c308\""
|
38
|
+
}
|
26
39
|
end
|
27
40
|
end
|
28
41
|
end
|
@@ -0,0 +1,78 @@
|
|
1
|
+
module Fog
|
2
|
+
module Network
|
3
|
+
class AzureRM
|
4
|
+
# Real class for Network Request
|
5
|
+
class Real
|
6
|
+
def create_traffic_manager_endpoint(resource_group, name, traffic_manager_profile_name, type,
|
7
|
+
target_resource_id, target, weight, priority, endpoint_location,
|
8
|
+
min_child_endpoints)
|
9
|
+
Fog::Logger.debug "Creating Traffic Manager Endpoint: #{name}..."
|
10
|
+
resource_url = "#{AZURE_RESOURCE}/subscriptions/#{@subscription_id}/resourceGroups/#{resource_group}/providers/Microsoft.Network/trafficManagerProfiles/#{traffic_manager_profile_name}/#{type}Endpoints/#{name}?api-version=2015-11-01"
|
11
|
+
payload = serialize_endpoint_request(name, type, target_resource_id, target, weight, priority, endpoint_location,
|
12
|
+
min_child_endpoints)
|
13
|
+
begin
|
14
|
+
token = Fog::Credentials::AzureRM.get_token(@tenant_id, @client_id, @client_secret)
|
15
|
+
response = RestClient.put(
|
16
|
+
resource_url,
|
17
|
+
payload.to_json,
|
18
|
+
accept: :json,
|
19
|
+
content_type: :json,
|
20
|
+
authorization: token
|
21
|
+
)
|
22
|
+
Fog::Logger.debug "Traffic Manager Endpoint: #{name} created successfully."
|
23
|
+
JSON.parse(response)
|
24
|
+
rescue => e
|
25
|
+
Fog::Logger.warning "Exception creating Traffic Manager Endpoint: #{name} in resource group #{resource_group}"
|
26
|
+
error_msg = JSON.parse(e.response)['message']
|
27
|
+
msg = "Exception creating Traffic Manager Endpoint: #{name} in resource group #{resource_group}. #{error_msg}"
|
28
|
+
raise msg
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
private
|
33
|
+
|
34
|
+
def serialize_endpoint_request(name, type, target_resource_id, target, weight, priority, endpoint_location,
|
35
|
+
min_child_endpoints)
|
36
|
+
|
37
|
+
properties = {}
|
38
|
+
properties['targetResourceId'] = target_resource_id unless target_resource_id.nil?
|
39
|
+
properties['target'] = target unless target.nil?
|
40
|
+
properties['weight'] = weight
|
41
|
+
properties['priority'] = priority
|
42
|
+
properties['endpointLocation'] = endpoint_location unless endpoint_location.nil?
|
43
|
+
properties['minChildEndpoints'] = min_child_endpoints unless min_child_endpoints.nil?
|
44
|
+
|
45
|
+
payload = {}
|
46
|
+
payload['name'] = name
|
47
|
+
payload['type'] = "Microsoft.Network/trafficManagerProfiles/#{type}Endpoints"
|
48
|
+
payload['properties'] = properties
|
49
|
+
|
50
|
+
payload
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
# Mock class for Network Request
|
55
|
+
class Mock
|
56
|
+
def create_traffic_manager_endpoint(resource_group, name, traffic_manager_profile_name, type,
|
57
|
+
target_resource_id, target, weight, priority, endpoint_location,
|
58
|
+
min_child_endpoints)
|
59
|
+
response = {}
|
60
|
+
properties = {}
|
61
|
+
|
62
|
+
properties['weight'] = weight
|
63
|
+
properties['priority'] = priority
|
64
|
+
properties['targetResourceId'] = target_resource_id unless target_resource_id.nil?
|
65
|
+
properties['target'] = target unless target.nil?
|
66
|
+
properties['endpointLocation'] = endpoint_location unless endpoint_location.nil?
|
67
|
+
properties['minChildEndpoints'] = min_child_endpoints unless min_child_endpoints.nil?
|
68
|
+
|
69
|
+
response['id'] = "/subscriptions/######/resourceGroups/#{resource_group}/providers/Microsoft.Network/trafficManagerProfiles/#{traffic_manager_profile_name}/#{type}Endpoints/#{name}?api-version=2015-11-01"
|
70
|
+
response['type'] = "Microsoft.Network/trafficManagerProfiles/#{type}Endpoints"
|
71
|
+
response['properties'] = properties
|
72
|
+
|
73
|
+
response
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
@@ -0,0 +1,127 @@
|
|
1
|
+
module Fog
|
2
|
+
module Network
|
3
|
+
class AzureRM
|
4
|
+
# Real class for Network Request
|
5
|
+
class Real
|
6
|
+
def create_traffic_manager_profile(resource_group, name, traffic_routing_method, relative_name, ttl, protocol,
|
7
|
+
port, path)
|
8
|
+
Fog::Logger.debug "Creating Traffic Manager Profile: #{name}..."
|
9
|
+
resource_url = "#{AZURE_RESOURCE}/subscriptions/#{@subscription_id}/resourceGroups/#{resource_group}/providers/Microsoft.Network/trafficManagerProfiles/#{name}?api-version=2015-04-28-preview"
|
10
|
+
payload = serialize_profile_request(traffic_routing_method, relative_name, ttl, protocol, port, path)
|
11
|
+
begin
|
12
|
+
token = Fog::Credentials::AzureRM.get_token(@tenant_id, @client_id, @client_secret)
|
13
|
+
response = RestClient.put(
|
14
|
+
resource_url,
|
15
|
+
payload.to_json,
|
16
|
+
accept: :json,
|
17
|
+
content_type: :json,
|
18
|
+
authorization: token
|
19
|
+
)
|
20
|
+
Fog::Logger.debug "Traffic Manager Profile: #{name} created successfully."
|
21
|
+
JSON.parse(response)
|
22
|
+
rescue => e
|
23
|
+
Fog::Logger.warning "Exception creating Traffic Manager Profile: #{name} in resource group #{resource_group}"
|
24
|
+
error_msg = JSON.parse(e.response)['message']
|
25
|
+
msg = "Exception creating Traffic Manager Profile: #{name} in resource group #{resource_group}. #{error_msg}"
|
26
|
+
raise msg
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
private
|
31
|
+
|
32
|
+
def serialize_profile_request(traffic_routing_method, relative_name, ttl, protocol, port, path)
|
33
|
+
dns_config = {}
|
34
|
+
dns_config['relativeName'] = relative_name
|
35
|
+
dns_config['ttl'] = ttl
|
36
|
+
|
37
|
+
monitor_config = {}
|
38
|
+
monitor_config['protocol'] = protocol
|
39
|
+
monitor_config['port'] = port
|
40
|
+
monitor_config['path'] = path
|
41
|
+
|
42
|
+
properties = {}
|
43
|
+
properties['trafficRoutingMethod'] = traffic_routing_method
|
44
|
+
properties['dnsConfig'] = dns_config
|
45
|
+
properties['monitorConfig'] = monitor_config
|
46
|
+
properties['endpoints'] = []
|
47
|
+
|
48
|
+
payload = {}
|
49
|
+
payload['location'] = 'global'
|
50
|
+
payload['tags'] = {}
|
51
|
+
payload['properties'] = properties
|
52
|
+
|
53
|
+
payload
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
# Mock class for Network Request
|
58
|
+
class Mock
|
59
|
+
def create_traffic_manager_profile(resource_group, name, traffic_routing_method, relative_name, ttl, protocol,
|
60
|
+
port, path)
|
61
|
+
{
|
62
|
+
location: 'global',
|
63
|
+
tags: {},
|
64
|
+
id: "/subscriptions/####/resourceGroups/#{resource_group}/Microsoft.Network/trafficManagerProfiles/#{name}",
|
65
|
+
name: "#{name}",
|
66
|
+
type: 'Microsoft.Network/trafficManagerProfiles',
|
67
|
+
properties: {
|
68
|
+
profileStatus: 'Enabled',
|
69
|
+
trafficRoutingMethod: "#{traffic_routing_method}",
|
70
|
+
dnsConfig: {
|
71
|
+
relativeName: "#{relative_name}",
|
72
|
+
fqdn: 'myapp.trafficmanager.net',
|
73
|
+
ttl: ttl
|
74
|
+
},
|
75
|
+
monitorConfig: {
|
76
|
+
profileMonitorStatus: 'Online',
|
77
|
+
protocol: "#{protocol}",
|
78
|
+
port: port,
|
79
|
+
path: "#{path}"
|
80
|
+
},
|
81
|
+
|
82
|
+
endpoints: [{
|
83
|
+
id: "/subscriptions/####/resourceGroups/#{resource_group}/Microsoft.Network/trafficManagerProfiles/#{name}/azureEndpoints/endpoint-name1",
|
84
|
+
name: 'endpoint-name1',
|
85
|
+
type: 'Microsoft.Network/trafficManagerProfiles/azureEndpoints',
|
86
|
+
properties: {
|
87
|
+
endpointStatus: 'Enabled',
|
88
|
+
endpointMonitorStatus: 'Online',
|
89
|
+
targetResourceId: "/subscriptions/####/resourceGroups/#{resource_group}/Microsoft.Network",
|
90
|
+
target: 'myapp.azurewebsites.net',
|
91
|
+
weight: 10,
|
92
|
+
priority: 3,
|
93
|
+
endpointLocation: 'centralus'
|
94
|
+
}
|
95
|
+
}, {
|
96
|
+
id: "/subscriptions/####/resourceGroups/#{resource_group}/Microsoft.Network/trafficManagerProfiles/#{name}/externalEndpoints/endpoint-name2",
|
97
|
+
name: 'endpoint-name2',
|
98
|
+
type: 'Microsoft.Network/trafficManagerProfiles/externalEndpoints',
|
99
|
+
properties: {
|
100
|
+
endpointStatus: 'Enabled',
|
101
|
+
endpointMonitorStatus: 'Online',
|
102
|
+
target: 'myendpoint.contoso.com',
|
103
|
+
weight: 10,
|
104
|
+
priority: 5,
|
105
|
+
endpointLocation: 'northeurope'
|
106
|
+
}
|
107
|
+
}, {
|
108
|
+
id: "/subscriptions/####/resourceGroups/#{resource_group}/Microsoft.Network/trafficManagerProfiles/#{name}/nestedEndpoints/endpoint-name3",
|
109
|
+
name: 'endpoint-name3',
|
110
|
+
type: 'Microsoft.Network/trafficManagerProfiles/nestedEndpoints',
|
111
|
+
properties: {
|
112
|
+
endpointStatus: 'Enabled',
|
113
|
+
endpointMonitorStatus: 'Online',
|
114
|
+
targetResourceId: '####',
|
115
|
+
weight: 10,
|
116
|
+
priority: 1,
|
117
|
+
endpointLocation: 'westeurope',
|
118
|
+
minChildEndpoints: 1
|
119
|
+
}
|
120
|
+
}]
|
121
|
+
}
|
122
|
+
}
|
123
|
+
end
|
124
|
+
end
|
125
|
+
end
|
126
|
+
end
|
127
|
+
end
|