Class: Azure::Loadbalancer
- Inherits:
-
Object
- Object
- Azure::Loadbalancer
- Includes:
- AzureUtility
- Defined in:
- lib/azure/service_management/loadbalancer.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
Returns the value of attribute name.
-
#service ⇒ Object
Returns the value of attribute service.
-
#subnet ⇒ Object
Returns the value of attribute subnet.
-
#vip ⇒ Object
Returns the value of attribute vip.
Instance Method Summary collapse
- #all ⇒ Object
- #create(params) ⇒ Object
- #exists?(name) ⇒ Boolean
- #find(name) ⇒ Object
-
#initialize(connection) ⇒ Loadbalancer
constructor
A new instance of Loadbalancer.
- #load ⇒ Object
- #parse(lbXML, hostedservicename) ⇒ Object
Methods included from AzureUtility
#error_from_response_xml, #xml_content
Constructor Details
#initialize(connection) ⇒ Loadbalancer
Returns a new instance of Loadbalancer.
24 25 26 |
# File 'lib/azure/service_management/loadbalancer.rb', line 24 def initialize(connection) @connection = connection end |
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
22 23 24 |
# File 'lib/azure/service_management/loadbalancer.rb', line 22 def name @name end |
#service ⇒ Object
Returns the value of attribute service.
22 23 24 |
# File 'lib/azure/service_management/loadbalancer.rb', line 22 def service @service end |
#subnet ⇒ Object
Returns the value of attribute subnet.
22 23 24 |
# File 'lib/azure/service_management/loadbalancer.rb', line 22 def subnet @subnet end |
#vip ⇒ Object
Returns the value of attribute vip.
22 23 24 |
# File 'lib/azure/service_management/loadbalancer.rb', line 22 def vip @vip end |
Instance Method Details
#all ⇒ Object
38 39 40 |
# File 'lib/azure/service_management/loadbalancer.rb', line 38 def all load.values end |
#create(params) ⇒ Object
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/azure/service_management/loadbalancer.rb', line 59 def create(params) if params[:azure_lb_static_vip] && !params[:azure_subnet_name] Chef::Log.fatal "Unable to create Loadbalancer, :azure_subnet_name needs to be set if :azure_lb_static_vip is set" end builder = Nokogiri::XML::Builder.new(encoding: "utf-8") do |xml| xml.LoadBalancer(xmlns: "http://schemas.microsoft.com/windowsazure") do xml.Name params[:azure_load_balancer] xml.FrontendIpConfiguration do xml.Type "Private" xml.SubnetName params[:azure_subnet_name] if params[:azure_subnet_name] xml.StaticVirtualNetworkIPAddress params[:azure_lb_static_vip] if params[:azure_lb_static_vip] end end end deploy_name = @connection.deploys.get_deploy_name_for_hostedservice(params[:azure_dns_name]) servicecall = "hostedservices/#{params[:azure_dns_name]}/deployments/#{deploy_name}/loadbalancers" @connection.query_azure(servicecall, "post", builder.doc.to_xml) end |
#exists?(name) ⇒ Boolean
42 43 44 |
# File 'lib/azure/service_management/loadbalancer.rb', line 42 def exists?(name) load.key?(name) end |
#find(name) ⇒ Object
46 47 48 |
# File 'lib/azure/service_management/loadbalancer.rb', line 46 def find(name) load[name] end |
#load ⇒ Object
28 29 30 31 32 33 34 35 36 |
# File 'lib/azure/service_management/loadbalancer.rb', line 28 def load @lbs ||= begin @lbs = {} @connection.deploys.all.each do |deploy| @lbs.merge!(deploy.loadbalancers) end @lbs end end |
#parse(lbXML, hostedservicename) ⇒ Object
50 51 52 53 54 55 56 57 |
# File 'lib/azure/service_management/loadbalancer.rb', line 50 def parse(lbXML, hostedservicename) @name = xml_content(lbXML, "Name") ip_configXML = lbXML.css("FrontendIpConfiguration") @subnet = xml_content(ip_configXML, "SubnetName") @vip = xml_content(ip_configXML, "StaticVirtualNetworkIPAddress") @service = hostedservicename self end |