fog-azure-rm 0.2.6 → 0.2.7

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9b24d2c21a6e6802af2ca763b1230cb7a7d75acc
4
- data.tar.gz: 1a176bf88ef73639cf5c4cceafdebfb13f676d28
3
+ metadata.gz: abba2750995255a81a2edf8cb5d51bf41331f5b3
4
+ data.tar.gz: d883aa12233282ce91ce91ceb1ca895eb2ae2810
5
5
  SHA512:
6
- metadata.gz: 57b1cd6b6c20875fcd62db652f45818741b6fb37bd855250881ea261a50b401900dea6851384565642fa9cb492030aac6f4e3708135fe03bd69525c9bee6a3de
7
- data.tar.gz: e730e48874f042e56027233ee84167ae48cdb38fbc96c02a49ecf9aaddee839bbdcf4953fb88b9a8087d80cb6a3262d1bd8296a403ec3b237a8592c8be39833d
6
+ metadata.gz: c17370ff19fd0e568d8309ca054b957e6affee602909e7fc102640eeab68a218ff1f2b47438fc4e015392e9d7d77c9cd4ea7e855fe440dcb35eca441f1d79e32
7
+ data.tar.gz: 390a20c58f0321402dc6ebc7d6c789a7a5c8a484b76b14deec8ebf274a50cf09b908f4cfcc1efcc7c41041cdc4d88e734a788582d1afeade4cc49e1e4fda4f2c
@@ -1,3 +1,11 @@
1
+ ## 0.2.7
2
+
3
+ **Changed:**
4
+ - Traffic Manager Service - Updated Traffic Manager Profile create method to receive and create Endpoints with it.
5
+
6
+ **Fixed:**
7
+ - Network Service - Fixed issue in check_virtual_network_exists request
8
+
1
9
  ## 0.2.6
2
10
 
3
11
  **Fixed:**
@@ -16,6 +16,7 @@ RESOURCE_GROUP_NAME = 4
16
16
  RESOURCE_PROVIDER_NAMESPACE = 6
17
17
  RESOURCE_TYPE = 7
18
18
  RESOURCE_NAME = 8
19
+ ENDPOINT_PREFIX = 'Microsoft.Network/trafficManagerProfiles'.freeze
19
20
  AZURE_ENDPOINTS = 'azureEndpoints'.freeze
20
21
  EXTERNAL_ENDPOINTS = 'externalEndpoints'.freeze
21
22
  NESTED_ENDPOINTS = 'nestedEndpoints'.freeze
@@ -77,7 +77,8 @@ module Fog
77
77
  ttl: ttl,
78
78
  protocol: protocol,
79
79
  port: port,
80
- path: path
80
+ path: path,
81
+ endpoints: endpoints
81
82
  }
82
83
  end
83
84
  end
@@ -15,7 +15,11 @@ module Fog
15
15
  begin
16
16
  virtual_machine = @compute_mgmt_client.virtual_machines.create_or_update(resource_group, vm_name, vm)
17
17
  rescue MsRestAzure::AzureOperationError => e
18
+ if e.body.to_s =~ /InvalidParameter/ && e.body.to_s =~ /already exists/
19
+ Fog::Logger.debug 'The disk is already attached'
20
+ else
18
21
  raise_azure_exception(e, msg)
22
+ end
19
23
  end
20
24
  Fog::Logger.debug "Data Disk #{disk_name} attached to Virtual Machine #{vm_name} successfully."
21
25
  virtual_machine
@@ -66,9 +70,9 @@ module Fog
66
70
  data_disk.lun = lun
67
71
  data_disk.disk_size_gb = disk_size.to_s
68
72
  data_disk.vhd = Azure::ARM::Compute::Models::VirtualHardDisk.new
69
- data_disk.vhd.uri = "https://#{storage_account_name}.blob.core.windows.net/vhds/#{disk_name}.vhd"
73
+ data_disk.vhd.uri = "https://#{storage_account_name}.blob.core.windows.net/vhds/#{storage_account_name}-#{disk_name}.vhd"
70
74
  data_disk.caching = Azure::ARM::Compute::Models::CachingTypes::ReadWrite
71
- blob_name = "#{disk_name}.vhd"
75
+ blob_name = "#{storage_account_name}-#{disk_name}.vhd"
72
76
  disk_exist = check_blob_exist(storage_account_name, blob_name, access_key)
73
77
  data_disk.create_option = Azure::ARM::Compute::Models::DiskCreateOptionTypes::Empty
74
78
  data_disk.create_option = Azure::ARM::Compute::Models::DiskCreateOptionTypes::Attach if disk_exist
@@ -11,7 +11,7 @@ module Fog
11
11
  Fog::Logger.debug "Virtual Network #{name} exists."
12
12
  true
13
13
  rescue MsRestAzure::AzureOperationError => e
14
- if e.response.status == '404'
14
+ if e.error_code == 'ResourceNotFound'
15
15
  Fog::Logger.debug "Virtual Network #{name} doesn't exist."
16
16
  false
17
17
  else
@@ -6,7 +6,7 @@ module Fog
6
6
  def create_or_update_traffic_manager_profile(profile_hash)
7
7
  msg = "Creating Traffic Manager Profile: #{profile_hash[:name]}."
8
8
  Fog::Logger.debug msg
9
- profile_parameters = get_profile_object(profile_hash[:traffic_routing_method], profile_hash[:relative_name], profile_hash[:ttl], profile_hash[:protocol], profile_hash[:port], profile_hash[:path])
9
+ profile_parameters = get_profile_object(profile_hash[:traffic_routing_method], profile_hash[:relative_name], profile_hash[:ttl], profile_hash[:protocol], profile_hash[:port], profile_hash[:path], profile_hash[:endpoints])
10
10
  begin
