right_aws 1.8.1 → 1.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/History.txt +15 -0
- data/Manifest.txt +3 -0
- data/README.txt +8 -3
- data/Rakefile +7 -0
- data/lib/acf/right_acf_interface.rb +379 -0
- data/lib/awsbase/right_awsbase.rb +42 -3
- data/lib/ec2/right_ec2.rb +217 -57
- data/lib/right_aws.rb +3 -2
- data/lib/s3/right_s3_interface.rb +13 -14
- data/test/acf/test_helper.rb +2 -0
- data/test/acf/test_right_acf.rb +146 -0
- data/test/ts_right_aws.rb +1 -0
- metadata +8 -4
@@ -120,7 +120,7 @@ module RightAws
|
|
120
120
|
def self.caching=(caching)
|
121
121
|
@@caching = caching
|
122
122
|
end
|
123
|
-
|
123
|
+
|
124
124
|
# Current aws_access_key_id
|
125
125
|
attr_reader :aws_access_key_id
|
126
126
|
# Last HTTP request object
|
@@ -175,10 +175,13 @@ module RightAws
|
|
175
175
|
def cache_hits?(function, response, do_raise=:raise)
|
176
176
|
result = false
|
177
177
|
if caching?
|
178
|
-
function
|
178
|
+
function = function.to_sym
|
179
|
+
# get rid of requestId (this bad boy was added for API 2008-08-08+ and it is uniq for every response)
|
180
|
+
response = response.sub(%r{<requestId>.+?</requestId>}, '')
|
179
181
|
response_md5 = MD5.md5(response).to_s
|
180
|
-
#
|
182
|
+
# check for changes
|
181
183
|
unless @cache[function] && @cache[function][:response_md5] == response_md5
|
184
|
+
# well, the response is new, reset cache data
|
182
185
|
update_cache(function, {:response_md5 => response_md5,
|
183
186
|
:timestamp => Time.now,
|
184
187
|
:hits => 0,
|
@@ -282,6 +285,27 @@ module RightAws
|
|
282
285
|
raise
|
283
286
|
end
|
284
287
|
|
288
|
+
def request_cache_or_info(method, link, parser_class, benchblock, use_cache=true) #:nodoc:
|
289
|
+
# We do not want to break the logic of parsing hence will use a dummy parser to process all the standard
|
290
|
+
# steps (errors checking etc). The dummy parser does nothig - just returns back the params it received.
|
291
|
+
# If the caching is enabled and hit then throw AwsNoChange.
|
292
|
+
# P.S. caching works for the whole images list only! (when the list param is blank)
|
293
|
+
# check cache
|
294
|
+
response, params = request_info(link, RightDummyParser.new)
|
295
|
+
cache_hits?(method.to_sym, response.body) if use_cache
|
296
|
+
parser = parser_class.new(:logger => @logger)
|
297
|
+
benchblock.xml.add!{ parser.parse(response, params) }
|
298
|
+
result = block_given? ? yield(parser) : parser.result
|
299
|
+
# update parsed data
|
300
|
+
update_cache(method.to_sym, :parsed => result) if use_cache
|
301
|
+
result
|
302
|
+
end
|
303
|
+
|
304
|
+
# Returns Amazons request ID for the latest request
|
305
|
+
def last_request_id
|
306
|
+
@last_response && @last_response.body.to_s[%r{<requestId>(.+?)</requestId>}] && $1
|
307
|
+
end
|
308
|
+
|
285
309
|
end
|
286
310
|
|
287
311
|
|
@@ -674,5 +698,20 @@ module RightAws
|
|
674
698
|
end
|
675
699
|
end
|
676
700
|
|
701
|
+
# Dummy parser - does nothing
|
702
|
+
# Returns the original params back
|
703
|
+
class RightDummyParser # :nodoc:
|
704
|
+
attr_accessor :result
|
705
|
+
def parse(response, params={})
|
706
|
+
@result = [response, params]
|
707
|
+
end
|
708
|
+
end
|
709
|
+
|
710
|
+
class RightHttp2xxParser < RightAWSParser # :nodoc:
|
711
|
+
def parse(response)
|
712
|
+
@result = response.is_a?(Net::HTTPSuccess)
|
713
|
+
end
|
714
|
+
end
|
715
|
+
|
677
716
|
end
|
678
717
|
|
data/lib/ec2/right_ec2.rb
CHANGED
@@ -68,7 +68,7 @@ module RightAws
|
|
68
68
|
include RightAwsBaseInterface
|
69
69
|
|
70
70
|
# Amazon EC2 API version being used
|
71
|
-
API_VERSION = "2008-
|
71
|
+
API_VERSION = "2008-08-08"
|
72
72
|
DEFAULT_HOST = "ec2.amazonaws.com"
|
73
73
|
DEFAULT_PATH = '/'
|
74
74
|
DEFAULT_PROTOCOL = 'https'
|
@@ -106,6 +106,10 @@ module RightAws
|
|
106
106
|
# * <tt>:multi_thread</tt>: true=HTTP connection per thread, false=per process
|
107
107
|
# * <tt>:logger</tt>: for log messages, default: RAILS_DEFAULT_LOGGER else STDOUT
|
108
108
|
# * <tt>:signature_version</tt>: The signature version : '0' or '1'(default)
|
109
|
+
# * <tt>:cache</tt>: true/false: caching for: ec2_describe_images, describe_instances,
|
110
|
+
# describe_images_by_owner, describe_images_by_executable_by, describe_availability_zones,
|
111
|
+
# describe_security_groups, describe_key_pairs, describe_addresses,
|
112
|
+
# describe_volumes, describe_snapshots methods, default: false.
|
109
113
|
#
|
110
114
|
def initialize(aws_access_key_id=nil, aws_secret_access_key=nil, params={})
|
111
115
|
init({ :name => 'EC2',
|
@@ -126,7 +130,7 @@ module RightAws
|
|
126
130
|
"Timestamp" => Time.now.utc.strftime("%Y-%m-%dT%H:%M:%S.000Z"),
|
127
131
|
"SignatureVersion" => signature_version }
|
128
132
|
service_hash.update(params)
|
129
|
-
# prepare string to
|
133
|
+
# prepare string to sign
|
130
134
|
string_to_sign = case signature_version
|
131
135
|
when '0' then service_hash["Action"] + service_hash["Timestamp"]
|
132
136
|
when '1' then service_hash.sort{|a,b| (a[0].to_s.downcase)<=>(b[0].to_s.downcase)}.to_s
|
@@ -149,22 +153,6 @@ module RightAws
|
|
149
153
|
request_info_impl(thread[:ec2_connection], @@bench, request, parser)
|
150
154
|
end
|
151
155
|
|
152
|
-
def request_cache_or_info(method, link, parser_class, use_cache=true) #:nodoc:
|
153
|
-
# We do not want to break the logic of parsing hence will use a dummy parser to process all the standart
|
154
|
-
# steps (errors checking etc). The dummy parser does nothig - just returns back the params it received.
|
155
|
-
# If the caching is enabled and hit then throw AwsNoChange.
|
156
|
-
# P.S. caching works for the whole images list only! (when the list param is blank) response, params = request_info(link, QEc2DummyParser.new)
|
157
|
-
# check cache
|
158
|
-
response, params = request_info(link, QEc2DummyParser.new)
|
159
|
-
cache_hits?(method.to_sym, response.body) if use_cache
|
160
|
-
parser = parser_class.new(:logger => @logger)
|
161
|
-
@@bench.xml.add!{ parser.parse(response, params) }
|
162
|
-
result = block_given? ? yield(parser) : parser.result
|
163
|
-
# update parsed data
|
164
|
-
update_cache(method.to_sym, :parsed => result) if use_cache
|
165
|
-
result
|
166
|
-
end
|
167
|
-
|
168
156
|
def hash_params(prefix, list) #:nodoc:
|
169
157
|
groups = {}
|
170
158
|
list.each_index{|i| groups.update("#{prefix}.#{i+1}"=>list[i])} if list
|
@@ -175,11 +163,19 @@ module RightAws
|
|
175
163
|
# Images
|
176
164
|
#-----------------------------------------------------------------
|
177
165
|
|
178
|
-
|
179
|
-
|
166
|
+
# params:
|
167
|
+
# { 'ImageId' => ['id1', ..., 'idN'],
|
168
|
+
# 'Owner' => ['self', ..., 'userN'],
|
169
|
+
# 'ExecutableBy' => ['self', 'all', ..., 'userN']
|
170
|
+
# }
|
171
|
+
def ec2_describe_images(params={}, image_type=nil, cache_for=nil) #:nodoc:
|
172
|
+
request_hash = {}
|
173
|
+
params.each do |list_by, list|
|
174
|
+
request_hash.merge! hash_params(list_by, list.to_a)
|
175
|
+
end
|
180
176
|
request_hash['ImageType'] = image_type if image_type
|
181
177
|
link = generate_request("DescribeImages", request_hash)
|
182
|
-
request_cache_or_info
|
178
|
+
request_cache_or_info cache_for, link, QEc2DescribeImagesParser, @@bench, cache_for
|
183
179
|
rescue Exception
|
184
180
|
on_exception
|
185
181
|
end
|
@@ -210,7 +206,9 @@ module RightAws
|
|
210
206
|
# :aws_image_type => "machine"}]
|
211
207
|
#
|
212
208
|
def describe_images(list=[], image_type=nil)
|
213
|
-
|
209
|
+
list = list.to_a
|
210
|
+
cache_for = list.empty? && !image_type ? :describe_images : nil
|
211
|
+
ec2_describe_images({ 'ImageId' => list }, image_type, cache_for)
|
214
212
|
end
|
215
213
|
|
216
214
|
#
|
@@ -219,8 +217,10 @@ module RightAws
|
|
219
217
|
# ec2.describe_images_by_owner('522821470517')
|
220
218
|
# ec2.describe_images_by_owner('self')
|
221
219
|
#
|
222
|
-
def describe_images_by_owner(list, image_type=nil)
|
223
|
-
|
220
|
+
def describe_images_by_owner(list=['self'], image_type=nil)
|
221
|
+
list = list.to_a
|
222
|
+
cache_for = list==['self'] && !image_type ? :describe_images_by_owner : nil
|
223
|
+
ec2_describe_images({ 'Owner' => list }, image_type, cache_for)
|
224
224
|
end
|
225
225
|
|
226
226
|
#
|
@@ -228,9 +228,12 @@ module RightAws
|
|
228
228
|
#
|
229
229
|
# ec2.describe_images_by_executable_by('522821470517')
|
230
230
|
# ec2.describe_images_by_executable_by('self')
|
231
|
+
# ec2.describe_images_by_executable_by('all')
|
231
232
|
#
|
232
|
-
def describe_images_by_executable_by(list, image_type=nil)
|
233
|
-
|
233
|
+
def describe_images_by_executable_by(list=['self'], image_type=nil)
|
234
|
+
list = list.to_a
|
235
|
+
cache_for = list==['self'] && !image_type ? :describe_images_by_executable_by : nil
|
236
|
+
ec2_describe_images({ 'ExecutableBy' => list }, image_type, cache_for)
|
234
237
|
end
|
235
238
|
|
236
239
|
|
@@ -398,7 +401,7 @@ module RightAws
|
|
398
401
|
#
|
399
402
|
def describe_instances(list=[])
|
400
403
|
link = generate_request("DescribeInstances", hash_params('InstanceId',list.to_a))
|
401
|
-
request_cache_or_info(:describe_instances, link, QEc2DescribeInstancesParser, list.blank?) do |parser|
|
404
|
+
request_cache_or_info(:describe_instances, link, QEc2DescribeInstancesParser, @@bench, list.blank?) do |parser|
|
402
405
|
get_desc_instances(parser.result)
|
403
406
|
end
|
404
407
|
rescue Exception
|
@@ -412,7 +415,7 @@ module RightAws
|
|
412
415
|
#
|
413
416
|
def confirm_product_instance(instance, product_code)
|
414
417
|
link = generate_request("ConfirmProductInstance", { 'ProductCode' => product_code,
|
415
|
-
|
418
|
+
'InstanceId' => instance })
|
416
419
|
request_info(link, QEc2ConfirmProductInstanceParser.new(:logger => @logger))
|
417
420
|
end
|
418
421
|
|
@@ -573,7 +576,127 @@ module RightAws
|
|
573
576
|
rescue Exception
|
574
577
|
on_exception
|
575
578
|
end
|
579
|
+
|
580
|
+
#-----------------------------------------------------------------
|
581
|
+
# Instances: Windows addons
|
582
|
+
#-----------------------------------------------------------------
|
583
|
+
|
584
|
+
# Get initial Windows Server setup password from an instance console output.
|
585
|
+
#
|
586
|
+
# my_awesome_key = ec2.create_key_pair('my_awesome_key') #=>
|
587
|
+
# {:aws_key_name => "my_awesome_key",
|
588
|
+
# :aws_fingerprint => "01:02:03:f4:25:e6:97:e8:9b:02:1a:26:32:4e:58:6b:7a:8c:9f:03",
|
589
|
+
# :aws_material => "-----BEGIN RSA PRIVATE KEY-----\nMIIEpQIBAAK...Q8MDrCbuQ=\n-----END RSA PRIVATE KEY-----"}
|
590
|
+
#
|
591
|
+
# my_awesome_instance = ec2.run_instances('ami-a000000a',1,1,['my_awesome_group'],'my_awesome_key', 'WindowsInstance!!!') #=>
|
592
|
+
# [{:aws_image_id => "ami-a000000a",
|
593
|
+
# :aws_instance_id => "i-12345678",
|
594
|
+
# ...
|
595
|
+
# :aws_availability_zone => "us-east-1b"
|
596
|
+
# }]
|
597
|
+
#
|
598
|
+
# # wait until instance enters 'operational' state and get it's initial password
|
599
|
+
#
|
600
|
+
# puts ec2.get_initial_password(my_awesome_instance[:aws_instance_id], my_awesome_key[:aws_material]) #=> "MhjWcgZuY6"
|
601
|
+
#
|
602
|
+
def get_initial_password(instance_id, private_key)
|
603
|
+
console_output = get_console_output(instance_id)
|
604
|
+
crypted_password = console_output[:aws_output][%r{<Password>(.+)</Password>}m] && $1
|
605
|
+
unless crypted_password
|
606
|
+
raise AwsError.new("Initial password was not found in console output for #{instance_id}")
|
607
|
+
else
|
608
|
+
OpenSSL::PKey::RSA.new(private_key).private_decrypt(Base64.decode64(crypted_password))
|
609
|
+
end
|
610
|
+
rescue Exception
|
611
|
+
on_exception
|
612
|
+
end
|
613
|
+
|
614
|
+
# Bundle a Windows image.
|
615
|
+
# Internally, it queues the bundling task and shuts down the instance.
|
616
|
+
# It then takes a snapshot of the Windows volume bundles it, and uploads it to
|
617
|
+
# S3. After bundling completes, Rightaws::Ec2#register_image may be used to
|
618
|
+
# register the new Windows AMI for subsequent launches.
|
619
|
+
#
|
620
|
+
# ec2.bundle_instance('i-e3e24e8a', 'my-awesome-bucket', 'my-win-image-1') #=>
|
621
|
+
# [{:aws_update_time => "2008-10-16T13:58:25.000Z",
|
622
|
+
# :s3_bucket => "kd-win-1",
|
623
|
+
# :s3_prefix => "win2pr",
|
624
|
+
# :aws_state => "pending",
|
625
|
+
# :aws_id => "bun-26a7424f",
|
626
|
+
# :aws_instance_id => "i-878a25ee",
|
627
|
+
# :aws_start_time => "2008-10-16T13:58:02.000Z"}]
|
628
|
+
#
|
629
|
+
def bundle_instance(instance_id, s3_bucket, s3_prefix,
|
630
|
+
s3_owner_aws_access_key_id=nil, s3_owner_aws_secret_access_key=nil,
|
631
|
+
s3_expires = S3Interface::DEFAULT_EXPIRES_AFTER,
|
632
|
+
s3_upload_policy='ec2-bundle-read')
|
633
|
+
# S3 access and signatures
|
634
|
+
s3_owner_aws_access_key_id ||= @aws_access_key_id
|
635
|
+
s3_owner_aws_secret_access_key ||= @aws_secret_access_key
|
636
|
+
s3_expires = Time.now.utc + s3_expires if s3_expires.is_a?(Fixnum) && (s3_expires < S3Interface::ONE_YEAR_IN_SECONDS)
|
637
|
+
# policy
|
638
|
+
policy = { 'expiration' => s3_expires.strftime('%Y-%m-%dT%H:%M:%SZ'),
|
639
|
+
'conditions' => [ { 'bucket' => s3_bucket },
|
640
|
+
{ 'acl' => s3_upload_policy },
|
641
|
+
[ 'starts-with', '$key', s3_prefix ] ] }.to_json
|
642
|
+
policy64 = Base64.encode64(policy).gsub("\n","")
|
643
|
+
signed_policy64 = AwsUtils.sign(s3_owner_aws_secret_access_key, policy64)
|
644
|
+
# fill request params
|
645
|
+
params = { 'InstanceId' => instance_id,
|
646
|
+
'Storage.S3.AWSAccessKeyId' => s3_owner_aws_access_key_id,
|
647
|
+
'Storage.S3.UploadPolicy' => policy64,
|
648
|
+
'Storage.S3.UploadPolicySignature' => signed_policy64,
|
649
|
+
'Storage.S3.Bucket' => s3_bucket,
|
650
|
+
'Storage.S3.Prefix' => s3_prefix,
|
651
|
+
}
|
652
|
+
link = generate_request("BundleInstance", params)
|
653
|
+
request_info(link, QEc2BundleInstanceParser.new)
|
654
|
+
rescue Exception
|
655
|
+
on_exception
|
656
|
+
end
|
576
657
|
|
658
|
+
# Describe the status of the Windows AMI bundlings.
|
659
|
+
# If +list+ is omitted the returns the whole list of tasks.
|
660
|
+
#
|
661
|
+
# ec2.describe_bundle_tasks(['bun-4fa74226']) #=>
|
662
|
+
# [{:s3_bucket => "my-awesome-bucket"
|
663
|
+
# :aws_id => "bun-0fa70206",
|
664
|
+
# :s3_prefix => "win1pr",
|
665
|
+
# :aws_start_time => "2008-10-14T16:27:57.000Z",
|
666
|
+
# :aws_update_time => "2008-10-14T16:37:10.000Z",
|
667
|
+
# :aws_error_code => "Client.S3Error",
|
668
|
+
# :aws_error_message =>
|
669
|
+
# "AccessDenied(403)- Invalid according to Policy: Policy Condition failed: [\"eq\", \"$acl\", \"aws-exec-read\"]",
|
670
|
+
# :aws_state => "failed",
|
671
|
+
# :aws_instance_id => "i-e3e24e8a"}]
|
672
|
+
#
|
673
|
+
def describe_bundle_tasks(list=[])
|
674
|
+
link = generate_request("DescribeBundleTasks", hash_params('BundleId', list.to_a))
|
675
|
+
request_info(link, QEc2DescribeBundleTasksParser.new)
|
676
|
+
rescue Exception
|
677
|
+
on_exception
|
678
|
+
end
|
679
|
+
|
680
|
+
# Cancel an in‐progress or pending bundle task by id.
|
681
|
+
#
|
682
|
+
# ec2.cancel_bundle_task('bun-73a7421a') #=>
|
683
|
+
# [{:s3_bucket => "my-awesome-bucket"
|
684
|
+
# :aws_id => "bun-0fa70206",
|
685
|
+
# :s3_prefix => "win02",
|
686
|
+
# :aws_start_time => "2008-10-14T13:00:29.000Z",
|
687
|
+
# :aws_error_message => "User has requested bundling operation cancellation",
|
688
|
+
# :aws_state => "failed",
|
689
|
+
# :aws_update_time => "2008-10-14T13:01:31.000Z",
|
690
|
+
# :aws_error_code => "Client.Cancelled",
|
691
|
+
# :aws_instance_id => "i-e3e24e8a"}
|
692
|
+
#
|
693
|
+
def cancel_bundle_task(bundle_id)
|
694
|
+
link = generate_request("CancelBundleTask", { 'BundleId' => bundle_id })
|
695
|
+
request_info(link, QEc2BundleInstanceParser.new)
|
696
|
+
rescue Exception
|
697
|
+
on_exception
|
698
|
+
end
|
699
|
+
|
577
700
|
#-----------------------------------------------------------------
|
578
701
|
# Security groups
|
579
702
|
#-----------------------------------------------------------------
|
@@ -595,7 +718,7 @@ module RightAws
|
|
595
718
|
#
|
596
719
|
def describe_security_groups(list=[])
|
597
720
|
link = generate_request("DescribeSecurityGroups", hash_params('GroupName',list.to_a))
|
598
|
-
request_cache_or_info( :describe_security_groups, link, QEc2DescribeSecurityGroupsParser, list.blank?) do |parser|
|
721
|
+
request_cache_or_info( :describe_security_groups, link, QEc2DescribeSecurityGroupsParser, @@bench, list.blank?) do |parser|
|
599
722
|
result = []
|
600
723
|
parser.result.each do |item|
|
601
724
|
perms = []
|
@@ -640,7 +763,7 @@ module RightAws
|
|
640
763
|
# EC2 doesn't like an empty description...
|
641
764
|
description = " " if description.blank?
|
642
765
|
link = generate_request("CreateSecurityGroup",
|
643
|
-
'GroupName' => name.to_s,
|
766
|
+
'GroupName' => name.to_s,
|
644
767
|
'GroupDescription' => description.to_s)
|
645
768
|
request_info(link, RightBoolResponseParser.new(:logger => @logger))
|
646
769
|
rescue Exception
|
@@ -666,8 +789,8 @@ module RightAws
|
|
666
789
|
#
|
667
790
|
def authorize_security_group_named_ingress(name, owner, group)
|
668
791
|
link = generate_request("AuthorizeSecurityGroupIngress",
|
669
|
-
'GroupName' => name.to_s,
|
670
|
-
|
792
|
+
'GroupName' => name.to_s,
|
793
|
+
'SourceSecurityGroupName' => group.to_s,
|
671
794
|
'SourceSecurityGroupOwnerId' => owner.to_s.gsub(/-/,''))
|
672
795
|
request_info(link, RightBoolResponseParser.new(:logger => @logger))
|
673
796
|
rescue Exception
|
@@ -680,8 +803,8 @@ module RightAws
|
|
680
803
|
#
|
681
804
|
def revoke_security_group_named_ingress(name, owner, group)
|
682
805
|
link = generate_request("RevokeSecurityGroupIngress",
|
683
|
-
'GroupName' => name.to_s,
|
684
|
-
'SourceSecurityGroupName' => group.to_s,
|
806
|
+
'GroupName' => name.to_s,
|
807
|
+
'SourceSecurityGroupName' => group.to_s,
|
685
808
|
'SourceSecurityGroupOwnerId' => owner.to_s.gsub(/-/,''))
|
686
809
|
request_info(link, RightBoolResponseParser.new(:logger => @logger))
|
687
810
|
rescue Exception
|
@@ -695,10 +818,10 @@ module RightAws
|
|
695
818
|
#
|
696
819
|
def authorize_security_group_IP_ingress(name, from_port, to_port, protocol='tcp', cidr_ip='0.0.0.0/0')
|
697
820
|
link = generate_request("AuthorizeSecurityGroupIngress",
|
698
|
-
'GroupName' => name.to_s,
|
699
|
-
'IpProtocol' => protocol.to_s,
|
700
|
-
'FromPort' => from_port.to_s,
|
701
|
-
'ToPort' => to_port.to_s,
|
821
|
+
'GroupName' => name.to_s,
|
822
|
+
'IpProtocol' => protocol.to_s,
|
823
|
+
'FromPort' => from_port.to_s,
|
824
|
+
'ToPort' => to_port.to_s,
|
702
825
|
'CidrIp' => cidr_ip.to_s)
|
703
826
|
request_info(link, RightBoolResponseParser.new(:logger => @logger))
|
704
827
|
rescue Exception
|
@@ -711,10 +834,10 @@ module RightAws
|
|
711
834
|
#
|
712
835
|
def revoke_security_group_IP_ingress(name, from_port, to_port, protocol='tcp', cidr_ip='0.0.0.0/0')
|
713
836
|
link = generate_request("RevokeSecurityGroupIngress",
|
714
|
-
'GroupName' => name.to_s,
|
715
|
-
'IpProtocol' => protocol.to_s,
|
716
|
-
'FromPort' => from_port.to_s,
|
717
|
-
'ToPort' => to_port.to_s,
|
837
|
+
'GroupName' => name.to_s,
|
838
|
+
'IpProtocol' => protocol.to_s,
|
839
|
+
'FromPort' => from_port.to_s,
|
840
|
+
'ToPort' => to_port.to_s,
|
718
841
|
'CidrIp' => cidr_ip.to_s)
|
719
842
|
request_info(link, RightBoolResponseParser.new(:logger => @logger))
|
720
843
|
rescue Exception
|
@@ -735,7 +858,7 @@ module RightAws
|
|
735
858
|
#
|
736
859
|
def describe_key_pairs(list=[])
|
737
860
|
link = generate_request("DescribeKeyPairs", hash_params('KeyName',list.to_a))
|
738
|
-
request_cache_or_info :describe_key_pairs, link, QEc2DescribeKeyPairParser, list.blank?
|
861
|
+
request_cache_or_info :describe_key_pairs, link, QEc2DescribeKeyPairParser, @@bench, list.blank?
|
739
862
|
rescue Exception
|
740
863
|
on_exception
|
741
864
|
end
|
@@ -754,7 +877,7 @@ module RightAws
|
|
754
877
|
rescue Exception
|
755
878
|
on_exception
|
756
879
|
end
|
757
|
-
|
880
|
+
|
758
881
|
# Delete a key pair. Returns +true+ or an exception.
|
759
882
|
#
|
760
883
|
# ec2.delete_key_pair('my_awesome_key') #=> true
|
@@ -808,7 +931,7 @@ module RightAws
|
|
808
931
|
def describe_addresses(list=[])
|
809
932
|
link = generate_request("DescribeAddresses",
|
810
933
|
hash_params('PublicIp',list.to_a))
|
811
|
-
request_cache_or_info :describe_addresses, link, QEc2DescribeAddressesParser, list.blank?
|
934
|
+
request_cache_or_info :describe_addresses, link, QEc2DescribeAddressesParser, @@bench, list.blank?
|
812
935
|
rescue Exception
|
813
936
|
on_exception
|
814
937
|
end
|
@@ -855,7 +978,7 @@ module RightAws
|
|
855
978
|
def describe_availability_zones(list=[])
|
856
979
|
link = generate_request("DescribeAvailabilityZones",
|
857
980
|
hash_params('ZoneName',list.to_a))
|
858
|
-
request_cache_or_info :describe_availability_zones, link, QEc2DescribeAvailabilityZonesParser, list.blank?
|
981
|
+
request_cache_or_info :describe_availability_zones, link, QEc2DescribeAvailabilityZonesParser, @@bench, list.blank?
|
859
982
|
rescue Exception
|
860
983
|
on_exception
|
861
984
|
end
|
@@ -887,7 +1010,7 @@ module RightAws
|
|
887
1010
|
def describe_volumes(list=[])
|
888
1011
|
link = generate_request("DescribeVolumes",
|
889
1012
|
hash_params('VolumeId',list.to_a))
|
890
|
-
request_cache_or_info :describe_volumes, link, QEc2DescribeVolumesParser, list.blank?
|
1013
|
+
request_cache_or_info :describe_volumes, link, QEc2DescribeVolumesParser, @@bench, list.blank?
|
891
1014
|
rescue Exception
|
892
1015
|
on_exception
|
893
1016
|
end
|
@@ -989,7 +1112,7 @@ module RightAws
|
|
989
1112
|
def describe_snapshots(list=[])
|
990
1113
|
link = generate_request("DescribeSnapshots",
|
991
1114
|
hash_params('SnapshotId',list.to_a))
|
992
|
-
request_cache_or_info :describe_snapshots, link, QEc2DescribeSnapshotsParser, list.blank?
|
1115
|
+
request_cache_or_info :describe_snapshots, link, QEc2DescribeSnapshotsParser, @@bench, list.blank?
|
993
1116
|
rescue Exception
|
994
1117
|
on_exception
|
995
1118
|
end
|
@@ -1255,6 +1378,7 @@ module RightAws
|
|
1255
1378
|
when 'launchTime' then @instance[:aws_launch_time] = @text
|
1256
1379
|
when 'kernelId' then @instance[:aws_kernel_id] = @text
|
1257
1380
|
when 'ramdiskId' then @instance[:aws_ramdisk_id] = @text
|
1381
|
+
when 'platform' then @instance[:aws_platform] = @text
|
1258
1382
|
when 'availabilityZone' then @instance[:aws_availability_zone] = @text
|
1259
1383
|
when 'item'
|
1260
1384
|
if @xmlpath == 'DescribeInstancesResponse/reservationSet/item/instancesSet' || # DescribeInstances property
|
@@ -1319,18 +1443,54 @@ module RightAws
|
|
1319
1443
|
end
|
1320
1444
|
|
1321
1445
|
#-----------------------------------------------------------------
|
1322
|
-
#
|
1446
|
+
# Instances: Wondows related part
|
1323
1447
|
#-----------------------------------------------------------------
|
1324
|
-
|
1325
|
-
|
1326
|
-
|
1327
|
-
|
1328
|
-
|
1329
|
-
|
1330
|
-
|
1448
|
+
class QEc2DescribeBundleTasksParser < RightAWSParser #:nodoc:
|
1449
|
+
def tagstart(name, attributes)
|
1450
|
+
@bundle = {} if name == 'item'
|
1451
|
+
end
|
1452
|
+
def tagend(name)
|
1453
|
+
case name
|
1454
|
+
# when 'requestId' then @bundle[:request_id] = @text
|
1455
|
+
when 'instanceId' then @bundle[:aws_instance_id] = @text
|
1456
|
+
when 'bundleId' then @bundle[:aws_id] = @text
|
1457
|
+
when 'bucket' then @bundle[:s3_bucket] = @text
|
1458
|
+
when 'prefix' then @bundle[:s3_prefix] = @text
|
1459
|
+
when 'startTime' then @bundle[:aws_start_time] = @text
|
1460
|
+
when 'updateTime' then @bundle[:aws_update_time] = @text
|
1461
|
+
when 'state' then @bundle[:aws_state] = @text
|
1462
|
+
when 'progress' then @bundle[:aws_progress] = @text
|
1463
|
+
when 'code' then @bundle[:aws_error_code] = @text
|
1464
|
+
when 'message' then @bundle[:aws_error_message] = @text
|
1465
|
+
when 'item' then @result << @bundle
|
1466
|
+
end
|
1467
|
+
end
|
1468
|
+
def reset
|
1469
|
+
@result = []
|
1331
1470
|
end
|
1332
1471
|
end
|
1333
|
-
|
1472
|
+
|
1473
|
+
class QEc2BundleInstanceParser < RightAWSParser #:nodoc:
|
1474
|
+
def tagend(name)
|
1475
|
+
case name
|
1476
|
+
# when 'requestId' then @result[:request_id] = @text
|
1477
|
+
when 'instanceId' then @result[:aws_instance_id] = @text
|
1478
|
+
when 'bundleId' then @result[:aws_id] = @text
|
1479
|
+
when 'bucket' then @result[:s3_bucket] = @text
|
1480
|
+
when 'prefix' then @result[:s3_prefix] = @text
|
1481
|
+
when 'startTime' then @result[:aws_start_time] = @text
|
1482
|
+
when 'updateTime' then @result[:aws_update_time] = @text
|
1483
|
+
when 'state' then @result[:aws_state] = @text
|
1484
|
+
when 'progress' then @result[:aws_progress] = @text
|
1485
|
+
when 'code' then @result[:aws_error_code] = @text
|
1486
|
+
when 'message' then @result[:aws_error_message] = @text
|
1487
|
+
end
|
1488
|
+
end
|
1489
|
+
def reset
|
1490
|
+
@result = {}
|
1491
|
+
end
|
1492
|
+
end
|
1493
|
+
|
1334
1494
|
#-----------------------------------------------------------------
|
1335
1495
|
# PARSERS: Elastic IPs
|
1336
1496
|
#-----------------------------------------------------------------
|