knife-azure 1.8.7 → 1.9.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. checksums.yaml +4 -4
  2. data/lib/azure/azure_interface.rb +79 -81
  3. data/lib/azure/custom_errors.rb +34 -35
  4. data/lib/azure/helpers.rb +43 -44
  5. data/lib/azure/resource_management/ARM_deployment_template.rb +679 -678
  6. data/lib/azure/resource_management/ARM_interface.rb +513 -515
  7. data/lib/azure/resource_management/vnet_config.rb +43 -43
  8. data/lib/azure/resource_management/windows_credentials.rb +181 -184
  9. data/lib/azure/service_management/ASM_interface.rb +309 -317
  10. data/lib/azure/service_management/ag.rb +16 -16
  11. data/lib/azure/service_management/certificate.rb +30 -31
  12. data/lib/azure/service_management/connection.rb +31 -31
  13. data/lib/azure/service_management/deploy.rb +40 -38
  14. data/lib/azure/service_management/disk.rb +14 -10
  15. data/lib/azure/service_management/host.rb +28 -24
  16. data/lib/azure/service_management/image.rb +23 -22
  17. data/lib/azure/service_management/loadbalancer.rb +12 -12
  18. data/lib/azure/service_management/rest.rb +20 -19
  19. data/lib/azure/service_management/role.rb +274 -273
  20. data/lib/azure/service_management/storageaccount.rb +29 -25
  21. data/lib/azure/service_management/utility.rb +6 -7
  22. data/lib/azure/service_management/vnet.rb +44 -44
  23. data/lib/chef/knife/azure_ag_create.rb +18 -18
  24. data/lib/chef/knife/azure_ag_list.rb +3 -3
  25. data/lib/chef/knife/azure_base.rb +56 -56
  26. data/lib/chef/knife/azure_image_list.rb +8 -10
  27. data/lib/chef/knife/azure_internal-lb_create.rb +15 -15
  28. data/lib/chef/knife/azure_internal-lb_list.rb +3 -3
  29. data/lib/chef/knife/azure_server_create.rb +49 -50
  30. data/lib/chef/knife/azure_server_delete.rb +22 -24
  31. data/lib/chef/knife/azure_server_list.rb +4 -4
  32. data/lib/chef/knife/azure_server_show.rb +5 -5
  33. data/lib/chef/knife/azure_vnet_create.rb +17 -17
  34. data/lib/chef/knife/azure_vnet_list.rb +3 -3
  35. data/lib/chef/knife/azurerm_base.rb +58 -60
  36. data/lib/chef/knife/azurerm_server_create.rb +23 -22
  37. data/lib/chef/knife/azurerm_server_delete.rb +30 -34
  38. data/lib/chef/knife/azurerm_server_list.rb +42 -42
  39. data/lib/chef/knife/azurerm_server_show.rb +1 -1
  40. data/lib/chef/knife/bootstrap/bootstrap_options.rb +7 -8
  41. data/lib/chef/knife/bootstrap/bootstrapper.rb +65 -65
  42. data/lib/chef/knife/bootstrap/common_bootstrap_options.rb +3 -4
  43. data/lib/chef/knife/bootstrap_azure.rb +13 -13
  44. data/lib/chef/knife/bootstrap_azurerm.rb +106 -106
  45. data/lib/knife-azure/version.rb +2 -2
  46. metadata +43 -76
  47. data/lib/azure/resource_management/ARM_base.rb +0 -29
@@ -1,6 +1,6 @@
1
1
  #
2
2
  # Author:: Jeff Mendoza (jeffmendoza@live.com)
3
- # Copyright:: Copyright (c) 2013 Opscode, Inc.
3
+ # Copyright:: Copyright 2013-2018 Chef Software, Inc.
4
4
  # License:: Apache License, Version 2.0
5
5
  #
6
6
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -25,13 +25,13 @@ module Azure
25
25
  def load
26
26
  @ags ||= begin
27
27
  @ags = {}