11
11
  traffic_manager_profile = @traffic_mgmt_client.profiles.create_or_update(profile_hash[:resource_group], profile_hash[:name], profile_parameters)
12
12
  rescue MsRestAzure::AzureOperationError => e
@@ -18,16 +18,29 @@ module Fog
18
18
 
19
19
  private
20
20
 
21
- def get_profile_object(traffic_routing_method, relative_name, ttl, protocol, port, path)
21
+ def get_profile_object(traffic_routing_method, relative_name, ttl, protocol, port, path, endpoints)
22
22
  traffic_manager_profile = Azure::ARM::TrafficManager::Models::Profile.new
23
23
  traffic_manager_profile.traffic_routing_method = traffic_routing_method
24
24
  traffic_manager_profile.location = GLOBAL
25
25
 
26
26
  traffic_manager_profile.dns_config = get_traffic_manager_dns_config(relative_name, ttl)
27
27
  traffic_manager_profile.monitor_config = get_traffic_manager_monitor_config(protocol, port, path)
28
+ traffic_manager_profile.endpoints = get_endpoints(endpoints) unless endpoints.nil?
28
29
  traffic_manager_profile
29
30
  end
30
31
 
32
+ def get_endpoints(endpoints)
33
+ endpoint_objects = []
34
+
35
+ endpoints.each do |endpoint|
36
+ endpoint_object = get_endpoint_object(endpoint[:target_resource_id], endpoint[:target], endpoint[:weight], endpoint[:priority], endpoint[:endpoint_location], endpoint[:min_child_endpoints])
37
+ endpoint_object.name = endpoint[:name]
38
+ endpoint_object.type = "#{ENDPOINT_PREFIX}/#{endpoint[:type]}"
39
+ endpoint_objects.push(endpoint_object)
40
+ end
41
+ endpoint_objects
42
+ end
43
+
31
44
  def get_traffic_manager_dns_config(relative_name, ttl)
32
45
  traffic_manager_dns_config = Azure::ARM::TrafficManager::Models::DnsConfig.new
33
46
  traffic_manager_dns_config.relative_name = relative_name
@@ -1,5 +1,5 @@
1
1
  module Fog
2
2
  module AzureRM
3
- VERSION = '0.2.6'.freeze
3
+ VERSION = '0.2.7'.freeze
4
4
  end
5
5
  end
@@ -146,7 +146,18 @@ module ApiStub
146
146
  ttl: 'ttl',
147
147
  protocol: 'protocol',
148
148
  port: 'port',
149
- path: 'path'
149
+ path: 'path',
150
+ endpoints: [{
151
+ name: 'endpoint2',
152
+ traffic_manager_profile_name: 'test-tmp',
153
+ resource_group: 'TestRG-TM',
154
+ type: 'externalEndpoints',
155
+ target: 'test-app.com',
156
+ endpoint_location: 'eastus',
157
+ endpoint_status: 'Enabled',
158
+ priority: 5,
159
+ weight: 10
160
+ }]
150
161
  }
151
162
  end
152
163
  end
@@ -51,7 +51,16 @@ begin
51
51
  ttl: '30',
52
52
  protocol: 'http',
53
53
  port: '80',
54
- path: '/monitorpage.aspx'
54
+ path: '/monitorpage.aspx',
55
+ endpoints: [{
56
+ name: 'endpoint1',
57
+ type: 'externalEndpoints',
58
+ target: 'test-app.com',
59
+ endpoint_location: 'eastus',
60
+ endpoint_status: 'Enabled',
61
+ priority: 5,
62
+ weight: 10
63
+ }]
55
64
  )
56
65
  puts "Created traffic manager profile: #{traffic_manager_profile.name}"
57
66
 
@@ -18,10 +18,8 @@ class TestCheckVirtualNetworkExists < Minitest::Test
18
18
  faraday_response = Faraday::Response.new(nil)
19
19
  response = proc { raise MsRestAzure::AzureOperationError.new(nil, faraday_response, 'error' => { 'message' => 'mocked exception', 'code' => 'ResourceNotFound' }) }
20
20
 
21
- faraday_response.stub :status, '404' do
22
- @virtual_networks.stub :get, response do
23
- assert !@service.check_virtual_network_exists('fog-test-rg', 'fog-test-virtual-network')
24
- end
21
+ @virtual_networks.stub :get, response do
22
+ assert !@service.check_virtual_network_exists('fog-test-rg', 'fog-test-virtual-network')
25
23
  end
26
24
  end
27
25
 
@@ -29,10 +27,8 @@ class TestCheckVirtualNetworkExists < Minitest::Test
29
27
  faraday_response = Faraday::Response.new(nil)
30
28
  response = proc { raise MsRestAzure::AzureOperationError.new(nil, faraday_response, 'error' => { 'message' => 'mocked exception', 'code' => 'ResourceGroupNotFound' }) }
31
29
 
32
- faraday_response.stub :status, '400' do
33
- @virtual_networks.stub :get, response do
34
- assert_raises(RuntimeError) { @service.check_virtual_network_exists('fog-test-rg', 'fog-test-virtual-network') }
35
- end
30
+ @virtual_networks.stub :get, response do
31
+ assert_raises(RuntimeError) { @service.check_virtual_network_exists('fog-test-rg', 'fog-test-virtual-network') }
36
32
  end
37
33
  end
38
34
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fog-azure-rm
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.6
4
+ version: 0.2.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shaffan Chaudhry
@@ -14,7 +14,7 @@ authors:
14
14
  autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
- date: 2017-01-30 00:00:00.000000000 Z
17
+ date: 2017-02-08 00:00:00.000000000 Z
18
18
  dependencies:
19
19
  - !ruby/object:Gem::Dependency
20
20
  name: rake