Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

#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...
commit afe78818a174ae191ab75150d7d23ffb82ab6c58 1 parent faf4735
Konstantin Dzreev authored June 26, 2008
224  History.txt
@@ -89,163 +89,133 @@ Initial release.
89 89
     (The Ec2 functions are being cached: describe_images, describe_instances, 
90 90
     describe_security_groups and describe_key_pairs)
91 91
 
92  
-== 1.4.5
93  
-== 1.4.6
94  
-*r 2619, konstantin, 01-17-08 16:18:36  +0300
  92
+== 1.4.5 - 1.4.6
  93
+* r 2619, konstantin, 01-17-08 16:18:36  +0300
95 94
   * S3 Location constraints support added.
96 95
   * Fixed bug with trailing '/' in the bucket name for 'EU' located buckets
97 96
   * Added: S3Interface#bucket_location, S3::Bucket#location
98 97
 
99 98
 == 1.4.7
100  
-*r 2622, konstantin, 01-18-08 13:52:20  +0300
  99
+* r 2622, konstantin, 01-18-08 13:52:20  +0300
101 100
   * Virtual domains doc added
102 101
   * S3 Query API fixed to support virtual domains.
103 102
 
104 103
 == 1.4.8
105  
-*r 2650, konstantin, 01-24-08 11:12:00  +0300
  104
+* r 2650, konstantin, 01-24-08 11:12:00  +0300
106 105
   * net_fix.rb moved to right_http_connection
107 106
 
108 107
 == 1.5.0
109  
-*r 2688, konstantin, 02-30-08 15:42:00  +0300
  108
+* r 2688, konstantin, 02-30-08 15:42:00  +0300
110 109
   * SDB support added.
111 110
   * RightAws::S3::bucket and RightAws::S3::Bucket.create methods behaviour 
112 111
     changed: param +create+ is set to +false+ by default.
113 112
 
114 113
 == 1.6.0
115 114
 
116  
-r2780 | todd | 2008-02-11 11:41:07 -0800 (Mon, 11 Feb 2008) | 4 lines
117  
-Some doc updates & tweaks: we now support ultra-large PUTs to S3, small SDB
118  
-cleanups, add SDB to the list of interfaces in RightAws, update some copyrights,
119  
-warn about loading attachment_fu AFTER right_aws (big no-no).
  115
+* r2780, todd, 2008-02-11 11:41:07 -0800 (Mon, 11 Feb 2008), 4 lines
  116
+  * Some doc updates & tweaks: we now support ultra-large PUTs to S3, small SDB
  117
+    cleanups, add SDB to the list of interfaces in RightAws, update some copyrights,
  118
+    warn about loading attachment_fu AFTER right_aws (big no-no).
120 119
 
121  
-r2784 | todd | 2008-02-11 13:46:47 -0800 (Mon, 11 Feb 2008) | 2 lines
122  
-One final clarification: you may get a Net::HTTP bad monkey patch exception
  120
+* r2784, todd, 2008-02-11 13:46:47 -0800 (Mon, 11 Feb 2008), 2 lines
  121
+  * One final clarification: you may get a Net::HTTP bad monkey patch exception
123 122
 
124  
-r2880 | todd | 2008-02-25 18:06:22 -0800 (Mon, 25 Feb 2008) | 2 lines
125  
-Add SQS 'Gen 2' interface implementation
  123
+* r2880, todd, 2008-02-25 18:06:22 -0800 (Mon, 25 Feb 2008), 2 lines
  124
+  * Add SQS 'Gen 2' interface implementation
126 125
 
127  
-r2913 | todd | 2008-02-29 16:57:07 -0800 (Fri, 29 Feb 2008) | 3 lines
128  
-SqsGen2 (object interface), unit tests for both interfaces, documentation
129  
-updates.
  126
+* r2913, todd, 2008-02-29 16:57:07 -0800 (Fri, 29 Feb 2008), 3 lines
  127
+  * SqsGen2 (object interface), unit tests for both interfaces, documentation updates.
130 128
 
131  
-r2922 | todd | 2008-03-03 15:26:42 -0800 (Mon, 03 Mar 2008) | 2 lines
132  
-couple of documentation tweaks in prep for 1.6.0
  129
+* r2922, todd, 2008-03-03 15:26:42 -0800 (Mon, 03 Mar 2008), 2 lines
  130
+  * couple of documentation tweaks in prep for 1.6.0
133 131
 
134 132
 == 1.6.1 2008-03-14
135 133
 
136  
-------------------------------------------------------------------------
137  
-r2963 | todd | 2008-03-06 19:10:23 -0800 (Thu, 06 Mar 2008) | 3 lines
  134
+* r2963, todd, 2008-03-06 19:10:23 -0800 (Thu, 06 Mar 2008), 3 lines
  135
