appoxy-aws 1.11.29 → 1.11.30

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,189 @@
1
+ module RightAws
2
+
3
+
4
+
5
+ class Elb < RightAwsBase
6
+ include RightAwsBaseInterface
7
+
8
+
9
+ #Amazon EC2 API version being used
10
+ API_VERSION = "2008-12-01"
11
+ DEFAULT_HOST = "elasticloadbalancing.amazonaws.com"
12
+ DEFAULT_PATH = '/'
13
+ DEFAULT_PROTOCOL = 'http'
14
+ DEFAULT_PORT = 80
15
+
16
+
17
+ @@bench = AwsBenchmarkingBlock.new
18
+ def self.bench_xml
19
+ @@bench.xml
20
+ end
21
+ def self.bench_ec2
22
+ @@bench.service
23
+ end
24
+
25
+ # Current API version (sometimes we have to check it outside the GEM).
26
+ @@api = ENV['EC2_API_VERSION'] || API_VERSION
27
+ def self.api
28
+ @@api
29
+ end
30
+
31
+
32
+ def initialize(aws_access_key_id=nil, aws_secret_access_key=nil, params={})
33
+ init({ :name => 'ELB',
34
+ :default_host => ENV['ELB_URL'] ? URI.parse(ENV['ELB_URL']).host : DEFAULT_HOST,
35
+ :default_port => ENV['ELB_URL'] ? URI.parse(ENV['ELB_URL']).port : DEFAULT_PORT,
36
+ :default_service => ENV['ELB_URL'] ? URI.parse(ENV['ELB_URL']).path : DEFAULT_PATH,
37
+ :default_protocol => ENV['ELB_URL'] ? URI.parse(ENV['ELB_URL']).scheme : DEFAULT_PROTOCOL },
38
+ aws_access_key_id || ENV['AWS_ACCESS_KEY_ID'],
39
+ aws_secret_access_key|| ENV['AWS_SECRET_ACCESS_KEY'],
40
+ params)
41
+ end
42
+
43
+
44
+ def generate_request(action, params={})
45
+ service_hash = {"Action" => action,
46
+ "AWSAccessKeyId" => @aws_access_key_id,
47
+ "Version" => @@api }
48
+ service_hash.update(params)
49
+ service_params = signed_service_params(@aws_secret_access_key, service_hash, :get, @params[:server], @params[:service])
50
+
51
+ # use POST method if the length of the query string is too large
52
+ if service_params.size > 2000
53
+ if signature_version == '2'
54
+ # resign the request because HTTP verb is included into signature
55
+ service_params = signed_service_params(@aws_secret_access_key, service_hash, :post, @params[:server], @params[:service])
56
+ end
57
+ request = Net::HTTP::Post.new(service)
58
+ request.body = service_params
59
+ request['Content-Type'] = 'application/x-www-form-urlencoded'
60
+ else
61
+ request = Net::HTTP::Get.new("#{@params[:service]}?#{service_params}")
62
+ end
63
+
64
+ #puts "\n\n --------------- QUERY REQUEST TO AWS -------------- \n\n"
65
+ #puts "#{@params[:service]}?#{service_params}\n\n"
66
+
67
+ # prepare output hash
68
+ { :request => request,
69
+ :server => @params[:server],
70
+ :port => @params[:port],
71
+ :protocol => @params[:protocol] }
72
+ end
73
+
74
+
75
+ # Sends request to Amazon and parses the response
76
+ # Raises AwsError if any banana happened
77
+ def request_info(request, parser)
78
+ thread = @params[:multi_thread] ? Thread.current : Thread.main
79
+ thread[:elb_connection] ||= Rightscale::HttpConnection.new(:exception => RightAws::AwsError, :logger => @logger)
80
+ request_info_impl(thread[:elb_connection], @@bench, request, parser)
81
+ end
82
+
83
+
84
+ #-----------------------------------------------------------------
85
+ # REQUESTS
86
+ #-----------------------------------------------------------------
87
+
88
+
89
+ def register_instance_with_elb(instance_id, lparams={})
90
+ params = {}
91
+
92
+ params['LoadBalancerName'] = lparams[:load_balancer_name]
93
+ params['Instances.member.1.InstanceId'] = instance_id
94
+
95
+ @logger.info("Registering Instance #{instance_id} with Load Balancer '#{params['LoadBalancerName']}'")
96
+
97
+ link = generate_request("RegisterInstancesWithLoadBalancer", params)
98
+ resp = request_info(link, QElbRegisterInstanceParser.new(:logger => @logger))
99
+
100
+ rescue Exception
101
+ on_exception
102
+ end
103
+
104
+
105
+
106
+
107
+
108
+
109
+ def describe_load_balancers
110
+ @logger.info("Describing Load Balancers")
111
+
112
+ params = {}
113
+
114
+ link = generate_request("DescribeLoadBalancers", params)
115
+
116
+ resp = request_info(link, QElbDescribeLoadBalancersParser.new(:logger => @logger))
117
+
118
+ rescue Exception
119
+ on_exception
120
+ end
121
+
122
+
123
+
124
+
125
+ #-----------------------------------------------------------------
126
+ # PARSERS: Instances
127
+ #-----------------------------------------------------------------
128
+
129
+ class QElbDescribeLoadBalancersParser < RightAWSParser
130
+
131
+ def reset
132
+ @result = []
133
+ end
134
+
135
+
136
+ def tagend(name)
137
+ #case name
138
+ # when 'LoadBalancerName' then
139
+ # @result[:load_balancer_name] = @text
140
+ # when 'AvailabilityZones' then
141
+ # @result[:availability_zones] = @text
142
+ # when 'CreatedTime' then
143
+ # @result[:created_time] = Time.parse(@text)
144
+ # when 'DNSName' then
145
+ # @result[:dns_name] = @text
146
+ # when 'Instances' then
147
+ # @result[:instances] = @text
148
+ # when 'HealthCheck' then
149
+ # @result[:health_check] = @text
150
+ # when 'Listeners' then
151
+ # @result[:listeners] = @text
152
+ #end
153
+ end
154
+ end
155
+
156
+ class QElbRegisterInstanceParser < RightAWSParser
157
+
158
+ def reset
159
+ @result = []
160
+ end
161
+
162
+
163
+ def tagend(name)
164
+ #case name
165
+ # when 'LoadBalancerName' then
166
+ # @result[:load_balancer_name] = @text
167
+ # when 'AvailabilityZones' then
168
+ # @result[:availability_zones] = @text
169
+ # when 'CreatedTime' then
170
+ # @result[:created_time] = Time.parse(@text)
171
+ # when 'DNSName' then
172
+ # @result[:dns_name] = @text
173
+ # when 'Instances' then
174
+ # @result[:instances] = @text
175
+ # when 'HealthCheck' then
176
+ # @result[:health_check] = @text
177
+ # when 'Listeners' then
178
+ # @result[:listeners] = @text
179
+ #end
180
+ end
181
+ end
182
+
183
+
184
+
185
+
186
+ end
187
+
188
+
189
+ end
@@ -45,13 +45,14 @@ require 'sqs/right_sqs_interface'
45
45
  require 'sqs/right_sqs'
