Class: Azure::Deploy
- Inherits:
-
Object
- Object
- Azure::Deploy
- Includes:
- AzureUtility
- Defined in:
- lib/azure/service_management/deploy.rb
Instance Attribute Summary collapse
-
#connection ⇒ Object
Returns the value of attribute connection.
-
#hostedservicename ⇒ Object
Returns the value of attribute hostedservicename.
-
#input_endpoints ⇒ Object
Returns the value of attribute input_endpoints.
-
#loadbalancers ⇒ Object
Returns the value of attribute loadbalancers.
-
#name ⇒ Object
Returns the value of attribute name.
-
#status ⇒ Object
Returns the value of attribute status.
-
#url ⇒ Object
Returns the value of attribute url.
Instance Method Summary collapse
- #create(params, deployXML) ⇒ Object
-
#delete_role_if_present(role) ⇒ Object
just delete from local cache.
- #find_role(name) ⇒ Object
-
#initialize(connection) ⇒ Deploy
constructor
A new instance of Deploy.
-
#parse_endpoint(inputendpoint_xml) ⇒ Object
This parses endpoints from a RoleList-Role-InputEndpoint, NOT a RoleInstanceList-RoleInstance-InstanceEndpoint Refactor: make this an object rather than a hash..?.
- #retrieve(hostedservicename) ⇒ Object
- #roles ⇒ Object
- #setup(params) ⇒ Object
Methods included from AzureUtility
#error_from_response_xml, #xml_content
Constructor Details
#initialize(connection) ⇒ Deploy
Returns a new instance of Deploy.
122 123 124 |
# File 'lib/azure/service_management/deploy.rb', line 122 def initialize(connection) @connection = connection end |
Instance Attribute Details
#connection ⇒ Object
Returns the value of attribute connection.
120 121 122 |
# File 'lib/azure/service_management/deploy.rb', line 120 def connection @connection end |
#hostedservicename ⇒ Object
Returns the value of attribute hostedservicename.
120 121 122 |
# File 'lib/azure/service_management/deploy.rb', line 120 def hostedservicename @hostedservicename end |
#input_endpoints ⇒ Object
Returns the value of attribute input_endpoints.
120 121 122 |
# File 'lib/azure/service_management/deploy.rb', line 120 def input_endpoints @input_endpoints end |
#loadbalancers ⇒ Object
Returns the value of attribute loadbalancers.
120 121 122 |
# File 'lib/azure/service_management/deploy.rb', line 120 def loadbalancers @loadbalancers end |
#name ⇒ Object
Returns the value of attribute name.
120 121 122 |
# File 'lib/azure/service_management/deploy.rb', line 120 def name @name end |
#status ⇒ Object
Returns the value of attribute status.
120 121 122 |
# File 'lib/azure/service_management/deploy.rb', line 120 def status @status end |
#url ⇒ Object
Returns the value of attribute url.
120 121 122 |
# File 'lib/azure/service_management/deploy.rb', line 120 def url @url end |
Instance Method Details
#create(params, deployXML) ⇒ Object
181 182 183 184 |
# File 'lib/azure/service_management/deploy.rb', line 181 def create(params, deployXML) servicecall = "hostedservices/#{params[:azure_dns_name]}/deployments" @connection.query_azure(servicecall, "post", deployXML.to_xml) end |
#delete_role_if_present(role) ⇒ Object
just delete from local cache
212 213 214 |
# File 'lib/azure/service_management/deploy.rb', line 212 def delete_role_if_present(role) @roles.delete(role.name) if @roles end |
#find_role(name) ⇒ Object
216 217 218 |
# File 'lib/azure/service_management/deploy.rb', line 216 def find_role(name) @roles[name] if @roles end |
#parse_endpoint(inputendpoint_xml) ⇒ Object
This parses endpoints from a RoleList-Role-InputEndpoint, NOT a RoleInstanceList-RoleInstance-InstanceEndpoint Refactor: make this an object rather than a hash..?
188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 |
# File 'lib/azure/service_management/deploy.rb', line 188 def parse_endpoint(inputendpoint_xml) hash = Hash.new %w{LoadBalancedEndpointSetName LocalPort Name Port Protocol EnableDirectServerReturn LoadBalancerName IdleTimeoutInMinutes}.each do |key| hash[key] = xml_content(inputendpoint_xml, key, nil) end # Protocol could be in there twice... If we have two, pick the second one as the first is for the probe. if inputendpoint_xml.css('Protocol').count > 1 hash['Protocol'] = inputendpoint_xml.css('Protocol')[1].content end probe = inputendpoint_xml.css('LoadBalancerProbe') if probe hash['LoadBalancerProbe'] = Hash.new %w{Path Port Protocol IntervalInSeconds TimeoutInSeconds}.each do |key| hash['LoadBalancerProbe'][key] = xml_content(probe, key, nil) end end hash end |
#retrieve(hostedservicename) ⇒ Object
125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 |
# File 'lib/azure/service_management/deploy.rb', line 125 def retrieve(hostedservicename) @hostedservicename = hostedservicename deployXML = @connection.query_azure("hostedservices/#{hostedservicename}/deploymentslots/Production") if deployXML.at_css('Deployment Name') != nil @name = xml_content(deployXML, 'Deployment Name') @status = xml_content(deployXML,'Deployment Status') @url = xml_content(deployXML, 'Deployment Url') @roles = Hash.new rolesXML = deployXML.css('Deployment RoleInstanceList RoleInstance') rolesListXML = deployXML.css('Deployment RoleList Role') rolesXML.zip(rolesListXML).each do |roleXML,roleListXML| role = Role.new(@connection) role.parse(roleXML, hostedservicename, @name) if role.publicipaddress.to_s.empty? role.publicipaddress = xml_content(deployXML, 'VirtualIPs VirtualIP Address') end role.parse_role_list_xml(roleListXML) @roles[role.name] = role end @input_endpoints = Array.new endpointsXML = deployXML.css('InputEndpoint') endpointsXML.each do |endpointXML| @input_endpoints << parse_endpoint(endpointXML) end @loadbalancers = Hash.new lbsXML = deployXML.css('Deployment LoadBalancers LoadBalancer') lbsXML.each do |lbXML| loadbalancer = Loadbalancer.new(@connection) loadbalancer.parse(lbXML, hostedservicename) @loadbalancers[loadbalancer.name] = loadbalancer end end end |
#roles ⇒ Object
207 208 209 |
# File 'lib/azure/service_management/deploy.rb', line 207 def roles @roles.values if @roles end |
#setup(params) ⇒ Object
159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 |
# File 'lib/azure/service_management/deploy.rb', line 159 def setup(params) role = Role.new(@connection) roleXML = role.setup(params) #roleXML = Nokogiri::XML role.setup(params) builder = Nokogiri::XML::Builder.new do |xml| xml.Deployment( 'xmlns'=>'http://schemas.microsoft.com/windowsazure', 'xmlns:i'=>'http://www.w3.org/2001/XMLSchema-instance' ) { xml.Name params['deploy_name'] xml.DeploymentSlot 'Production' xml.Label Base64.encode64(params['deploy_name']).strip xml.RoleList { xml.Role('i:type'=>'PersistentVMRole') } if params[:azure_network_name] xml.VirtualNetworkName params[:azure_network_name] end } end builder.doc.at_css('Role') << roleXML.at_css('PersistentVMRole').children.to_s builder.doc end |