+  * (#950) Many minor fixes in incrementally_list_bucket to prevent a death loop
  136
+    in certain rare conditions
138 137
 
139  
-(#950) Many minor fixes in incrementally_list_bucket to prevent a death loop
140  
-in
141  
-certain rare conditions
  138
+== 1.7.0
142 139
 
  140
+* r3051, konstantin, 2008-03-14 21:26:12 +0300 (Fri, 14 Mar 2008), 1 line
  141
+  * #897, ActiveSdb alpha release
143 142
 
144  
-== 1.7.0
  143
+== 1.8.0
145 144
 
146  
-r3051 | konstantin | 2008-03-14 21:26:12 +0300 (Fri, 14 Mar 2008) | 1 line
147  
-#897, ActiveSdb alpha release
  145
+* r3264, konstantin, 2008-03-28 18:32:10 +0300 (Fri, 28 Mar 2008), 1 line
  146
+  * #978, EBS support added
148 147
 
149  
-#897, ActiveSdb alpha release
  148
+* r3288, konstantin, 2008-03-31 17:53:10 +0400 (–ü–Ω–¥, 31 –ú–∞—Ä 2008), 5 lines
  149
+  * 1. remove code duplication on the methods being cached
  150
+  * 2. add describe_availability_zones to cached methods
  151
+  * 3. refactor EBS methods output keys
150 152
 
151  
-== 1.8.0
  153
+* r3204, todd, 2008-03-26 17:50:45 -0700 (Wed, 26 Mar 2008), 4 lines
  154
+  * Do not autoload right_sdb with the rest of the modules; it requires uuidtools.
  155
+    We want the user to explicly request ActiveSdb, at least as long as it is
  156
+    alpha/beta.
152 157
 
153  
-r3264 | konstantin | 2008-03-28 18:32:10 +0300 (Fri, 28 Mar 2008) | 1 line
154  
-#978, EBS support added
155  
-
156  
-r3288 | konstantin | 2008-03-31 17:53:10 +0400 (–ü–Ω–¥, 31 –ú–∞—Ä 2008) | 5 lines
157  
-1. remove code duplication on the methods being cached
158  
-2. add describe_availability_zones to cached methods
159  
-3. refactor EBS methods output keys
160  
-=======
161  
-
162  
-------------------------------------------------------------------------
163  
-r3204 | todd | 2008-03-26 17:50:45 -0700 (Wed, 26 Mar 2008) | 4 lines
164  
-
165  
-Do not autoload right_sdb with the rest of the modules; it requires uuidtools.
166  
-We want the user to explicly request ActiveSdb, at least as long as it is
167  
-alpha/beta.
168  
-
169  
-------------------------------------------------------------------------
170  
-r3220 | konstantin | 2008-03-26 23:03:51 -0700 (Wed, 26 Mar 2008) | 1 line
171  
-
172  
-mark ActiveSdb release as alpha,(port to 1.7.0)
173  
-------------------------------------------------------------------------
174  
-r3229 | konstantin | 2008-03-27 03:43:17 -0700 (Thu, 27 Mar 2008) | 1 line
175  
-
176  
-aws pcode fix (release 2.5)
177  
-------------------------------------------------------------------------
178  
-r3243 | todd | 2008-03-27 12:10:49 -0700 (Thu, 27 Mar 2008) | 1 line
179  
-
180  
-(#991) Bring SqsGen2::Queue.pop fix into 1.7.0.  Also bring removal of
181  
-uuidtools dependency.
182  
-------------------------------------------------------------------------
183  
-r3249 | todd | 2008-03-27 17:59:14 -0700 (Thu, 27 Mar 2008) | 1 line
184  
-
185  
-(#991) Print an informational message if the require of uuidtools fails for
186  
-ActiveSdb.  Update RDoc to show how to include ActiveSdb class.  Update README
187  
-to point to ActiveSdb RDoc.
188  
-------------------------------------------------------------------------
189  
-r3250 | todd | 2008-03-27 18:03:09 -0700 (Thu, 27 Mar 2008) | 2 lines
190  
-
191  
-(#991) Change manifest entry from right_sdb to active_sdb
192  
-------------------------------------------------------------------------
193  
-r3251 | todd | 2008-03-27 18:03:33 -0700 (Thu, 27 Mar 2008) | 1 line
194  
-
195  
-(#991) Rename file from right_sdb to active_sdb.
196  
-------------------------------------------------------------------------
197  
-r3289 | konstantin | 2008-03-31 17:56:46 +0400 (Fri, 31 Mar 2008) | 1 line
198  
-
199  
-right_aws 1.8.0 history fix
200  
-------------------------------------------------------------------------
201  
-r3292 | konstantin | 2008-03-31 19:58:08 +0400 (Fri, 31 Mar 2008) | 1 line
202  
-
203  
-right_aws 1.8.0: get volume size as string
204  
-------------------------------------------------------------------------
205  
-r3288 | konstantin | 2008-03-31 17:53:10 +0400 (Mon, 31 Mar 2008) | 5 lines
206  
-
207  
-1. remove code duplication on the methods being cached
208  
-2. add describe_availability_zones to cached methods
209  
-3. refactor EBS methods output keys
210  
-------------------------------------------------------------------------
211  
-r3286 | konstantin | 2008-03-31 06:45:19 -0700 (Mon, 31 Mar 2008) | 4 lines
212  
-
213  
-1. remove code duplication on the methods being cached
214  
-2. add describe_availability_zones to cached methods
215  
-------------------------------------------------------------------------
216  
-r3351 | todd | 2008-04-04 02:14:45 +0400 (Fri, 04 Apr 2008) | 1 line
217  
-
218  
-Fix escaping problem in SqsGen2Interface: POST bodies did not properly escape the '&' character
219  
-------------------------------------------------------------------------
220  
-r3374 | todd | 2008-04-04 21:11:55 +0400 (Fri, 04 Apr 2008) | 1 line
221  
-
222  
-Port all 1.7.0/1.7.1 branch changes back to trunk
223  
-------------------------------------------------------------------------
224  
-r3427 | konstantin | 2008-04-08 21:01:04 +0400 (Tue, 08 Apr 2008) | 5 lines
225  
-
226  
-1. #1018, signature version '0' support added for: Ec2, SQS, SDB (Jurgen thanks)
227  
-2. #1017, perform sha1 digest calculation once only
228  
-------------------------------------------------------------------------
229  
-r3678 | konstantin | 2008-04-29 15:38:57 +0400 (Tue, 29 Apr 2008) | 1 line
230  
-
231  
-1. #1086, right_aws active_support dependency removal from S3Interface#generate_link
232  
-2. S3Interface#get_link doc improved
233  
-
234  
-------------------------------------------------------------------------
235  
-r3823 | konstantin | 2008-05-12 18:05:29 +0400 (Mon, 12 May 2008) | 11 lines
236  
-
237  
-#1141
238  
-Fixed:
239  
- - RightAWSParser#text method ('ETag' field was parsed incorrectly)
240  
-Added:
241  
- - RightAws::S3Interface : rename, copy and move methods
242  
- - RightAws::S3::Bucket  : rename_key, copy_key and move_key methods
243  
- - RightAws::S3::Key     : rename, copy, move, reload_meta and save_meta methods
244  
-Improved:
245  
- - test_right_s3.rb to test all the methods above
246  
- 
247  
-------------------------------------------------------------------------
248  
-r3940 | konstantin | 2008-05-20 14:56:06 +0400 (Tue, 20 May 2008) | 4 lines
  158
+* r3220, konstantin, 2008-03-26 23:03:51 -0700 (Wed, 26 Mar 2008), 1 line
  159
+  * mark ActiveSdb release as alpha,(port to 1.7.0)
  160
+
  161
+* r3229, konstantin, 2008-03-27 03:43:17 -0700 (Thu, 27 Mar 2008), 1 line
  162
+  * aws pcode fix (release 2.5)
  163
+
  164
+* r3243, todd, 2008-03-27 12:10:49 -0700 (Thu, 27 Mar 2008), 1 line
  165
+  * (#991) Bring SqsGen2::Queue.pop fix into 1.7.0.  Also bring removal of
  166
+    uuidtools dependency.
  167
+
  168
+* r3249, todd, 2008-03-27 17:59:14 -0700 (Thu, 27 Mar 2008), 1 line
  169
+  * (#991) Print an informational message if the require of uuidtools fails for
  170
+    ActiveSdb.  Update RDoc to show how to include ActiveSdb class.  Update README
  171
+    to point to ActiveSdb RDoc.
  172
+
  173
+* r3250, todd, 2008-03-27 18:03:09 -0700 (Thu, 27 Mar 2008), 2 lines
  174
+  * (#991) Change manifest entry from right_sdb to active_sdb
  175
+
  176
+* r3251, todd, 2008-03-27 18:03:33 -0700 (Thu, 27 Mar 2008), 1 line
  177
+  * (#991) Rename file from right_sdb to active_sdb.
249 178
 
250  
- - ec2: c1.medium and c1.xlarge types support
251  
-  
  179
+* r3289, konstantin, 2008-03-31 17:56:46 +0400 (Fri, 31 Mar 2008), 1 line
  180
+  * right_aws 1.8.0 history fix
  181
+
  182
+* r3292, konstantin, 2008-03-31 19:58:08 +0400 (Fri, 31 Mar 2008), 1 line
  183
+  * right_aws 1.8.0: get volume size as string
  184
+
  185
+* r3288, konstantin, 2008-03-31 17:53:10 +0400 (Mon, 31 Mar 2008), 5 lines
  186
+  * 1. remove code duplication on the methods being cached
  187
+  * 2. add describe_availability_zones to cached methods
  188
+  * 3. refactor EBS methods output keys
  189
+
  190
+* r3286, konstantin, 2008-03-31 06:45:19 -0700 (Mon, 31 Mar 2008), 4 lines
  191
+  * 1. remove code duplication on the methods being cached
  192
+  * 2. add describe_availability_zones to cached methods
  193
+
  194
+* r3351, todd, 2008-04-04 02:14:45 +0400 (Fri, 04 Apr 2008), 1 line
  195
+  * Fix escaping problem in SqsGen2Interface: POST bodies did not properly escape the '&' character
  196
+
  197
+* r3374, todd, 2008-04-04 21:11:55 +0400 (Fri, 04 Apr 2008), 1 line
  198
+  * Port all 1.7.0/1.7.1 branch changes back to trunk
  199
+
  200
+* r3427, konstantin, 2008-04-08 21:01:04 +0400 (Tue, 08 Apr 2008), 5 lines
  201
+  * 1. #1018, signature version '0' support added for: Ec2, SQS, SDB (Jurgen thanks)
  202
+  * 2. #1017, perform sha1 digest calculation once only
  203
+
  204
+* r3678, konstantin, 2008-04-29 15:38:57 +0400 (Tue, 29 Apr 2008), 1 line
  205
+  * 1. #1086, right_aws active_support dependency removal from S3Interface#generate_link
  206
+  * 2. S3Interface#get_link doc improved
  207
+
  208
+* r3823, konstantin, 2008-05-12 18:05:29 +0400 (Mon, 12 May 2008), 11 lines
  209
+  * #1141
  210
+    Fixed:
  211
+      - RightAWSParser#text method ('ETag' field was parsed incorrectly)
  212
+    Added:
  213
+      - RightAws::S3Interface : rename, copy and move methods
  214
+      - RightAws::S3::Bucket  : rename_key, copy_key and move_key methods
  215
+      - RightAws::S3::Key     : rename, copy, move, reload_meta and save_meta methods
  216
+    Improved:
  217
+     - test_right_s3.rb to test all the methods above
  218
+ 
  219
+* r3940, konstantin, 2008-05-20 14:56:06 +0400 (Tue, 20 May 2008), 4 lines
  220
+  * ec2: c1.medium and c1.xlarge types support
  221
+  
292  lib/ec2/right_ec2.rb
@@ -125,8 +125,8 @@ def generate_request(action, params={}) #:nodoc:
125 125
       service_hash.update(params)
126 126
       # prepare string to sight
127 127
       string_to_sign = case signature_version
128  
-                       when '0' : service_hash["Action"] + service_hash["Timestamp"]
129  
-                       when '1' : service_hash.sort{|a,b| (a[0].to_s.downcase)<=>(b[0].to_s.downcase)}.to_s
  128
+                       when '0' then service_hash["Action"] + service_hash["Timestamp"]
  129
+                       when '1' then service_hash.sort{|a,b| (a[0].to_s.downcase)<=>(b[0].to_s.downcase)}.to_s
130 130
                        end
131 131
       service_hash.update('Signature' =>  AwsUtils::sign(@aws_secret_access_key, string_to_sign))
132 132
       request_params = service_hash.to_a.collect{|key,val| key + "=" + CGI::escape(val) }.join("&")
@@ -864,18 +864,22 @@ def describe_availability_zones(list=[])
864 864
     # Describe all EBS volumes.
865 865
     #
866 866
     #  ec2.describe_volumes #=> 
867  
-    #    [{ :aws_id         => "vol-5782673e",
868  
-    #       :aws_status     => "available",
869  
-    #       :aws_created_at => "2008-02-23T16:47:19.000Z",
870  
-    #       :aws_size       => "1000001765375"},
871  
-    #     { :aws_id         =>"vol-268a6f4f",
872  
-    #       :aws_status     => "in-use",
873  
-    #       :aws_created_at => "2008-03-26T15:54:38.000Z",
874  
-    #       :aws_size       => 1073741824,
875  
-    #       :aws_attachment_status => "attached",
876  
-    #       :aws_instance_id => "i-067db86f",
877  
-    #       :aws_device      => "/dev/sdj",
878  
-    #       :aws_attached_at => "2008-03-29T17:46:01.000Z"}, ... ]
  867
+    #      [{:aws_size              => 94,
  868
+    #        :aws_device            => "/dev/sdc",
  869
+    #        :aws_attachment_status => "attached",
  870
+    #        :zone                  => "merlot",
  871
+    #        :snapshot_id           => nil,
  872
+    #        :aws_attached_at       => Wed Jun 18 08:19:28 UTC 2008,
  873
+    #        :aws_status            => "in-use",
  874
+    #        :aws_id                => "vol-60957009",
  875
+    #        :aws_created_at        => Wed Jun 18 08:19:20s UTC 2008,
  876
+    #        :aws_instance_id       => "i-c014c0a9"},
  877
+    #       {:aws_size       => 1,
  878
+    #        :zone           => "merlot",
  879
+    #        :snapshot_id    => nil,
  880
+    #        :aws_status     => "available",
  881
+    #        :aws_id         => "vol-58957031",
  882
+    #        :aws_created_at => Wed Jun 18 08:19:21 UTC 2008,}, ... ]
879 883
     #
880 884
     def describe_volumes(list=[])
881 885
       link = generate_request("DescribeVolumes", 
@@ -885,19 +889,23 @@ def describe_volumes(list=[])
885 889
       on_exception
886 890
     end
887 891
 
888  
-    # Create new EBS volume based on previously created snapshot.
  892
+    # Create new EBS volume based on previously created snapshot. 
  893
+    # +Size+ in Gigabytes.
889 894
     #
890  
-    #  ec2.create_volume('snap-000000', 10*.megabyte*1024*1024*1024) #=> 
891  
-    #    { :aws_created_at => "2008-03-28T13:03:33.000Z",
892  
-    #      :aws_status     => "creating",
893  
-    #      :aws_id         => "vol-b48a6fdd",
894  
-    #      :aws_size       => "100931731456" }
  895
+    #  ec2.create_volume('snap-000000', 10, zone) #=> 
  896
+    #      {:snapshot_id    => "snap-e21df98b",
  897
+    #       :aws_status     => "creating",
  898
+    #       :aws_id         => "vol-fc9f7a95",
  899
+    #       :zone           => "merlot",
  900
+    #       :aws_created_at => Tue Jun 24 18:13:32 UTC 2008,
  901
+    #       :aws_size       => 94}
895 902
     #
896  
-    def create_volume(snapshot_id, size)
  903
+    def create_volume(snapshot_id, size, zone)
897 904
       link = generate_request("CreateVolume", 
898 905
                               "SnapshotId" => snapshot_id.to_s,
899  
-                              "Size"       => size.to_s  )
900  
-      request_info(link, QEc2CreateAndDeleteVolumeParser.new(:logger => @logger))
  906
+                              "Size"       => size.to_s,
  907
+                              "Zone"       => zone.to_s )
  908
+      request_info(link, QEc2CreateVolumeParser.new(:logger => @logger))
901 909
     rescue Exception
902 910
       on_exception
903 911
     end
@@ -905,16 +913,12 @@ def create_volume(snapshot_id, size)
905 913
     # Delete the specified EBS volume. 
906 914
     # This does not deletes any snapshots created from this volume.
907 915
     #
908  
-    #  ec2.delete_volume('vol-b48a6fdd') #=> 
909  
-    #    { :aws_created_at => "2008-03-28T13:03:33.000Z",
910  
-    #      :aws_status     => "deleting",
911  
-    #      :aws_id         => "vol-b48a6fdd",
912  
-    #      :aws_size       => "100931731456" }
  916
+    #  ec2.delete_volume('vol-b48a6fdd') #=> true
913 917
     #
914 918
     def delete_volume(volume_id)
915 919
       link = generate_request("DeleteVolume", 
916 920
                               "VolumeId" => volume_id.to_s)
917  
-      request_info(link, QEc2CreateAndDeleteVolumeParser.new(:logger => @logger))
  921
+      request_info(link, RightBoolResponseParser.new(:logger => @logger))
918 922
     rescue Exception
919 923
       on_exception
920 924
     end
@@ -941,17 +945,20 @@ def attach_volume(volume_id, instance_id, device)
941 945
     
942 946
     # Detach the specified EBS volume from the instance to which it is attached.
943 947
     # 
944  
-    #   ec2.detach_volume('vol-898a6fe0', 'i-7c905415') #=> 
  948
+    #   ec2.detach_volume('vol-898a6fe0') #=> 
945 949
     #     { :aws_instance_id => "i-7c905415",
946 950
     #       :aws_device      => "/dev/sdh",
947 951
     #       :aws_status      => "detaching",
948 952
     #       :aws_attached_at => "2008-03-28T14:38:34.000Z",
949 953
     #       :aws_id          => "vol-898a6fe0"}
950 954
     #
951  
-    def detach_volume(volume_id, instance_id)
952  
-      link = generate_request("DetachVolume", 
953  
-                              "VolumeId"   => volume_id.to_s,
954  
-                              "InstanceId" => instance_id.to_s)
  955
+    def detach_volume(volume_id, instance_id=nil, device=nil, force=nil)
  956
+      hash = { "VolumeId" => volume_id.to_s }
  957
+      hash["InstanceId"] = instance_id.to_s unless instance_id.blank?
  958
+      hash["Device"]     = device.to_s      unless device.blank?
  959
+      hash["Force"]      = 'true'           if     force
  960
+      #
  961
+      link = generate_request("DetachVolume", hash)
955 962
       request_info(link, QEc2AttachAndDetachVolumeParser.new(:logger => @logger))
956 963
     rescue Exception
957 964
       on_exception
@@ -987,33 +994,28 @@ def describe_snapshots(list=[])
987 994
     # Create a snapshot of specified volume.
988 995
     #
989 996
     #  ec2.create_snapshot('vol-898a6fe0') #=> 
990  
-    #    { :aws_progress    => "",
991  
-    #      :aws_started_at  => "2008-03-28T13:47:02.000Z",
992  
-    #      :aws_status      => "pending",
993  
-    #      :aws_id          => "snap-55a5403c",
994  
-    #      :aws_volume_id   => "vol-898a6fe0" }
  997
+    #      {:aws_volume_id  => "vol-fd9f7a94",
  998
+    #       :aws_started_at => Tue Jun 24 18:40:40 UTC 2008,
  999
+    #       :aws_progress   => "",
  1000
+    #       :aws_status     => "pending",
  1001
+    #       :aws_id         => "snap-d56783bc"}
995 1002
     #
996 1003
     def create_snapshot(volume_id)
997 1004
       link = generate_request("CreateSnapshot", 
998 1005
                               "VolumeId" => volume_id.to_s)
999  
-      request_info(link, QEc2CreateAndDeleteSnapshotParser.new(:logger => @logger))
  1006
+      request_info(link, QEc2CreateSnapshotParser.new(:logger => @logger))
1000 1007
     rescue Exception
1001 1008
       on_exception
1002 1009
     end
1003 1010
 
1004 1011
     # Delete the specified snapshot.
1005 1012
     #
1006  
-    #  ec2.delete_snapshot('snap-55a5403c') #=> 
1007  
-    #    { :aws_progress   => "100%",
1008  
-    #      :aws_started_at => "2008-03-28T13:47:02.000Z",
1009  
-    #      :aws_status     => "deleted",
1010  
-    #      :aws_id         => "snap-55a5403c",
1011  
-    #      :aws_volume_id  => "vol-898a6fe0" }
  1013
+    #  ec2.delete_snapshot('snap-55a5403c') #=> true
1012 1014
     #
1013 1015
     def delete_snapshot(snapshot_id)
1014 1016
       link = generate_request("DeleteSnapshot", 
1015 1017
                               "SnapshotId" => snapshot_id.to_s)
1016  
-      request_info(link, QEc2CreateAndDeleteSnapshotParser.new(:logger => @logger))
  1018
+      request_info(link, RightBoolResponseParser.new(:logger => @logger))
1017 1019
     rescue Exception
1018 1020
       on_exception
1019 1021
     end
@@ -1038,9 +1040,9 @@ def tagstart(name, attributes)
1038 1040
       end
1039 1041
       def tagend(name)
1040 1042
         case name 
1041  
-          when 'keyName'       : @item[:aws_key_name]    = @text
1042  
-          when 'keyFingerprint': @item[:aws_fingerprint] = @text
1043  
-          when 'item'          : @result                << @item
  1043
+          when 'keyName'        then @item[:aws_key_name]    = @text
  1044
+          when 'keyFingerprint' then @item[:aws_fingerprint] = @text
  1045
+          when 'item'           then @result                << @item
1044 1046
         end
1045 1047
       end
1046 1048
       def reset
@@ -1054,9 +1056,9 @@ def tagstart(name, attributes)
1054 1056
       end
1055 1057
       def tagend(name)
1056 1058
         case name 
1057  
-          when 'keyName'       : @result[:aws_key_name]    = @text
1058  
-          when 'keyFingerprint': @result[:aws_fingerprint] = @text
1059  
-          when 'keyMaterial'   : @result[:aws_material]    = @text
  1059
+          when 'keyName'        then @result[:aws_key_name]    = @text
  1060
+          when 'keyFingerprint' then @result[:aws_fingerprint] = @text
  1061
+          when 'keyMaterial'    then @result[:aws_material]    = @text
1060 1062
         end
1061 1063
       end
1062 1064
     end
@@ -1104,19 +1106,19 @@ def tagstart(name, attributes)
1104 1106
       end
1105 1107
       def tagend(name)
1106 1108
         case name
1107  
-          when 'ownerId'          ; @group.ownerId   = @text
1108  
-          when 'groupDescription' ; @group.groupDescription = @text
  1109
+          when 'ownerId'          then @group.ownerId   = @text
  1110
+          when 'groupDescription' then @group.groupDescription = @text
1109 1111
           when 'groupName'
1110 1112
             if @xmlpath=='DescribeSecurityGroupsResponse/securityGroupInfo/item'
1111 1113
               @group.groupName  = @text 
1112 1114
             elsif @xmlpath=='DescribeSecurityGroupsResponse/securityGroupInfo/item/ipPermissions/item/groups/item'
1113 1115
               @sgroup.groupName = @text 
1114 1116
             end
1115  
-          when 'ipProtocol'       ; @perm.ipProtocol = @text
1116  
-          when 'fromPort'         ; @perm.fromPort   = @text
1117  
-          when 'toPort'           ; @perm.toPort     = @text
1118  
-          when 'userId'           ; @sgroup.userId   = @text
1119  
-          when 'cidrIp'           ; @perm.ipRanges  << @text
  1117
+          when 'ipProtocol'       then @perm.ipProtocol = @text
  1118
+          when 'fromPort'         then @perm.fromPort   = @text
  1119
+          when 'toPort'           then @perm.toPort     = @text
  1120
+          when 'userId'           then @sgroup.userId   = @text
  1121
+          when 'cidrIp'           then @perm.ipRanges  << @text
1120 1122
           when 'item'
1121 1123
             if @xmlpath=='DescribeSecurityGroupsResponse/securityGroupInfo/item/ipPermissions/item/groups'
1122 1124
               @perm.groups << @sgroup
@@ -1144,17 +1146,17 @@ def tagstart(name, attributes)
1144 1146
       end
1145 1147
       def tagend(name)
1146 1148
         case name
1147  
-          when 'imageId'       ; @image[:aws_id]       = @text
1148  
-          when 'imageLocation' ; @image[:aws_location] = @text
1149  
-          when 'imageState'    ; @image[:aws_state]    = @text
1150  
-          when 'imageOwnerId'  ; @image[:aws_owner]    = @text
1151  
-          when 'isPublic'      ; @image[:aws_is_public]= @text == 'true' ? true : false
1152  
-          when 'productCode'   ;(@image[:aws_product_codes] ||= []) << @text
1153  
-          when 'architecture'  ; @image[:aws_architecture] = @text
1154  
-          when 'imageType'     ; @image[:aws_image_type] = @text
1155  
-          when 'kernelId'      ; @image[:aws_kernel_id]  = @text
1156  
-          when 'ramdiskId'     ; @image[:aws_ramdisk_id] = @text
1157  
-          when 'item'          ; @result << @image if @xmlpath[%r{.*/imagesSet$}]
  1149
+          when 'imageId'       then @image[:aws_id]       = @text
  1150
+          when 'imageLocation' then @image[:aws_location] = @text
  1151
+          when 'imageState'    then @image[:aws_state]    = @text
  1152
+          when 'imageOwnerId'  then @image[:aws_owner]    = @text
  1153
+          when 'isPublic'      then @image[:aws_is_public]= @text == 'true' ? true : false
  1154
+          when 'productCode'   then (@image[:aws_product_codes] ||= []) << @text
  1155
+          when 'architecture'  then @image[:aws_architecture] = @text
  1156
+          when 'imageType'     then @image[:aws_image_type] = @text
  1157
+          when 'kernelId'      then @image[:aws_kernel_id]  = @text
  1158
+          when 'ramdiskId'     then @image[:aws_ramdisk_id] = @text
  1159
+          when 'item'          then @result << @image if @xmlpath[%r{.*/imagesSet$}]
1158 1160
         end
1159 1161
       end
1160 1162
       def reset
@@ -1187,13 +1189,13 @@ def tagend(name)
1187 1189
           # But nobody know what will they xml later as attribute. That is why we 
1188 1190
           # check for 'group' and 'userId' inside of 'launchPermission/item'
1189 1191
         case name
1190  
-          when 'imageId'            : @result[:aws_id] = @text
1191  
-          when 'group'              : @result[:groups] << @text if @xmlpath == 'DescribeImageAttributeResponse/launchPermission/item'
1192  
-          when 'userId'             : @result[:users]  << @text if @xmlpath == 'DescribeImageAttributeResponse/launchPermission/item'
1193  
-          when 'productCode'        : @result[:aws_product_codes] << @text
1194  
-          when 'kernel'             : @result[:aws_kernel]  = @text
1195  
-          when 'ramdisk'            : @result[:aws_ramdisk] = @text
1196  
-          when 'blockDeviceMapping' : @result[:block_device_mapping] = @text
  1192
+          when 'imageId'            then @result[:aws_id] = @text
  1193
+          when 'group'              then @result[:groups] << @text if @xmlpath == 'DescribeImageAttributeResponse/launchPermission/item'
  1194
+          when 'userId'             then @result[:users]  << @text if @xmlpath == 'DescribeImageAttributeResponse/launchPermission/item'
  1195
+          when 'productCode'        then @result[:aws_product_codes] << @text
  1196
+          when 'kernel'             then @result[:aws_kernel]  = @text
  1197
+          when 'ramdisk'            then @result[:aws_ramdisk] = @text
  1198
+          when 'blockDeviceMapping' then @result[:block_device_mapping] = @text
1197 1199
         end
1198 1200
       end
1199 1201
       def reset
@@ -1232,25 +1234,25 @@ def tagstart(name, attributes)
1232 1234
       def tagend(name)
1233 1235
         case name 
1234 1236
           # reservation
1235  
-          when 'reservationId'   : @reservation[:aws_reservation_id] = @text
1236  
-          when 'ownerId'         : @reservation[:aws_owner]          = @text
1237  
-          when 'groupId'         : @reservation[:aws_groups]        << @text
  1237
+          when 'reservationId'    then @reservation[:aws_reservation_id] = @text
  1238
+          when 'ownerId'          then @reservation[:aws_owner]          = @text
  1239
+          when 'groupId'          then @reservation[:aws_groups]        << @text
1238 1240
           # instance  
1239  
-          when 'instanceId'      : @instance[:aws_instance_id]    = @text
1240  
-          when 'imageId'         : @instance[:aws_image_id]       = @text
1241  
-          when 'dnsName'         : @instance[:dns_name]           = @text
1242  
-          when 'privateDnsName'  : @instance[:private_dns_name]   = @text
1243  
-          when 'reason'          : @instance[:aws_reason]         = @text
1244  
-          when 'keyName'         : @instance[:ssh_key_name]       = @text
1245  
-          when 'amiLaunchIndex'  : @instance[:ami_launch_index]   = @text
1246  
-          when 'code'            : @instance[:aws_state_code]     = @text
1247  
-          when 'name'            : @instance[:aws_state]          = @text
1248  
-          when 'productCode'     : @instance[:aws_product_codes] << @text
1249  
-          when 'instanceType'    : @instance[:aws_instance_type]  = @text
1250  
-          when 'launchTime'      : @instance[:aws_launch_time]    = @text
1251  
-          when 'kernelId'        : @instance[:aws_kernel_id]      = @text
1252  
-          when 'ramdiskId'       : @instance[:aws_ramdisk_id]     = @text
1253  
-          when 'availabilityZone': @instance[:aws_availability_zone] = @text
  1241
+          when 'instanceId'       then @instance[:aws_instance_id]    = @text
  1242
+          when 'imageId'          then @instance[:aws_image_id]       = @text
  1243
+          when 'dnsName'          then @instance[:dns_name]           = @text
  1244
+          when 'privateDnsName'   then @instance[:private_dns_name]   = @text
  1245
+          when 'reason'           then @instance[:aws_reason]         = @text
  1246
+          when 'keyName'          then @instance[:ssh_key_name]       = @text
  1247
+          when 'amiLaunchIndex'   then @instance[:ami_launch_index]   = @text
  1248
+          when 'code'             then @instance[:aws_state_code]     = @text
  1249
+          when 'name'             then @instance[:aws_state]          = @text
  1250
+          when 'productCode'      then @instance[:aws_product_codes] << @text
  1251
+          when 'instanceType'     then @instance[:aws_instance_type]  = @text
  1252
+          when 'launchTime'       then @instance[:aws_launch_time]    = @text
  1253
+          when 'kernelId'         then @instance[:aws_kernel_id]      = @text
  1254
+          when 'ramdiskId'        then @instance[:aws_ramdisk_id]     = @text
  1255
+          when 'availabilityZone' then @instance[:aws_availability_zone] = @text
1254 1256
           when 'item'
1255 1257
             if @xmlpath == 'DescribeInstancesResponse/reservationSet/item/instancesSet' || # DescribeInstances property
1256 1258
                @xmlpath == 'RunInstancesResponse/instancesSet'            # RunInstances property
@@ -1258,7 +1260,7 @@ def tagend(name)
1258 1260
             elsif @xmlpath=='DescribeInstancesResponse/reservationSet'    # DescribeInstances property
1259 1261
               @result << @reservation
1260 1262
             end
1261  
-          when 'RunInstancesResponse': @result << @reservation            # RunInstances property
  1263
+          when 'RunInstancesResponse' then @result << @reservation            # RunInstances property
1262 1264
         end
1263 1265
       end
1264 1266
       def reset
@@ -1278,7 +1280,7 @@ def tagstart(name, attributes)
1278 1280
       end
1279 1281
       def tagend(name)
1280 1282
         case name
1281  
-        when 'instanceId' : @instance[:aws_instance_id] = @text
  1283
+        when 'instanceId' then @instance[:aws_instance_id] = @text
1282 1284
         when 'code'
1283 1285
           if @xmlpath == 'TerminateInstancesResponse/instancesSet/item/shutdownState'
1284 1286
                @instance[:aws_shutdown_state_code] = @text.to_i
@@ -1287,7 +1289,7 @@ def tagend(name)
1287 1289
           if @xmlpath == 'TerminateInstancesResponse/instancesSet/item/shutdownState'
1288 1290
                @instance[:aws_shutdown_state] = @text
1289 1291
           else @instance[:aws_prev_state]     = @text end
1290  
-        when 'item'       : @result << @instance
  1292
+        when 'item'       then @result << @instance
1291 1293
         end
1292 1294
       end
1293 1295
       def reset
@@ -1302,10 +1304,10 @@ def reset
1302 1304
     class QEc2GetConsoleOutputParser < RightAWSParser #:nodoc:
1303 1305
       def tagend(name)
1304 1306
         case name
1305  
-        when 'instanceId' : @result[:aws_instance_id] = @text
1306  
-        when 'timestamp'  : @result[:aws_timestamp]   = @text
1307  
-                            @result[:timestamp]       = (Time.parse(@text)).utc
1308  
-        when 'output'     : @result[:aws_output]      = Base64.decode64(@text)
  1307
+        when 'instanceId' then @result[:aws_instance_id] = @text
  1308
+        when 'timestamp'  then @result[:aws_timestamp]   = @text
  1309
+                               @result[:timestamp]       = (Time.parse(@text)).utc
  1310
+        when 'output'     then @result[:aws_output]      = Base64.decode64(@text)
1309 1311
         end
1310 1312
       end
1311 1313
       def reset
@@ -1342,9 +1344,9 @@ def tagstart(name, attributes)
1342 1344
       end
1343 1345
       def tagend(name)
1344 1346
         case name
1345  
-        when 'instanceId' ; @address[:instance_id] = @text.blank? ? nil : @text 
1346  
-        when 'publicIp'   ; @address[:public_ip]   = @text
1347  
-        when 'item'       ; @result << @address
  1347
+        when 'instanceId' then @address[:instance_id] = @text.blank? ? nil : @text 
  1348
+        when 'publicIp'   then @address[:public_ip]   = @text
  1349
+        when 'item'       then @result << @address
1348 1350
         end
1349 1351
       end
1350 1352
       def reset
@@ -1362,9 +1364,9 @@ def tagstart(name, attributes)
1362 1364
       end
1363 1365
       def tagend(name)
1364 1366
         case name
1365  
-        when 'zoneName'  ; @zone[:zone_name]  = @text
1366  
-        when 'zoneState' ; @zone[:zone_state] = @text
1367  
-        when 'item'      ; @result << @zone
  1367
+        when 'zoneName'  then @zone[:zone_name]  = @text
  1368
+        when 'zoneState' then @zone[:zone_state] = @text
  1369
+        when 'item'      then @result << @zone
1368 1370
         end
1369 1371
       end
1370 1372
       def reset
@@ -1376,13 +1378,15 @@ def reset
1376 1378
   #      PARSERS: EBS - Volumes
1377 1379
   #-----------------------------------------------------------------
1378 1380
   
1379  
-    class QEc2CreateAndDeleteVolumeParser < RightAWSParser #:nodoc:
  1381
+    class QEc2CreateVolumeParser < RightAWSParser #:nodoc:
1380 1382
       def tagend(name)
1381 1383
         case name 
1382  
-          when 'volumeId'   : @result[:aws_id]         = @text
1383  
-          when 'size'       : @result[:aws_size]       = @text
1384  
-          when 'status'     : @result[:aws_status]     = @text
1385  
-          when 'createTime' : @result[:aws_created_at] = @text
  1384
+          when 'volumeId'   then @result[:aws_id]         = @text
  1385
+          when 'status'     then @result[:aws_status]     = @text
  1386
+          when 'createTime' then @result[:aws_created_at] = Time.parse(@text)
  1387
+          when 'size'       then @result[:aws_size]       = @text.to_i ###
  1388
+          when 'snapshotId' then @result[:snapshot_id]    = @text.blank? ? nil : @text ###
  1389
+          when 'zone'       then @result[:zone]           = @text ###
1386 1390
         end
1387 1391
       end
1388 1392
       def reset
@@ -1393,11 +1397,11 @@ def reset
1393 1397
     class QEc2AttachAndDetachVolumeParser < RightAWSParser #:nodoc:
1394 1398
       def tagend(name)
1395 1399
         case name 
1396  
-          when 'volumeId'   : @result[:aws_id]                = @text
1397  
-          when 'instanceId' : @result[:aws_instance_id]       = @text
1398  
-          when 'device'     : @result[:aws_device]            = @text
1399  
-          when 'status'     : @result[:aws_attachment_status] = @text
1400  
-          when 'attachTime' : @result[:aws_attached_at]       = @text
  1400
+          when 'volumeId'   then @result[:aws_id]                = @text
  1401
+          when 'instanceId' then @result[:aws_instance_id]       = @text
  1402
+          when 'device'     then @result[:aws_device]            = @text
  1403
+          when 'status'     then @result[:aws_attachment_status] = @text
  1404
+          when 'attachTime' then @result[:aws_attached_at]       = Time.parse(@text)
1401 1405
         end
1402 1406
       end
1403 1407
       def reset
@@ -1410,7 +1414,7 @@ def tagstart(name, attributes)
1410 1414
         case name
1411 1415
         when 'item'
1412 1416
           case @xmlpath
1413  
-          when 'DescribeVolumesResponse/volumeSet' : @volume = {}
  1417
+          when 'DescribeVolumesResponse/volumeSet' then @volume = {}
1414 1418
           end
1415 1419
         end
1416 1420
       end
@@ -1418,21 +1422,23 @@ def tagend(name)
1418 1422
         case name 
1419 1423
           when 'volumeId'
1420 1424
             case @xmlpath
1421  
-            when 'DescribeVolumesResponse/volumeSet/item' : @volume[:aws_id] = @text
  1425
+            when 'DescribeVolumesResponse/volumeSet/item' then @volume[:aws_id] = @text
1422 1426
             end
1423 1427
           when 'status'
1424 1428
             case @xmlpath
1425  
-            when 'DescribeVolumesResponse/volumeSet/item' : @volume[:aws_status] = @text
1426  
-            when 'DescribeVolumesResponse/volumeSet/item/attachmentSet/item' : @volume[:aws_attachment_status] = @text
  1429
+            when 'DescribeVolumesResponse/volumeSet/item' then @volume[:aws_status] = @text
  1430
+            when 'DescribeVolumesResponse/volumeSet/item/attachmentSet/item' then @volume[:aws_attachment_status] = @text
1427 1431
             end
1428  
-          when 'size'       : @volume[:aws_size]        = @text
1429  
-          when 'createTime' : @volume[:aws_created_at]  = @text
1430  
-          when 'instanceId' : @volume[:aws_instance_id] = @text
1431  
-          when 'device'     : @volume[:aws_device]      = @text
1432  
-          when 'attachTime' : @volume[:aws_attached_at] = @text
  1432
+          when 'size'       then @volume[:aws_size]        = @text.to_i
  1433
+          when 'createTime' then @volume[:aws_created_at]  = Time.parse(@text)
  1434
+          when 'instanceId' then @volume[:aws_instance_id] = @text
  1435
+          when 'device'     then @volume[:aws_device]      = @text
  1436
+          when 'attachTime' then @volume[:aws_attached_at] = Time.parse(@text)
  1437
+          when 'snapshotId' then @volume[:snapshot_id]     = @text.blank? ? nil : @text
  1438
+          when 'zone'       then @volume[:zone]            = @text
1433 1439
           when 'item' 
1434 1440
             case @xmlpath
1435  
-            when 'DescribeVolumesResponse/volumeSet' : @result << @volume
  1441
+            when 'DescribeVolumesResponse/volumeSet' then @result << @volume
1436 1442
             end
1437 1443
         end
1438 1444
       end
@@ -1447,18 +1453,16 @@ def reset
1447 1453
   
1448 1454
     class QEc2DescribeSnapshotsParser < RightAWSParser #:nodoc:
1449 1455
       def tagstart(name, attributes)
1450  
-        case name
1451  
-        when 'item' : @snapshot = {}
1452  
-        end
  1456
+        @snapshot = {} if name == 'item'
1453 1457
       end
1454 1458
       def tagend(name)
1455 1459
         case name 
1456  
-          when 'volumeId'   : @snapshot[:aws_volume_id]  = @text
1457  
-          when 'snapshotId' : @snapshot[:aws_id]         = @text
1458  
-          when 'status'     : @snapshot[:aws_status]     = @text
1459  
-          when 'startTime'  : @snapshot[:aws_started_at] = @text
1460  
-          when 'progress'   : @snapshot[:aws_progress]   = @text
1461  
-          when 'item'       : @result                   << @snapshot
  1460
+          when 'volumeId'   then @snapshot[:aws_volume_id]  = @text
  1461
+          when 'snapshotId' then @snapshot[:aws_id]         = @text
  1462
+          when 'status'     then @snapshot[:aws_status]     = @text
  1463
+          when 'startTime'  then @snapshot[:aws_started_at] = Time.parse(@text)
  1464
+          when 'progress'   then @snapshot[:aws_progress]   = @text
  1465
+          when 'item'       then @result                   << @snapshot
1462 1466
         end
1463 1467
       end
1464 1468
       def reset
@@ -1466,14 +1470,14 @@ def reset
1466 1470
       end
1467 1471
     end
1468 1472
 
1469  
-    class QEc2CreateAndDeleteSnapshotParser < RightAWSParser #:nodoc:
  1473
+    class QEc2CreateSnapshotParser < RightAWSParser #:nodoc:
1470 1474
       def tagend(name)
1471 1475
         case name 
1472  
-          when 'volumeId'   : @result[:aws_volume_id]  = @text
1473  
-          when 'snapshotId' : @result[:aws_id]         = @text
1474  
-          when 'status'     : @result[:aws_status]     = @text
1475  
-          when 'startTime'  : @result[:aws_started_at] = @text
1476  
-          when 'progress'   : @result[:aws_progress]   = @text
  1476
+          when 'volumeId'   then @result[:aws_volume_id]  = @text
  1477
+          when 'snapshotId' then @result[:aws_id]         = @text
  1478
+          when 'status'     then @result[:aws_status]     = @text
  1479
+          when 'startTime'  then @result[:aws_started_at] = Time.parse(@text)
  1480
+          when 'progress'   then @result[:aws_progress]   = @text
1477 1481
         end
1478 1482
       end
1479 1483
       def reset

0 notes on commit afe7881

Please sign in to comment.
Something went wrong with that request. Please try again.