46
46
  require 'sdb/right_sdb_interface'
47
47
  require 'acf/right_acf_interface'
48
+ require 'elb/right_elb_interface'
48
49
 
49
50
 
50
51
  module RightAws #:nodoc:
51
52
  module VERSION #:nodoc:
52
53
  MAJOR = 1
53
54
  MINOR = 11
54
- TINY = 9
55
+ TINY = 30
55
56
 
56
57
  STRING = [MAJOR, MINOR, TINY].join('.')
57
58
  end
metadata CHANGED
@@ -1,20 +1,21 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: appoxy-aws
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.11.29
4
+ version: 1.11.30
5
5
  platform: ruby
6
6
  authors:
7
7
  - Travis Reeder
8
+ - Chad Arimura
8
9
  - RightScale
9
10
  autorequire:
10
11
  bindir: bin
11
12
  cert_chain: []
12
13
 
13
- date: 2009-08-01 00:00:00 -07:00
14
+ date: 2009-08-10 00:00:00 -07:00
14
15
  default_executable:
15
16
  dependencies: []
16
17
 
17
- description: AWS Library for amazon web services.
18
+ description: AWS Ruby Library for interfacing with Amazon Web Services.
18
19
  email: travis@appoxy.com
19
20
  executables: []
20
21
 
@@ -28,6 +29,7 @@ files:
28
29
  - lib/awsbase/right_awsbase.rb
29
30
  - lib/awsbase/support.rb
30
31
  - lib/ec2/right_ec2.rb
32
+ - lib/elb/right_elb_interface.rb
31
33
  - lib/right_aws.rb
32
34
  - lib/s3/right_s3.rb
33
35
  - lib/s3/right_s3_interface.rb
@@ -36,7 +38,7 @@ files:
36
38
  - lib/sqs/right_sqs.rb
37
39
  - lib/sqs/right_sqs_interface.rb
38
40
  - README.markdown
39
- has_rdoc: true
41
+ has_rdoc: false
40
42
  homepage: http://github.com/appoxy/aws/
41
43
  licenses:
42
44
  post_install_message:
@@ -61,8 +63,8 @@ requirements: []
61
63
  rubyforge_project:
62
64
  rubygems_version: 1.3.5
63
65
  signing_key:
64
- specification_version: 2
65
- summary: AWS Library for amazon web services.
66
+ specification_version: 3
67
+ summary: AWS Ruby Library for interfacing with Amazon Web Services.
66
68
  test_files:
67
69
  - test/acf/test_helper.rb
68
70
  - test/acf/test_right_acf.rb