Class: Azure::Connection
- Inherits:
-
Object
- Object
- Azure::Connection
- Includes:
- AzureAPI, AzureUtility
- Defined in:
- lib/azure/connection.rb
Instance Attribute Summary collapse
-
#ags ⇒ Object
Returns the value of attribute ags.
-
#certificates ⇒ Object
Returns the value of attribute certificates.
-
#deploys ⇒ Object
Returns the value of attribute deploys.
-
#disks ⇒ Object
Returns the value of attribute disks.
-
#hosts ⇒ Object
Returns the value of attribute hosts.
-
#images ⇒ Object
Returns the value of attribute images.
-
#rest ⇒ Object
Returns the value of attribute rest.
-
#roles ⇒ Object
Returns the value of attribute roles.
-
#storageaccounts ⇒ Object
Returns the value of attribute storageaccounts.
-
#vnets ⇒ Object
Returns the value of attribute vnets.
Instance Method Summary collapse
-
#initialize(params = {}) ⇒ Connection
constructor
A new instance of Connection.
- #query_azure(service_name, verb = 'get', body = '', params = '', wait = true, services = true) ⇒ Object
- #wait_for_completion ⇒ Object
Methods included from AzureUtility
#error_from_response_xml, #xml_content
Constructor Details
#initialize(params = {}) ⇒ Connection
Returns a new instance of Connection.
36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/azure/connection.rb', line 36 def initialize(params={}) @rest = Rest.new(params) @hosts = Hosts.new(self) @storageaccounts = StorageAccounts.new(self) @images = Images.new(self) @deploys = Deploys.new(self) @roles = Roles.new(self) @disks = Disks.new(self) @certificates = Certificates.new(self) @ags = AGs.new(self) @vnets = Vnets.new(self) end |
Instance Attribute Details
#ags ⇒ Object
Returns the value of attribute ags.
34 35 36 |
# File 'lib/azure/connection.rb', line 34 def ags @ags end |
#certificates ⇒ Object
Returns the value of attribute certificates.
34 35 36 |
# File 'lib/azure/connection.rb', line 34 def certificates @certificates end |
#deploys ⇒ Object
Returns the value of attribute deploys.
34 35 36 |
# File 'lib/azure/connection.rb', line 34 def deploys @deploys end |
#disks ⇒ Object
Returns the value of attribute disks.
34 35 36 |
# File 'lib/azure/connection.rb', line 34 def disks @disks end |
#hosts ⇒ Object
Returns the value of attribute hosts.
34 35 36 |
# File 'lib/azure/connection.rb', line 34 def hosts @hosts end |
#images ⇒ Object
Returns the value of attribute images.
34 35 36 |
# File 'lib/azure/connection.rb', line 34 def images @images end |
#rest ⇒ Object
Returns the value of attribute rest.
34 35 36 |
# File 'lib/azure/connection.rb', line 34 def rest @rest end |
#roles ⇒ Object
Returns the value of attribute roles.
34 35 36 |
# File 'lib/azure/connection.rb', line 34 def roles @roles end |
#storageaccounts ⇒ Object
Returns the value of attribute storageaccounts.
34 35 36 |
# File 'lib/azure/connection.rb', line 34 def storageaccounts @storageaccounts end |
#vnets ⇒ Object
Returns the value of attribute vnets.
34 35 36 |
# File 'lib/azure/connection.rb', line 34 def vnets @vnets end |
Instance Method Details
#query_azure(service_name, verb = 'get', body = '', params = '', wait = true, services = true) ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/azure/connection.rb', line 49 def query_azure(service_name, verb = 'get', body = '', params = '', wait = true, services = true) Chef::Log.info 'calling ' + verb + ' ' + service_name + (wait ? " synchronously" : " asynchronously") Chef::Log.debug body unless body == '' response = @rest.query_azure(service_name, verb, body, params, services) if response.code.to_i == 200 ret_val = Nokogiri::XML response.body elsif !wait && response.code.to_i == 202 Chef::Log.debug 'Request accepted in asynchronous mode' ret_val = Nokogiri::XML response.body elsif response.code.to_i >= 201 && response.code.to_i <= 299 ret_val = wait_for_completion() else if response.body ret_val = Nokogiri::XML response.body Chef::Log.debug ret_val.to_xml error_code, = error_from_response_xml(ret_val) Chef::Log.warn error_code + ' : ' + if error_code.length > 0 else Chef::Log.warn 'http error: ' + response.code end end ret_val end |
#wait_for_completion ⇒ Object
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/azure/connection.rb', line 77 def wait_for_completion() status = 'InProgress' Chef::Log.info 'Waiting while status returns InProgress' while status == 'InProgress' response = @rest.query_for_completion() ret_val = Nokogiri::XML response.body status = xml_content(ret_val,'Status') if status == 'InProgress' print '.' sleep(0.5) elsif status == 'Succeeded' Chef::Log.debug 'not InProgress : ' + ret_val.to_xml else error_code, = error_from_response_xml(ret_val) Chef::Log.warn status + error_code + ' : ' + if error_code.length > 0 end end ret_val end |