Permalink
Browse files

#978, right_aws gem: API 2008-05-05 support added (EBS improvements)

git-svn-id: https://wush.net/svn/rightscale/right_aws/trunk@4374 9f0cbaf6-ce18-0410-ad37-d14a22affa91
  • Loading branch information...
1 parent faf4735 commit afe78818a174ae191ab75150d7d23ffb82ab6c58 @konstantin-dzreev konstantin-dzreev committed Jun 26, 2008
Showing with 245 additions and 271 deletions.
  1. +97 −127 History.txt
  2. +148 −144 lib/ec2/right_ec2.rb
View
224 History.txt
@@ -89,163 +89,133 @@ Initial release.
(The Ec2 functions are being cached: describe_images, describe_instances,
describe_security_groups and describe_key_pairs)
-== 1.4.5
-== 1.4.6
-*r 2619, konstantin, 01-17-08 16:18:36 +0300
+== 1.4.5 - 1.4.6
+* r 2619, konstantin, 01-17-08 16:18:36 +0300
* S3 Location constraints support added.
* Fixed bug with trailing '/' in the bucket name for 'EU' located buckets
* Added: S3Interface#bucket_location, S3::Bucket#location
== 1.4.7
-*r 2622, konstantin, 01-18-08 13:52:20 +0300
+* r 2622, konstantin, 01-18-08 13:52:20 +0300
* Virtual domains doc added
* S3 Query API fixed to support virtual domains.
== 1.4.8
-*r 2650, konstantin, 01-24-08 11:12:00 +0300
+* r 2650, konstantin, 01-24-08 11:12:00 +0300
* net_fix.rb moved to right_http_connection
== 1.5.0
-*r 2688, konstantin, 02-30-08 15:42:00 +0300
+* r 2688, konstantin, 02-30-08 15:42:00 +0300
* SDB support added.
* RightAws::S3::bucket and RightAws::S3::Bucket.create methods behaviour
changed: param +create+ is set to +false+ by default.
== 1.6.0
-r2780 | todd | 2008-02-11 11:41:07 -0800 (Mon, 11 Feb 2008) | 4 lines
-Some doc updates & tweaks: we now support ultra-large PUTs to S3, small SDB
-cleanups, add SDB to the list of interfaces in RightAws, update some copyrights,
-warn about loading attachment_fu AFTER right_aws (big no-no).
+* r2780, todd, 2008-02-11 11:41:07 -0800 (Mon, 11 Feb 2008), 4 lines
+ * Some doc updates & tweaks: we now support ultra-large PUTs to S3, small SDB
+ cleanups, add SDB to the list of interfaces in RightAws, update some copyrights,
+ warn about loading attachment_fu AFTER right_aws (big no-no).
-r2784 | todd | 2008-02-11 13:46:47 -0800 (Mon, 11 Feb 2008) | 2 lines
-One final clarification: you may get a Net::HTTP bad monkey patch exception
+* r2784, todd, 2008-02-11 13:46:47 -0800 (Mon, 11 Feb 2008), 2 lines
+ * One final clarification: you may get a Net::HTTP bad monkey patch exception
-r2880 | todd | 2008-02-25 18:06:22 -0800 (Mon, 25 Feb 2008) | 2 lines
-Add SQS 'Gen 2' interface implementation
+* r2880, todd, 2008-02-25 18:06:22 -0800 (Mon, 25 Feb 2008), 2 lines
+ * Add SQS 'Gen 2' interface implementation
-r2913 | todd | 2008-02-29 16:57:07 -0800 (Fri, 29 Feb 2008) | 3 lines
-SqsGen2 (object interface), unit tests for both interfaces, documentation
-updates.
+* r2913, todd, 2008-02-29 16:57:07 -0800 (Fri, 29 Feb 2008), 3 lines
+ * SqsGen2 (object interface), unit tests for both interfaces, documentation updates.
-r2922 | todd | 2008-03-03 15:26:42 -0800 (Mon, 03 Mar 2008) | 2 lines
-couple of documentation tweaks in prep for 1.6.0
+* r2922, todd, 2008-03-03 15:26:42 -0800 (Mon, 03 Mar 2008), 2 lines
+ * couple of documentation tweaks in prep for 1.6.0
== 1.6.1 2008-03-14
-------------------------------------------------------------------------
-r2963 | todd | 2008-03-06 19:10:23 -0800 (Thu, 06 Mar 2008) | 3 lines
+* r2963, todd, 2008-03-06 19:10:23 -0800 (Thu, 06 Mar 2008), 3 lines
+ * (#950) Many minor fixes in incrementally_list_bucket to prevent a death loop
+ in certain rare conditions
-(#950) Many minor fixes in incrementally_list_bucket to prevent a death loop
-in
-certain rare conditions
+== 1.7.0
+* r3051, konstantin, 2008-03-14 21:26:12 +0300 (Fri, 14 Mar 2008), 1 line
+ * #897, ActiveSdb alpha release
-== 1.7.0
+== 1.8.0
-r3051 | konstantin | 2008-03-14 21:26:12 +0300 (Fri, 14 Mar 2008) | 1 line
-#897, ActiveSdb alpha release
+* r3264, konstantin, 2008-03-28 18:32:10 +0300 (Fri, 28 Mar 2008), 1 line
+ * #978, EBS support added
-#897, ActiveSdb alpha release
+* r3288, konstantin, 2008-03-31 17:53:10 +0400 (–ü–Ω–¥, 31 –ú–∞—Ä 2008), 5 lines
+ * 1. remove code duplication on the methods being cached
+ * 2. add describe_availability_zones to cached methods
+ * 3. refactor EBS methods output keys
-== 1.8.0
+* r3204, todd, 2008-03-26 17:50:45 -0700 (Wed, 26 Mar 2008), 4 lines
+ * Do not autoload right_sdb with the rest of the modules; it requires uuidtools.
+ We want the user to explicly request ActiveSdb, at least as long as it is
+ alpha/beta.
-r3264 | konstantin | 2008-03-28 18:32:10 +0300 (Fri, 28 Mar 2008) | 1 line
-#978, EBS support added
-
-r3288 | konstantin | 2008-03-31 17:53:10 +0400 (–ü–Ω–¥, 31 –ú–∞—Ä 2008) | 5 lines
-1. remove code duplication on the methods being cached
-2. add describe_availability_zones to cached methods
-3. refactor EBS methods output keys
-=======
-
-------------------------------------------------------------------------
-r3204 | todd | 2008-03-26 17:50:45 -0700 (Wed, 26 Mar 2008) | 4 lines
-
-Do not autoload right_sdb with the rest of the modules; it requires uuidtools.
-We want the user to explicly request ActiveSdb, at least as long as it is
-alpha/beta.
-
-------------------------------------------------------------------------
-r3220 | konstantin | 2008-03-26 23:03:51 -0700 (Wed, 26 Mar 2008) | 1 line
-
-mark ActiveSdb release as alpha,(port to 1.7.0)
-------------------------------------------------------------------------
-r3229 | konstantin | 2008-03-27 03:43:17 -0700 (Thu, 27 Mar 2008) | 1 line
-
-aws pcode fix (release 2.5)
-------------------------------------------------------------------------
-r3243 | todd | 2008-03-27 12:10:49 -0700 (Thu, 27 Mar 2008) | 1 line
-
-(#991) Bring SqsGen2::Queue.pop fix into 1.7.0. Also bring removal of
-uuidtools dependency.
-------------------------------------------------------------------------
-r3249 | todd | 2008-03-27 17:59:14 -0700 (Thu, 27 Mar 2008) | 1 line
-
-(#991) Print an informational message if the require of uuidtools fails for
-ActiveSdb. Update RDoc to show how to include ActiveSdb class. Update README
-to point to ActiveSdb RDoc.
-------------------------------------------------------------------------
-r3250 | todd | 2008-03-27 18:03:09 -0700 (Thu, 27 Mar 2008) | 2 lines
-
-(#991) Change manifest entry from right_sdb to active_sdb
-------------------------------------------------------------------------
-r3251 | todd | 2008-03-27 18:03:33 -0700 (Thu, 27 Mar 2008) | 1 line
-
-(#991) Rename file from right_sdb to active_sdb.
-------------------------------------------------------------------------
-r3289 | konstantin | 2008-03-31 17:56:46 +0400 (Fri, 31 Mar 2008) | 1 line
-
-right_aws 1.8.0 history fix
-------------------------------------------------------------------------
-r3292 | konstantin | 2008-03-31 19:58:08 +0400 (Fri, 31 Mar 2008) | 1 line
-
-right_aws 1.8.0: get volume size as string
-------------------------------------------------------------------------
-r3288 | konstantin | 2008-03-31 17:53:10 +0400 (Mon, 31 Mar 2008) | 5 lines
-
-1. remove code duplication on the methods being cached
-2. add describe_availability_zones to cached methods
-3. refactor EBS methods output keys
-------------------------------------------------------------------------
-r3286 | konstantin | 2008-03-31 06:45:19 -0700 (Mon, 31 Mar 2008) | 4 lines
-
-1. remove code duplication on the methods being cached
-2. add describe_availability_zones to cached methods
-------------------------------------------------------------------------
-r3351 | todd | 2008-04-04 02:14:45 +0400 (Fri, 04 Apr 2008) | 1 line
-
-Fix escaping problem in SqsGen2Interface: POST bodies did not properly escape the '&' character
-------------------------------------------------------------------------
-r3374 | todd | 2008-04-04 21:11:55 +0400 (Fri, 04 Apr 2008) | 1 line
-
-Port all 1.7.0/1.7.1 branch changes back to trunk
-------------------------------------------------------------------------
-r3427 | konstantin | 2008-04-08 21:01:04 +0400 (Tue, 08 Apr 2008) | 5 lines
-
-1. #1018, signature version '0' support added for: Ec2, SQS, SDB (Jurgen thanks)
-2. #1017, perform sha1 digest calculation once only
-------------------------------------------------------------------------
-r3678 | konstantin | 2008-04-29 15:38:57 +0400 (Tue, 29 Apr 2008) | 1 line
-
-1. #1086, right_aws active_support dependency removal from S3Interface#generate_link
-2. S3Interface#get_link doc improved
-
-------------------------------------------------------------------------
-r3823 | konstantin | 2008-05-12 18:05:29 +0400 (Mon, 12 May 2008) | 11 lines
-
-#1141
-Fixed:
- - RightAWSParser#text method ('ETag' field was parsed incorrectly)
-Added:
- - RightAws::S3Interface : rename, copy and move methods
- - RightAws::S3::Bucket : rename_key, copy_key and move_key methods
- - RightAws::S3::Key : rename, copy, move, reload_meta and save_meta methods
-Improved:
- - test_right_s3.rb to test all the methods above
-
-------------------------------------------------------------------------
-r3940 | konstantin | 2008-05-20 14:56:06 +0400 (Tue, 20 May 2008) | 4 lines
+* r3220, konstantin, 2008-03-26 23:03:51 -0700 (Wed, 26 Mar 2008), 1 line
+ * mark ActiveSdb release as alpha,(port to 1.7.0)
+
+* r3229, konstantin, 2008-03-27 03:43:17 -0700 (Thu, 27 Mar 2008), 1 line
+ * aws pcode fix (release 2.5)
+
+* r3243, todd, 2008-03-27 12:10:49 -0700 (Thu, 27 Mar 2008), 1 line
+ * (#991) Bring SqsGen2::Queue.pop fix into 1.7.0. Also bring removal of
+ uuidtools dependency.
+
+* r3249, todd, 2008-03-27 17:59:14 -0700 (Thu, 27 Mar 2008), 1 line
+ * (#991) Print an informational message if the require of uuidtools fails for
+ ActiveSdb. Update RDoc to show how to include ActiveSdb class. Update README
+ to point to ActiveSdb RDoc.
+
+* r3250, todd, 2008-03-27 18:03:09 -0700 (Thu, 27 Mar 2008), 2 lines
+ * (#991) Change manifest entry from right_sdb to active_sdb
+
+* r3251, todd, 2008-03-27 18:03:33 -0700 (Thu, 27 Mar 2008), 1 line
+ * (#991) Rename file from right_sdb to active_sdb.
- - ec2: c1.medium and c1.xlarge types support
-
+* r3289, konstantin, 2008-03-31 17:56:46 +0400 (Fri, 31 Mar 2008), 1 line
+ * right_aws 1.8.0 history fix
+
+* r3292, konstantin, 2008-03-31 19:58:08 +0400 (Fri, 31 Mar 2008), 1 line
+ * right_aws 1.8.0: get volume size as string
+
+* r3288, konstantin, 2008-03-31 17:53:10 +0400 (Mon, 31 Mar 2008), 5 lines
+ * 1. remove code duplication on the methods being cached
+ * 2. add describe_availability_zones to cached methods
+ * 3. refactor EBS methods output keys
+
+* r3286, konstantin, 2008-03-31 06:45:19 -0700 (Mon, 31 Mar 2008), 4 lines
+ * 1. remove code duplication on the methods being cached
+ * 2. add describe_availability_zones to cached methods
+
+* r3351, todd, 2008-04-04 02:14:45 +0400 (Fri, 04 Apr 2008), 1 line
+ * Fix escaping problem in SqsGen2Interface: POST bodies did not properly escape the '&' character
+
+* r3374, todd, 2008-04-04 21:11:55 +0400 (Fri, 04 Apr 2008), 1 line
+ * Port all 1.7.0/1.7.1 branch changes back to trunk
+
+* r3427, konstantin, 2008-04-08 21:01:04 +0400 (Tue, 08 Apr 2008), 5 lines
+ * 1. #1018, signature version '0' support added for: Ec2, SQS, SDB (Jurgen thanks)
+ * 2. #1017, perform sha1 digest calculation once only
+
+* r3678, konstantin, 2008-04-29 15:38:57 +0400 (Tue, 29 Apr 2008), 1 line
+ * 1. #1086, right_aws active_support dependency removal from S3Interface#generate_link
+ * 2. S3Interface#get_link doc improved
+
+* r3823, konstantin, 2008-05-12 18:05:29 +0400 (Mon, 12 May 2008), 11 lines
+ * #1141
+ Fixed:
+ - RightAWSParser#text method ('ETag' field was parsed incorrectly)
+ Added:
+ - RightAws::S3Interface : rename, copy and move methods
+ - RightAws::S3::Bucket : rename_key, copy_key and move_key methods
+ - RightAws::S3::Key : rename, copy, move, reload_meta and save_meta methods
+ Improved:
+ - test_right_s3.rb to test all the methods above
+
+* r3940, konstantin, 2008-05-20 14:56:06 +0400 (Tue, 20 May 2008), 4 lines
+ * ec2: c1.medium and c1.xlarge types support
+
View
292 lib/ec2/right_ec2.rb
@@ -125,8 +125,8 @@ def generate_request(action, params={}) #:nodoc:
service_hash.update(params)
# prepare string to sight
string_to_sign = case signature_version
- when '0' : service_hash["Action"] + service_hash["Timestamp"]
- when '1' : service_hash.sort{|a,b| (a[0].to_s.downcase)<=>(b[0].to_s.downcase)}.to_s
+ when '0' then service_hash["Action"] + service_hash["Timestamp"]
+ when '1' then service_hash.sort{|a,b| (a[0].to_s.downcase)<=>(b[0].to_s.downcase)}.to_s
end
service_hash.update('Signature' => AwsUtils::sign(@aws_secret_access_key, string_to_sign))
request_params = service_hash.to_a.collect{|key,val| key + "=" + CGI::escape(val) }.join("&")
@@ -864,18 +864,22 @@ def describe_availability_zones(list=[])
# Describe all EBS volumes.
#
# ec2.describe_volumes #=>
- # [{ :aws_id => "vol-5782673e",
- # :aws_status => "available",
- # :aws_created_at => "2008-02-23T16:47:19.000Z",
- # :aws_size => "1000001765375"},
- # { :aws_id =>"vol-268a6f4f",
- # :aws_status => "in-use",
- # :aws_created_at => "2008-03-26T15:54:38.000Z",
- # :aws_size => 1073741824,
- # :aws_attachment_status => "attached",
- # :aws_instance_id => "i-067db86f",
- # :aws_device => "/dev/sdj",
- # :aws_attached_at => "2008-03-29T17:46:01.000Z"}, ... ]
+ # [{:aws_size => 94,
+ # :aws_device => "/dev/sdc",
+ # :aws_attachment_status => "attached",
+ # :zone => "merlot",
+ # :snapshot_id => nil,
+ # :aws_attached_at => Wed Jun 18 08:19:28 UTC 2008,
+ # :aws_status => "in-use",
+ # :aws_id => "vol-60957009",
+ # :aws_created_at => Wed Jun 18 08:19:20s UTC 2008,
+ # :aws_instance_id => "i-c014c0a9"},
+ # {:aws_size => 1,
+ # :zone => "merlot",
+ # :snapshot_id => nil,
+ # :aws_status => "available",
+ # :aws_id => "vol-58957031",
+ # :aws_created_at => Wed Jun 18 08:19:21 UTC 2008,}, ... ]
#
def describe_volumes(list=[])
link = generate_request("DescribeVolumes",
@@ -885,36 +889,36 @@ def describe_volumes(list=[])
on_exception
end
- # Create new EBS volume based on previously created snapshot.
+ # Create new EBS volume based on previously created snapshot.
+ # +Size+ in Gigabytes.
#
- # ec2.create_volume('snap-000000', 10*.megabyte*1024*1024*1024) #=>
- # { :aws_created_at => "2008-03-28T13:03:33.000Z",
- # :aws_status => "creating",
- # :aws_id => "vol-b48a6fdd",
- # :aws_size => "100931731456" }
+ # ec2.create_volume('snap-000000', 10, zone) #=>
+ # {:snapshot_id => "snap-e21df98b",
+ # :aws_status => "creating",
+ # :aws_id => "vol-fc9f7a95",
+ # :zone => "merlot",
+ # :aws_created_at => Tue Jun 24 18:13:32 UTC 2008,
+ # :aws_size => 94}
#
- def create_volume(snapshot_id, size)
+ def create_volume(snapshot_id, size, zone)
link = generate_request("CreateVolume",
"SnapshotId" => snapshot_id.to_s,
- "Size" => size.to_s )
- request_info(link, QEc2CreateAndDeleteVolumeParser.new(:logger => @logger))
+ "Size" => size.to_s,
+ "Zone" => zone.to_s )
+ request_info(link, QEc2CreateVolumeParser.new(:logger => @logger))
rescue Exception
on_exception
end
# Delete the specified EBS volume.
# This does not deletes any snapshots created from this volume.
#
- # ec2.delete_volume('vol-b48a6fdd') #=>
- # { :aws_created_at => "2008-03-28T13:03:33.000Z",
- # :aws_status => "deleting",
- # :aws_id => "vol-b48a6fdd",
- # :aws_size => "100931731456" }
+ # ec2.delete_volume('vol-b48a6fdd') #=> true
#
def delete_volume(volume_id)
link = generate_request("DeleteVolume",
"VolumeId" => volume_id.to_s)
- request_info(link, QEc2CreateAndDeleteVolumeParser.new(:logger => @logger))
+ request_info(link, RightBoolResponseParser.new(:logger => @logger))
rescue Exception
on_exception
end
@@ -941,17 +945,20 @@ def attach_volume(volume_id, instance_id, device)
# Detach the specified EBS volume from the instance to which it is attached.
#
- # ec2.detach_volume('vol-898a6fe0', 'i-7c905415') #=>
+ # ec2.detach_volume('vol-898a6fe0') #=>
# { :aws_instance_id => "i-7c905415",
# :aws_device => "/dev/sdh",
# :aws_status => "detaching",
# :aws_attached_at => "2008-03-28T14:38:34.000Z",
# :aws_id => "vol-898a6fe0"}
#
- def detach_volume(volume_id, instance_id)
- link = generate_request("DetachVolume",
- "VolumeId" => volume_id.to_s,
- "InstanceId" => instance_id.to_s)
+ def detach_volume(volume_id, instance_id=nil, device=nil, force=nil)
+ hash = { "VolumeId" => volume_id.to_s }
+ hash["InstanceId"] = instance_id.to_s unless instance_id.blank?
+ hash["Device"] = device.to_s unless device.blank?
+ hash["Force"] = 'true' if force
+ #
+ link = generate_request("DetachVolume", hash)
request_info(link, QEc2AttachAndDetachVolumeParser.new(:logger => @logger))
rescue Exception
on_exception
@@ -987,33 +994,28 @@ def describe_snapshots(list=[])
# Create a snapshot of specified volume.
#
# ec2.create_snapshot('vol-898a6fe0') #=>
- # { :aws_progress => "",
- # :aws_started_at => "2008-03-28T13:47:02.000Z",
- # :aws_status => "pending",
- # :aws_id => "snap-55a5403c",
- # :aws_volume_id => "vol-898a6fe0" }
+ # {:aws_volume_id => "vol-fd9f7a94",
+ # :aws_started_at => Tue Jun 24 18:40:40 UTC 2008,
+ # :aws_progress => "",
+ # :aws_status => "pending",
+ # :aws_id => "snap-d56783bc"}
#
def create_snapshot(volume_id)
link = generate_request("CreateSnapshot",
"VolumeId" => volume_id.to_s)
- request_info(link, QEc2CreateAndDeleteSnapshotParser.new(:logger => @logger))
+ request_info(link, QEc2CreateSnapshotParser.new(:logger => @logger))
rescue Exception
on_exception
end
# Delete the specified snapshot.
#
- # ec2.delete_snapshot('snap-55a5403c') #=>
- # { :aws_progress => "100%",
- # :aws_started_at => "2008-03-28T13:47:02.000Z",
- # :aws_status => "deleted",
- # :aws_id => "snap-55a5403c",
- # :aws_volume_id => "vol-898a6fe0" }
+ # ec2.delete_snapshot('snap-55a5403c') #=> true
#
def delete_snapshot(snapshot_id)
link = generate_request("DeleteSnapshot",
"SnapshotId" => snapshot_id.to_s)
- request_info(link, QEc2CreateAndDeleteSnapshotParser.new(:logger => @logger))
+ request_info(link, RightBoolResponseParser.new(:logger => @logger))
rescue Exception
on_exception
end
@@ -1038,9 +1040,9 @@ def tagstart(name, attributes)
end
def tagend(name)
case name
- when 'keyName' : @item[:aws_key_name] = @text
- when 'keyFingerprint': @item[:aws_fingerprint] = @text
- when 'item' : @result << @item
+ when 'keyName' then @item[:aws_key_name] = @text
+ when 'keyFingerprint' then @item[:aws_fingerprint] = @text
+ when 'item' then @result << @item
end
end
def reset
@@ -1054,9 +1056,9 @@ def tagstart(name, attributes)
end
def tagend(name)
case name
- when 'keyName' : @result[:aws_key_name] = @text
- when 'keyFingerprint': @result[:aws_fingerprint] = @text
- when 'keyMaterial' : @result[:aws_material] = @text
+ when 'keyName' then @result[:aws_key_name] = @text
+ when 'keyFingerprint' then @result[:aws_fingerprint] = @text
+ when 'keyMaterial' then @result[:aws_material] = @text
end
end
end
@@ -1104,19 +1106,19 @@ def tagstart(name, attributes)
end
def tagend(name)
case name
- when 'ownerId' ; @group.ownerId = @text
- when 'groupDescription' ; @group.groupDescription = @text
+ when 'ownerId' then @group.ownerId = @text
+ when 'groupDescription' then @group.groupDescription = @text
when 'groupName'
if @xmlpath=='DescribeSecurityGroupsResponse/securityGroupInfo/item'
@group.groupName = @text
elsif @xmlpath=='DescribeSecurityGroupsResponse/securityGroupInfo/item/ipPermissions/item/groups/item'
@sgroup.groupName = @text
end
- when 'ipProtocol' ; @perm.ipProtocol = @text
- when 'fromPort' ; @perm.fromPort = @text
- when 'toPort' ; @perm.toPort = @text
- when 'userId' ; @sgroup.userId = @text
- when 'cidrIp' ; @perm.ipRanges << @text
+ when 'ipProtocol' then @perm.ipProtocol = @text
+ when 'fromPort' then @perm.fromPort = @text
+ when 'toPort' then @perm.toPort = @text
+ when 'userId' then @sgroup.userId = @text
+ when 'cidrIp' then @perm.ipRanges << @text
when 'item'
if @xmlpath=='DescribeSecurityGroupsResponse/securityGroupInfo/item/ipPermissions/item/groups'
@perm.groups << @sgroup
@@ -1144,17 +1146,17 @@ def tagstart(name, attributes)
end
def tagend(name)
case name
- when 'imageId' ; @image[:aws_id] = @text
- when 'imageLocation' ; @image[:aws_location] = @text
- when 'imageState' ; @image[:aws_state] = @text
- when 'imageOwnerId' ; @image[:aws_owner] = @text
- when 'isPublic' ; @image[:aws_is_public]= @text == 'true' ? true : false
- when 'productCode' ;(@image[:aws_product_codes] ||= []) << @text
- when 'architecture' ; @image[:aws_architecture] = @text
- when 'imageType' ; @image[:aws_image_type] = @text
- when 'kernelId' ; @image[:aws_kernel_id] = @text
- when 'ramdiskId' ; @image[:aws_ramdisk_id] = @text
- when 'item' ; @result << @image if @xmlpath[%r{.*/imagesSet$}]
+ when 'imageId' then @image[:aws_id] = @text
+ when 'imageLocation' then @image[:aws_location] = @text
+ when 'imageState' then @image[:aws_state] = @text
+ when 'imageOwnerId' then @image[:aws_owner] = @text
+ when 'isPublic' then @image[:aws_is_public]= @text == 'true' ? true : false
+ when 'productCode' then (@image[:aws_product_codes] ||= []) << @text
+ when 'architecture' then @image[:aws_architecture] = @text
+ when 'imageType' then @image[:aws_image_type] = @text
+ when 'kernelId' then @image[:aws_kernel_id] = @text
+ when 'ramdiskId' then @image[:aws_ramdisk_id] = @text
+ when 'item' then @result << @image if @xmlpath[%r{.*/imagesSet$}]
end
end
def reset
@@ -1187,13 +1189,13 @@ def tagend(name)
# But nobody know what will they xml later as attribute. That is why we
# check for 'group' and 'userId' inside of 'launchPermission/item'
case name
- when 'imageId' : @result[:aws_id] = @text
- when 'group' : @result[:groups] << @text if @xmlpath == 'DescribeImageAttributeResponse/launchPermission/item'
- when 'userId' : @result[:users] << @text if @xmlpath == 'DescribeImageAttributeResponse/launchPermission/item'
- when 'productCode' : @result[:aws_product_codes] << @text
- when 'kernel' : @result[:aws_kernel] = @text
- when 'ramdisk' : @result[:aws_ramdisk] = @text
- when 'blockDeviceMapping' : @result[:block_device_mapping] = @text
+ when 'imageId' then @result[:aws_id] = @text
+ when 'group' then @result[:groups] << @text if @xmlpath == 'DescribeImageAttributeResponse/launchPermission/item'
+ when 'userId' then @result[:users] << @text if @xmlpath == 'DescribeImageAttributeResponse/launchPermission/item'
+ when 'productCode' then @result[:aws_product_codes] << @text
+ when 'kernel' then @result[:aws_kernel] = @text
+ when 'ramdisk' then @result[:aws_ramdisk] = @text
+ when 'blockDeviceMapping' then @result[:block_device_mapping] = @text
end
end
def reset
@@ -1232,33 +1234,33 @@ def tagstart(name, attributes)
def tagend(name)
case name
# reservation
- when 'reservationId' : @reservation[:aws_reservation_id] = @text
- when 'ownerId' : @reservation[:aws_owner] = @text
- when 'groupId' : @reservation[:aws_groups] << @text
+ when 'reservationId' then @reservation[:aws_reservation_id] = @text
+ when 'ownerId' then @reservation[:aws_owner] = @text
+ when 'groupId' then @reservation[:aws_groups] << @text
# instance
- when 'instanceId' : @instance[:aws_instance_id] = @text
- when 'imageId' : @instance[:aws_image_id] = @text
- when 'dnsName' : @instance[:dns_name] = @text
- when 'privateDnsName' : @instance[:private_dns_name] = @text
- when 'reason' : @instance[:aws_reason] = @text
- when 'keyName' : @instance[:ssh_key_name] = @text
- when 'amiLaunchIndex' : @instance[:ami_launch_index] = @text
- when 'code' : @instance[:aws_state_code] = @text
- when 'name' : @instance[:aws_state] = @text
- when 'productCode' : @instance[:aws_product_codes] << @text
- when 'instanceType' : @instance[:aws_instance_type] = @text
- when 'launchTime' : @instance[:aws_launch_time] = @text
- when 'kernelId' : @instance[:aws_kernel_id] = @text
- when 'ramdiskId' : @instance[:aws_ramdisk_id] = @text
- when 'availabilityZone': @instance[:aws_availability_zone] = @text
+ when 'instanceId' then @instance[:aws_instance_id] = @text
+ when 'imageId' then @instance[:aws_image_id] = @text
+ when 'dnsName' then @instance[:dns_name] = @text
+ when 'privateDnsName' then @instance[:private_dns_name] = @text
+ when 'reason' then @instance[:aws_reason] = @text
+ when 'keyName' then @instance[:ssh_key_name] = @text
+ when 'amiLaunchIndex' then @instance[:ami_launch_index] = @text
+ when 'code' then @instance[:aws_state_code] = @text
+ when 'name' then @instance[:aws_state] = @text
+ when 'productCode' then @instance[:aws_product_codes] << @text
+ when 'instanceType' then @instance[:aws_instance_type] = @text
+ when 'launchTime' then @instance[:aws_launch_time] = @text
+ when 'kernelId' then @instance[:aws_kernel_id] = @text
+ when 'ramdiskId' then @instance[:aws_ramdisk_id] = @text
+ when 'availabilityZone' then @instance[:aws_availability_zone] = @text
when 'item'
if @xmlpath == 'DescribeInstancesResponse/reservationSet/item/instancesSet' || # DescribeInstances property
@xmlpath == 'RunInstancesResponse/instancesSet' # RunInstances property
@reservation[:instances_set] << @instance
elsif @xmlpath=='DescribeInstancesResponse/reservationSet' # DescribeInstances property
@result << @reservation
end
- when 'RunInstancesResponse': @result << @reservation # RunInstances property
+ when 'RunInstancesResponse' then @result << @reservation # RunInstances property
end
end
def reset
@@ -1278,7 +1280,7 @@ def tagstart(name, attributes)
end
def tagend(name)
case name
- when 'instanceId' : @instance[:aws_instance_id] = @text
+ when 'instanceId' then @instance[:aws_instance_id] = @text
when 'code'
if @xmlpath == 'TerminateInstancesResponse/instancesSet/item/shutdownState'
@instance[:aws_shutdown_state_code] = @text.to_i
@@ -1287,7 +1289,7 @@ def tagend(name)
if @xmlpath == 'TerminateInstancesResponse/instancesSet/item/shutdownState'
@instance[:aws_shutdown_state] = @text
else @instance[:aws_prev_state] = @text end
- when 'item' : @result << @instance
+ when 'item' then @result << @instance
end
end
def reset
@@ -1302,10 +1304,10 @@ def reset
class QEc2GetConsoleOutputParser < RightAWSParser #:nodoc:
def tagend(name)
case name
- when 'instanceId' : @result[:aws_instance_id] = @text
- when 'timestamp' : @result[:aws_timestamp] = @text
- @result[:timestamp] = (Time.parse(@text)).utc
- when 'output' : @result[:aws_output] = Base64.decode64(@text)
+ when 'instanceId' then @result[:aws_instance_id] = @text
+ when 'timestamp' then @result[:aws_timestamp] = @text
+ @result[:timestamp] = (Time.parse(@text)).utc
+ when 'output' then @result[:aws_output] = Base64.decode64(@text)
end
end
def reset
@@ -1342,9 +1344,9 @@ def tagstart(name, attributes)
end
def tagend(name)
case name
- when 'instanceId' ; @address[:instance_id] = @text.blank? ? nil : @text
- when 'publicIp' ; @address[:public_ip] = @text
- when 'item' ; @result << @address
+ when 'instanceId' then @address[:instance_id] = @text.blank? ? nil : @text
+ when 'publicIp' then @address[:public_ip] = @text
+ when 'item' then @result << @address
end
end
def reset
@@ -1362,9 +1364,9 @@ def tagstart(name, attributes)
end
def tagend(name)
case name
- when 'zoneName' ; @zone[:zone_name] = @text
- when 'zoneState' ; @zone[:zone_state] = @text
- when 'item' ; @result << @zone
+ when 'zoneName' then @zone[:zone_name] = @text
+ when 'zoneState' then @zone[:zone_state] = @text
+ when 'item' then @result << @zone
end
end
def reset
@@ -1376,13 +1378,15 @@ def reset
# PARSERS: EBS - Volumes
#-----------------------------------------------------------------
- class QEc2CreateAndDeleteVolumeParser < RightAWSParser #:nodoc:
+ class QEc2CreateVolumeParser < RightAWSParser #:nodoc:
def tagend(name)
case name
- when 'volumeId' : @result[:aws_id] = @text
- when 'size' : @result[:aws_size] = @text
- when 'status' : @result[:aws_status] = @text
- when 'createTime' : @result[:aws_created_at] = @text
+ when 'volumeId' then @result[:aws_id] = @text
+ when 'status' then @result[:aws_status] = @text
+ when 'createTime' then @result[:aws_created_at] = Time.parse(@text)
+ when 'size' then @result[:aws_size] = @text.to_i ###
+ when 'snapshotId' then @result[:snapshot_id] = @text.blank? ? nil : @text ###
+ when 'zone' then @result[:zone] = @text ###
end
end
def reset
@@ -1393,11 +1397,11 @@ def reset
class QEc2AttachAndDetachVolumeParser < RightAWSParser #:nodoc:
def tagend(name)
case name
- when 'volumeId' : @result[:aws_id] = @text
- when 'instanceId' : @result[:aws_instance_id] = @text
- when 'device' : @result[:aws_device] = @text
- when 'status' : @result[:aws_attachment_status] = @text
- when 'attachTime' : @result[:aws_attached_at] = @text
+ when 'volumeId' then @result[:aws_id] = @text
+ when 'instanceId' then @result[:aws_instance_id] = @text
+ when 'device' then @result[:aws_device] = @text
+ when 'status' then @result[:aws_attachment_status] = @text
+ when 'attachTime' then @result[:aws_attached_at] = Time.parse(@text)
end
end
def reset
@@ -1410,29 +1414,31 @@ def tagstart(name, attributes)
case name
when 'item'
case @xmlpath
- when 'DescribeVolumesResponse/volumeSet' : @volume = {}
+ when 'DescribeVolumesResponse/volumeSet' then @volume = {}
end
end
end
def tagend(name)
case name
when 'volumeId'
case @xmlpath
- when 'DescribeVolumesResponse/volumeSet/item' : @volume[:aws_id] = @text
+ when 'DescribeVolumesResponse/volumeSet/item' then @volume[:aws_id] = @text
end
when 'status'
case @xmlpath
- when 'DescribeVolumesResponse/volumeSet/item' : @volume[:aws_status] = @text
- when 'DescribeVolumesResponse/volumeSet/item/attachmentSet/item' : @volume[:aws_attachment_status] = @text
+ when 'DescribeVolumesResponse/volumeSet/item' then @volume[:aws_status] = @text
+ when 'DescribeVolumesResponse/volumeSet/item/attachmentSet/item' then @volume[:aws_attachment_status] = @text
end
- when 'size' : @volume[:aws_size] = @text
- when 'createTime' : @volume[:aws_created_at] = @text
- when 'instanceId' : @volume[:aws_instance_id] = @text
- when 'device' : @volume[:aws_device] = @text
- when 'attachTime' : @volume[:aws_attached_at] = @text
+ when 'size' then @volume[:aws_size] = @text.to_i
+ when 'createTime' then @volume[:aws_created_at] = Time.parse(@text)
+ when 'instanceId' then @volume[:aws_instance_id] = @text
+ when 'device' then @volume[:aws_device] = @text
+ when 'attachTime' then @volume[:aws_attached_at] = Time.parse(@text)
+ when 'snapshotId' then @volume[:snapshot_id] = @text.blank? ? nil : @text
+ when 'zone' then @volume[:zone] = @text
when 'item'
case @xmlpath
- when 'DescribeVolumesResponse/volumeSet' : @result << @volume
+ when 'DescribeVolumesResponse/volumeSet' then @result << @volume
end
end
end
@@ -1447,33 +1453,31 @@ def reset
class QEc2DescribeSnapshotsParser < RightAWSParser #:nodoc:
def tagstart(name, attributes)
- case name
- when 'item' : @snapshot = {}
- end
+ @snapshot = {} if name == 'item'
end
def tagend(name)
case name
- when 'volumeId' : @snapshot[:aws_volume_id] = @text
- when 'snapshotId' : @snapshot[:aws_id] = @text
- when 'status' : @snapshot[:aws_status] = @text
- when 'startTime' : @snapshot[:aws_started_at] = @text
- when 'progress' : @snapshot[:aws_progress] = @text
- when 'item' : @result << @snapshot
+ when 'volumeId' then @snapshot[:aws_volume_id] = @text
+ when 'snapshotId' then @snapshot[:aws_id] = @text
+ when 'status' then @snapshot[:aws_status] = @text
+ when 'startTime' then @snapshot[:aws_started_at] = Time.parse(@text)
+ when 'progress' then @snapshot[:aws_progress] = @text
+ when 'item' then @result << @snapshot
end
end
def reset
@result = []
end
end
- class QEc2CreateAndDeleteSnapshotParser < RightAWSParser #:nodoc:
+ class QEc2CreateSnapshotParser < RightAWSParser #:nodoc:
def tagend(name)
case name
- when 'volumeId' : @result[:aws_volume_id] = @text
- when 'snapshotId' : @result[:aws_id] = @text
- when 'status' : @result[:aws_status] = @text
- when 'startTime' : @result[:aws_started_at] = @text
- when 'progress' : @result[:aws_progress] = @text
+ when 'volumeId' then @result[:aws_volume_id] = @text
+ when 'snapshotId' then @result[:aws_id] = @text
+ when 'status' then @result[:aws_status] = @text
+ when 'startTime' then @result[:aws_started_at] = Time.parse(@text)
+ when 'progress' then @result[:aws_progress] = @text
end
end
def reset

0 comments on commit afe7881

Please sign in to comment.