aws 2.1.0 → 2.1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -34,7 +34,7 @@ module Aws
34
34
  # Examples:
35
35
  #
36
36
  # Create an EC2 interface handle:
37
- #
37
+ #
38
38
  # @ec2 = Aws::Ec2.new(aws_access_key_id,
39
39
  # aws_secret_access_key)
40
40
  # Create a new SSH key pair:
@@ -56,33 +56,33 @@ module Aws
56
56
  #
57
57
  # Launch an instance:
58
58
  # ec2.run_instances('ami-9a9e7bf3', 1, 1, ['default'], @key, 'SomeImportantUserData', 'public')
59
- #
59
+ #
60
60
  #
61
61
  # Describe running instances:
62
62
  # @ec2.describe_instances
63
63
  #
64
64
  # Error handling: all operations raise an Aws::AwsError in case
65
65
  # of problems. Note that transient errors are automatically retried.
66
-
66
+
67
67
  class Ec2 < AwsBase
68
68
  include AwsBaseInterface
69
-
69
+
70
70
  # Amazon EC2 API version being used
71
- API_VERSION = "2008-12-01"
71
+ API_VERSION = "2009-08-15"
72
72
  DEFAULT_HOST = "ec2.amazonaws.com"
73
73
  DEFAULT_PATH = '/'
74
74
  DEFAULT_PROTOCOL = 'http'
75
75
  DEFAULT_PORT = 80
76
-
76
+
77
77
  # Default addressing type (public=NAT, direct=no-NAT) used when launching instances.
78
78
  DEFAULT_ADDRESSING_TYPE = 'public'
79
79
  DNS_ADDRESSING_SET = ['public','direct']
80
-
80
+
81
81
  # Amazon EC2 Instance Types : http://www.amazon.com/b?ie=UTF8&node=370375011
82
- # Default EC2 instance type (platform)
83
- DEFAULT_INSTANCE_TYPE = 'm1.small'
82
+ # Default EC2 instance type (platform)
83
+ DEFAULT_INSTANCE_TYPE = 'm1.small'
84
84
  INSTANCE_TYPES = ['m1.small','c1.medium','m1.large','m1.xlarge','c1.xlarge']
85
-
85
+
86
86
  @@bench = AwsBenchmarkingBlock.new
87
87
  def self.bench_xml
88
88
  @@bench.xml
@@ -90,13 +90,13 @@ module Aws
90
90
  def self.bench_ec2
91
91
  @@bench.service
92
92
  end
93
-
93
+
94
94
  # Current API version (sometimes we have to check it outside the GEM).
95
95
  @@api = ENV['EC2_API_VERSION'] || API_VERSION
96
- def self.api
96
+ def self.api
97
97
  @@api
98
98
  end
99
-
99
+
100
100
  # Create a new handle to an EC2 account. All handles share the same per process or per thread
101
101
  # HTTP connection to Amazon EC2. Each handle is for a specific account. The params have the
102
102
  # following options:
@@ -110,16 +110,16 @@ module Aws
110
110
  # * <tt>:signature_version</tt>: The signature version : '0' or '1'(default)
111
111
  # * <tt>:cache</tt>: true/false: caching for: ec2_describe_images, describe_instances,
112
112
  # describe_images_by_owner, describe_images_by_executable_by, describe_availability_zones,
113
- # describe_security_groups, describe_key_pairs, describe_addresses,
113
+ # describe_security_groups, describe_key_pairs, describe_addresses,
114
114
  # describe_volumes, describe_snapshots methods, default: false.
115
115
  #
116
116
  def initialize(aws_access_key_id=nil, aws_secret_access_key=nil, params={})
117
- init({ :name => 'EC2',
118
- :default_host => ENV['EC2_URL'] ? URI.parse(ENV['EC2_URL']).host : DEFAULT_HOST,
117
+ init({ :name => 'EC2',
118
+ :default_host => ENV['EC2_URL'] ? URI.parse(ENV['EC2_URL']).host : DEFAULT_HOST,
119
119
  :default_port => ENV['EC2_URL'] ? URI.parse(ENV['EC2_URL']).port : DEFAULT_PORT,
120
- :default_service => ENV['EC2_URL'] ? URI.parse(ENV['EC2_URL']).path : DEFAULT_PATH,
121
- :default_protocol => ENV['EC2_URL'] ? URI.parse(ENV['EC2_URL']).scheme : DEFAULT_PROTOCOL },
122
- aws_access_key_id || ENV['AWS_ACCESS_KEY_ID'] ,
120
+ :default_service => ENV['EC2_URL'] ? URI.parse(ENV['EC2_URL']).path : DEFAULT_PATH,
121
+ :default_protocol => ENV['EC2_URL'] ? URI.parse(ENV['EC2_URL']).scheme : DEFAULT_PROTOCOL },
122
+ aws_access_key_id || ENV['AWS_ACCESS_KEY_ID'] ,
123
123
  aws_secret_access_key|| ENV['AWS_SECRET_ACCESS_KEY'],
124
124
  params)
125
125
  # EC2 doesn't really define any transient errors to retry, and in fact,
@@ -137,7 +137,7 @@ module Aws
137
137
  "Version" => @@api }
138
138
  service_hash.update(params)
139
139
  service_params = signed_service_params(@aws_secret_access_key, service_hash, :get, @params[:server], @params[:service])
140
-
140
+
141
141
  # use POST method if the length of the query string is too large
142
142
  if service_params.size > 2000
143
143
  if signature_version == '2'
@@ -151,7 +151,7 @@ module Aws
151
151
  request = Net::HTTP::Get.new("#{@params[:service]}?#{service_params}")
152
152
  end
153
153
  # prepare output hash