28
- response = @connection.query_azure('affinitygroups',
29
- 'get',
30
- '',
31
- '',
28
+ response = @connection.query_azure("affinitygroups",
29
+ "get",
30
+ "",
31
+ "",
32
32
  true,
33
33
  false)
34
- response.css('AffinityGroup').each do |ag|
34
+ response.css("AffinityGroup").each do |ag|
35
35
  item = AG.new(@connection).parse(ag)
36
36
  @ags[item.name] = item
37
37
  end
@@ -67,18 +67,18 @@ module Azure
67
67
  end
68
68
 
69
69
  def parse(image)
70
- @name = image.at_css('Name').content
71
- @label = image.at_css('Label').content
72
- @description = image.at_css('Description').content if
73
- image.at_css('Description')
74
- @location = image.at_css('Location').content if image.at_css('Location')
70
+ @name = image.at_css("Name").content
71
+ @label = image.at_css("Label").content
72
+ @description = image.at_css("Description").content if
73
+ image.at_css("Description")
74
+ @location = image.at_css("Location").content if image.at_css("Location")
75
75
  self
76
76
  end
77
77
 
78
78
  def create(params)
79
- builder = Nokogiri::XML::Builder.new(encoding: 'utf-8') do |xml|
79
+ builder = Nokogiri::XML::Builder.new(encoding: "utf-8") do |xml|
80
80
  xml.CreateAffinityGroup(
81
- xmlns: 'http://schemas.microsoft.com/windowsazure'
81
+ xmlns: "http://schemas.microsoft.com/windowsazure"
82
82
  ) do
83
83
  xml.Name params[:azure_ag_name]
84
84
  xml.Label Base64.strict_encode64(params[:azure_ag_name])
@@ -88,10 +88,10 @@ module Azure
88
88
  xml.Location params[:azure_location]
89
89
  end
90
90
  end
91
- @connection.query_azure('affinitygroups',
92
- 'post',
91
+ @connection.query_azure("affinitygroups",
92
+ "post",
93
93
  builder.to_xml,
94
- '',
94
+ "",
95
95
  true,
96
96
  false)
97
97
  end
@@ -1,6 +1,6 @@
1
1
  #
2
2
  # Author:: Mukta Aphale (mukta.aphale@clogeny.com)
3
- # Copyright:: Copyright (c) 2010-2011 Opscode, Inc.
3
+ # Copyright:: Copyright 2010-2018 Chef Software, Inc.
4
4
  # License:: Apache License, Version 2.0
5
5
  #
6
6
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -19,7 +19,7 @@
19
19
  module Azure
20
20
  class Certificates
21
21
  def initialize(connection)
22
- @connection=connection
22
+ @connection = connection
23
23
  end
24
24
 
25
25
  def create(params)
@@ -33,7 +33,7 @@ module Azure
33
33
  end
34
34
 
35
35
  def create_ssl_certificate(azure_dns_name)
36
- cert_params = { output_file: 'winrm', key_length: 2048, cert_validity: 24,
36
+ cert_params = { output_file: "winrm", key_length: 2048, cert_validity: 24,
37
37
  azure_dns_name: azure_dns_name }
38
38
  certificate = Certificate.new(@connection)
39
39
  thumbprint = certificate.create_ssl_certificate(cert_params)
@@ -58,15 +58,15 @@ module Azure
58
58
  def create(params)
59
59
  # If RSA private key has been specified, then generate an x 509 certificate from the
60
60
  # public part of the key
61
- @cert_data = generate_public_key_certificate_data({:ssh_key => params[:identity_file],
62
- :ssh_key_passphrase => params[:identity_file_passphrase]})
63
- add_certificate @cert_data, 'knifeazure', 'pfx', params[:azure_dns_name]
61
+ @cert_data = generate_public_key_certificate_data({ :ssh_key => params[:identity_file],
62
+ :ssh_key_passphrase => params[:identity_file_passphrase] })
63
+ add_certificate @cert_data, "knifeazure", "pfx", params[:azure_dns_name]
64
64
 
65
65
  # Return the fingerprint to be used while adding role
66
66
  @fingerprint
67
67
  end
68
68
 
69
- def generate_public_key_certificate_data (params)
69
+ def generate_public_key_certificate_data(params)
70
70
  # Generate OpenSSL RSA key from the mentioned ssh key path (and passphrase)
71
71
  key = OpenSSL::PKey::RSA.new(File.read(params[:ssh_key]), params[:ssh_key_passphrase])
72
72
  # Generate X 509 certificate
@@ -81,28 +81,28 @@ module Azure
81
81
  ef = OpenSSL::X509::ExtensionFactory.new
82
82
  ef.subject_certificate = ca
83
83
  ef.issuer_certificate = ca
84
- ca.add_extension(ef.create_extension("basicConstraints","CA:TRUE",true))
85
- ca.add_extension(ef.create_extension("keyUsage","keyCertSign, cRLSign", true))
86
- ca.add_extension(ef.create_extension("subjectKeyIdentifier","hash",false))
87
- ca.add_extension(ef.create_extension("authorityKeyIdentifier","keyid:always",false))
84
+ ca.add_extension(ef.create_extension("basicConstraints", "CA:TRUE", true))
85
+ ca.add_extension(ef.create_extension("keyUsage", "keyCertSign, cRLSign", true))
86
+ ca.add_extension(ef.create_extension("subjectKeyIdentifier", "hash", false))
87
+ ca.add_extension(ef.create_extension("authorityKeyIdentifier", "keyid:always", false))
88
88
  ca.sign(key, OpenSSL::Digest::SHA256.new)
89
89
  # Generate the SHA1 fingerprint of the der format of the X 509 certificate
90
- @fingerprint = OpenSSL::Digest::SHA1.new(ca.to_der)
90
+ @fingerprint = OpenSSL::Digest::SHA1.new(ca.to_der)
91
91
  # Create the pfx format of the certificate
92
- pfx = OpenSSL::PKCS12.create('knifeazure', 'knife-azure-pfx', key, ca)
92
+ pfx = OpenSSL::PKCS12.create("knifeazure", "knife-azure-pfx", key, ca)
93
93
  # Encode the pfx format - upload this certificate
94
94
  Base64.strict_encode64(pfx.to_der)
95
95
  end
96
96
 
97
- def add_certificate certificate_data, certificate_password, certificate_format, dns_name
97
+ def add_certificate(certificate_data, certificate_password, certificate_format, dns_name)
98
98
  # Generate XML to call the API
99
99
  # Add certificate to the hosted service
100
100
  builder = Nokogiri::XML::Builder.new do |xml|
101
- xml.CertificateFile('xmlns'=>'http://schemas.microsoft.com/windowsazure') {
102
- xml.Data certificate_data
103
- xml.CertificateFormat certificate_format
104
- xml.Password certificate_password
105
- }
101
+ xml.CertificateFile("xmlns" => "http://schemas.microsoft.com/windowsazure") do
102
+ xml.Data certificate_data
103
+ xml.CertificateFormat certificate_format
104
+ xml.Password certificate_password
105
+ end
106
106
  end
107
107
  # Windows Azure API call
108
108
  @connection.query_azure("hostedservices/#{dns_name}/certificates", "post", builder.to_xml)
@@ -125,8 +125,8 @@ module Azure
125
125
  end
126
126
 
127
127
  ######## SSL certificate generation for knife-azure ssl bootstrap ######
128
- def create_ssl_certificate cert_params
129
- file_path = cert_params[:output_file].sub(/\.(\w+)$/,'')
128
+ def create_ssl_certificate(cert_params)
129
+ file_path = cert_params[:output_file].sub(/\.(\w+)$/, "")
130
130
  path = prompt_for_file_path
131
131
  file_path = File.join(path, file_path) unless path.empty?
132
132
  cert_params[:domain] = prompt_for_domain
@@ -134,21 +134,21 @@ module Azure
134
134
  rsa_key = generate_keypair cert_params[:key_length]
135
135
  cert = generate_certificate(rsa_key, cert_params)
136
136
  write_certificate_to_file cert, file_path, rsa_key, cert_params
137
- puts "*"*70
137
+ puts "*" * 70
138
138
  puts "Generated Certificates:"
139
139
  puts "- #{file_path}.pfx - PKCS12 format keypair. Contains both the public and private keys, usually used on the server."
140
140
  puts "- #{file_path}.b64 - Base64 encoded PKCS12 keypair. Contains both the public and private keys, for upload to the Azure REST API."
141
141
  puts "- #{file_path}.pem - Base64 encoded public certificate only. Required by the client to connect to the server."
142
142
  puts "Certificate Thumbprint: #{@thumbprint.to_s.upcase}"
143
- puts "*"*70
143
+ puts "*" * 70
144
144
 
145
145
  Chef::Config[:knife][:ca_trust_file] = file_path + ".pem" if Chef::Config[:knife][:ca_trust_file].nil?
146
146
  cert_data = File.read (file_path + ".b64")
147
- add_certificate cert_data, @winrm_cert_passphrase, 'pfx', cert_params[:azure_dns_name]
147
+ add_certificate cert_data, @winrm_cert_passphrase, "pfx", cert_params[:azure_dns_name]
148
148
  @thumbprint
149
149
  end
150
150
 
151
- def generate_keypair key_length
151
+ def generate_keypair(key_length)
152
152
  OpenSSL::PKey::RSA.new(key_length.to_i)
153
153
  end
154
154
 
@@ -166,7 +166,7 @@ module Azure
166
166
  end
167
167
 
168
168
  def prompt_for_file_path
169
- file_path = ''
169
+ file_path = ""
170
170
  counter = 0
171
171
  begin
172
172
  print "Invalid location! \n" unless file_path.empty?
@@ -183,7 +183,7 @@ module Azure
183
183
  def prompt_for_domain
184
184
  counter = 0
185
185
  begin
186
- print 'Enter the domain (mandatory):'
186
+ print "Enter the domain (mandatory):"
187
187
  domain = STDIN.gets
188
188
  domain = domain.strip
189
189
  counter += 1
@@ -211,15 +211,15 @@ module Azure
211
211
  ef = OpenSSL::X509::ExtensionFactory.new
212
212
  ef.subject_certificate = cert
213
213
  ef.issuer_certificate = cert
214
- cert.add_extension(ef.create_extension("subjectKeyIdentifier","hash",false))
215
- cert.add_extension(ef.create_extension("authorityKeyIdentifier","keyid:always",false))
214
+ cert.add_extension(ef.create_extension("subjectKeyIdentifier", "hash", false))
215
+ cert.add_extension(ef.create_extension("authorityKeyIdentifier", "keyid:always", false))
216
216
  cert.add_extension(ef.create_extension("extendedKeyUsage", "1.3.6.1.5.5.7.3.1", false))
217
217
  cert.sign(rsa_key, OpenSSL::Digest::SHA1.new)
218
218
  @thumbprint = OpenSSL::Digest::SHA1.new(cert.to_der)
219
219
  cert
220
220
  end
221
221
 
222
- def write_certificate_to_file cert, file_path, rsa_key, cert_params
222
+ def write_certificate_to_file(cert, file_path, rsa_key, cert_params)
223
223
  File.open(file_path + ".pem", "wb") { |f| f.print cert.to_pem }
224
224
  @winrm_cert_passphrase = prompt_for_passphrase unless @winrm_cert_passphrase
225
225
  pfx = OpenSSL::PKCS12.create("#{cert_params[:winrm_cert_passphrase]}", "winrmcert", rsa_key, cert)
@@ -229,6 +229,5 @@ module Azure
229
229
 
230
230
  ########## SSL certificate generation ends ###########
231
231
 
232
-
233
232
  end
234
233
  end
@@ -1,6 +1,6 @@
1
1
  #
2
2
  # Author:: Barry Davis (barryd@jetstreamsoftware.com)
3
- # Copyright:: Copyright (c) 2010-2011 Opscode, Inc.
3
+ # Copyright:: Copyright 2010-2018 Chef Software, Inc.
4
4
  # License:: Apache License, Version 2.0
5
5
  #
6
6
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -16,17 +16,17 @@
16
16
  # limitations under the License.
17
17
  #
18
18
 
19
- require 'azure/service_management/image'
20
- require 'azure/service_management/role'
21
- require 'azure/service_management/deploy'
22
- require 'azure/service_management/host'
23
- require 'azure/service_management/loadbalancer'
24
- require 'azure/service_management/vnet'
25
- require 'azure/service_management/utility'
26
- require 'azure/service_management/ag'
27
- require 'azure/service_management/storageaccount'
28
- require 'azure/service_management/certificate'
29
- require 'azure/service_management/disk'
19
+ require "azure/service_management/image"
20
+ require "azure/service_management/role"
21
+ require "azure/service_management/deploy"
22
+ require "azure/service_management/host"
23
+ require "azure/service_management/loadbalancer"
24
+ require "azure/service_management/vnet"
25
+ require "azure/service_management/utility"
26
+ require "azure/service_management/ag"
27
+ require "azure/service_management/storageaccount"
28
+ require "azure/service_management/certificate"
29
+ require "azure/service_management/disk"
30
30
 
31
31
  module Azure
32
32
  class ServiceManagement
@@ -37,7 +37,7 @@ module Azure
37
37
  def initialize(rest)
38
38
  @images = Images.new(self)
39
39
  @roles = Roles.new(self)
40
- @deploys = Deploys.new(self)
40
+ @deploys = Deploys.new(self)
41
41
  @hosts = Hosts.new(self)
42
42
  @rest = rest
43
43
  @lbs = Loadbalancer.new(self)
@@ -49,19 +49,19 @@ module Azure
49
49
  end
50
50
 
51
51
  def query_azure(service_name,
52
- verb = 'get',
53
- body = '',
54
- params = '',
52
+ verb = "get",
53
+ body = "",
54
+ params = "",
55
55
  wait = true,
56
56
  services = true,
57
57
  content_type = nil)
58
- Chef::Log.info 'calling ' + verb + ' ' + service_name + (wait ? " synchronously" : " asynchronously")
59
- Chef::Log.debug body unless body == ''
58
+ Chef::Log.info "calling " + verb + " " + service_name + (wait ? " synchronously" : " asynchronously")
59
+ Chef::Log.debug body unless body == ""
60
60
  response = @rest.query_azure(service_name, verb, body, params, services, content_type)
61
61
  if response.code.to_i == 200
62
62
  ret_val = Nokogiri::XML response.body
63
63
  elsif !wait && response.code.to_i == 202
64
- Chef::Log.debug 'Request accepted in asynchronous mode'
64
+ Chef::Log.debug "Request accepted in asynchronous mode"
65
65
  ret_val = Nokogiri::XML response.body
66
66
  elsif response.code.to_i >= 201 && response.code.to_i <= 299
67
67
  ret_val = wait_for_completion()
@@ -70,29 +70,29 @@ module Azure
70
70
  ret_val = Nokogiri::XML response.body
71
71
  Chef::Log.debug ret_val.to_xml
72
72
  error_code, error_message = error_from_response_xml(ret_val)
73
- Chef::Log.debug error_code + ' : ' + error_message if error_code.length > 0
73
+ Chef::Log.debug error_code + " : " + error_message if error_code.length > 0
74
74
  else
75
- Chef::Log.warn 'http error: ' + response.code
75
+ Chef::Log.warn "http error: " + response.code
76
76
  end
77
77
  end
78
78
  ret_val
79
79
  end
80
80
 
81
- def wait_for_completion()
82
- status = 'InProgress'
83
- Chef::Log.info 'Waiting while status returns InProgress'
84
- while status == 'InProgress'
81
+ def wait_for_completion
82
+ status = "InProgress"
83
+ Chef::Log.info "Waiting while status returns InProgress"
84
+ while status == "InProgress"
85
85
  response = @rest.query_for_completion()
86
86
  ret_val = Nokogiri::XML response.body
87
- status = xml_content(ret_val,'Status')
88
- if status == 'InProgress'
89
- print '.'
87
+ status = xml_content(ret_val, "Status")
88
+ if status == "InProgress"
89
+ print "."
90
90
  sleep(0.5)
91
- elsif status == 'Succeeded'
92
- Chef::Log.debug 'not InProgress : ' + ret_val.to_xml
91
+ elsif status == "Succeeded"
92
+ Chef::Log.debug "not InProgress : " + ret_val.to_xml
93
93
  else
94
94
  error_code, error_message = error_from_response_xml(ret_val)
95
- Chef::Log.debug status + error_code + ' : ' + error_message if error_code.length > 0
95
+ Chef::Log.debug status + error_code + " : " + error_message if error_code.length > 0
96
96
  end
97
97
  end
98
98
  ret_val
@@ -1,6 +1,6 @@
1
1
  #
2
2
  # Author:: Barry Davis (barryd@jetstreamsoftware.com)
3
- # Copyright:: Copyright (c) 2010-2011 Opscode, Inc.
3
+ # Copyright:: Copyright 2010-2018 Chef Software, Inc.
4
4
  # License:: Apache License, Version 2.0
5
5
  #
6
6
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -20,8 +20,9 @@ module Azure
20
20
  class Deploys
21
21
  include AzureUtility
22
22
  def initialize(connection)
23
- @connection=connection
23
+ @connection = connection
24
24
  end
25
+
25
26
  # force_load should be true when there is something in local cache and we want to reload
26
27
  # first call is always load.
27
28
  def load(force_load = false)
@@ -44,7 +45,7 @@ module Azure
44
45
  end
45
46
 
46
47
  def all
47
- self.load
48
+ load
48
49
  end
49
50
 
50
51
  # TODO - Current knife-azure plug-in seems to have assumption that single hostedservice
@@ -61,14 +62,14 @@ module Azure
61
62
  def create(params)
62
63
  if params[:azure_connect_to_existing_dns]
63
64
  unless @connection.hosts.exists?(params[:azure_dns_name])
64
- Chef::Log.fatal 'The specified Azure DNS Name does not exist.'
65
+ Chef::Log.fatal "The specified Azure DNS Name does not exist."
65
66
  exit 1
66
67
  end
67
68
  else
68
69
  ret_val = @connection.hosts.create(params)
69
70
  error_code, error_message = error_from_response_xml(ret_val)
70
71
  if error_code.length > 0
71
- Chef::Log.fatal 'Unable to create DNS:' + error_code + ' : ' + error_message
72
+ Chef::Log.fatal "Unable to create DNS:" + error_code + " : " + error_message
72
73
  exit 1
73
74
  end
74
75
  end
@@ -80,19 +81,19 @@ module Azure
80
81
  end
81
82
  if params[:cert_path]
82
83
  cert_data = File.read (params[:cert_path])
83
- @connection.certificates.add cert_data, params[:cert_password], 'pfx', params[:azure_dns_name]
84
- elsif(params[:winrm_transport] == "ssl")
84
+ @connection.certificates.add cert_data, params[:cert_password], "pfx", params[:azure_dns_name]
85
+ elsif params[:winrm_transport] == "ssl"
85
86
  #TODO: generate certificates for ssl listener
86
87
  end
87
88
 
88
- params['deploy_name'] = get_deploy_name_for_hostedservice(params[:azure_dns_name])
89
+ params["deploy_name"] = get_deploy_name_for_hostedservice(params[:azure_dns_name])
89
90
 
90
- if params['deploy_name'] != nil
91
+ if !params["deploy_name"].nil?
91
92
  role = Role.new(@connection)
92
93
  roleXML = role.setup(params)
93
94
  ret_val = role.create(params, roleXML)
94
95
  else
95
- params['deploy_name'] = params[:azure_dns_name]
96
+ params["deploy_name"] = params[:azure_dns_name]
96
97
  deploy = Deploy.new(@connection)
97
98
  deployXML = deploy.setup(params)
98
99
  ret_val = deploy.create(params, deployXML)
@@ -100,7 +101,7 @@ module Azure
100
101
  error_code, error_message = error_from_response_xml(ret_val)
101
102
  if error_code.length > 0
102
103
  Chef::Log.debug(ret_val.to_s)
103
- raise Chef::Log.fatal 'Unable to create role:' + error_code + ' : ' + error_message
104
+ raise Chef::Log.fatal "Unable to create role:" + error_code + " : " + error_message
104
105
  end
105
106
  @connection.roles.find_in_hosted_service(params[:azure_vm_name], params[:azure_dns_name])
106
107
  end
@@ -109,9 +110,9 @@ module Azure
109
110
  end
110
111
 
111
112
  def queryDeploy(hostedservicename)
112
- deploy = Deploy.new(@connection)
113
- deploy.retrieve(hostedservicename)
114
- deploy
113
+ deploy = Deploy.new(@connection)
114
+ deploy.retrieve(hostedservicename)
115
+ deploy
115
116
  end
116
117
  end
117
118
 
@@ -122,32 +123,33 @@ module Azure
122
123
  def initialize(connection)
123
124
  @connection = connection
124
125
  end
126
+
125
127
  def retrieve(hostedservicename)
126
128
  @hostedservicename = hostedservicename
127
129
  deployXML = @connection.query_azure("hostedservices/#{hostedservicename}/deploymentslots/Production")
128
- if deployXML.at_css('Deployment Name') != nil
129
- @name = xml_content(deployXML, 'Deployment Name')
130
- @status = xml_content(deployXML,'Deployment Status')
131
- @url = xml_content(deployXML, 'Deployment Url')
130
+ if deployXML.at_css("Deployment Name") != nil
131
+ @name = xml_content(deployXML, "Deployment Name")
132
+ @status = xml_content(deployXML, "Deployment Status")
133
+ @url = xml_content(deployXML, "Deployment Url")
132
134
  @roles = Hash.new
133
- rolesXML = deployXML.css('Deployment RoleInstanceList RoleInstance')
134
- rolesListXML = deployXML.css('Deployment RoleList Role')
135
- rolesXML.zip(rolesListXML).each do |roleXML,roleListXML|
135
+ rolesXML = deployXML.css("Deployment RoleInstanceList RoleInstance")
136
+ rolesListXML = deployXML.css("Deployment RoleList Role")
137
+ rolesXML.zip(rolesListXML).each do |roleXML, roleListXML|
136
138
  role = Role.new(@connection)
137
139
  role.parse(roleXML, hostedservicename, @name)
138
140
  if role.publicipaddress.to_s.empty?
139
- role.publicipaddress = xml_content(deployXML, 'VirtualIPs VirtualIP Address')
141
+ role.publicipaddress = xml_content(deployXML, "VirtualIPs VirtualIP Address")
140
142
  end
141
143
  role.parse_role_list_xml(roleListXML)
142
144
  @roles[role.name] = role
143
145
  end
144
146
  @input_endpoints = Array.new
145
- endpointsXML = deployXML.css('InputEndpoint')
147
+ endpointsXML = deployXML.css("InputEndpoint")
146
148
  endpointsXML.each do |endpointXML|
147
149
  @input_endpoints << parse_endpoint(endpointXML)
148
150
  end
149
151
  @loadbalancers = Hash.new
150
- lbsXML = deployXML.css('Deployment LoadBalancers LoadBalancer')
152
+ lbsXML = deployXML.css("Deployment LoadBalancers LoadBalancer")
151
153
  lbsXML.each do |lbXML|
152
154
  loadbalancer = Loadbalancer.new(@connection)
153
155
  loadbalancer.parse(lbXML, hostedservicename)
@@ -162,19 +164,19 @@ module Azure
162
164
  #roleXML = Nokogiri::XML role.setup(params)
163
165
  builder = Nokogiri::XML::Builder.new do |xml|
164
166
  xml.Deployment(
165
- 'xmlns'=>'http://schemas.microsoft.com/windowsazure',
166
- 'xmlns:i'=>'http://www.w3.org/2001/XMLSchema-instance'
167
- ) {
168
- xml.Name params['deploy_name']
169
- xml.DeploymentSlot 'Production'
170
- xml.Label Base64.encode64(params['deploy_name']).strip
171
- xml.RoleList { xml.Role('i:type'=>'PersistentVMRole') }
167
+ "xmlns" => "http://schemas.microsoft.com/windowsazure",
168
+ "xmlns:i" => "http://www.w3.org/2001/XMLSchema-instance"
169
+ ) do
170
+ xml.Name params["deploy_name"]
171
+ xml.DeploymentSlot "Production"
172
+ xml.Label Base64.encode64(params["deploy_name"]).strip
173
+ xml.RoleList { xml.Role("i:type" => "PersistentVMRole") }
172
174
  if params[:azure_network_name]
173
175
  xml.VirtualNetworkName params[:azure_network_name]
174
176
  end
175
- }
177
+ end
176
178
  end
177
- builder.doc.at_css('Role') << roleXML.at_css('PersistentVMRole').children.to_s
179
+ builder.doc.at_css("Role") << roleXML.at_css("PersistentVMRole").children.to_s
178
180
  builder.doc
179
181
  end
180
182
 
@@ -191,14 +193,14 @@ module Azure
191
193
  hash[key] = xml_content(inputendpoint_xml, key, nil)
192
194
  end
193
195
  # Protocol could be in there twice... If we have two, pick the second one as the first is for the probe.
194
- if inputendpoint_xml.css('Protocol').count > 1
195
- hash['Protocol'] = inputendpoint_xml.css('Protocol')[1].content
196
+ if inputendpoint_xml.css("Protocol").count > 1
197
+ hash["Protocol"] = inputendpoint_xml.css("Protocol")[1].content
196
198
  end
197
- probe = inputendpoint_xml.css('LoadBalancerProbe')
199
+ probe = inputendpoint_xml.css("LoadBalancerProbe")
198
200
  if probe
199
- hash['LoadBalancerProbe'] = Hash.new
201
+ hash["LoadBalancerProbe"] = Hash.new
200
202
  %w{Path Port Protocol IntervalInSeconds TimeoutInSeconds}.each do |key|
201
- hash['LoadBalancerProbe'][key] = xml_content(probe, key, nil)
203
+ hash["LoadBalancerProbe"][key] = xml_content(probe, key, nil)
202
204
  end
203
205
  end
204
206
  hash