fog-azure-rm 0.0.0
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.
- checksums.yaml +7 -0
- data/CONTRIBUTING.md +27 -0
- data/CONTRIBUTORS.md +4 -0
- data/LICENSE.md +20 -0
- data/README.md +82 -0
- data/lib/fog/azurerm.rb +40 -0
- data/lib/fog/azurerm/compute.rb +61 -0
- data/lib/fog/azurerm/config.rb +1 -0
- data/lib/fog/azurerm/core.rb +12 -0
- data/lib/fog/azurerm/credentials.rb +37 -0
- data/lib/fog/azurerm/dns.rb +48 -0
- data/lib/fog/azurerm/models/compute/availability_set.rb +31 -0
- data/lib/fog/azurerm/models/compute/availability_sets.rb +36 -0
- data/lib/fog/azurerm/models/compute/server.rb +94 -0
- data/lib/fog/azurerm/models/compute/servers.rb +32 -0
- data/lib/fog/azurerm/models/dns/record_set.rb +28 -0
- data/lib/fog/azurerm/models/dns/record_sets.rb +44 -0
- data/lib/fog/azurerm/models/dns/zone.rb +21 -0
- data/lib/fog/azurerm/models/dns/zones.rb +30 -0
- data/lib/fog/azurerm/models/network/network_interface.rb +34 -0
- data/lib/fog/azurerm/models/network/network_interfaces.rb +35 -0
- data/lib/fog/azurerm/models/network/public_ip.rb +34 -0
- data/lib/fog/azurerm/models/network/public_ips.rb +46 -0
- data/lib/fog/azurerm/models/network/subnet.rb +34 -0
- data/lib/fog/azurerm/models/network/subnets.rb +37 -0
- data/lib/fog/azurerm/models/network/virtual_network.rb +30 -0
- data/lib/fog/azurerm/models/network/virtual_networks.rb +42 -0
- data/lib/fog/azurerm/models/resources/resource_group.rb +21 -0
- data/lib/fog/azurerm/models/resources/resource_groups.rb +28 -0
- data/lib/fog/azurerm/models/storage/storage_account.rb +37 -0
- data/lib/fog/azurerm/models/storage/storage_accounts.rb +45 -0
- data/lib/fog/azurerm/network.rb +67 -0
- data/lib/fog/azurerm/requests/compute/create_availability_set.rb +45 -0
- data/lib/fog/azurerm/requests/compute/create_virtual_machine.rb +100 -0
- data/lib/fog/azurerm/requests/compute/deallocate_virtual_machine.rb +26 -0
- data/lib/fog/azurerm/requests/compute/delete_availability_set.rb +26 -0
- data/lib/fog/azurerm/requests/compute/delete_virtual_machine.rb +26 -0
- data/lib/fog/azurerm/requests/compute/generalize_virtual_machine.rb +26 -0
- data/lib/fog/azurerm/requests/compute/get_virtual_machine.rb +24 -0
- data/lib/fog/azurerm/requests/compute/list_availability_sets.rb +24 -0
- data/lib/fog/azurerm/requests/compute/list_available_sizes_for_virtual_machine.rb +24 -0
- data/lib/fog/azurerm/requests/compute/list_virtual_machines.rb +64 -0
- data/lib/fog/azurerm/requests/compute/power_off_virtual_machine.rb +26 -0
- data/lib/fog/azurerm/requests/compute/redeploy_virtual_machine.rb +26 -0
- data/lib/fog/azurerm/requests/compute/restart_virtual_machine.rb +26 -0
- data/lib/fog/azurerm/requests/compute/start_virtual_machine.rb +26 -0
- data/lib/fog/azurerm/requests/dns/check_for_zone.rb +39 -0
- data/lib/fog/azurerm/requests/dns/create_record_set.rb +61 -0
- data/lib/fog/azurerm/requests/dns/create_zone.rb +47 -0
- data/lib/fog/azurerm/requests/dns/delete_record_set.rb +38 -0
- data/lib/fog/azurerm/requests/dns/delete_zone.rb +38 -0
- data/lib/fog/azurerm/requests/dns/get_records_from_record_set.rb +57 -0
- data/lib/fog/azurerm/requests/dns/list_record_sets.rb +44 -0
- data/lib/fog/azurerm/requests/dns/list_zones.rb +52 -0
- data/lib/fog/azurerm/requests/network/check_for_public_ip.rb +27 -0
- data/lib/fog/azurerm/requests/network/check_for_virtual_network.rb +27 -0
- data/lib/fog/azurerm/requests/network/create_network_interface.rb +52 -0
- data/lib/fog/azurerm/requests/network/create_public_ip.rb +28 -0
- data/lib/fog/azurerm/requests/network/create_subnet.rb +30 -0
- data/lib/fog/azurerm/requests/network/create_virtual_network.rb +80 -0
- data/lib/fog/azurerm/requests/network/delete_network_interface.rb +27 -0
- data/lib/fog/azurerm/requests/network/delete_public_ip.rb +27 -0
- data/lib/fog/azurerm/requests/network/delete_subnet.rb +27 -0
- data/lib/fog/azurerm/requests/network/delete_virtual_network.rb +27 -0
- data/lib/fog/azurerm/requests/network/list_network_interfaces.rb +32 -0
- data/lib/fog/azurerm/requests/network/list_public_ips.rb +32 -0
- data/lib/fog/azurerm/requests/network/list_subnets.rb +30 -0
- data/lib/fog/azurerm/requests/network/list_virtual_networks.rb +29 -0
- data/lib/fog/azurerm/requests/resources/create_resource_group.rb +27 -0
- data/lib/fog/azurerm/requests/resources/delete_resource_group.rb +25 -0
- data/lib/fog/azurerm/requests/resources/list_resource_groups.rb +28 -0
- data/lib/fog/azurerm/requests/storage/check_storage_account_name_availability.rb +33 -0
- data/lib/fog/azurerm/requests/storage/create_storage_account.rb +33 -0
- data/lib/fog/azurerm/requests/storage/delete_storage_account.rb +27 -0
- data/lib/fog/azurerm/requests/storage/list_storage_account_for_rg.rb +25 -0
- data/lib/fog/azurerm/requests/storage/list_storage_accounts.rb +28 -0
- data/lib/fog/azurerm/resources.rb +48 -0
- data/lib/fog/azurerm/storage.rb +51 -0
- data/lib/fog/azurerm/version.rb +5 -0
- metadata +278 -0
@@ -0,0 +1,24 @@
|
|
1
|
+
module Fog
|
2
|
+
module Compute
|
3
|
+
class AzureRM
|
4
|
+
# This class provides the actual implemention for service calls.
|
5
|
+
class Real
|
6
|
+
def get_virtual_machine(resource_group, name)
|
7
|
+
begin
|
8
|
+
promise = @compute_mgmt_client.virtual_machines.get(resource_group, name)
|
9
|
+
response = promise.value!
|
10
|
+
response.body
|
11
|
+
rescue MsRestAzure::AzureOperationError => e
|
12
|
+
msg = "Exception getting Virtual Machine #{name} from Resource Group '#{resource_group}'. #{e.body['error']['message']}"
|
13
|
+
raise msg
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
# This class provides the mock implementation for unit tests.
|
18
|
+
class Mock
|
19
|
+
def get_virtual_machine(resource_group, name)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module Fog
|
2
|
+
module Compute
|
3
|
+
class AzureRM
|
4
|
+
# This class provides the actual implemention for service calls.
|
5
|
+
class Real
|
6
|
+
def list_availability_sets(resource_group)
|
7
|
+
begin
|
8
|
+
promise = @compute_mgmt_client.availability_sets.list(resource_group)
|
9
|
+
response = promise.value!
|
10
|
+
response.body.value
|
11
|
+
rescue MsRestAzure::AzureOperationError => e
|
12
|
+
msg = "Exception listing availability sets in Resource Group #{resource_group}. #{e.body['error']['message']}"
|
13
|
+
raise msg
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
# This class provides the mock implementation for unit tests.
|
18
|
+
class Mock
|
19
|
+
def list_availability_sets(resource_group)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module Fog
|
2
|
+
module Compute
|
3
|
+
class AzureRM
|
4
|
+
# This class provides the actual implemention for service calls.
|
5
|
+
class Real
|
6
|
+
def list_available_sizes_for_virtual_machine(resource_group, name)
|
7
|
+
begin
|
8
|
+
response = @compute_mgmt_client.virtual_machines.list_available_sizes(resource_group, name)
|
9
|
+
result = response.value!
|
10
|
+
result.body.value
|
11
|
+
rescue MsRestAzure::AzureOperationError => e
|
12
|
+
msg = "Error listing Sizes for Virtual Machine #{name} in Resource Group '#{resource_group}'. #{e.body['error']['message']}"
|
13
|
+
raise msg
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
# This class provides the mock implementation for unit tests.
|
18
|
+
class Mock
|
19
|
+
def list_available_sizes_for_virtual_machine(resource_group, name)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
module Fog
|
2
|
+
module Compute
|
3
|
+
class AzureRM
|
4
|
+
# This class provides the actual implemention for service calls.
|
5
|
+
class Real
|
6
|
+
def list_virtual_machines(resource_group)
|
7
|
+
begin
|
8
|
+
response = @compute_mgmt_client.virtual_machines.list(resource_group)
|
9
|
+
result = response.value!
|
10
|
+
Azure::ARM::Compute::Models::VirtualMachineListResult.serialize_object(result.body)['value']
|
11
|
+
rescue MsRestAzure::AzureOperationError => e
|
12
|
+
msg = "Error listing Virtual Machines in Resource Group '#{resource_group}'. #{e.body['error']['message']}"
|
13
|
+
raise msg
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
# This class provides the mock implementation for unit tests.
|
18
|
+
class Mock
|
19
|
+
def list_virtual_machines(resource_group)
|
20
|
+
[
|
21
|
+
{
|
22
|
+
'id' => "/subscriptions/########-####-####-####-############/resourceGroups/#{resource_group}/providers/Microsoft.Compute/virtualMachines/fog-test-server",
|
23
|
+
'name' => 'fog-test-server',
|
24
|
+
'location' => 'West US',
|
25
|
+
'properties' => {
|
26
|
+
'hardwareProfile' => {
|
27
|
+
'vmSize' => 'Basic_A0'
|
28
|
+
},
|
29
|
+
'storageProfile' => {
|
30
|
+
'imageReference' => {
|
31
|
+
'publisher' => 'Canonical',
|
32
|
+
'offer' => 'UbuntuServer',
|
33
|
+
'sku' => '14.04.2-LTS',
|
34
|
+
'version' => 'latest'
|
35
|
+
},
|
36
|
+
'osDisk' => {
|
37
|
+
'name' => 'fog-test-server_os_disk',
|
38
|
+
'vhd' => {
|
39
|
+
'uri' => 'http://storageAccount.blob.core.windows.net/vhds/fog-test-server_os_disk.vhd'
|
40
|
+
}
|
41
|
+
}
|
42
|
+
},
|
43
|
+
'osProfile' => {
|
44
|
+
'computerName' => 'fog-test-server',
|
45
|
+
'adminUsername' => 'shaffan',
|
46
|
+
'linuxConfiguration' => {
|
47
|
+
'disablePasswordAuthentication' => false
|
48
|
+
}
|
49
|
+
},
|
50
|
+
'networkProfile' => {
|
51
|
+
'networkInterfaces' => [
|
52
|
+
{
|
53
|
+
'id' => "/subscriptions/########-####-####-####-############/resourceGroups/#{resource_group}/providers/Microsoft.Network/networkInterfaces/fogtestnetworkinterface"
|
54
|
+
}
|
55
|
+
]
|
56
|
+
}
|
57
|
+
}
|
58
|
+
}
|
59
|
+
]
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module Fog
|
2
|
+
module Compute
|
3
|
+
class AzureRM
|
4
|
+
# This class provides the actual implemention for service calls.
|
5
|
+
class Real
|
6
|
+
def power_off_virtual_machine(resource_group, name)
|
7
|
+
Fog::Logger.debug "Powering off Virtual Machine #{name} in Resource Group #{resource_group}."
|
8
|
+
begin
|
9
|
+
promise = @compute_mgmt_client.virtual_machines.power_off(resource_group, name)
|
10
|
+
result = promise.value!
|
11
|
+
Fog::Logger.debug "Virtual Machine #{name} Powered off Successfully."
|
12
|
+
result
|
13
|
+
rescue MsRestAzure::AzureOperationError => e
|
14
|
+
msg = "Error Powering off Virtual Machine '#{name}' in Resource Group '#{resource_group}'. #{e.body['error']['message']}"
|
15
|
+
raise msg
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
# This class provides the mock implementation for unit tests.
|
20
|
+
class Mock
|
21
|
+
def power_off_virtual_machine(resource_group, name)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module Fog
|
2
|
+
module Compute
|
3
|
+
class AzureRM
|
4
|
+
# This class provides the actual implemention for service calls.
|
5
|
+
class Real
|
6
|
+
def redeploy_virtual_machine(resource_group, name)
|
7
|
+
Fog::Logger.debug "Redeploying Virtual Machine #{name} in Resource Group #{resource_group}."
|
8
|
+
begin
|
9
|
+
promise = @compute_mgmt_client.virtual_machines.redeploy(resource_group, name)
|
10
|
+
result = promise.value!
|
11
|
+
Fog::Logger.debug "Virtual Machine #{name} Redeployed Successfully."
|
12
|
+
result
|
13
|
+
rescue MsRestAzure::AzureOperationError => e
|
14
|
+
msg = "Error Redeploying Virtual Machine '#{name}' in Resource Group '#{resource_group}'. #{e.body['error']['message']}"
|
15
|
+
raise msg
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
# This class provides the mock implementation for unit tests.
|
20
|
+
class Mock
|
21
|
+
def redeploy_virtual_machine(resource_group, name)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module Fog
|
2
|
+
module Compute
|
3
|
+
class AzureRM
|
4
|
+
# This class provides the actual implemention for service calls.
|
5
|
+
class Real
|
6
|
+
def restart_virtual_machine(resource_group, name)
|
7
|
+
Fog::Logger.debug "Restarting Virtual Machine #{name} in Resource Group #{resource_group}."
|
8
|
+
begin
|
9
|
+
promise = @compute_mgmt_client.virtual_machines.restart(resource_group, name)
|
10
|
+
result = promise.value!
|
11
|
+
Fog::Logger.debug "Virtual Machine #{name} Restarted Successfully."
|
12
|
+
result
|
13
|
+
rescue MsRestAzure::AzureOperationError => e
|
14
|
+
msg = "Error Restarting Virtual Machine '#{name}' in Resource Group '#{resource_group}'. #{e.body['error']['message']}"
|
15
|
+
raise msg
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
# This class provides the mock implementation for unit tests.
|
20
|
+
class Mock
|
21
|
+
def restart_virtual_machine(resource_group, name)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module Fog
|
2
|
+
module Compute
|
3
|
+
class AzureRM
|
4
|
+
# This class provides the actual implemention for service calls.
|
5
|
+
class Real
|
6
|
+
def start_virtual_machine(resource_group, name)
|
7
|
+
Fog::Logger.debug "Starting Virtual Machine #{name} in Resource Group #{resource_group}."
|
8
|
+
begin
|
9
|
+
promise = @compute_mgmt_client.virtual_machines.start(resource_group, name)
|
10
|
+
result = promise.value!
|
11
|
+
Fog::Logger.debug "Virtual Machine #{name} started Successfully."
|
12
|
+
result
|
13
|
+
rescue MsRestAzure::AzureOperationError => e
|
14
|
+
msg = "Error starting Virtual Machine '#{name}' in Resource Group '#{resource_group}'. #{e.body['error']['message']}"
|
15
|
+
raise msg
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
# This class provides the mock implementation for unit tests.
|
20
|
+
class Mock
|
21
|
+
def start_virtual_machine(resource_group, name)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
module Fog
|
2
|
+
module DNS
|
3
|
+
class AzureRM
|
4
|
+
class Real
|
5
|
+
def check_for_zone(resource_group, name)
|
6
|
+
resource_url = "#{AZURE_RESOURCE}/subscriptions/#{@subscription_id}/resourceGroups/#{resource_group}/providers/Microsoft.Network/dnsZones/#{name}?api-version=2015-05-04-preview"
|
7
|
+
begin
|
8
|
+
token = Fog::Credentials::AzureRM.get_token(@tenant_id, @client_id, @client_secret)
|
9
|
+
dns_response = RestClient.get(
|
10
|
+
resource_url,
|
11
|
+
accept: 'application/json',
|
12
|
+
content_type: 'application/json',
|
13
|
+
authorization: token)
|
14
|
+
dns_hash = JSON.parse(dns_response)
|
15
|
+
if dns_hash.key?('id') && !dns_hash['id'].nil?
|
16
|
+
true
|
17
|
+
else
|
18
|
+
false
|
19
|
+
end
|
20
|
+
rescue RestClient::Exception => e
|
21
|
+
if e.http_code == 404
|
22
|
+
false
|
23
|
+
else
|
24
|
+
body = JSON.parse(e.http_body)
|
25
|
+
msg = "Exception checking if the zone exists: #{body['code']}, #{body['message']}"
|
26
|
+
fail msg
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
class Mock
|
33
|
+
def check_for_zone(resource_group, name)
|
34
|
+
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
module Fog
|
2
|
+
module DNS
|
3
|
+
class AzureRM
|
4
|
+
class Real
|
5
|
+
def create_record_set(dns_resource_group, zone_name, record_set_name, records, record_type, ttl)
|
6
|
+
resource_url = "#{AZURE_RESOURCE}/subscriptions/#{@subscription_id}/resourceGroups/#{dns_resource_group}/providers/Microsoft.Network/dnsZones/#{zone_name}/#{record_type}/#{record_set_name}?api-version=2015-05-04-preview"
|
7
|
+
Fog::Logger.debug "Creating/Updating RecordSet #{record_set_name} of type '#{record_type}' in zone #{zone_name}"
|
8
|
+
|
9
|
+
case record_type
|
10
|
+
when 'A'
|
11
|
+
a_type_records_array = Array.new
|
12
|
+
records.each do |ip|
|
13
|
+
a_type_records_array.push({'ipv4Address' => ip})
|
14
|
+
end
|
15
|
+
body = {
|
16
|
+
:location => 'global',
|
17
|
+
:tags => '',
|
18
|
+
:properties => {
|
19
|
+
:TTL => ttl,
|
20
|
+
:ARecords => a_type_records_array
|
21
|
+
}
|
22
|
+
}
|
23
|
+
when 'CNAME'
|
24
|
+
body = {
|
25
|
+
:location => 'global',
|
26
|
+
:tags => '',
|
27
|
+
:properties => {
|
28
|
+
:TTL => ttl,
|
29
|
+
:CNAMERecord => {
|
30
|
+
'cname' => records.first # because cname only has 1 value and we know the object is an array passed in.
|
31
|
+
}
|
32
|
+
}
|
33
|
+
}
|
34
|
+
end
|
35
|
+
|
36
|
+
begin
|
37
|
+
token = Fog::Credentials::AzureRM.get_token(@tenant_id, @client_id, @client_secret)
|
38
|
+
RestClient.put(
|
39
|
+
resource_url,
|
40
|
+
body.to_json,
|
41
|
+
accept: 'application/json',
|
42
|
+
content_type: 'application/json',
|
43
|
+
authorization: token
|
44
|
+
)
|
45
|
+
Fog::Logger.debug "RecordSet #{record_set_name} Created/Updated Successfully!"
|
46
|
+
rescue Exception => e
|
47
|
+
Fog::Logger.warning "Exception setting #{record_type} records for the record set: #{record_set_name}"
|
48
|
+
msg = "AzureDns::RecordSet - Exception is: #{e.message}"
|
49
|
+
raise msg
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
class Mock
|
55
|
+
def create_record_set(dns_resource_group, zone_name, record_set_name, records, record_type, ttl)
|
56
|
+
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
module Fog
|
2
|
+
module DNS
|
3
|
+
class AzureRM
|
4
|
+
class Real
|
5
|
+
def create_zone(dns_resource_group, zone_name)
|
6
|
+
Fog::Logger.debug "Creating Zone #{zone_name} ..."
|
7
|
+
resource_url = "#{AZURE_RESOURCE}/subscriptions/#{@subscription_id}/resourceGroups/#{dns_resource_group}/providers/Microsoft.Network/dnsZones/#{zone_name}?api-version=2015-05-04-preview"
|
8
|
+
|
9
|
+
body = {
|
10
|
+
location: 'global',
|
11
|
+
tags: {},
|
12
|
+
properties: {}
|
13
|
+
}
|
14
|
+
|
15
|
+
begin
|
16
|
+
token = Fog::Credentials::AzureRM.get_token(@tenant_id, @client_id, @client_secret)
|
17
|
+
dns_response = RestClient.put(
|
18
|
+
resource_url,
|
19
|
+
body.to_json,
|
20
|
+
accept: 'application/json',
|
21
|
+
content_type: 'application/json',
|
22
|
+
authorization: token)
|
23
|
+
response_hash = JSON.parse(dns_response)
|
24
|
+
Fog::Logger.debug "Zone #{zone_name} created successfully."
|
25
|
+
response_hash
|
26
|
+
rescue RestClient::Exception => e
|
27
|
+
body = JSON.parse(e.http_body)
|
28
|
+
if body.key?('error')
|
29
|
+
body = body['error']
|
30
|
+
msg = "Exception creating zone: #{body['code']}, #{body['message']}"
|
31
|
+
else
|
32
|
+
msg = "Exception creating zone: #{body['code']}, #{body['message']}"
|
33
|
+
end
|
34
|
+
|
35
|
+
raise msg
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
class Mock
|
41
|
+
def create_zone(dns_resource_group, zone_name)
|
42
|
+
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
module Fog
|
2
|
+
module DNS
|
3
|
+
class AzureRM
|
4
|
+
class Real
|
5
|
+
def delete_record_set(record_set_name, dns_resource_group, zone_name, record_type)
|
6
|
+
resource_url = "#{AZURE_RESOURCE}/subscriptions/#{@subscription_id}/resourceGroups/#{dns_resource_group}/providers/Microsoft.Network/dnsZones/#{zone_name}/#{record_type}/#{record_set_name}?api-version=2015-05-04-preview"
|
7
|
+
Fog::Logger.debug "Deleting RecordSet #{record_set_name} of type '#{record_type}' in zone #{zone_name}"
|
8
|
+
|
9
|
+
begin
|
10
|
+
token = Fog::Credentials::AzureRM.get_token(@tenant_id, @client_id, @client_secret)
|
11
|
+
RestClient.delete(
|
12
|
+
resource_url,
|
13
|
+
accept: 'application/json',
|
14
|
+
content_type: 'application/json',
|
15
|
+
authorization: token
|
16
|
+
)
|
17
|
+
Fog::Logger.debug "RecordSet #{record_set_name} Deleted Successfully!"
|
18
|
+
rescue RestClient::Exception => e
|
19
|
+
body = JSON.parse(e.http_body)
|
20
|
+
if body.key?('error')
|
21
|
+
body = body['error']
|
22
|
+
msg = "Exception deleting zone: #{body['code']}, #{body['message']}"
|
23
|
+
else
|
24
|
+
msg = "Exception deleting zone: #{body['code']}, #{body['message']}"
|
25
|
+
end
|
26
|
+
raise msg
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
class Mock
|
32
|
+
def delete_record_set(record_set_name, dns_resource_group, zone_name, record_type)
|
33
|
+
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
module Fog
|
2
|
+
module DNS
|
3
|
+
class AzureRM
|
4
|
+
class Real
|
5
|
+
|
6
|
+
def delete_zone(zone_name, dns_resource_group)
|
7
|
+
Fog::Logger.debug "Deleting Zone #{zone_name} ..."
|
8
|
+
resource_url = "#{AZURE_RESOURCE}/subscriptions/#{@subscription_id}/resourceGroups/#{dns_resource_group}/providers/Microsoft.Network/dnsZones/#{zone_name}?api-version=2015-05-04-preview"
|
9
|
+
begin
|
10
|
+
token = Fog::Credentials::AzureRM.get_token(@tenant_id, @client_id, @client_secret)
|
11
|
+
RestClient.delete(
|
12
|
+
resource_url,
|
13
|
+
accept: 'application/json',
|
14
|
+
content_type: 'application/json',
|
15
|
+
authorization: token)
|
16
|
+
Fog::Logger.debug "Zone #{zone_name} deleted successfully."
|
17
|
+
true
|
18
|
+
rescue RestClient::Exception => e
|
19
|
+
body = JSON.parse(e.http_body)
|
20
|
+
if body.key?('error')
|
21
|
+
body = body['error']
|
22
|
+
msg = "Exception deleting zone: #{body['code']}, #{body['message']}"
|
23
|
+
else
|
24
|
+
msg = "Exception deleting zone: #{body['code']}, #{body['message']}"
|
25
|
+
end
|
26
|
+
raise msg
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
class Mock
|
32
|
+
def delete_zone(zone_name, dns_resource_group)
|
33
|
+
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|