154
- { :request => request,
154
+ { :request => request,
155
155
  :server => @params[:server],
156
156
  :port => @params[:port],
157
157
  :protocol => @params[:protocol] }
@@ -175,11 +175,11 @@ module Aws
175
175
  # Images
176
176
  #-----------------------------------------------------------------
177
177
 
178
- # params:
178
+ # params:
179
179
  # { 'ImageId' => ['id1', ..., 'idN'],
180
180
  # 'Owner' => ['self', ..., 'userN'],
181
181
  # 'ExecutableBy' => ['self', 'all', ..., 'userN']
182
- # }
182
+ # }
183
183
  def ec2_describe_images(params={}, image_type=nil, cache_for=nil) #:nodoc:
184
184
  request_hash = {}
185
185
  params.each do |list_by, list|
@@ -193,8 +193,8 @@ module Aws
193
193
  end
194
194
 
195
195
  # Retrieve a list of images. Returns array of hashes describing the images or an exception:
196
- # +image_type+ = 'machine' || 'kernel' || 'ramdisk'
197
- #
196
+ # +image_type+ = 'machine' || 'kernel' || 'ramdisk'
197
+ #
198
198
  # ec2.describe_images #=>
199
199
  # [{:aws_owner => "522821470517",
200
200
  # :aws_id => "ami-e4b6538d",
@@ -249,25 +249,25 @@ module Aws
249
249
  end
250
250
 
251
251
 
252
- # Register new image at Amazon.
252
+ # Register new image at Amazon.
253
253
  # Returns new image id or an exception.
254
254
  #
255
255
  # ec2.register_image('bucket/key/manifest') #=> 'ami-e444444d'
256
256
  #
257
257
  def register_image(image_location)
258
- link = generate_request("RegisterImage",
258
+ link = generate_request("RegisterImage",
259
259
  'ImageLocation' => image_location.to_s)
260
260
  request_info(link, QEc2RegisterImageParser.new(:logger => @logger))
261
261
  rescue Exception
262
262
  on_exception
263
263
  end
264
-
264
+
265
265
  # Deregister image at Amazon. Returns +true+ or an exception.
266
266
  #
267
267
  # ec2.deregister_image('ami-e444444d') #=> true
268
268
  #
269
269
  def deregister_image(image_id)
270
- link = generate_request("DeregisterImage",
270
+ link = generate_request("DeregisterImage",
271
271
  'ImageId' => image_id.to_s)
272
272
  request_info(link, RightBoolResponseParser.new(:logger => @logger))
273
273
  rescue Exception
@@ -280,20 +280,20 @@ module Aws
280
280
  # ec2.describe_image_attribute('ami-e444444d') #=> {:groups=>["all"], :users=>["000000000777"]}
281
281
  #
282
282
  def describe_image_attribute(image_id, attribute='launchPermission')
283
- link = generate_request("DescribeImageAttribute",
283
+ link = generate_request("DescribeImageAttribute",
284
284
  'ImageId' => image_id,
285
285
  'Attribute' => attribute)
286
286
  request_info(link, QEc2DescribeImageAttributeParser.new(:logger => @logger))
287
287
  rescue Exception
288
288
  on_exception
289
289
  end
290
-
290
+
291
291
  # Reset image attribute. Currently, only 'launchPermission' is supported. Returns +true+ or an exception.
292
292
  #
293
293
  # ec2.reset_image_attribute('ami-e444444d') #=> true
294
294
  #
295
295
  def reset_image_attribute(image_id, attribute='launchPermission')
296
- link = generate_request("ResetImageAttribute",
296
+ link = generate_request("ResetImageAttribute",
297
297
  'ImageId' => image_id,
298
298
  'Attribute' => attribute)
299
299
  request_info(link, RightBoolResponseParser.new(:logger => @logger))
@@ -303,13 +303,13 @@ module Aws
303
303
 
304
304
  # Modify an image's attributes. It is recommended that you use
305
305
  # modify_image_launch_perm_add_users, modify_image_launch_perm_remove_users, etc.
306
- # instead of modify_image_attribute because the signature of
306
+ # instead of modify_image_attribute because the signature of
307
307
  # modify_image_attribute may change with EC2 service changes.
308
308
  #
309
309
  # attribute : currently, only 'launchPermission' is supported.
310
310
  # operation_type : currently, only 'add' & 'remove' are supported.
311
- # vars:
312
- # :user_group : currently, only 'all' is supported.
311
+ # vars:
312
+ # :user_group : currently, only 'all' is supported.
313
313
  # :user_id
314
314
  # :product_code
315
315
  def modify_image_attribute(image_id, attribute, operation_type = nil, vars = {})
@@ -342,7 +342,7 @@ module Aws
342
342
  modify_image_attribute(image_id, 'launchPermission', 'remove', :user_id => user_id.to_a)
343
343
  end
344
344
 
345
- # Add image launch permissions for users groups (currently only 'all' is supported, which gives public launch permissions).
345
+ # Add image launch permissions for users groups (currently only 'all' is supported, which gives public launch permissions).
346
346
  # Returns +true+ or an exception.
347
347
  #
348
348
  # ec2.modify_image_launch_perm_add_groups('ami-e444444d') #=> true
@@ -350,15 +350,15 @@ module Aws
350
350
  def modify_image_launch_perm_add_groups(image_id, user_group=['all'])
351
351
  modify_image_attribute(image_id, 'launchPermission', 'add', :user_group => user_group.to_a)
352
352
  end
353
-
354
- # Remove image launch permissions for users groups (currently only 'all' is supported, which gives public launch permissions).
353
+
354
+ # Remove image launch permissions for users groups (currently only 'all' is supported, which gives public launch permissions).
355
355
  #
356
356
  # ec2.modify_image_launch_perm_remove_groups('ami-e444444d') #=> true
357
357
  #
358
358
  def modify_image_launch_perm_remove_groups(image_id, user_group=['all'])
359
359
  modify_image_attribute(image_id, 'launchPermission', 'remove', :user_group => user_group.to_a)
360
360
  end
361
-
361
+
362
362
  # Add product code to image
363
363
  #
364
364
  # ec2.modify_image_product_code('ami-e444444d','0ABCDEF') #=> true
@@ -370,7 +370,7 @@ module Aws
370
370
  #-----------------------------------------------------------------
371
371
  # Instances
372
372
  #-----------------------------------------------------------------
373
-
373
+
374
374
  def get_desc_instances(instances) # :nodoc:
375
375
  result = []
376
376
  instances.each do |reservation|
@@ -388,11 +388,11 @@ module Aws
388
388
  rescue Exception
389
389
  on_exception
390
390
  end
391
-
391
+
392
392
  # Retrieve information about EC2 instances. If +list+ is omitted then returns the
393
393
  # list of all instances.
394
394
  #
395
- # ec2.describe_instances #=>
395
+ # ec2.describe_instances #=>
396
396
  # [{:aws_image_id => "ami-e444444d",
397
397
  # :aws_reason => "",
398
398
  # :aws_state_code => "16",
@@ -409,6 +409,7 @@ module Aws
409
409
  # :aws_availability_zone => "us-east-1b",
410
410
  # :aws_kernel_id => "aki-ba3adfd3",
411
411
  # :aws_ramdisk_id => "ari-badbad00",
412
+ # :monitoring_state => ...,
412
413
  # ..., {...}]
413
414
  #
414
415
  def describe_instances(list=[])
@@ -419,7 +420,7 @@ module Aws
419
420
  rescue Exception
420
421
  on_exception
421
422
  end
422
-
423
+
423
424
  # Return the product code attached to instance or +nil+ otherwise.
424
425
  #
425
426
  # ec2.confirm_product_instance('ami-e444444d','12345678') #=> nil
@@ -430,7 +431,7 @@ module Aws
430
431
  'InstanceId' => instance })
431
432
  request_info(link, QEc2ConfirmProductInstanceParser.new(:logger => @logger))
432
433
  end
433
-
434
+
434
435
  # Launch new EC2 instances. Returns a list of launched instances or an exception.
435
436
  #
436
437
  # ec2.run_instances('ami-e444444d',1,1,['my_awesome_group'],'my_awesome_key', 'Woohoo!!!', 'public') #=>
@@ -453,82 +454,84 @@ module Aws
453
454
  # :aws_availability_zone => "us-east-1b"
454
455
  # }]
455
456
  #
456
- def run_instances(image_id, min_count, max_count, group_ids, key_name, user_data='',
457
+ def run_instances(image_id, min_count, max_count, group_ids, key_name, user_data='',
457
458
  addressing_type = nil, instance_type = nil,
458
- kernel_id = nil, ramdisk_id = nil, availability_zone = nil,
459
- block_device_mappings = nil)
460
- launch_instances(image_id, { :min_count => min_count,
461
- :max_count => max_count,
462
- :user_data => user_data,
463
- :group_ids => group_ids,
464
- :key_name => key_name,
465
- :instance_type => instance_type,
459
+ kernel_id = nil, ramdisk_id = nil, availability_zone = nil,
460
+ block_device_mappings = nil)
461
+ launch_instances(image_id, { :min_count => min_count,
462
+ :max_count => max_count,
463
+ :user_data => user_data,
464
+ :group_ids => group_ids,
465
+ :key_name => key_name,
466
+ :instance_type => instance_type,
466
467
  :addressing_type => addressing_type,
467
468
  :kernel_id => kernel_id,
468
469
  :ramdisk_id => ramdisk_id,
469
470
  :availability_zone => availability_zone,
470
471
  :block_device_mappings => block_device_mappings
471
- })
472
+ })
472
473
  end
473
-
474
-
475
- # Launch new EC2 instances. Returns a list of launched instances or an exception.
474
+
475
+
476
+ # Launch new EC2 instances. Returns a list of launched instances or an exception.
476
477
  #
477
478
  # +lparams+ keys (default values in parenthesis):
478
479
  # :min_count fixnum, (1)
479
480
  # :max_count fixnum, (1)
480
481
  # :group_ids array or string ([] == 'default')
481
482
  # :instance_type string (DEFAULT_INSTACE_TYPE)
482
- # :addressing_type string (DEFAULT_ADDRESSING_TYPE
483
+ # :addressing_type string (DEFAULT_ADDRESSING_TYPE
483
484
  # :key_name string
484
485
  # :kernel_id string
485
- # :ramdisk_id string
486
+ # :ramdisk_id string
486
487
  # :availability_zone string
487
488
  # :block_device_mappings string
488
489
  # :user_data string
489
- #
490
- # ec2.launch_instances('ami-e444444d', :group_ids => 'my_awesome_group',
491
- # :user_data => "Woohoo!!!",
492
- # :addressing_type => "public",
493
- # :key_name => "my_awesome_key",
494
- # :availability_zone => "us-east-1c") #=>
495
- # [{:aws_image_id => "ami-e444444d",
496
- # :aws_reason => "",
497
- # :aws_state_code => "0",
498
- # :aws_owner => "000000000888",
499
- # :aws_instance_id => "i-123f1234",
500
- # :aws_reservation_id => "r-aabbccdd",
501
- # :aws_state => "pending",
502
- # :dns_name => "",
503
- # :ssh_key_name => "my_awesome_key",
504
- # :aws_groups => ["my_awesome_group"],
505
- # :private_dns_name => "",
490
+ # :monitoring_enabled boolean (default=false)
491
+ #
492
+ # ec2.launch_instances('ami-e444444d', :group_ids => 'my_awesome_group',
493
+ # :user_data => "Woohoo!!!",
494
+ # :addressing_type => "public",
495
+ # :key_name => "my_awesome_key",
496
+ # :availability_zone => "us-east-1c") #=>
497
+ # [{:aws_image_id => "ami-e444444d",
498
+ # :aws_reason => "",
499
+ # :aws_state_code => "0",
500
+ # :aws_owner => "000000000888",
501
+ # :aws_instance_id => "i-123f1234",
502
+ # :aws_reservation_id => "r-aabbccdd",
503
+ # :aws_state => "pending",
504
+ # :dns_name => "",
505
+ # :ssh_key_name => "my_awesome_key",
506
+ # :aws_groups => ["my_awesome_group"],
507
+ # :private_dns_name => "",
506
508
  # :aws_instance_type => "m1.small",
507
509
  # :aws_launch_time => "2008-1-1T00:00:00.000Z",
508
510
  # :aws_ramdisk_id => "ari-8605e0ef"
509
511
  # :aws_kernel_id => "aki-9905e0f0",
510
512
  # :ami_launch_index => "0",
511
513
  # :aws_availability_zone => "us-east-1c"
512
- # }]
513
- #
514
- def launch_instances(image_id, lparams={})
515
- @logger.info("Launching instance of image #{image_id} for #{@aws_access_key_id}, " +
514
+ # }]
515
+ #
516
+ def launch_instances(image_id, lparams={})
517
+ @logger.info("Launching instance of image #{image_id} for #{@aws_access_key_id}, " +
516
518
  "key: #{lparams[:key_name]}, groups: #{(lparams[:group_ids]).to_a.join(',')}")
517
519
  # careful: keyName and securityGroups may be nil
518
520
  params = hash_params('SecurityGroup', lparams[:group_ids].to_a)
519
521
  params.update( {'ImageId' => image_id,
520
- 'MinCount' => (lparams[:min_count] || 1).to_s,
521
- 'MaxCount' => (lparams[:max_count] || 1).to_s,
522
- 'AddressingType' => lparams[:addressing_type] || DEFAULT_ADDRESSING_TYPE,
522
+ 'MinCount' => (lparams[:min_count] || 1).to_s,
523
+ 'MaxCount' => (lparams[:max_count] || 1).to_s,
524
+ 'AddressingType' => lparams[:addressing_type] || DEFAULT_ADDRESSING_TYPE,
523
525
  'InstanceType' => lparams[:instance_type] || DEFAULT_INSTANCE_TYPE })
524
526
  # optional params
525
- params['KeyName'] = lparams[:key_name] unless lparams[:key_name].blank?
526
- params['KernelId'] = lparams[:kernel_id] unless lparams[:kernel_id].blank?
527
- params['RamdiskId'] = lparams[:ramdisk_id] unless lparams[:ramdisk_id].blank?
528
- params['Placement.AvailabilityZone'] = lparams[:availability_zone] unless lparams[:availability_zone].blank?
527
+ params['KeyName'] = lparams[:key_name] unless lparams[:key_name].blank?
528
+ params['KernelId'] = lparams[:kernel_id] unless lparams[:kernel_id].blank?
529
+ params['RamdiskId'] = lparams[:ramdisk_id] unless lparams[:ramdisk_id].blank?
530
+ params['Placement.AvailabilityZone'] = lparams[:availability_zone] unless lparams[:availability_zone].blank?
529
531
  params['BlockDeviceMappings'] = lparams[:block_device_mappings] unless lparams[:block_device_mappings].blank?
530
- unless lparams[:user_data].blank?
531
- lparams[:user_data].strip!
532
+ params['Monitoring.Enabled'] = lparams[:monitoring_enabled] unless lparams[:monitoring_enabled].blank?
533
+ unless lparams[:user_data].blank?
534
+ lparams[:user_data].strip!
532
535
  # Do not use CGI::escape(encode64(...)) as it is done in Amazons EC2 library.
533
536
  # Amazon 169.254.169.254 does not like escaped symbols!
534
537
  # And it doesn't like "\n" inside of encoded string! Grrr....
@@ -542,19 +545,26 @@ module Aws
542
545
  rescue Exception
543
546
  on_exception
544
547
  end
545
-
548
+
549
+ def monitor_instances(list=[])
550
+ link = generate_request("MonitorInstances", hash_params('InstanceId',list.to_a))
551
+ request_info(link, QEc2TerminateInstancesParser.new(:logger => @logger))
552
+ rescue Exception
553
+ on_exception
554
+ end
555
+
546
556
  # Terminates EC2 instances. Returns a list of termination params or an exception.
547
557
  #
548
558
  # ec2.terminate_instances(['i-f222222d','i-f222222e']) #=>
549
- # [{:aws_shutdown_state => "shutting-down",
550
- # :aws_instance_id => "i-f222222d",
551
- # :aws_shutdown_state_code => 32,
552
- # :aws_prev_state => "running",
553
- # :aws_prev_state_code => 16},
554
- # {:aws_shutdown_state => "shutting-down",
555
- # :aws_instance_id => "i-f222222e",
556
- # :aws_shutdown_state_code => 32,
557
- # :aws_prev_state => "running",
559
+ # [{:aws_shutdown_state => "shutting-down",
560
+ # :aws_instance_id => "i-f222222d",
561
+ # :aws_shutdown_state_code => 32,
562
+ # :aws_prev_state => "running",
563
+ # :aws_prev_state_code => 16},
564
+ # {:aws_shutdown_state => "shutting-down",
565
+ # :aws_instance_id => "i-f222222e",
566
+ # :aws_shutdown_state_code => 32,
567
+ # :aws_prev_state => "running",
558
568
  # :aws_prev_state_code => 16}]
559
569
  #
560
570
  def terminate_instances(list=[])
@@ -592,7 +602,7 @@ module Aws
592
602
  #-----------------------------------------------------------------
593
603
  # Instances: Windows addons
594
604
  #-----------------------------------------------------------------
595
-
605
+
596
606
  # Get initial Windows Server setup password from an instance console output.
597
607
  #
598
608
  # my_awesome_key = ec2.create_key_pair('my_awesome_key') #=>
@@ -638,7 +648,7 @@ module Aws
638
648
  # :aws_instance_id => "i-878a25ee",
639
649
  # :aws_start_time => "2008-10-16T13:58:02.000Z"}]
640
650
  #
641
- def bundle_instance(instance_id, s3_bucket, s3_prefix,
651
+ def bundle_instance(instance_id, s3_bucket, s3_prefix,
642
652
  s3_owner_aws_access_key_id=nil, s3_owner_aws_secret_access_key=nil,
643
653
  s3_expires = S3Interface::DEFAULT_EXPIRES_AFTER,
644
654
  s3_upload_policy='ec2-bundle-read')
@@ -666,7 +676,7 @@ module Aws
666
676
  rescue Exception
667
677
  on_exception
668
678
  end
669
-
679
+
670
680
  # Describe the status of the Windows AMI bundlings.
671
681
  # If +list+ is omitted the returns the whole list of tasks.
672
682
  #
@@ -731,7 +741,7 @@ module Aws
731
741
  def describe_security_groups(list=[])
732
742
  link = generate_request("DescribeSecurityGroups", hash_params('GroupName',list.to_a))
733
743
  request_cache_or_info( :describe_security_groups, link, QEc2DescribeSecurityGroupsParser, @@bench, list.blank?) do |parser|
734
- result = []
744
+ result = []
735
745
  parser.result.each do |item|
736
746
  perms = []
737
747
  item.ipPermissions.each do |perm|
@@ -740,8 +750,8 @@ module Aws
740
750
  :owner => ngroup.userId}
741
751
  end
742
752
  perm.ipRanges.each do |cidr_ip|
743
- perms << {:from_port => perm.fromPort,
744
- :to_port => perm.toPort,
753
+ perms << {:from_port => perm.fromPort,
754
+ :to_port => perm.toPort,
745
755
  :protocol => perm.ipProtocol,
746
756
  :cidr_ips => cidr_ip}
747
757
  end
@@ -755,18 +765,18 @@ module Aws
755
765
  end
756
766
  perms.compact!
757
767
 
758
- result << {:aws_owner => item.ownerId,
759
- :aws_group_name => item.groupName,
768
+ result << {:aws_owner => item.ownerId,
769
+ :aws_group_name => item.groupName,
760
770
  :aws_description => item.groupDescription,
761
771
  :aws_perms => perms}
762
-
772
+
763
773
  end
764
774
  result
765
775
  end
766
776
  rescue Exception
767
777
  on_exception
768
778
  end
769
-
779
+
770
780
  # Create new Security Group. Returns +true+ or an exception.
771
781
  #
772
782
  # ec2.create_security_group('default-1',"Default allowing SSH, HTTP, and HTTPS ingress") #=> true
@@ -774,7 +784,7 @@ module Aws
774
784
  def create_security_group(name, description)
775
785
  # EC2 doesn't like an empty description...
776
786
  description = " " if description.blank?
777
- link = generate_request("CreateSecurityGroup",
787
+ link = generate_request("CreateSecurityGroup",
778
788
  'GroupName' => name.to_s,
779
789
  'GroupDescription' => description.to_s)
780
790
  request_info(link, RightBoolResponseParser.new(:logger => @logger))
@@ -787,20 +797,20 @@ module Aws
787
797
  # ec2.delete_security_group('default-1') #=> true
788
798
  #
789
799
  def delete_security_group(name)
790
- link = generate_request("DeleteSecurityGroup",
800
+ link = generate_request("DeleteSecurityGroup",
791
801
  'GroupName' => name.to_s)
792
802
  request_info(link, RightBoolResponseParser.new(:logger => @logger))
793
803
  rescue Exception
794
804
  on_exception
795
805
  end
796
-
806
+
797
807
  # Authorize named ingress for security group. Allows instances that are member of someone
798
808
  # else's security group to open connections to instances in my group.
799
809
  #
800
810
  # ec2.authorize_security_group_named_ingress('my_awesome_group', '7011-0219-8268', 'their_group_name') #=> true
801
811
  #
802
812
  def authorize_security_group_named_ingress(name, owner, group)
803
- link = generate_request("AuthorizeSecurityGroupIngress",
813
+ link = generate_request("AuthorizeSecurityGroupIngress",
804
814
  'GroupName' => name.to_s,
805
815
  'SourceSecurityGroupName' => group.to_s,
806
816
  'SourceSecurityGroupOwnerId' => owner.to_s.gsub(/-/,''))
@@ -808,13 +818,13 @@ module Aws
808
818
  rescue Exception
809
819
  on_exception
810
820
  end
811
-
821
+
812
822
  # Revoke named ingress for security group.
813
823
  #
814
824
  # ec2.revoke_security_group_named_ingress('my_awesome_group', aws_user_id, 'another_group_name') #=> true
815
825
  #
816
826
  def revoke_security_group_named_ingress(name, owner, group)
817
- link = generate_request("RevokeSecurityGroupIngress",
827
+ link = generate_request("RevokeSecurityGroupIngress",
818
828
  'GroupName' => name.to_s,
819
829
  'SourceSecurityGroupName' => group.to_s,
820
830
  'SourceSecurityGroupOwnerId' => owner.to_s.gsub(/-/,''))
@@ -822,14 +832,14 @@ module Aws
822
832
  rescue Exception
823
833
  on_exception
824
834
  end
825
-
835
+
826
836
  # Add permission to a security group. Returns +true+ or an exception. +protocol+ is one of :'tcp'|'udp'|'icmp'.
827
837
  #
828
838
  # ec2.authorize_security_group_IP_ingress('my_awesome_group', 80, 82, 'udp', '192.168.1.0/8') #=> true
829
839
  # ec2.authorize_security_group_IP_ingress('my_awesome_group', -1, -1, 'icmp') #=> true
830
840
  #
831
841
  def authorize_security_group_IP_ingress(name, from_port, to_port, protocol='tcp', cidr_ip='0.0.0.0/0')
832
- link = generate_request("AuthorizeSecurityGroupIngress",
842
+ link = generate_request("AuthorizeSecurityGroupIngress",
833
843
  'GroupName' => name.to_s,
834
844
  'IpProtocol' => protocol.to_s,
835
845
  'FromPort' => from_port.to_s,
@@ -839,13 +849,13 @@ module Aws
839
849
  rescue Exception
840
850
  on_exception
841
851
  end
842
-
843
- # Remove permission from a security group. Returns +true+ or an exception. +protocol+ is one of :'tcp'|'udp'|'icmp' ('tcp' is default).
852
+
853
+ # Remove permission from a security group. Returns +true+ or an exception. +protocol+ is one of :'tcp'|'udp'|'icmp' ('tcp' is default).
844
854
  #
845
855
  # ec2.revoke_security_group_IP_ingress('my_awesome_group', 80, 82, 'udp', '192.168.1.0/8') #=> true
846
856
  #
847
857
  def revoke_security_group_IP_ingress(name, from_port, to_port, protocol='tcp', cidr_ip='0.0.0.0/0')
848
- link = generate_request("RevokeSecurityGroupIngress",
858
+ link = generate_request("RevokeSecurityGroupIngress",
849
859
  'GroupName' => name.to_s,
850
860
  'IpProtocol' => protocol.to_s,
851
861
  'FromPort' => from_port.to_s,
@@ -859,7 +869,7 @@ module Aws
859
869
  #-----------------------------------------------------------------
860
870
  # Keys
861
871
  #-----------------------------------------------------------------
862
-
872
+
863
873
  # Retrieve a list of SSH keys. Returns an array of keys or an exception. Each key is
864
874
  # represented as a two-element hash.
865
875
  #
@@ -874,7 +884,7 @@ module Aws
874
884
  rescue Exception
875
885
  on_exception
876
886
  end
877
-
887
+
878
888
  # Create new SSH key. Returns a hash of the key's data or an exception.
879
889
  #
880
890
  # ec2.create_key_pair('my_awesome_key') #=>
@@ -883,7 +893,7 @@ module Aws
883
893
  # :aws_material => "-----BEGIN RSA PRIVATE KEY-----\nMIIEpQIBAAK...Q8MDrCbuQ=\n-----END RSA PRIVATE KEY-----"}
884
894
  #
885
895
  def create_key_pair(name)
886
- link = generate_request("CreateKeyPair",
896
+ link = generate_request("CreateKeyPair",
887
897
  'KeyName' => name.to_s)
888
898
  request_info(link, QEc2CreateKeyPairParser.new(:logger => @logger))
889
899
  rescue Exception
@@ -895,13 +905,13 @@ module Aws
895
905
  # ec2.delete_key_pair('my_awesome_key') #=> true
896
906
  #
897
907
  def delete_key_pair(name)
898
- link = generate_request("DeleteKeyPair",
908
+ link = generate_request("DeleteKeyPair",
899
909
  'KeyName' => name.to_s)
900
910
  request_info(link, RightBoolResponseParser.new(:logger => @logger))
901
911
  rescue Exception
902
912
  on_exception
903
913
  end
904
-
914
+
905
915
  #-----------------------------------------------------------------
906
916
  # Elastic IPs
907
917
  #-----------------------------------------------------------------
@@ -924,7 +934,7 @@ module Aws
924
934
  # ec2.associate_address('i-d630cbbf', '75.101.154.140') #=> true
925
935
  #
926
936
  def associate_address(instance_id, public_ip)
927
- link = generate_request("AssociateAddress",
937
+ link = generate_request("AssociateAddress",
928
938
  "InstanceId" => instance_id.to_s,
929
939
  "PublicIp" => public_ip.to_s)
930
940
  request_info(link, RightBoolResponseParser.new(:logger => @logger))
@@ -941,7 +951,7 @@ module Aws
941
951
  # ec2.describe_addresses('75.101.154.140') #=> [{:instance_id=>"i-d630cbbf", :public_ip=>"75.101.154.140"}]
942
952
  #
943
953
  def describe_addresses(list=[])
944
- link = generate_request("DescribeAddresses",
954
+ link = generate_request("DescribeAddresses",
945
955
  hash_params('PublicIp',list.to_a))
946
956
  request_cache_or_info :describe_addresses, link, QEc2DescribeAddressesParser, @@bench, list.blank?
947
957
  rescue Exception
@@ -950,11 +960,11 @@ module Aws
950
960
 
951
961
  # Disassociate the specified elastic IP address from the instance to which it is assigned.
952
962
  # Returns +true+ or an exception.
953
- #
963
+ #
954
964
  # ec2.disassociate_address('75.101.154.140') #=> true
955
965
  #
956
966
  def disassociate_address(public_ip)
957
- link = generate_request("DisassociateAddress",
967
+ link = generate_request("DisassociateAddress",
958
968
  "PublicIp" => public_ip.to_s)
959
969
  request_info(link, RightBoolResponseParser.new(:logger => @logger))
960
970
  rescue Exception
@@ -967,7 +977,7 @@ module Aws
967
977
  # ec2.release_address('75.101.154.140') #=> true
968
978
  #
969
979
  def release_address(public_ip)
970
- link = generate_request("ReleaseAddress",
980
+ link = generate_request("ReleaseAddress",
971
981
  "PublicIp" => public_ip.to_s)
972
982
  request_info(link, RightBoolResponseParser.new(:logger => @logger))
973
983
  rescue Exception
@@ -977,7 +987,7 @@ module Aws
977
987
  #-----------------------------------------------------------------
978
988
  # Availability zones
979
989
  #-----------------------------------------------------------------
980
-
990
+
981
991
  # Describes availability zones that are currently available to the account and their states.
982
992
  # Returns an array of 2 keys (:zone_name and :zone_state) hashes:
983
993
  #
@@ -985,12 +995,12 @@ module Aws
985
995
  # :zone_name=>"us-east-1a",
986
996
  # :zone_state=>"available"}, ... ]
987
997
  #
988
- # ec2.describe_availability_zones('us-east-1c') #=> [{:region_name=>"us-east-1",
998
+ # ec2.describe_availability_zones('us-east-1c') #=> [{:region_name=>"us-east-1",
989
999
  # :zone_state=>"available",
990
1000
  # :zone_name=>"us-east-1c"}]
991
1001
  #
992
1002
  def describe_availability_zones(list=[])
993
- link = generate_request("DescribeAvailabilityZones",
1003
+ link = generate_request("DescribeAvailabilityZones",
994
1004
  hash_params('ZoneName',list.to_a))
995
1005
  request_cache_or_info :describe_availability_zones, link, QEc2DescribeAvailabilityZonesParser, @@bench, list.blank?
996
1006
  rescue Exception
@@ -1017,10 +1027,10 @@ module Aws
1017
1027
  #-----------------------------------------------------------------
1018
1028
  # EBS: Volumes
1019
1029
  #-----------------------------------------------------------------
1020
-
1030
+
1021
1031
  # Describe all EBS volumes.
1022
1032
  #
1023
- # ec2.describe_volumes #=>
1033
+ # ec2.describe_volumes #=>
1024
1034
  # [{:aws_size => 94,
1025
1035
  # :aws_device => "/dev/sdc",
1026
1036
  # :aws_attachment_status => "attached",
@@ -1039,17 +1049,17 @@ module Aws
1039
1049
  # :aws_created_at => Wed Jun 18 08:19:21 UTC 2008,}, ... ]
1040
1050
  #
1041
1051
  def describe_volumes(list=[])
1042
- link = generate_request("DescribeVolumes",
1052
+ link = generate_request("DescribeVolumes",
1043
1053
  hash_params('VolumeId',list.to_a))
1044
1054
  request_cache_or_info :describe_volumes, link, QEc2DescribeVolumesParser, @@bench, list.blank?
1045
1055
  rescue Exception
1046
1056
  on_exception
1047
1057
  end
1048
-
1049
- # Create new EBS volume based on previously created snapshot.
1058
+
1059
+ # Create new EBS volume based on previously created snapshot.
1050
1060
  # +Size+ in Gigabytes.
1051
1061
  #
1052
- # ec2.create_volume('snap-000000', 10, zone) #=>
1062
+ # ec2.create_volume('snap-000000', 10, zone) #=>
1053
1063
  # {:snapshot_id => "snap-e21df98b",
1054
1064
  # :aws_status => "creating",
1055
1065
  # :aws_id => "vol-fc9f7a95",
@@ -1058,7 +1068,7 @@ module Aws
1058
1068
  # :aws_size => 94}
1059
1069
  #
1060
1070
  def create_volume(snapshot_id, size, zone)
1061
- link = generate_request("CreateVolume",
1071
+ link = generate_request("CreateVolume",
1062
1072
  "SnapshotId" => snapshot_id.to_s,
1063
1073
  "Size" => size.to_s,
1064
1074
  "AvailabilityZone" => zone.to_s )
@@ -1067,19 +1077,19 @@ module Aws
1067
1077
  on_exception
1068
1078
  end
1069
1079
 
1070
- # Delete the specified EBS volume.
1080
+ # Delete the specified EBS volume.
1071
1081
  # This does not deletes any snapshots created from this volume.
1072
1082
  #
1073
1083
  # ec2.delete_volume('vol-b48a6fdd') #=> true
1074
1084
  #
1075
1085
  def delete_volume(volume_id)
1076
- link = generate_request("DeleteVolume",
1086
+ link = generate_request("DeleteVolume",
1077
1087
  "VolumeId" => volume_id.to_s)
1078
1088
  request_info(link, RightBoolResponseParser.new(:logger => @logger))
1079
1089
  rescue Exception
1080
1090
  on_exception
1081
1091
  end
1082
-
1092
+
1083
1093
  # Attach the specified EBS volume to a specified instance, exposing the
1084
1094
  # volume using the specified device name.
1085
1095
  #
@@ -1091,7 +1101,7 @@ module Aws
1091
1101
  # :aws_id => "vol-898a6fe0" }
1092
1102
  #
1093
1103
  def attach_volume(volume_id, instance_id, device)
1094
- link = generate_request("AttachVolume",
1104
+ link = generate_request("AttachVolume",
1095
1105
  "VolumeId" => volume_id.to_s,
1096
1106
  "InstanceId" => instance_id.to_s,
1097
1107
  "Device" => device.to_s)
@@ -1099,10 +1109,10 @@ module Aws
1099
1109
  rescue Exception
1100
1110
  on_exception
1101
1111
  end
1102
-
1112
+
1103
1113
  # Detach the specified EBS volume from the instance to which it is attached.
1104
- #
1105
- # ec2.detach_volume('vol-898a6fe0') #=>
1114
+ #
1115
+ # ec2.detach_volume('vol-898a6fe0') #=>
1106
1116
  # { :aws_instance_id => "i-7c905415",
1107
1117
  # :aws_device => "/dev/sdh",
1108
1118
  # :aws_status => "detaching",
@@ -1121,14 +1131,14 @@ module Aws
1121
1131
  on_exception
1122
1132
  end
1123
1133
 
1124
-
1134
+
1125
1135
  #-----------------------------------------------------------------
1126
1136
  # EBS: Snapshots
1127
1137
  #-----------------------------------------------------------------
1128
1138
 
1129
1139
  # Describe all EBS snapshots.
1130
1140
  #
1131
- # ec2.describe_snapshots #=>
1141
+ # ec2.describe_snapshots #=>
1132
1142
  # [ { :aws_progress => "100%",
1133
1143
  # :aws_status => "completed",
1134
1144
  # :aws_id => "snap-72a5401b",
@@ -1141,7 +1151,7 @@ module Aws
1141
1151
  # :aws_started_at => "2008-02-23T16:23:19.000Z" },...]
1142
1152
  #
1143
1153
  def describe_snapshots(list=[])
1144
- link = generate_request("DescribeSnapshots",
1154
+ link = generate_request("DescribeSnapshots",
1145
1155
  hash_params('SnapshotId',list.to_a))
1146
1156
  request_cache_or_info :describe_snapshots, link, QEc2DescribeSnapshotsParser, @@bench, list.blank?
1147
1157
  rescue Exception
@@ -1150,7 +1160,7 @@ module Aws
1150
1160
 
1151
1161
  # Create a snapshot of specified volume.
1152
1162
  #
1153
- # ec2.create_snapshot('vol-898a6fe0') #=>
1163
+ # ec2.create_snapshot('vol-898a6fe0') #=>
1154
1164
  # {:aws_volume_id => "vol-fd9f7a94",
1155
1165
  # :aws_started_at => Tue Jun 24 18:40:40 UTC 2008,
1156
1166
  # :aws_progress => "",
@@ -1158,19 +1168,19 @@ module Aws
1158
1168
  # :aws_id => "snap-d56783bc"}
1159
1169
  #
1160
1170
  def create_snapshot(volume_id)
1161
- link = generate_request("CreateSnapshot",
1171
+ link = generate_request("CreateSnapshot",
1162
1172
  "VolumeId" => volume_id.to_s)
1163
1173
  request_info(link, QEc2CreateSnapshotParser.new(:logger => @logger))
1164
1174
  rescue Exception
1165
1175
  on_exception
1166
1176
  end
1167
-
1177
+
1168
1178
  # Create a snapshot of specified volume, but with the normal retry algorithms disabled.
1169
1179
  # This method will return immediately upon error. The user can specify connect and read timeouts (in s)
1170
1180
  # for the connection to AWS. If the user does not specify timeouts, try_create_snapshot uses the default values
1171
1181
  # in Rightscale::HttpConnection.
1172
1182
  #
1173
- # ec2.try_create_snapshot('vol-898a6fe0') #=>
1183
+ # ec2.try_create_snapshot('vol-898a6fe0') #=>
1174
1184
  # {:aws_volume_id => "vol-fd9f7a94",
1175
1185
  # :aws_started_at => Tue Jun 24 18:40:40 UTC 2008,
1176
1186
  # :aws_progress => "",
@@ -1178,25 +1188,25 @@ module Aws
1178
1188
  # :aws_id => "snap-d56783bc"}
1179
1189
  #
1180
1190
  def try_create_snapshot(volume_id, connect_timeout = nil, read_timeout = nil)
1181
- # For safety in the ensure block...we don't want to restore values
1191
+ # For safety in the ensure block...we don't want to restore values
1182
1192
  # if we never read them in the first place
1183
1193
  orig_reiteration_time = nil
1184
1194
  orig_http_params = nil
1185
-
1195
+
1186
1196
  orig_reiteration_time = Aws::AWSErrorHandler::reiteration_time
1187
1197
  Aws::AWSErrorHandler::reiteration_time = 0
1188
-
1198
+
1189
1199
  orig_http_params = Rightscale::HttpConnection::params()
1190
1200
  new_http_params = orig_http_params.dup
1191
1201
  new_http_params[:http_connection_retry_count] = 0
1192
1202
  new_http_params[:http_connection_open_timeout] = connect_timeout if !connect_timeout.nil?
1193
1203
  new_http_params[:http_connection_read_timeout] = read_timeout if !read_timeout.nil?
1194
1204
  Rightscale::HttpConnection::params = new_http_params
1195
-
1196
- link = generate_request("CreateSnapshot",
1205
+
1206
+ link = generate_request("CreateSnapshot",
1197
1207
  "VolumeId" => volume_id.to_s)
1198
1208
  request_info(link, QEc2CreateSnapshotParser.new(:logger => @logger))
1199
-
1209
+
1200
1210
  rescue Exception
1201
1211
  on_exception
1202
1212
  ensure
@@ -1209,17 +1219,17 @@ module Aws
1209
1219
  # ec2.delete_snapshot('snap-55a5403c') #=> true
1210
1220
  #
1211
1221
  def delete_snapshot(snapshot_id)
1212
- link = generate_request("DeleteSnapshot",
1222
+ link = generate_request("DeleteSnapshot",
1213
1223
  "SnapshotId" => snapshot_id.to_s)
1214
1224
  request_info(link, RightBoolResponseParser.new(:logger => @logger))
1215
1225
  rescue Exception
1216
1226
  on_exception
1217
1227
  end
1218
-
1228
+
1219
1229
  #-----------------------------------------------------------------
1220
1230
  # PARSERS: Boolean Response Parser
1221
1231
  #-----------------------------------------------------------------
1222
-
1232
+
1223
1233
  class RightBoolResponseParser < AwsParser #:nodoc:
1224
1234
  def tagend(name)
1225
1235
  @result = @text=='true' ? true : false if name == 'return'
@@ -1235,14 +1245,14 @@ module Aws
1235
1245
  @item = {} if name == 'item'
1236
1246
  end
1237
1247
  def tagend(name)
1238
- case name
1248
+ case name
1239
1249
  when 'keyName' then @item[:aws_key_name] = @text
1240
1250
  when 'keyFingerprint' then @item[:aws_fingerprint] = @text
1241
1251
  when 'item' then @result << @item
1242
1252
  end
1243
1253
  end
1244
1254
  def reset
1245
- @result = [];
1255
+ @result = [];
1246
1256
  end
1247
1257
  end
1248
1258
 
@@ -1251,7 +1261,7 @@ module Aws
1251
1261
  @result = {} if name == 'CreateKeyPairResponse'
1252
1262
  end
1253
1263
  def tagend(name)
1254
- case name
1264
+ case name
1255
1265
  when 'keyName' then @result[:aws_key_name] = @text
1256
1266
  when 'keyFingerprint' then @result[:aws_fingerprint] = @text
1257
1267
  when 'keyMaterial' then @result[:aws_material] = @text
@@ -1287,9 +1297,9 @@ module Aws
1287
1297
  class QEc2DescribeSecurityGroupsParser < AwsParser #:nodoc:
1288
1298
  def tagstart(name, attributes)
1289
1299
  case name
1290
- when 'item'
1300
+ when 'item'
1291
1301
  if @xmlpath=='DescribeSecurityGroupsResponse/securityGroupInfo'
1292
- @group = QEc2SecurityGroupItemType.new
1302
+ @group = QEc2SecurityGroupItemType.new
1293
1303
  @group.ipPermissions = []
1294
1304
  elsif @xmlpath=='DescribeSecurityGroupsResponse/securityGroupInfo/item/ipPermissions'
1295
1305
  @perm = QEc2IpPermissionType.new
@@ -1306,9 +1316,9 @@ module Aws
1306
1316
  when 'groupDescription' then @group.groupDescription = @text
1307
1317
  when 'groupName'
1308
1318
  if @xmlpath=='DescribeSecurityGroupsResponse/securityGroupInfo/item'
1309
- @group.groupName = @text
1319
+ @group.groupName = @text
1310
1320
  elsif @xmlpath=='DescribeSecurityGroupsResponse/securityGroupInfo/item/ipPermissions/item/groups/item'
1311
- @sgroup.groupName = @text
1321
+ @sgroup.groupName = @text
1312
1322
  end
1313
1323
  when 'ipProtocol' then @perm.ipProtocol = @text
1314
1324
  when 'fromPort' then @perm.fromPort = @text
@@ -1333,7 +1343,7 @@ module Aws
1333
1343
  #-----------------------------------------------------------------
1334
1344
  # PARSERS: Images
1335
1345
  #-----------------------------------------------------------------
1336
-
1346
+
1337
1347
  class QEc2DescribeImagesParser < AwsParser #:nodoc:
1338
1348
  def tagstart(name, attributes)
1339
1349
  if name == 'item' && @xmlpath[%r{.*/imagesSet$}]
@@ -1381,8 +1391,8 @@ module Aws
1381
1391
  end
1382
1392
  end
1383
1393
  def tagend(name)
1384
- # right now only 'launchPermission' is supported by Amazon.
1385
- # But nobody know what will they xml later as attribute. That is why we
1394
+ # right now only 'launchPermission' is supported by Amazon.
1395
+ # But nobody know what will they xml later as attribute. That is why we
1386
1396
  # check for 'group' and 'userId' inside of 'launchPermission/item'
1387
1397
  case name
1388
1398
  when 'imageId' then @result[:aws_id] = @text
@@ -1406,18 +1416,18 @@ module Aws
1406
1416
  class QEc2DescribeInstancesParser < AwsParser #:nodoc:
1407
1417
  def tagstart(name, attributes)
1408
1418
  # DescribeInstances property
1409
- if (name == 'item' && @xmlpath == 'DescribeInstancesResponse/reservationSet') ||
1419
+ if (name == 'item' && @xmlpath == 'DescribeInstancesResponse/reservationSet') ||
1410
1420
  # RunInstances property
1411
- (name == 'RunInstancesResponse')
1421
+ (name == 'RunInstancesResponse')
1412
1422
  @reservation = { :aws_groups => [],
1413
1423
  :instances_set => [] }
1414
-
1415
- elsif (name == 'item') &&
1424
+
1425
+ elsif (name == 'item') &&
1416
1426
  # DescribeInstances property
1417
1427
  ( @xmlpath=='DescribeInstancesResponse/reservationSet/item/instancesSet' ||
1418
1428
  # RunInstances property
1419
1429
  @xmlpath=='RunInstancesResponse/instancesSet' )
1420
- # the optional params (sometimes are missing and we dont want them to be nil)
1430
+ # the optional params (sometimes are missing and we dont want them to be nil)
1421
1431
  @instance = { :aws_reason => '',
1422
1432
  :dns_name => '',
1423
1433
  :private_dns_name => '',
@@ -1428,12 +1438,12 @@ module Aws
1428
1438
  end
1429
1439
  end
1430
1440
  def tagend(name)
1431
- case name
1441
+ case name
1432
1442
  # reservation
1433
1443
  when 'reservationId' then @reservation[:aws_reservation_id] = @text
1434
1444
  when 'ownerId' then @reservation[:aws_owner] = @text
1435
1445
  when 'groupId' then @reservation[:aws_groups] << @text
1436
- # instance
1446
+ # instance
1437
1447
  when 'instanceId' then @instance[:aws_instance_id] = @text
1438
1448
  when 'imageId' then @instance[:aws_image_id] = @text
1439
1449
  when 'dnsName' then @instance[:dns_name] = @text
@@ -1450,6 +1460,11 @@ module Aws
1450
1460
  when 'ramdiskId' then @instance[:aws_ramdisk_id] = @text
1451
1461
  when 'platform' then @instance[:aws_platform] = @text
1452
1462
  when 'availabilityZone' then @instance[:aws_availability_zone] = @text
1463
+ when 'state'
1464
+ if @xmlpath == 'DescribeInstancesResponse/reservationSet/item/instancesSet/item/monitoring' || # DescribeInstances property
1465
+ @xmlpath == 'RunInstancesResponse/instancesSet/item/monitoring' # RunInstances property
1466
+ @instance[:monitoring_state] = @text
1467
+ end
1453
1468
  when 'item'
1454
1469
  if @xmlpath == 'DescribeInstancesResponse/reservationSet/item/instancesSet' || # DescribeInstances property
1455
1470
  @xmlpath == 'RunInstancesResponse/instancesSet' # RunInstances property
@@ -1471,6 +1486,23 @@ module Aws
1471
1486
  end
1472
1487
  end
1473
1488
 
1489
+ class QEc2MonitorInstancesParser < AwsParser #:nodoc:
1490
+ def tagstart(name, attributes)
1491
+ @instance = {} if name == 'item'
1492
+ end
1493
+ def tagend(name)
1494
+ case name
1495
+ when 'instanceId' then @instance[:aws_instance_id] = @text
1496
+ when 'state' then @instance[:aws_monitoring_state] = @text
1497
+ when 'item' then @result << @instance
1498
+ end
1499
+ end
1500
+ def reset
1501
+ @result = []
1502
+ end
1503
+ end
1504
+
1505
+
1474
1506
  class QEc2TerminateInstancesParser < AwsParser #:nodoc:
1475
1507
  def tagstart(name, attributes)
1476
1508
  @instance = {} if name == 'item'
@@ -1564,20 +1596,20 @@ module Aws
1564
1596
  #-----------------------------------------------------------------
1565
1597
  # PARSERS: Elastic IPs
1566
1598
  #-----------------------------------------------------------------
1567
-
1599
+
1568
1600
  class QEc2AllocateAddressParser < AwsParser #:nodoc:
1569
1601
  def tagend(name)
1570
1602
  @result = @text if name == 'publicIp'
1571
1603
  end
1572
1604
  end
1573
-
1605
+
1574
1606
  class QEc2DescribeAddressesParser < AwsParser #:nodoc:
1575
1607
  def tagstart(name, attributes)
1576
1608
  @address = {} if name == 'item'
1577
1609
  end
1578
1610
  def tagend(name)
1579
1611
  case name
1580
- when 'instanceId' then @address[:instance_id] = @text.blank? ? nil : @text
1612
+ when 'instanceId' then @address[:instance_id] = @text.blank? ? nil : @text
1581
1613
  when 'publicIp' then @address[:public_ip] = @text
1582
1614
  when 'item' then @result << @address
1583
1615
  end
@@ -1624,10 +1656,10 @@ module Aws
1624
1656
  #-----------------------------------------------------------------
1625
1657
  # PARSERS: EBS - Volumes
1626
1658
  #-----------------------------------------------------------------
1627
-
1659
+
1628
1660
  class QEc2CreateVolumeParser < AwsParser #:nodoc:
1629
1661
  def tagend(name)
1630
- case name
1662
+ case name
1631
1663
  when 'volumeId' then @result[:aws_id] = @text
1632
1664
  when 'status' then @result[:aws_status] = @text
1633
1665
  when 'createTime' then @result[:aws_created_at] = Time.parse(@text)
@@ -1640,10 +1672,10 @@ module Aws
1640
1672
  @result = {}
1641
1673
  end
1642
1674
  end
1643
-
1675
+
1644
1676
  class QEc2AttachAndDetachVolumeParser < AwsParser #:nodoc:
1645
1677
  def tagend(name)
1646
- case name
1678
+ case name
1647
1679
  when 'volumeId' then @result[:aws_id] = @text
1648
1680
  when 'instanceId' then @result[:aws_instance_id] = @text
1649
1681
  when 'device' then @result[:aws_device] = @text
@@ -1655,7 +1687,7 @@ module Aws
1655
1687
  @result = {}
1656
1688
  end
1657
1689
  end
1658
-
1690
+
1659
1691
  class QEc2DescribeVolumesParser < AwsParser #:nodoc:
1660
1692
  def tagstart(name, attributes)
1661
1693
  case name
@@ -1666,7 +1698,7 @@ module Aws
1666
1698
  end
1667
1699
  end
1668
1700
  def tagend(name)
1669
- case name
1701
+ case name
1670
1702
  when 'volumeId'
1671
1703
  case @xmlpath
1672
1704
  when 'DescribeVolumesResponse/volumeSet/item' then @volume[:aws_id] = @text
@@ -1683,7 +1715,7 @@ module Aws
1683
1715
  when 'attachTime' then @volume[:aws_attached_at] = Time.parse(@text)
1684
1716
  when 'snapshotId' then @volume[:snapshot_id] = @text.blank? ? nil : @text
1685
1717
  when 'availabilityZone' then @volume[:zone] = @text
1686
- when 'item'
1718
+ when 'item'
1687
1719
  case @xmlpath
1688
1720
  when 'DescribeVolumesResponse/volumeSet' then @result << @volume
1689
1721
  end
@@ -1697,13 +1729,13 @@ module Aws
1697
1729
  #-----------------------------------------------------------------
1698
1730
  # PARSERS: EBS - Snapshots
1699
1731
  #-----------------------------------------------------------------
1700
-
1732
+
1701
1733
  class QEc2DescribeSnapshotsParser < AwsParser #:nodoc:
1702
1734
  def tagstart(name, attributes)
1703
1735
  @snapshot = {} if name == 'item'
1704
1736
  end
1705
1737
  def tagend(name)
1706
- case name
1738
+ case name
1707
1739
  when 'volumeId' then @snapshot[:aws_volume_id] = @text
1708
1740
  when 'snapshotId' then @snapshot[:aws_id] = @text
1709
1741
  when 'status' then @snapshot[:aws_status] = @text
@@ -1719,7 +1751,7 @@ module Aws
1719
1751
 
1720
1752
  class QEc2CreateSnapshotParser < AwsParser #:nodoc:
1721
1753
  def tagend(name)
1722
- case name
1754
+ case name
1723
1755
  when 'volumeId' then @result[:aws_volume_id] = @text
1724
1756
  when 'snapshotId' then @result[:aws_id] = @text
1725
1757
  when 'status' then @result[:aws_status] = @text
@@ -1731,7 +1763,7 @@ module Aws
1731
1763
  @result = {}
1732
1764
  end
1733
1765
  end
1734
-
1766
+
1735
1767
  end
1736
1768
 
1737
1769
  end
@@ -114,7 +114,7 @@ module Aws
114
114
  #
115
115
  # Optional parameters:
116
116
  # period: Integer 60 or multiple of 60
117
- # dimension: Hash containing keys ImageId, AutoScalingGroupName, InstanceId, InstanceType
117
+ # dimensions: Hash containing keys ImageId, AutoScalingGroupName, InstanceId, InstanceType
118
118
  # customUnit: nil. not supported currently.
119
119
  # namespace: AWS/EC2
120
120
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aws
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.0
4
+ version: 2.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Travis Reeder
@@ -11,7 +11,7 @@ autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
13
 
14
- date: 2009-10-30 00:00:00 -07:00
14
+ date: 2009-11-01 00:00:00 -07:00
15
15
  default_executable:
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency