azure 0.6.2 → 0.6.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ChangeLog.txt +7 -0
- data/lib/azure/cloud_service_management/cloud_service.rb +1 -1
- data/lib/azure/cloud_service_management/cloud_service_management_service.rb +7 -0
- data/lib/azure/cloud_service_management/serialization.rb +15 -0
- data/lib/azure/storage_management/serialization.rb +0 -6
- data/lib/azure/storage_management/storage_management_service.rb +1 -1
- data/lib/azure/version.rb +1 -1
- data/lib/azure/virtual_machine_management/serialization.rb +67 -19
- data/lib/azure/virtual_machine_management/virtual_machine.rb +0 -1
- data/lib/azure/virtual_machine_management/virtual_machine_management_service.rb +16 -0
- data/test/fixtures/list_storage_account_single.xml +25 -0
- data/test/integration/vm/VM_Create_test.rb +0 -1
- data/test/unit/storage_management/storage_management_service_test.rb +28 -0
- data/test/unit/virtual_machine_management/serialization_test.rb +35 -6
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 184071aad7a3c42ae4096da3d27aaadf01f5dd42
|
4
|
+
data.tar.gz: 2b8f026ba119dda6324cbaeb1c0c0857dade93b8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d73a29abe2a26c39630977cce42d940cc1d15b9c12eeb87aeb8cf880427691e5952e85798ad47488b0ccd8f36c8f41648bc40febe0ea32506ba78b739cd47d68
|
7
|
+
data.tar.gz: ed70f72f78035c46141b33d56a7b1611fd610e8c1a2eab44c944c11d78c4062006e8b8915f425c007e48402b4bdfb78c77093c8bdf7dc30979c3916a6f85d9b4
|
data/ChangeLog.txt
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
2014.03.28 - version 0.6.3
|
2
|
+
* Added get_cloud_service_properties method, which returns all cloud service properties (embed-detail=true), including info about all VMs
|
3
|
+
* Added winrm_http_port and winrm_https_port to get_virtual_machine method to allow the users to configure custom ports for winrm-http and winrm-https
|
4
|
+
* Checks if any ports are in use before adding a role in the existing cloud service
|
5
|
+
* Auto generate public port for add role.
|
6
|
+
* Fix issue https://github.com/WindowsAzure/azure-sdk-for-ruby/issues/130
|
7
|
+
|
1
8
|
2014.03.15 - version 0.6.2
|
2
9
|
* Restart Virtual Machine
|
3
10
|
* Add disk to Virtual Machine
|
@@ -91,6 +91,13 @@ module Azure
|
|
91
91
|
flag
|
92
92
|
end
|
93
93
|
|
94
|
+
def get_cloud_service_properties(name)
|
95
|
+
request_path = "/services/hostedservices/#{name}?embed-detail=true"
|
96
|
+
request = ManagementHttpRequest.new(:get, request_path)
|
97
|
+
response = request.call
|
98
|
+
Serialization.cloud_services_from_xml(response)
|
99
|
+
end
|
100
|
+
|
94
101
|
# Public: Deletes the specified cloud service of given subscription id from Windows Azure.
|
95
102
|
#
|
96
103
|
# ==== Attributes
|
@@ -14,6 +14,7 @@
|
|
14
14
|
#--------------------------------------------------------------------------
|
15
15
|
require 'base64'
|
16
16
|
require 'azure/cloud_service_management/cloud_service'
|
17
|
+
require 'azure/virtual_machine_management/serialization'
|
17
18
|
|
18
19
|
module Azure
|
19
20
|
module CloudServiceManagement
|
@@ -54,6 +55,8 @@ module Azure
|
|
54
55
|
def self.cloud_services_from_xml(cloud_xml)
|
55
56
|
clouds = []
|
56
57
|
cloud_services_xml = cloud_xml.css('HostedServices HostedService')
|
58
|
+
cloud_services_xml = cloud_xml.css('HostedService') if \
|
59
|
+
cloud_services_xml.length == 0
|
57
60
|
cloud_services_xml.each do |cloud_service_xml|
|
58
61
|
cloud = CloudService.new
|
59
62
|
cloud.url = xml_content(cloud_service_xml, 'Url')
|
@@ -80,6 +83,18 @@ module Azure
|
|
80
83
|
cloud_service_xml, 'DefaultWinRMCertificateThumbprint'
|
81
84
|
)
|
82
85
|
|
86
|
+
vms_in_deployment = {}
|
87
|
+
|
88
|
+
cloud_service_xml.css('Deployments').each do |deployxml|
|
89
|
+
deployment_name = xml_content(deployxml, 'Deployment Name')
|
90
|
+
vms = Azure::VirtualMachineManagement::Serialization.virtual_machines_from_xml(
|
91
|
+
deployxml, cloud.name
|
92
|
+
)
|
93
|
+
|
94
|
+
vms_in_deployment[deployment_name.to_sym] = vms
|
95
|
+
end
|
96
|
+
|
97
|
+
cloud.virtual_machines = vms_in_deployment
|
83
98
|
clouds << cloud
|
84
99
|
end
|
85
100
|
clouds.compact
|
@@ -107,12 +107,6 @@ module Azure
|
|
107
107
|
storage_accounts << storage_account
|
108
108
|
end
|
109
109
|
|
110
|
-
# returns the first storage account if only one found
|
111
|
-
# This will be the case when calling the get_storage_account_properties
|
112
|
-
# API or if only one storage account exists for the subscription
|
113
|
-
return storage_accounts.first if storage_accounts.size == 1
|
114
|
-
|
115
|
-
# returns all the storage accounts, if more than 1 found
|
116
110
|
storage_accounts.compact
|
117
111
|
end
|
118
112
|
|
@@ -67,7 +67,7 @@ module Azure
|
|
67
67
|
request_path = "/services/storageservices/#{name}"
|
68
68
|
request = ManagementHttpRequest.new(:get, request_path, nil)
|
69
69
|
response = request.call
|
70
|
-
Serialization.storage_services_from_xml(response)
|
70
|
+
Serialization.storage_services_from_xml(response).first
|
71
71
|
end
|
72
72
|
|
73
73
|
# Public: Create a new storage account in Windows Azure.
|
data/lib/azure/version.rb
CHANGED
@@ -91,7 +91,11 @@ module Azure
|
|
91
91
|
xml.ConfigurationSetType 'NetworkConfiguration'
|
92
92
|
xml.InputEndpoints do
|
93
93
|
default_endpoints_to_xml(xml, options)
|
94
|
-
tcp_endpoints_to_xml(
|
94
|
+
tcp_endpoints_to_xml(
|
95
|
+
xml,
|
96
|
+
options[:tcp_endpoints],
|
97
|
+
options[:existing_ports]
|
98
|
+
) if options[:tcp_endpoints]
|
95
99
|
end
|
96
100
|
if options[:virtual_network_name] && options[:subnet_name]
|
97
101
|
xml.SubnetNames do
|
@@ -127,10 +131,16 @@ module Azure
|
|
127
131
|
xml.SSH do
|
128
132
|
xml.PublicKeys do
|
129
133
|
xml.PublicKey do
|
130
|
-
xml.Fingerprint fingerprint
|
134
|
+
xml.Fingerprint fingerprint.to_s.upcase
|
131
135
|
xml.Path "/home/#{params[:vm_user]}/.ssh/authorized_keys"
|
132
136
|
end
|
133
137
|
end
|
138
|
+
xml.KeyPairs do
|
139
|
+
xml.KeyPair do
|
140
|
+
xml.Fingerprint fingerprint.to_s.upcase
|
141
|
+
xml.Path "/home/#{params[:vm_user]}/.ssh/id_rsa"
|
142
|
+
end
|
143
|
+
end
|
134
144
|
end
|
135
145
|
end
|
136
146
|
end
|
@@ -165,49 +175,64 @@ module Azure
|
|
165
175
|
|
166
176
|
def self.default_endpoints_to_xml(xml, options)
|
167
177
|
os_type = options[:os_type]
|
178
|
+
used_ports = options[:existing_ports]
|
168
179
|
endpoints = []
|
169
180
|
if os_type == 'Linux'
|
170
|
-
|
181
|
+
preferred_port = '22'
|
182
|
+
port_already_opened?(used_ports, options[:ssh_port])
|
183
|
+
endpoints << {
|
171
184
|
name: 'SSH',
|
172
|
-
public_port: options[:ssh_port] ||
|
185
|
+
public_port: options[:ssh_port] || assign_random_port(preferred_port, used_ports),
|
173
186
|
protocol: 'TCP',
|
174
|
-
local_port:
|
187
|
+
local_port: preferred_port
|
175
188
|
}
|
176
189
|
elsif os_type == 'Windows' && options[:winrm_transport]
|
177
190
|
if options[:winrm_transport].include?('http')
|
178
|
-
|
191
|
+
preferred_port = '5985'
|
192
|
+
port_already_opened?(used_ports, options[:winrm_http_port])
|
193
|
+
endpoints << {
|
179
194
|
name: 'WinRm-Http',
|
180
|
-
public_port:
|
195
|
+
public_port: options[:winrm_http_port] || assign_random_port(preferred_port, used_ports),
|
181
196
|
protocol: 'TCP',
|
182
|
-
local_port:
|
197
|
+
local_port: preferred_port
|
183
198
|
}
|
184
199
|
end
|
185
200
|
if options[:winrm_transport].include?('https')
|
186
|
-
|
201
|
+
preferred_port = '5986'
|
202
|
+
port_already_opened?(used_ports, options[:winrm_https_port])
|
203
|
+
endpoints << {
|
187
204
|
name: 'PowerShell',
|
188
|
-
public_port:
|
205
|
+
public_port: options[:winrm_https_port] || assign_random_port(preferred_port, used_ports),
|
189
206
|
protocol: 'TCP',
|
190
|
-
local_port:
|
207
|
+
local_port: preferred_port
|
191
208
|
}
|
192
209
|
end
|
193
210
|
end
|
194
211
|
endpoints_to_xml(xml, endpoints)
|
195
212
|
end
|
196
213
|
|
197
|
-
def self.tcp_endpoints_to_xml(xml, tcp_endpoints)
|
214
|
+
def self.tcp_endpoints_to_xml(xml, tcp_endpoints, existing_ports = [])
|
198
215
|
endpoints = []
|
216
|
+
|
199
217
|
tcp_endpoints.split(',').each do |endpoint|
|
200
218
|
ports = endpoint.split(':')
|
201
219
|
tcp_ep = {}
|
220
|
+
|
202
221
|
if ports.length > 1
|
203
|
-
|
222
|
+
port_already_opened?(existing_ports, ports[1])
|
223
|
+
|
224
|
+
tcp_ep[:name] = "TCP-PORT-#{ports[1]}"
|
204
225
|
tcp_ep[:public_port] = ports[1]
|
205
226
|
else
|
206
|
-
|
227
|
+
port_already_opened?(existing_ports, ports[0])
|
228
|
+
|
229
|
+
tcp_ep[:name] = "TCP-PORT-#{ports[0]}"
|
207
230
|
tcp_ep[:public_port] = ports[0]
|
208
231
|
end
|
232
|
+
|
209
233
|
tcp_ep[:local_port] = ports[0]
|
210
234
|
tcp_ep[:protocol] = 'TCP'
|
235
|
+
|
211
236
|
endpoints << tcp_ep
|
212
237
|
end
|
213
238
|
endpoints_to_xml(xml, endpoints)
|
@@ -230,17 +255,18 @@ module Azure
|
|
230
255
|
vm.cloud_service_name = cloud_service_name.downcase
|
231
256
|
vm.deployment_name = xml_content(deployXML, 'Deployment Name')
|
232
257
|
vm.deployment_status = xml_content(deployXML, 'Deployment Status')
|
233
|
-
vm.virtual_network_name =
|
258
|
+
vm.virtual_network_name = xml_content(
|
234
259
|
deployXML.css('Deployment'),
|
235
260
|
'VirtualNetworkName'
|
236
261
|
)
|
237
262
|
roles.each do |role|
|
238
|
-
if xml_content(role, 'RoleName') ==
|
263
|
+
if xml_content(role, 'RoleName') == role_name
|
239
264
|
vm.availability_set_name = xml_content(role, 'AvailabilitySetName')
|
240
265
|
endpoints_from_xml(role, vm)
|
241
266
|
vm.os_type = xml_content(role, 'OSVirtualHardDisk OS')
|
242
267
|
vm.disk_name = xml_content(role, 'OSVirtualHardDisk DiskName')
|
243
268
|
vm.media_link = xml_content(role, 'OSVirtualHardDisk MediaLink')
|
269
|
+
vm.image = xml_content(role, 'OSVirtualHardDisk SourceImageName')
|
244
270
|
break
|
245
271
|
end
|
246
272
|
end
|
@@ -266,7 +292,7 @@ module Azure
|
|
266
292
|
ep[:direct_server_return] = server_return if !server_return.empty?
|
267
293
|
unless lb_name.empty?
|
268
294
|
ep[:protocol] = endpoint.css('Protocol').last.text
|
269
|
-
ep[:load_balancer_name] =
|
295
|
+
ep[:load_balancer_name] = lb_name
|
270
296
|
lb_port = xml_content(endpoint, 'LoadBalancerProbe Port')
|
271
297
|
lb_protocol = xml_content(endpoint, 'LoadBalancerProbe Protocol')
|
272
298
|
lb_path = xml_content(endpoint, 'LoadBalancerProbe Path')
|
@@ -321,7 +347,7 @@ module Azure
|
|
321
347
|
protocol = endpoint[:protocol]
|
322
348
|
port = endpoint[:public_port]
|
323
349
|
interval = endpoint[:load_balancer][:interval]
|
324
|
-
timeout =
|
350
|
+
timeout = endpoint[:load_balancer][:timeout]
|
325
351
|
path = endpoint[:load_balancer][:path]
|
326
352
|
balancer_name = endpoint[:load_balancer_name]
|
327
353
|
xml.InputEndpoint do
|
@@ -359,7 +385,7 @@ module Azure
|
|
359
385
|
xml.Lun lun
|
360
386
|
xml.LogicalDiskSizeInGB options[:disk_size] || 1
|
361
387
|
unless options[:import]
|
362
|
-
disk_name
|
388
|
+
disk_name = media_link[/([^\/]+)$/]
|
363
389
|
media_link = media_link.gsub(/#{disk_name}/, (Time.now.strftime('disk_%Y_%m_%d_%H_%M')) + '.vhd')
|
364
390
|
xml.MediaLink media_link
|
365
391
|
end
|
@@ -368,6 +394,28 @@ module Azure
|
|
368
394
|
builder.doc.to_xml
|
369
395
|
end
|
370
396
|
|
397
|
+
private
|
398
|
+
|
399
|
+
def self.port_already_opened?(existing_ports, port)
|
400
|
+
return false if existing_ports.nil?
|
401
|
+
raise "Port #{port} conflicts with a port already opened. "\
|
402
|
+
"Please select a different port." if existing_ports.include?(port)
|
403
|
+
false
|
404
|
+
end
|
405
|
+
|
406
|
+
def self.assign_random_port(preferred_port, used_ports)
|
407
|
+
random_port = nil
|
408
|
+
if used_ports.nil? || !used_ports.include?(preferred_port)
|
409
|
+
random_port = preferred_port
|
410
|
+
else
|
411
|
+
random_port = Random.new.rand(10000..65535)
|
412
|
+
while(used_ports.include?(random_port.to_s))
|
413
|
+
random_port = Random.new.rand(10000..65535)
|
414
|
+
end
|
415
|
+
end
|
416
|
+
random_port
|
417
|
+
end
|
418
|
+
|
371
419
|
end
|
372
420
|
end
|
373
421
|
end
|
@@ -85,6 +85,8 @@ module Azure
|
|
85
85
|
# * +:ssh_private_key_file+ - String. Path of private key file.
|
86
86
|
# * +:ssh_certificate_file+ - String. Path of certificate file.
|
87
87
|
# * +:ssh_port+ - Integer. Specifies the SSH port number.
|
88
|
+
# * +:winrm_http_port - Integer. Specifies the WinRM HTTP port number.
|
89
|
+
# * +:winrm_https_port - Integer. Specifies the WinRM HTTPS port number.
|
88
90
|
# * +:vm_size+ - String. Specifies the size of the virtual machine instance.
|
89
91
|
# * +:winrm_transport+ - Array. Specifies WINRM transport protocol.
|
90
92
|
# * +:availability_set_name+ - String. Specifies the availability set name.
|
@@ -131,6 +133,20 @@ module Azure
|
|
131
133
|
body = Serialization.deployment_to_xml(params, options)
|
132
134
|
path = "/services/hostedservices/#{options[:cloud_service_name]}/deployments"
|
133
135
|
else
|
136
|
+
cloud_services = Azure::CloudServiceManagementService.new.get_cloud_service_properties(
|
137
|
+
options[:cloud_service_name]
|
138
|
+
)
|
139
|
+
existing_ports = []
|
140
|
+
# There should be only one cloud_serivce in the Array.
|
141
|
+
cloud_services.each do |cloud_service|
|
142
|
+
cloud_service.virtual_machines[options[:deployment_name].to_sym].each do |vm|
|
143
|
+
vm.tcp_endpoints.each do |endpoint|
|
144
|
+
existing_ports << endpoint[:public_port]
|
145
|
+
end
|
146
|
+
end
|
147
|
+
end
|
148
|
+
|
149
|
+
options[:existing_ports] = existing_ports
|
134
150
|
|
135
151
|
Loggerx.info 'Deployment exists, adding role...'
|
136
152
|
body = Serialization.role_to_xml(params, options).to_xml
|
@@ -0,0 +1,25 @@
|
|
1
|
+
|
2
|
+
<?xml version="1.0"?>
|
3
|
+
<StorageServices xmlns="http://schemas.microsoft.com/windowsazure" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
|
4
|
+
<StorageService>
|
5
|
+
<Url>https://management.core.windows.net/268a3762-abcd-4cd3-a4ea-80e84bddff87/services/storageservices/storage1</Url>
|
6
|
+
<ServiceName>storage1</ServiceName>
|
7
|
+
<StorageServiceProperties>
|
8
|
+
<Description i:nil="true"/>
|
9
|
+
<Location>West US</Location>
|
10
|
+
<Label>c3VzZQ==</Label>
|
11
|
+
<Status>Created</Status>
|
12
|
+
<Endpoints>
|
13
|
+
<Endpoint>http://storage1.blob.core.windows.net/</Endpoint>
|
14
|
+
<Endpoint>http://storage1.queue.core.windows.net/</Endpoint>
|
15
|
+
<Endpoint>http://storage1.table.core.windows.net/</Endpoint>
|
16
|
+
</Endpoints>
|
17
|
+
<GeoReplicationEnabled>true</GeoReplicationEnabled>
|
18
|
+
<GeoPrimaryRegion>West US</GeoPrimaryRegion>
|
19
|
+
<StatusOfPrimary/>
|
20
|
+
<GeoSecondaryRegion>East US</GeoSecondaryRegion>
|
21
|
+
<StatusOfSecondary/>
|
22
|
+
</StorageServiceProperties>
|
23
|
+
<ExtendedProperties/>
|
24
|
+
</StorageService>
|
25
|
+
</StorageServices>
|
@@ -83,7 +83,6 @@ describe Azure::VirtualMachineManagementService do
|
|
83
83
|
assert_match(/^#{params[:vm_name] + '-service'}*/, csn)
|
84
84
|
# Test for add role
|
85
85
|
params[:vm_name] = 'test-add-role-vm'
|
86
|
-
options[:ssh_port] = 2222
|
87
86
|
vm = subject.create_virtual_machine(params, options, true)
|
88
87
|
vm.cloud_service_name.must_equal csn
|
89
88
|
vm.vm_name.must_equal params[:vm_name]
|
@@ -19,14 +19,25 @@ describe Azure::StorageManagementService do
|
|
19
19
|
subject { Azure::StorageManagementService.new }
|
20
20
|
let(:request_path) {'/services/storageservices'}
|
21
21
|
let(:storage_accounts_xml) { Fixtures["list_storage_accounts"] }
|
22
|
+
let(:one_storage_account_xml) { Fixtures['list_storage_account_single']}
|
22
23
|
let(:method) { :get }
|
23
24
|
let(:mock_request){ mock() }
|
25
|
+
|
24
26
|
let(:response) {
|
25
27
|
response = mock()
|
26
28
|
response.stubs(:body).returns(storage_accounts_xml)
|
27
29
|
response
|
28
30
|
}
|
31
|
+
|
32
|
+
let(:single_response) {
|
33
|
+
single_response = mock()
|
34
|
+
single_response.stubs(:body).returns(one_storage_account_xml)
|
35
|
+
single_response
|
36
|
+
}
|
37
|
+
|
29
38
|
let(:response_body) {Nokogiri::XML response.body}
|
39
|
+
let(:single_response_body) { Nokogiri::XML single_response.body }
|
40
|
+
|
30
41
|
before{
|
31
42
|
Loggerx.expects(:puts).returns(nil).at_least(0)
|
32
43
|
}
|
@@ -54,6 +65,23 @@ describe Azure::StorageManagementService do
|
|
54
65
|
end
|
55
66
|
end
|
56
67
|
|
68
|
+
describe "#list_storage_accounts_single" do
|
69
|
+
before {
|
70
|
+
ManagementHttpRequest.stubs(:new).with(
|
71
|
+
method, request_path, nil
|
72
|
+
).returns(mock_request)
|
73
|
+
mock_request.expects(:call).returns(single_response_body)
|
74
|
+
}
|
75
|
+
|
76
|
+
it "returns an array even if single account exists" do
|
77
|
+
results = subject.list_storage_accounts
|
78
|
+
results.must_be_kind_of Array
|
79
|
+
results.length.must_equal 1
|
80
|
+
results.first.must_be_kind_of Azure::StorageManagement::StorageAccount
|
81
|
+
results.first.name.must_equal 'storage1'
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
57
85
|
describe "#get_storage_account" do
|
58
86
|
before {
|
59
87
|
ManagementHttpRequest.stubs(:new).with(method, request_path, nil).returns(mock_request)
|
@@ -105,7 +105,7 @@ describe Azure::VirtualMachineManagement::Serialization do
|
|
105
105
|
end
|
106
106
|
|
107
107
|
describe '#deployment_to_xml' do
|
108
|
-
let(:params)do
|
108
|
+
let(:params) do
|
109
109
|
{
|
110
110
|
vm_name: 'virtual-machine-name',
|
111
111
|
vm_user: 'username',
|
@@ -125,7 +125,7 @@ describe Azure::VirtualMachineManagement::Serialization do
|
|
125
125
|
end
|
126
126
|
|
127
127
|
it 'returns an VirtualMachine object with correct tcp endpoints' do
|
128
|
-
params[:certificate] = {
|
128
|
+
params[:certificate] = {fingerprint: 'CFB8C256D2986559C630547F2D0'}
|
129
129
|
result = subject.deployment_to_xml params, options
|
130
130
|
doc = Nokogiri::XML(result)
|
131
131
|
endpoints = doc.css('Deployment RoleList ConfigurationSet InputEndpoints InputEndpoint')
|
@@ -160,7 +160,7 @@ describe Azure::VirtualMachineManagement::Serialization do
|
|
160
160
|
describe '#add_data_disk_to_xml' do
|
161
161
|
|
162
162
|
let(:options) do
|
163
|
-
{
|
163
|
+
{disk_size: 100}
|
164
164
|
end
|
165
165
|
let(:media_link) { 'https://sta.blob.managment.core.net/vhds/1234.vhd' }
|
166
166
|
let(:lun) { 5 }
|
@@ -169,7 +169,7 @@ describe Azure::VirtualMachineManagement::Serialization do
|
|
169
169
|
end
|
170
170
|
|
171
171
|
it 'returns an xml for newly created data disk' do
|
172
|
-
result = subject.add_data_disk_to_xml(lun, media_link
|
172
|
+
result = subject.add_data_disk_to_xml(lun, media_link, options)
|
173
173
|
doc = Nokogiri::XML(result)
|
174
174
|
disk_size = doc.css('DataVirtualHardDisk LogicalDiskSizeInGB').text
|
175
175
|
media_link = doc.css('DataVirtualHardDisk MediaLink').text
|
@@ -184,7 +184,7 @@ describe Azure::VirtualMachineManagement::Serialization do
|
|
184
184
|
it 'returns an xml for existing data disk' do
|
185
185
|
options[:import] = true
|
186
186
|
options[:disk_name] = 'disk_name'
|
187
|
-
result = subject.add_data_disk_to_xml(lun, media_link
|
187
|
+
result = subject.add_data_disk_to_xml(lun, media_link, options)
|
188
188
|
doc = Nokogiri::XML(result)
|
189
189
|
media_link = doc.css('DataVirtualHardDisk MediaLink').text
|
190
190
|
disk_name = doc.css('DataVirtualHardDisk DiskName').text
|
@@ -197,10 +197,39 @@ describe Azure::VirtualMachineManagement::Serialization do
|
|
197
197
|
it 'raise error when disk name is empty' do
|
198
198
|
options[:import] = true
|
199
199
|
exception = assert_raises(RuntimeError) do
|
200
|
-
subject.add_data_disk_to_xml(lun, media_link
|
200
|
+
subject.add_data_disk_to_xml(lun, media_link, options)
|
201
201
|
end
|
202
202
|
assert_match(/The data disk name is not valid/i, exception.message)
|
203
203
|
end
|
204
204
|
end
|
205
205
|
|
206
|
+
describe '#add_data_disk_to_xml' do
|
207
|
+
let(:preferred_port) { '22' }
|
208
|
+
before do
|
209
|
+
subject.class.send(:public, *subject.class.private_instance_methods)
|
210
|
+
Loggerx.expects(:puts).returns(nil).at_least(0)
|
211
|
+
end
|
212
|
+
|
213
|
+
it 'returns an xml for newly created data disk' do
|
214
|
+
result = subject.assign_random_port(preferred_port, [preferred_port])
|
215
|
+
assert_operator result.to_i, :>=, 10000
|
216
|
+
assert_operator result.to_i, :<=, 65535
|
217
|
+
end
|
218
|
+
|
219
|
+
it 'returns an xml for newly created data disk' do
|
220
|
+
result = subject.assign_random_port(preferred_port, nil)
|
221
|
+
result.must_equal preferred_port
|
222
|
+
end
|
223
|
+
|
224
|
+
it 'returns an xml for newly created data disk' do
|
225
|
+
result = subject.assign_random_port(preferred_port, [])
|
226
|
+
result.must_equal preferred_port
|
227
|
+
end
|
228
|
+
|
229
|
+
it 'returns an xml for newly created data disk' do
|
230
|
+
result = subject.assign_random_port(preferred_port, ['1', preferred_port])
|
231
|
+
assert_operator result.to_i, :>=, 10000
|
232
|
+
assert_operator result.to_i, :<=, 65535
|
233
|
+
end
|
234
|
+
end
|
206
235
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: azure
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Microsoft Corporation
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-03-
|
12
|
+
date: 2014-03-29 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: nokogiri
|
@@ -281,6 +281,7 @@ files:
|
|
281
281
|
- test/fixtures/list_page_ranges.xml
|
282
282
|
- test/fixtures/list_sql_database.xml
|
283
283
|
- test/fixtures/list_sql_server_firewall.xml
|
284
|
+
- test/fixtures/list_storage_account_single.xml
|
284
285
|
- test/fixtures/list_storage_accounts.xml
|
285
286
|
- test/fixtures/list_virtual_networks.xml
|
286
287
|
- test/fixtures/logging.xml
|