azure 0.6.3 → 0.6.4
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 +4 -4
- data/ChangeLog.txt +7 -0
- data/README.md +52 -35
- data/lib/azure/base_management/management_http_request.rb +1 -1
- data/lib/azure/cloud_service_management/cloud_service.rb +1 -1
- data/lib/azure/cloud_service_management/cloud_service_management_service.rb +8 -10
- data/lib/azure/cloud_service_management/serialization.rb +9 -8
- data/lib/azure/storage_management/storage_management_service.rb +2 -2
- data/lib/azure/version.rb +1 -1
- data/lib/azure/virtual_machine_image_management/serialization.rb +4 -6
- data/lib/azure/virtual_machine_image_management/virtual_machine_disk.rb +0 -2
- data/lib/azure/virtual_machine_image_management/virtual_machine_image.rb +0 -2
- data/lib/azure/virtual_machine_image_management/virtual_machine_image_management_service.rb +4 -9
- data/lib/azure/virtual_machine_management/serialization.rb +19 -4
- data/lib/azure/virtual_machine_management/virtual_machine.rb +1 -0
- data/lib/azure/virtual_machine_management/virtual_machine_management_service.rb +118 -68
- data/test/integration/cloud_service/Cloud_Create_test.rb +44 -0
- data/test/integration/cloud_service/Cloud_Delete_test.rb +44 -0
- data/test/integration/vm/VM_Create_test.rb +56 -10
- data/test/integration/vm/VM_Operations_test.rb +3 -4
- data/test/unit/cloud_service_management/cloud_service_management_service_test.rb +30 -30
- data/test/unit/cloud_service_management/serialization_test.rb +20 -20
- data/test/unit/virtual_machine_image_management/serialization_test.rb +6 -6
- data/test/unit/virtual_machine_image_management/virtual_machine_image_management_service_test.rb +20 -20
- data/test/unit/virtual_machine_management/serialization_test.rb +26 -14
- data/test/unit/virtual_machine_management/virtual_machine_management_service_test.rb +80 -75
- metadata +4 -2
@@ -12,12 +12,11 @@
|
|
12
12
|
# See the License for the specific language governing permissions and
|
13
13
|
# limitations under the License.
|
14
14
|
#--------------------------------------------------------------------------
|
15
|
-
require
|
15
|
+
require 'azure/virtual_machine_image_management/serialization'
|
16
16
|
|
17
17
|
module Azure
|
18
18
|
module VirtualMachineImageManagement
|
19
19
|
class VirtualMachineImageManagementService < BaseManagementService
|
20
|
-
|
21
20
|
def initialize
|
22
21
|
super()
|
23
22
|
end
|
@@ -26,16 +25,14 @@ module Azure
|
|
26
25
|
#
|
27
26
|
# Returns an array of Azure::VirtualMachineImageManagementService objects
|
28
27
|
def list_virtual_machine_images
|
29
|
-
request_path =
|
28
|
+
request_path = '/services/images'
|
30
29
|
request = ManagementHttpRequest.new(:get, request_path, nil)
|
31
30
|
response = request.call
|
32
31
|
Serialization.virtual_machine_images_from_xml(response)
|
33
32
|
end
|
34
|
-
|
35
33
|
end
|
36
34
|
|
37
35
|
class VirtualMachineDiskManagementService < BaseManagementService
|
38
|
-
|
39
36
|
def initialize
|
40
37
|
super()
|
41
38
|
end
|
@@ -44,14 +41,14 @@ module Azure
|
|
44
41
|
#
|
45
42
|
# Returns an array of Azure::VirtualMachineDiskManagementService objects
|
46
43
|
def list_virtual_machine_disks
|
47
|
-
request_path =
|
44
|
+
request_path = '/services/disks'
|
48
45
|
request = ManagementHttpRequest.new(:get, request_path, nil)
|
49
46
|
response = request.call
|
50
47
|
Serialization.disks_from_xml(response)
|
51
48
|
end
|
52
49
|
|
53
50
|
def get_virtual_machine_disk(disk_name)
|
54
|
-
disk = list_virtual_machine_disks.select {|x| x.name == disk_name}
|
51
|
+
disk = list_virtual_machine_disks.select { |x| x.name == disk_name }
|
55
52
|
disk.first
|
56
53
|
end
|
57
54
|
|
@@ -64,8 +61,6 @@ module Azure
|
|
64
61
|
request = ManagementHttpRequest.new(:delete, path)
|
65
62
|
request.call
|
66
63
|
end
|
67
|
-
|
68
64
|
end
|
69
65
|
end
|
70
66
|
end
|
71
|
-
|
@@ -263,6 +263,7 @@ module Azure
|
|
263
263
|
if xml_content(role, 'RoleName') == role_name
|
264
264
|
vm.availability_set_name = xml_content(role, 'AvailabilitySetName')
|
265
265
|
endpoints_from_xml(role, vm)
|
266
|
+
vm.data_disks = data_disks_from_xml(role)
|
266
267
|
vm.os_type = xml_content(role, 'OSVirtualHardDisk OS')
|
267
268
|
vm.disk_name = xml_content(role, 'OSVirtualHardDisk DiskName')
|
268
269
|
vm.media_link = xml_content(role, 'OSVirtualHardDisk MediaLink')
|
@@ -276,6 +277,20 @@ module Azure
|
|
276
277
|
end
|
277
278
|
end
|
278
279
|
|
280
|
+
def self.data_disks_from_xml(rolesXML)
|
281
|
+
data_disks = []
|
282
|
+
virtual_hard_disks = rolesXML.css('DataVirtualHardDisks DataVirtualHardDisk')
|
283
|
+
virtual_hard_disks.each do |disk|
|
284
|
+
data_disk = {}
|
285
|
+
data_disk[:name] = xml_content(disk, 'DiskName')
|
286
|
+
data_disk[:lun] = xml_content(disk, 'Lun')
|
287
|
+
data_disk[:size_in_gb] = xml_content(disk, 'LogicalDiskSizeInGB')
|
288
|
+
data_disk[:media_link] = xml_content(disk, 'MediaLink')
|
289
|
+
data_disks << data_disk
|
290
|
+
end
|
291
|
+
data_disks
|
292
|
+
end
|
293
|
+
|
279
294
|
def self.endpoints_from_xml(rolesXML, vm)
|
280
295
|
vm.tcp_endpoints = []
|
281
296
|
vm.udp_endpoints = []
|
@@ -370,10 +385,11 @@ module Azure
|
|
370
385
|
end
|
371
386
|
end
|
372
387
|
|
373
|
-
def self.add_data_disk_to_xml(
|
388
|
+
def self.add_data_disk_to_xml(vm, options)
|
374
389
|
if options[:import] && options[:disk_name].nil?
|
375
390
|
Loggerx.error_with_exit "The data disk name is not valid."
|
376
391
|
end
|
392
|
+
media_link = vm.media_link
|
377
393
|
builder = Nokogiri::XML::Builder.new do |xml|
|
378
394
|
xml.DataVirtualHardDisk(
|
379
395
|
'xmlns' => 'http://schemas.microsoft.com/windowsazure',
|
@@ -382,8 +398,7 @@ module Azure
|
|
382
398
|
xml.HostCaching options[:host_caching] || 'ReadOnly'
|
383
399
|
xml.DiskLabel options[:disk_label]
|
384
400
|
xml.DiskName options[:disk_name] if options[:import]
|
385
|
-
xml.
|
386
|
-
xml.LogicalDiskSizeInGB options[:disk_size] || 1
|
401
|
+
xml.LogicalDiskSizeInGB options[:disk_size] || 100
|
387
402
|
unless options[:import]
|
388
403
|
disk_name = media_link[/([^\/]+)$/]
|
389
404
|
media_link = media_link.gsub(/#{disk_name}/, (Time.now.strftime('disk_%Y_%m_%d_%H_%M')) + '.vhd')
|
@@ -399,7 +414,7 @@ module Azure
|
|
399
414
|
def self.port_already_opened?(existing_ports, port)
|
400
415
|
return false if existing_ports.nil?
|
401
416
|
raise "Port #{port} conflicts with a port already opened. "\
|
402
|
-
|
417
|
+
"Please select a different port." if existing_ports.include?(port)
|
403
418
|
false
|
404
419
|
end
|
405
420
|
|
@@ -51,7 +51,7 @@ module Azure
|
|
51
51
|
#
|
52
52
|
# Returns an Azure::VirtualMachineManagement::VirtualMachine instance.
|
53
53
|
def get_virtual_machine(name, cloud_service_name)
|
54
|
-
server = list_virtual_machines(cloud_service_name).select { |x| x.vm_name == name
|
54
|
+
server = list_virtual_machines(cloud_service_name).select { |x| x.vm_name == name.downcase }
|
55
55
|
server.first
|
56
56
|
end
|
57
57
|
|
@@ -103,57 +103,33 @@ module Azure
|
|
103
103
|
# See:
|
104
104
|
# http://msdn.microsoft.com/en-us/library/windowsazure/jj157194.aspx
|
105
105
|
# http://msdn.microsoft.com/en-us/library/windowsazure/jj157186.aspx
|
106
|
-
def create_virtual_machine(params, options = {}
|
106
|
+
def create_virtual_machine(params, options = {})
|
107
107
|
options[:os_type] = get_os_type(params[:image])
|
108
108
|
validate_deployment_params(params, options)
|
109
109
|
options[:deployment_name] ||= options[:cloud_service_name]
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
if virtual_networks.empty?
|
120
|
-
Loggerx.error_with_exit "Virtual network #{options[:virtual_network_name]} doesn't exists"
|
121
|
-
else
|
122
|
-
optionals[:affinity_group_name] = virtual_networks.first.affinity_group
|
123
|
-
end
|
124
|
-
elsif options[:affinity_group_name]
|
125
|
-
optionals[:affinity_group_name] = options[:affinity_group_name]
|
110
|
+
Loggerx.info 'Creating deploymnent...'
|
111
|
+
options[:cloud_service_name] ||= generate_cloud_service_name(params[:vm_name])
|
112
|
+
options[:storage_account_name] ||= generate_storage_account_name(params[:vm_name])
|
113
|
+
optionals = {}
|
114
|
+
if options[:virtual_network_name]
|
115
|
+
virtual_network_service = Azure::VirtualNetworkManagementService.new
|
116
|
+
virtual_networks = virtual_network_service.list_virtual_networks.select { |x| x.name == options[:virtual_network_name] }
|
117
|
+
if virtual_networks.empty?
|
118
|
+
Loggerx.error_with_exit "Virtual network #{options[:virtual_network_name]} doesn't exists"
|
126
119
|
else
|
127
|
-
optionals[:
|
120
|
+
optionals[:affinity_group_name] = virtual_networks.first.affinity_group
|
128
121
|
end
|
129
|
-
|
130
|
-
|
131
|
-
cloud_service.upload_certificate(options[:cloud_service_name], params[:certificate]) unless params[:certificate].empty?
|
132
|
-
Azure::StorageManagementService.new.create_storage_account(options[:storage_account_name], optionals)
|
133
|
-
body = Serialization.deployment_to_xml(params, options)
|
134
|
-
path = "/services/hostedservices/#{options[:cloud_service_name]}/deployments"
|
122
|
+
elsif options[:affinity_group_name]
|
123
|
+
optionals[:affinity_group_name] = options[:affinity_group_name]
|
135
124
|
else
|
136
|
-
|
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
|
150
|
-
|
151
|
-
Loggerx.info 'Deployment exists, adding role...'
|
152
|
-
body = Serialization.role_to_xml(params, options).to_xml
|
153
|
-
path = "/services/hostedservices/#{options[:cloud_service_name]}/deployments/#{options[:deployment_name]}/roles"
|
125
|
+
optionals[:location] = params[:location]
|
154
126
|
end
|
155
|
-
|
156
|
-
|
127
|
+
cloud_service = Azure::CloudServiceManagementService.new
|
128
|
+
cloud_service.create_cloud_service(options[:cloud_service_name], optionals)
|
129
|
+
cloud_service.upload_certificate(options[:cloud_service_name], params[:certificate]) unless params[:certificate].empty?
|
130
|
+
Azure::StorageManagementService.new.create_storage_account(options[:storage_account_name], optionals)
|
131
|
+
body = Serialization.deployment_to_xml(params, options)
|
132
|
+
path = "/services/hostedservices/#{options[:cloud_service_name]}/deployments"
|
157
133
|
Loggerx.info 'Deployment in progress...'
|
158
134
|
request = ManagementHttpRequest.new(:post, path, body)
|
159
135
|
request.call
|
@@ -162,6 +138,71 @@ module Azure
|
|
162
138
|
e.message
|
163
139
|
end
|
164
140
|
|
141
|
+
# Public: Add a new role to a cloud service. Atleast one deployment should exist before you can add a role.
|
142
|
+
#
|
143
|
+
# ==== Attributes
|
144
|
+
#
|
145
|
+
# * +params+ - Hash. parameters.
|
146
|
+
# * +options+ - Hash. Optional parameters.
|
147
|
+
#
|
148
|
+
# ==== Params
|
149
|
+
#
|
150
|
+
# Accepted key/value pairs are:
|
151
|
+
# * +:vm_name+ - String. Name of virtual machine.
|
152
|
+
# * +:vm_user+ - String. User name for the virtual machine instance.
|
153
|
+
# * +:password+ - String. A description for the hosted service.
|
154
|
+
# * +:image+ - String. Name of the disk image to use to create the virtual machine.
|
155
|
+
# * +:cloud_service_name+ - String. Name of cloud service.
|
156
|
+
#
|
157
|
+
# ==== Options
|
158
|
+
#
|
159
|
+
# Accepted key/value pairs are:
|
160
|
+
# * +:storage_account_name+ - String. Name of storage account.
|
161
|
+
# * +:tcp_endpoints+ - String. Specifies the internal port and external/public port separated by a colon.
|
162
|
+
# You can map multiple internal and external ports by separating them with a comma.
|
163
|
+
# * +:ssh_private_key_file+ - String. Path of private key file.
|
164
|
+
# * +:ssh_certificate_file+ - String. Path of certificate file.
|
165
|
+
# * +:ssh_port+ - Integer. Specifies the SSH port number.
|
166
|
+
# * +:winrm_http_port - Integer. Specifies the WinRM HTTP port number.
|
167
|
+
# * +:winrm_https_port - Integer. Specifies the WinRM HTTPS port number.
|
168
|
+
# * +:vm_size+ - String. Specifies the size of the virtual machine instance.
|
169
|
+
# * +:winrm_transport+ - Array. Specifies WINRM transport protocol.
|
170
|
+
#
|
171
|
+
# Returns Azure::VirtualMachineManagement::VirtualMachine objects of newly created instance.
|
172
|
+
#
|
173
|
+
# See:
|
174
|
+
# http://msdn.microsoft.com/en-us/library/windowsazure/jj157186.aspx
|
175
|
+
def add_role(params, options = {})
|
176
|
+
options[:os_type] = get_os_type(params[:image])
|
177
|
+
validate_deployment_params(params, options, true)
|
178
|
+
cloud_service = Azure::CloudServiceManagementService.new
|
179
|
+
cloud_service = cloud_service.get_cloud_service_properties(params[:cloud_service_name])
|
180
|
+
deployment_name = cloud_service.deployment_name
|
181
|
+
Loggerx.error_with_exit "Deployment doesn't exists." if cloud_service && deployment_name.empty?
|
182
|
+
others = {}
|
183
|
+
if cloud_service.location
|
184
|
+
others[:location] = cloud_service.location
|
185
|
+
elsif cloud_service.affinity_group
|
186
|
+
others[:affinity_group_name] = cloud_service.affinity_group
|
187
|
+
end
|
188
|
+
options[:storage_account_name] ||= generate_storage_account_name(params[:vm_name])
|
189
|
+
Azure::StorageManagementService.new.create_storage_account(options[:storage_account_name], others)
|
190
|
+
Loggerx.info 'Deployment exists, adding role...'
|
191
|
+
existing_ports = []
|
192
|
+
cloud_service.virtual_machines[deployment_name.to_sym].each do |vm|
|
193
|
+
vm.tcp_endpoints.each do |endpoint|
|
194
|
+
existing_ports << endpoint[:public_port]
|
195
|
+
end
|
196
|
+
end
|
197
|
+
options[:existing_ports] = existing_ports
|
198
|
+
body = Serialization.role_to_xml(params, options).to_xml
|
199
|
+
path = "/services/hostedservices/#{cloud_service.name}/deployments/#{deployment_name}/roles"
|
200
|
+
Loggerx.info 'Deployment in progress...'
|
201
|
+
request = ManagementHttpRequest.new(:post, path, body)
|
202
|
+
request.call
|
203
|
+
get_virtual_machine(params[:vm_name], cloud_service.name)
|
204
|
+
end
|
205
|
+
|
165
206
|
# Public: Deletes the deployment, cloud service and disk.
|
166
207
|
#
|
167
208
|
# ==== Attributes
|
@@ -174,11 +215,19 @@ module Azure
|
|
174
215
|
#
|
175
216
|
# Returns NONE
|
176
217
|
def delete_virtual_machine(vm_name, cloud_service_name)
|
177
|
-
|
218
|
+
virtual_machines = list_virtual_machines(cloud_service_name)
|
219
|
+
vm = virtual_machines.select { |x| x.vm_name == vm_name }.first
|
178
220
|
if vm
|
179
|
-
|
180
|
-
|
181
|
-
|
221
|
+
if virtual_machines.size == 1
|
222
|
+
cloud_service = Azure::CloudServiceManagementService.new
|
223
|
+
cloud_service.delete_cloud_service_deployment(cloud_service_name)
|
224
|
+
cloud_service.delete_cloud_service(cloud_service_name)
|
225
|
+
else
|
226
|
+
path = "/services/hostedservices/#{vm.cloud_service_name}/deployments/#{vm.deployment_name}/roles/#{vm.vm_name}"
|
227
|
+
Loggerx.info "Deleting virtual machine #{vm_name}. \n"
|
228
|
+
request = ManagementHttpRequest.new(:delete, path)
|
229
|
+
request.call
|
230
|
+
end
|
182
231
|
Loggerx.info "Waiting for disk to be released.\n"
|
183
232
|
disk_name = vm.disk_name
|
184
233
|
disk_management_service = VirtualMachineDiskManagementService.new
|
@@ -217,7 +266,7 @@ module Azure
|
|
217
266
|
def shutdown_virtual_machine(vm_name, cloud_service_name)
|
218
267
|
vm = get_virtual_machine(vm_name, cloud_service_name)
|
219
268
|
if vm
|
220
|
-
if
|
269
|
+
if %w(StoppedVM StoppedDeallocated).include?(vm.status)
|
221
270
|
Loggerx.error 'Cannot perform the shutdown operation on a stopped virtual machine.'
|
222
271
|
elsif vm.deployment_status == 'Running'
|
223
272
|
path = "/services/hostedservices/#{vm.cloud_service_name}/deployments/#{vm.deployment_name}/roleinstances/#{vm.vm_name}/Operations"
|
@@ -282,7 +331,7 @@ module Azure
|
|
282
331
|
Loggerx.error "Cannot find virtual machine \"#{vm_name}\" under cloud service \"#{cloud_service_name}\"."
|
283
332
|
end
|
284
333
|
end
|
285
|
-
|
334
|
+
|
286
335
|
# Public: Add/Update endpoints of virtual machine.
|
287
336
|
#
|
288
337
|
# ==== Attributes
|
@@ -304,7 +353,7 @@ module Azure
|
|
304
353
|
# * +:protocol+ - String. Specifies the transport protocol
|
305
354
|
# for the endpoint. Possible values are: TCP, UDP
|
306
355
|
# * +:direct_server_return+ - String. Specifies whether the endpoint
|
307
|
-
# uses Direct Server Return. (optional)
|
356
|
+
# uses Direct Server Return. Possible values are: true, false (optional)
|
308
357
|
# * +:load_balancer - Hash. Contains properties that define the
|
309
358
|
# endpoint settings that the load balancer uses to monitor the
|
310
359
|
# availability of the Virtual Machine (optional)
|
@@ -333,7 +382,7 @@ module Azure
|
|
333
382
|
path = "/services/hostedservices/#{vm.cloud_service_name}/deployments/#{vm.deployment_name}/roles/#{vm_name}"
|
334
383
|
endpoints = vm.tcp_endpoints + vm.udp_endpoints
|
335
384
|
input_endpoints.each do |iep|
|
336
|
-
endpoints.delete_if { |ep| iep[:name].downcase == ep[:name].downcase
|
385
|
+
endpoints.delete_if { |ep| iep[:name].downcase == ep[:name].downcase }
|
337
386
|
end
|
338
387
|
endpoints += input_endpoints
|
339
388
|
body = Serialization.update_role_to_xml(endpoints, vm)
|
@@ -352,7 +401,7 @@ module Azure
|
|
352
401
|
# * +name+ - String. Virtual machine name.
|
353
402
|
# * +cloud_service_name+ - String. Cloud service name.
|
354
403
|
# * +endpoint_name+ - String. Name of endpoint.
|
355
|
-
#
|
404
|
+
#
|
356
405
|
# See http://msdn.microsoft.com/en-us/library/windowsazure/jj157187.aspx
|
357
406
|
#
|
358
407
|
# Returns NONE
|
@@ -377,8 +426,6 @@ module Azure
|
|
377
426
|
#
|
378
427
|
# * +cloud_service_name+ - String. Cloud service name.
|
379
428
|
# * +vm_name+ - String. Virtual machine name.
|
380
|
-
# * +lun+ - String. Specifies the Logical Unit Number
|
381
|
-
# (LUN) for the disk. Valid LUN values are 0 through 15.
|
382
429
|
# * +options+ - Hash. Optional parameters.
|
383
430
|
#
|
384
431
|
# ==== Options
|
@@ -396,12 +443,12 @@ module Azure
|
|
396
443
|
# See http://msdn.microsoft.com/en-us/library/windowsazure/jj157199.aspx
|
397
444
|
#
|
398
445
|
# Returns None
|
399
|
-
def add_data_disk(vm_name, cloud_service_name,
|
446
|
+
def add_data_disk(vm_name, cloud_service_name, options = {})
|
400
447
|
options[:import] ||= false
|
401
448
|
vm = get_virtual_machine(vm_name, cloud_service_name)
|
402
449
|
if vm
|
403
450
|
path = "/services/hostedservices/#{cloud_service_name}/deployments/#{vm.deployment_name}/roles/#{vm_name}/DataDisks"
|
404
|
-
body = Serialization.add_data_disk_to_xml(
|
451
|
+
body = Serialization.add_data_disk_to_xml(vm, options)
|
405
452
|
Loggerx.info "Adding data disk to virtual machine #{vm_name} ..."
|
406
453
|
request = ManagementHttpRequest.new(:post, path, body)
|
407
454
|
request.call
|
@@ -430,15 +477,17 @@ module Azure
|
|
430
477
|
random_string(vm_name + 'storage').gsub(/[^0-9a-z ]/i, '').downcase[0..23]
|
431
478
|
end
|
432
479
|
|
433
|
-
def validate_deployment_params(params, options)
|
480
|
+
def validate_deployment_params(params, options, add_role = false)
|
434
481
|
errors = []
|
435
|
-
params_keys =
|
436
|
-
if options[:os_type] == 'Windows'
|
437
|
-
params_keys += ['password']
|
438
|
-
end
|
482
|
+
params_keys = %w(vm_name image vm_user)
|
483
|
+
params_keys += ['password'] if options[:os_type] == 'Windows'
|
439
484
|
options_keys = []
|
440
|
-
options_keys =
|
441
|
-
|
485
|
+
options_keys = %w(private_key_file certificate_file) if certificate_required?(params, options)
|
486
|
+
if add_role
|
487
|
+
params_keys += ['cloud_service_name']
|
488
|
+
else
|
489
|
+
params_keys += ['location']
|
490
|
+
end
|
442
491
|
params_keys.each do |key|
|
443
492
|
errors << key if params[key.to_sym].nil?
|
444
493
|
end
|
@@ -446,9 +495,10 @@ module Azure
|
|
446
495
|
options_keys.each do |key|
|
447
496
|
errors << key if options[key.to_sym].nil?
|
448
497
|
end
|
449
|
-
|
450
|
-
validate_location(params[:location]) unless errors.include?('location')
|
498
|
+
|
451
499
|
if errors.empty?
|
500
|
+
validate_location(params[:location]) unless add_role
|
501
|
+
validate_role_size(options[:vm_size])
|
452
502
|
params[:certificate] = {}
|
453
503
|
if certificate_required?(params, options)
|
454
504
|
begin
|
@@ -479,7 +529,7 @@ module Azure
|
|
479
529
|
end
|
480
530
|
|
481
531
|
def validate_role_size(vm_size)
|
482
|
-
valid_role_sizes =
|
532
|
+
valid_role_sizes = %w(ExtraSmall Small Medium Large ExtraLarge A5 A6 A7 Basic_A0 Basic_A1 Basic_A2 Basic_A3 Basic_A4)
|
483
533
|
if vm_size && !valid_role_sizes.include?(vm_size)
|
484
534
|
Loggerx.error_with_exit "Value '#{vm_size}' specified for parameter 'vm_size' is invalid. Allowed values are 'ExtraSmall,Small,Medium,Large,ExtraLarge,A6,A7'"
|
485
535
|
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
#-------------------------------------------------------------------------
|
2
|
+
# Copyright 2013 Microsoft Open Technologies, Inc.
|
3
|
+
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
# you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
#
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
# See the License for the specific language governing permissions and
|
13
|
+
# limitations under the License.
|
14
|
+
#--------------------------------------------------------------------------
|
15
|
+
require 'integration/test_helper'
|
16
|
+
|
17
|
+
describe Azure::CloudServiceManagementService do
|
18
|
+
|
19
|
+
subject { Azure::CloudServiceManagementService.new }
|
20
|
+
let(:options) do
|
21
|
+
{
|
22
|
+
location: 'West US',
|
23
|
+
description: 'Test'
|
24
|
+
}
|
25
|
+
end
|
26
|
+
|
27
|
+
before do
|
28
|
+
Loggerx.expects(:puts).returns(nil).at_least(0)
|
29
|
+
end
|
30
|
+
|
31
|
+
describe '#create_cloud_service' do
|
32
|
+
before do
|
33
|
+
@cloud_name = random_string('test-service-cloud', 10)
|
34
|
+
subject.create_cloud_service(@cloud_name, options)
|
35
|
+
end
|
36
|
+
|
37
|
+
it 'Creates a new cloud service in Windows Azure.' do
|
38
|
+
cloud_service = subject.get_cloud_service_properties(@cloud_name)
|
39
|
+
assert cloud_service.name, @cloud_name
|
40
|
+
assert cloud_service.location, options[:location]
|
41
|
+
assert cloud_service.virtual_machines, Hash.new
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|