Skip to content

Commit 2f801e4

Browse files
committed
Merge branch 'release-0.6.4' of https://github.com/WindowsAzure/azure-sdk-for-ruby into release-0.6.4
2 parents 4e7c485 + 49f1d2d commit 2f801e4

24 files changed

+528
-301
lines changed

ChangeLog.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
2014.05.06 - version 0.6.4
2+
* Upgraded Service Management Versioning to 2014-04-01
3+
* Created separate API for add role
4+
* Logical Unit Number(lun) is optional argument in API add_data_disk
5+
* Cloud service should delete only if there are no other VMs/Deployments in the cloud service
6+
* Added more sizes(Basic_A0, Basic_A1, Basic_A2, Basic_A3, Basic_A4) options for Virtual Machine and Cloud Service.
7+
18
2014.03.28 - version 0.6.3
29
* Added get_cloud_service_properties method, which returns all cloud service properties (embed-detail=true), including info about all VMs
310
* 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

README.md

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -374,13 +374,13 @@ virtual_machine_service.start_virtual_machine('vm_name', 'cloud_service_name')
374374
virtual_machine_service.restart_virtual_machine('vm_name', 'cloud_service_name')
375375
376376
#API for add disk to Virtual Machine
377-
lun = 1 #Valid LUN values are 0 through 15.
378377
options = {
379378
:disk_label => 'disk-label',
380379
:disk_size => 100, #In GB
381-
:import => false
380+
:import => false,
381+
:disk_name => 'Disk name' #Required when import is true
382382
}
383-
virtual_machine_service.add_data_disk('vm_name', 'cloud_service_name', lun, options)
383+
virtual_machine_service.add_data_disk('vm_name', 'cloud_service_name', options)
384384
385385
#API to add/update Virtual Machine endpoints
386386
endpoint1 = {
@@ -422,19 +422,35 @@ options = {
422422
:private_key_file => 'c:/private_key.key', #required for ssh or winrm(https) certificate.
423423
:certificate_file => 'c:/certificate.pem', #required for ssh or winrm(https) certificate.
424424
:ssh_port => 2222,
425-
:vm_size => 'Small', #valid choices are (ExtraSmall, Small, Medium, Large, ExtraLarge, A6, A7)
425+
:vm_size => 'Small', #valid choices are (ExtraSmall Small Medium Large ExtraLarge A5 A6 A7 Basic_A0 Basic_A1 Basic_A2 Basic_A3 Basic_A4)
426426
:affinity_group_name => 'affinity1',
427427
:virtual_network_name => 'xplattestvnet',
428428
:subnet_name => 'subnet1',
429429
:availability_set_name => 'availabiltyset1'
430430
}
431-
virtual_machine_service.create_virtual_machine(params,options,add_role=false)
432-
# Here add_role is used as a flag to create multiple roles under the same cloud service. This parameter is false
433-
# by default. Atleast a single deployment should be created under a hosted service prior to setting this flag.
431+
virtual_machine_service.create_virtual_machine(params,options)
434432
435433
#API usage to add new roles under cloud service creating VM
436-
437-
virtual_machine_service.create_virtual_machine(params,options,add_role=true)
434+
#API add_role create multiple roles under the same cloud service. Atleast a single deployment should be created under a hosted service.
435+
params = {
436+
:vm_name => 'vm_name',
437+
:cloud_service_name => 'cloud_service_name',
438+
:vm_user => 'azureuser',
439+
:image => 'a699494373c04fc0bc8f2bb1389d6106__Win2K8R2SP1-Datacenter-201305.01-en.us-127GB.vhd',
440+
:password => 'ComplexPassword',
441+
}
442+
options = {
443+
:storage_account_name => 'storage_suse',
444+
:winrm_transport => ['https','http'], #Currently http is supported. To enable https, set the transport protocol to https, simply rdp to the VM once VM is in ready state, export the certificate ( CN name would be the deployment name) from the certstore of the VM and install to your local machine and communicate WinRM via https.
445+
:tcp_endpoints => '80,3389:3390',
446+
:private_key_file => 'c:/private_key.key', #required for ssh or winrm(https) certificate.
447+
:certificate_file => 'c:/certificate.pem', #required for ssh or winrm(https) certificate.
448+
:winrm_https_port => 5999,
449+
:winrm_http_port => 6999, #Used to open different powershell port
450+
:vm_size => 'Small', #valid choices are (ExtraSmall Small Medium Large ExtraLarge A5 A6 A7 Basic_A0 Basic_A1 Basic_A2 Basic_A3 Basic_A4)
451+
:availability_set_name => 'availabiltyset'
452+
}
453+
virtual_machine_service.add_role(params, options)
438454
439455
#Get a list of available virtual machine images
440456
virtual_machine_image_service = Azure::VirtualMachineImageManagementService.new

lib/azure/base_management/management_http_request.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def initialize(method, path, body = nil)
3535
@warn = false
3636
content_length = body ? body.bytesize.to_s : '0'
3737
@headers = {
38-
'x-ms-version' => '2013-06-01',
38+
'x-ms-version' => '2014-04-01',
3939
'Content-Type' => 'application/xml',
4040
'Content-Length' => content_length
4141
}

lib/azure/cloud_service_management/cloud_service.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
module Azure
1717
module CloudServiceManagement
1818
class CloudService
19-
2019
def initialize
2120
yield self if block_given?
2221
end
@@ -33,6 +32,7 @@ def initialize
3332
attr_accessor :extended_properties
3433
attr_accessor :default_winrm_certificate_thumbprint
3534
attr_accessor :virtual_machines
35+
attr_accessor :deployment_name
3636
end
3737
end
3838
end

lib/azure/cloud_service_management/cloud_service_management_service.rb

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
module Azure
1818
module CloudServiceManagement
1919
class CloudServiceManagementService < BaseManagementService
20-
2120
def initialize
2221
super()
2322
end
@@ -48,12 +47,12 @@ def initialize
4847
#
4948
# Returns None
5049
def create_cloud_service(name, options = {})
51-
Loggerx.error_with_exit "Cloud service name is not valid " unless name
50+
Loggerx.error_with_exit 'Cloud service name is not valid ' unless name
5251
if get_cloud_service(name)
5352
Loggerx.warn "Cloud service #{name} already exists. Skipped..."
5453
else
5554
Loggerx.info "Creating cloud service #{name}."
56-
request_path = "/services/hostedservices"
55+
request_path = '/services/hostedservices'
5756
body = Serialization.cloud_services_to_xml(name, options)
5857
request = ManagementHttpRequest.new(:post, request_path, body)
5958
request.call
@@ -64,7 +63,7 @@ def create_cloud_service(name, options = {})
6463
#
6564
# Returns an array of Azure::CloudServiceManagement::CloudService objects
6665
def list_cloud_services
67-
request_path = "/services/hostedservices"
66+
request_path = '/services/hostedservices'
6867
request = ManagementHttpRequest.new(:get, request_path, nil)
6968
response = request.call
7069
Serialization.cloud_services_from_xml(response)
@@ -95,7 +94,7 @@ def get_cloud_service_properties(name)
9594
request_path = "/services/hostedservices/#{name}?embed-detail=true"
9695
request = ManagementHttpRequest.new(:get, request_path)
9796
response = request.call
98-
Serialization.cloud_services_from_xml(response)
97+
Serialization.cloud_services_from_xml(response).first
9998
end
10099

101100
# Public: Deletes the specified cloud service of given subscription id from Windows Azure.
@@ -106,7 +105,7 @@ def get_cloud_service_properties(name)
106105
#
107106
# Returns: None
108107
def delete_cloud_service(cloud_service_name)
109-
request_path= "/services/hostedservices/#{cloud_service_name}"
108+
request_path = "/services/hostedservices/#{cloud_service_name}"
110109
request = ManagementHttpRequest.new(:delete, request_path)
111110
Loggerx.info "Deleting cloud service #{cloud_service_name}. \n"
112111
request.call
@@ -122,21 +121,20 @@ def delete_cloud_service(cloud_service_name)
122121
#
123122
# Returns NONE
124123
def delete_cloud_service_deployment(cloud_service_name)
125-
request_path= "/services/hostedservices/#{cloud_service_name}/deploymentslots/production"
124+
request_path = "/services/hostedservices/#{cloud_service_name}/deploymentslots/production"
126125
request = ManagementHttpRequest.new(:delete, request_path)
127126
Loggerx.info "Deleting deployment of cloud service \"#{cloud_service_name}\" ..."
128127
request.call
129128
end
130129

131130
def upload_certificate(cloud_service_name, ssh)
132131
data = export_der(ssh[:cert], ssh[:key])
133-
request_path= "/services/hostedservices/#{cloud_service_name}/certificates"
132+
request_path = "/services/hostedservices/#{cloud_service_name}/certificates"
134133
body = Serialization.add_certificate_to_xml(data)
135134
Loggerx.info "Uploading certificate to cloud service #{cloud_service_name}..."
136135
request = ManagementHttpRequest.new(:post, request_path, body)
137136
request.call
138137
end
139-
140138
end
141139
end
142-
end
140+
end

lib/azure/cloud_service_management/serialization.rb

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,10 @@ def self.cloud_services_from_xml(cloud_xml)
6666

6767
cloud.label = Base64.decode64(xml_content(props_xml, 'Label'))
6868
cloud.description = xml_content(props_xml, 'Description')
69-
cloud.location = xml_content(props_xml, 'Location')
70-
cloud.affinity_group = xml_content(props_xml, 'AffinityGroup')
69+
location = xml_content(props_xml, 'Location')
70+
cloud.location = location unless location.empty?
71+
affinity_group = xml_content(props_xml, 'AffinityGroup')
72+
cloud.affinity_group = affinity_group unless affinity_group
7173
cloud.status = xml_content(props_xml, 'Status')
7274
cloud.date_created = xml_content(props_xml, 'DateCreated')
7375
cloud.date_modified = xml_content(props_xml, 'DateLastModified')
@@ -82,16 +84,16 @@ def self.cloud_services_from_xml(cloud_xml)
8284
cloud.default_winrm_certificate_thumbprint = xml_content(
8385
cloud_service_xml, 'DefaultWinRMCertificateThumbprint'
8486
)
85-
87+
deployment_xml = cloud_services_xml.css('Deployments Deployment')
88+
cloud.deployment_name = xml_content(deployment_xml, 'Name')
8689
vms_in_deployment = {}
8790

8891
cloud_service_xml.css('Deployments').each do |deployxml|
8992
deployment_name = xml_content(deployxml, 'Deployment Name')
9093
vms = Azure::VirtualMachineManagement::Serialization.virtual_machines_from_xml(
9194
deployxml, cloud.name
9295
)
93-
94-
vms_in_deployment[deployment_name.to_sym] = vms
96+
vms_in_deployment[deployment_name.to_sym] = vms if vms
9597
end
9698

9799
cloud.virtual_machines = vms_in_deployment
@@ -102,15 +104,14 @@ def self.cloud_services_from_xml(cloud_xml)
102104

103105
def self.add_certificate_to_xml(data)
104106
builder = Nokogiri::XML::Builder.new do |xml|
105-
xml.CertificateFile('xmlns'=>'http://schemas.microsoft.com/windowsazure') {
107+
xml.CertificateFile('xmlns' => 'http://schemas.microsoft.com/windowsazure') do
106108
xml.Data data
107109
xml.CertificateFormat 'pfx'
108110
xml.Password nil
109-
}
111+
end
110112
end
111113
builder.doc.to_xml
112114
end
113-
114115
end
115116
end
116117
end

lib/azure/storage_management/storage_management_service.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,13 @@ def get_storage_account(name)
5555
end
5656

5757
# Public: Gets the properties of the storage account specified.
58-
#
58+
#
5959
# ==== Attributes
6060
#
6161
# * +name+ - String. The name of the storage account. Required.
6262
#
6363
# See http://msdn.microsoft.com/en-us/library/windowsazure/ee460802.aspx
64-
#
64+
#
6565
# Returns the storage account
6666
def get_storage_account_properties(name)
6767
request_path = "/services/storageservices/#{name}"

lib/azure/virtual_machine_image_management/serialization.rb

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,8 @@
1818
module Azure
1919
module VirtualMachineImageManagement
2020
module Serialization
21-
2221
def self.virtual_machine_images_from_xml(imageXML)
23-
os_images = Array.new
22+
os_images = []
2423
virtual_machine_images = imageXML.css('Images OSImage')
2524
virtual_machine_images.each do |image_node|
2625
image = VirtualMachineImage.new
@@ -34,20 +33,19 @@ def self.virtual_machine_images_from_xml(imageXML)
3433
end
3534

3635
def self.disks_from_xml(diskXML)
37-
os_disks = Array.new
36+
os_disks = []
3837
disks = diskXML.css('Disks Disk')
3938
disks.each do |disk_node|
4039
disk = VirtualMachineDisk.new
4140
disk.name = xml_content(disk_node, 'Name')
4241
disk.os_type = xml_content(disk_node, 'OS')
43-
disk.attached = !xml_content(disk_node,'AttachedTo').empty?
42+
disk.attached = !xml_content(disk_node, 'AttachedTo').empty?
4443
disk.image = xml_content(disk_node, 'SourceImageName')
4544
disk.size = xml_content(disk_node, 'LogicalDiskSizeInGB')
4645
os_disks << disk
4746
end
4847
os_disks
4948
end
50-
5149
end
5250
end
53-
end
51+
end

lib/azure/virtual_machine_image_management/virtual_machine_disk.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,11 @@
1515
module Azure
1616
module VirtualMachineImageManagement
1717
class VirtualMachineDisk
18-
1918
def initialize
2019
yield self if block_given?
2120
end
2221

2322
attr_accessor :name, :attached, :os_type, :image, :size
24-
2523
end
2624
end
2725
end

lib/azure/virtual_machine_image_management/virtual_machine_image.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,11 @@
1515
module Azure
1616
module VirtualMachineImageManagement
1717
class VirtualMachineImage
18-
1918
def initialize
2019
yield self if block_given?
2120
end
2221

2322
attr_accessor :os_type, :name, :category, :locations
24-
2523
end
2624
end
2725
end

0 commit comments

Comments
 (0)