Class: Azure::Host
- Inherits:
-
Object
- Object
- Azure::Host
- Includes:
- AzureUtility
- Defined in:
- lib/azure/service_management/host.rb
Instance Attribute Summary collapse
-
#connection ⇒ Object
Returns the value of attribute connection.
-
#dateCreated ⇒ Object
Returns the value of attribute dateCreated.
-
#dateModified ⇒ Object
Returns the value of attribute dateModified.
-
#description ⇒ Object
Returns the value of attribute description.
-
#label ⇒ Object
Returns the value of attribute label.
-
#location ⇒ Object
Returns the value of attribute location.
-
#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
-
#add_deploy(deploy) ⇒ Object
Deployments within this hostedservice.
- #create(params) ⇒ Object
- #delete_role(role) ⇒ Object
- #deploys ⇒ Object
- #details ⇒ Object
- #find_role(role_name, deploy_name = nil) ⇒ Object
-
#initialize(connection) ⇒ Host
constructor
A new instance of Host.
- #parse(serviceXML) ⇒ Object
- #roles ⇒ Object
Methods included from AzureUtility
#error_from_response_xml, #xml_content
Constructor Details
#initialize(connection) ⇒ Host
Returns a new instance of Host.
107 108 109 110 111 |
# File 'lib/azure/service_management/host.rb', line 107 def initialize(connection) @connection = connection @deploys_loaded = false @deploys = {} end |
Instance Attribute Details
#connection ⇒ Object
Returns the value of attribute connection.
103 104 105 |
# File 'lib/azure/service_management/host.rb', line 103 def connection @connection end |
#dateCreated ⇒ Object
Returns the value of attribute dateCreated.
104 105 106 |
# File 'lib/azure/service_management/host.rb', line 104 def dateCreated @dateCreated end |
#dateModified ⇒ Object
Returns the value of attribute dateModified.
105 106 107 |
# File 'lib/azure/service_management/host.rb', line 105 def dateModified @dateModified end |
#description ⇒ Object
Returns the value of attribute description.
104 105 106 |
# File 'lib/azure/service_management/host.rb', line 104 def description @description end |
#label ⇒ Object
Returns the value of attribute label.
103 104 105 |
# File 'lib/azure/service_management/host.rb', line 103 def label @label end |
#location ⇒ Object
Returns the value of attribute location.
104 105 106 |
# File 'lib/azure/service_management/host.rb', line 104 def location @location end |
#name ⇒ Object
Returns the value of attribute name.
103 104 105 |
# File 'lib/azure/service_management/host.rb', line 103 def name @name end |
#status ⇒ Object
Returns the value of attribute status.
105 106 107 |
# File 'lib/azure/service_management/host.rb', line 105 def status @status end |
#url ⇒ Object
Returns the value of attribute url.
103 104 105 |
# File 'lib/azure/service_management/host.rb', line 103 def url @url end |
Instance Method Details
#add_deploy(deploy) ⇒ Object
Deployments within this hostedservice
147 148 149 |
# File 'lib/azure/service_management/host.rb', line 147 def add_deploy(deploy) @deploys[deploy.name] = deploy end |
#create(params) ⇒ Object
125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 |
# File 'lib/azure/service_management/host.rb', line 125 def create(params) builder = Nokogiri::XML::Builder.new do |xml| xml.CreateHostedService("xmlns" => "http://schemas.microsoft.com/windowsazure") do xml.ServiceName params[:azure_dns_name] xml.Label Base64.encode64(params[:azure_dns_name]) xml.Description "Explicitly created hosted service" unless params[:azure_service_location].nil? xml.Location params[:azure_service_location] end unless params[:azure_affinity_group].nil? xml.AffinityGroup params[:azure_affinity_group] end end end @connection.query_azure("hostedservices", "post", builder.to_xml) end |
#delete_role(role) ⇒ Object
151 152 153 |
# File 'lib/azure/service_management/host.rb', line 151 def delete_role(role) deploys.each { |d| d.delete_role_if_present(role) } end |
#deploys ⇒ Object
155 156 157 158 159 160 161 162 163 164 |
# File 'lib/azure/service_management/host.rb', line 155 def deploys # check if we have deploys loaded, else load. if (@deploys.length == 0) && !@deploys_loaded deploy = Deploy.new(@connection) deploy.retrieve(@name) @deploys[deploy.name] = deploy @deploys_loaded = true end @deploys.values end |
#details ⇒ Object
142 143 144 |
# File 'lib/azure/service_management/host.rb', line 142 def details response = @connection.query_azure("hostedservices/" + @name + "?embed-detail=true") end |
#find_role(role_name, deploy_name = nil) ⇒ Object
174 175 176 177 178 179 180 181 182 |
# File 'lib/azure/service_management/host.rb', line 174 def find_role(role_name, deploy_name = nil) return @deploys[deploy_name].find_role(role_name) if deploy_name && deploys # else lookup all deploys within hostedservice deploys.each do |deploy| role = deploy.find_role(role_name) return role if role end end |
#parse(serviceXML) ⇒ Object
113 114 115 116 117 118 119 120 121 122 123 |
# File 'lib/azure/service_management/host.rb', line 113 def parse(serviceXML) @name = xml_content(serviceXML, "ServiceName") @url = xml_content(serviceXML, "Url") @label = xml_content(serviceXML, "HostedServiceProperties Label") @dateCreated = xml_content(serviceXML, "HostedServiceProperties DateCreated") @description = xml_content(serviceXML, "HostedServiceProperties Description") @location = xml_content(serviceXML, "HostedServiceProperties Location") @dateModified = xml_content(serviceXML, "HostedServiceProperties DateLastModified") @status = xml_content(serviceXML, "HostedServiceProperties Status") self end |
#roles ⇒ Object
166 167 168 169 170 171 172 |
# File 'lib/azure/service_management/host.rb', line 166 def roles roles = [] deploys.each do |deploy| roles.concat(deploy.roles) if deploy.roles end roles end |