amazon-ec2 0.4.8 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. data/ChangeLog +7 -4
  2. data/README.rdoc +12 -12
  3. data/README_dev.rdoc +6 -0
  4. data/Rakefile +2 -1
  5. data/VERSION +1 -1
  6. data/amazon-ec2.gemspec +25 -18
  7. data/bin/ec2-gem-example.rb +3 -3
  8. data/bin/ec2-gem-profile.rb +2 -2
  9. data/bin/ec2sh +4 -4
  10. data/bin/setup.rb +4 -2
  11. data/lib/{EC2.rb → AWS.rb} +33 -67
  12. data/lib/AWS/EC2.rb +67 -0
  13. data/lib/AWS/EC2/availability_zones.rb +43 -0
  14. data/lib/AWS/EC2/console.rb +46 -0
  15. data/lib/AWS/EC2/elastic_ips.rb +154 -0
  16. data/lib/AWS/EC2/image_attributes.rb +168 -0
  17. data/lib/AWS/EC2/images.rb +136 -0
  18. data/lib/AWS/EC2/instances.rb +218 -0
  19. data/lib/AWS/EC2/keypairs.rb +96 -0
  20. data/lib/AWS/EC2/products.rb +45 -0
  21. data/lib/AWS/EC2/security_groups.rb +234 -0
  22. data/lib/AWS/EC2/snapshots.rb +96 -0
  23. data/lib/AWS/EC2/volumes.rb +172 -0
  24. data/lib/AWS/ELB.rb +67 -0
  25. data/lib/AWS/ELB/load_balancers.rb +198 -0
  26. data/lib/{EC2 → AWS}/exceptions.rb +21 -2
  27. data/lib/{EC2 → AWS}/responses.rb +4 -5
  28. data/perftools/ec2prof-results.txt +4 -4
  29. data/perftools/ec2prof.symbols +4 -4
  30. data/test/test_EC2.rb +14 -14
  31. data/test/test_EC2_availability_zones.rb +2 -2
  32. data/test/test_EC2_console.rb +5 -5
  33. data/test/test_EC2_elastic_ips.rb +13 -13
  34. data/test/test_EC2_image_attributes.rb +35 -35
  35. data/test/test_EC2_images.rb +7 -7
  36. data/test/test_EC2_instances.rb +35 -35
  37. data/test/test_EC2_keypairs.rb +10 -10
  38. data/test/test_EC2_products.rb +7 -7
  39. data/test/test_EC2_responses.rb +2 -2
  40. data/test/test_EC2_s3_xmlsimple.rb +2 -2
  41. data/test/test_EC2_security_groups.rb +13 -13
  42. data/test/test_EC2_snapshots.rb +2 -2
  43. data/test/test_EC2_volumes.rb +2 -2
  44. data/test/test_ELB_load_balancers.rb +239 -0
  45. data/test/test_helper.rb +1 -1
  46. metadata +24 -17
  47. data/lib/EC2/availability_zones.rb +0 -41
  48. data/lib/EC2/console.rb +0 -44
  49. data/lib/EC2/elastic_ips.rb +0 -153
  50. data/lib/EC2/image_attributes.rb +0 -166
  51. data/lib/EC2/images.rb +0 -134
  52. data/lib/EC2/instances.rb +0 -216
  53. data/lib/EC2/keypairs.rb +0 -94
  54. data/lib/EC2/products.rb +0 -43
  55. data/lib/EC2/security_groups.rb +0 -232
  56. data/lib/EC2/snapshots.rb +0 -94
  57. data/lib/EC2/volumes.rb +0 -170
data/lib/EC2/console.rb DELETED
@@ -1,44 +0,0 @@
1
- #--
2
- # Amazon Web Services EC2 Query API Ruby library
3
- #
4
- # Ruby Gem Name:: amazon-ec2
5
- # Author:: Glenn Rempe (mailto:glenn@rempe.us)
6
- # Copyright:: Copyright (c) 2007-2008 Glenn Rempe
7
- # License:: Distributes under the same terms as Ruby
8
- # Home:: http://github.com/grempe/amazon-ec2/tree/master
9
- #++
10
-
11
- module EC2
12
-
13
- class Base
14
-
15
- #Amazon Developer Guide Docs:
16
- #
17
- # The GetConsoleOutput operation retrieves console output that has been posted for the specified instance.
18
- #
19
- # Instance console output is buffered and posted shortly after instance boot, reboot and once the instance
20
- # is terminated. Only the most recent 64 KB of posted output is available. Console output is available for
21
- # at least 1 hour after the most recent post.
22
- #
23
- #Required Arguments:
24
- #
25
- # :instance_id => String (default : "")
26
- #
27
- #Optional Arguments:
28
- #
29
- # none
30
- #
31
- def get_console_output( options ={} )
32
-
33
- options = {:instance_id => ""}.merge(options)
34
-
35
- raise ArgumentError, "No instance ID provided" if options[:instance_id].nil? || options[:instance_id].empty?
36
-
37
- params = { "InstanceId" => options[:instance_id] }
38
-
39
- return response_generator(:action => "GetConsoleOutput", :params => params)
40
-
41
- end
42
- end
43
-
44
- end
@@ -1,153 +0,0 @@
1
- #--
2
- # Amazon Web Services EC2 Query API Ruby library
3
- #
4
- # Ruby Gem Name:: amazon-ec2
5
- # Author:: Glenn Rempe (mailto:glenn@rempe.us)
6
- # Copyright:: Copyright (c) 2007-2008 Glenn Rempe
7
- # License:: Distributes under the same terms as Ruby
8
- # Home:: http://github.com/grempe/amazon-ec2/tree/master
9
- #++
10
-
11
- module EC2
12
-
13
- class Base
14
-
15
-
16
- #Amazon Developer Guide Docs:
17
- #
18
- # The AllocateAddress operation acquires an elastic IP address for use with your account.
19
- #
20
- #Required Arguments:
21
- #
22
- # none
23
- #
24
- #Optional Arguments:
25
- #
26
- # none
27
- #
28
- def allocate_address
29
-
30
- return response_generator(:action => "AllocateAddress")
31
-
32
- end
33
-
34
- #Amazon Developer Guide Docs:
35
- #
36
- # The DescribeAddresses operation lists elastic IP addresses assigned to your account.
37
- #
38
- #Required Arguments:
39
- #
40
- # :public_ip => Array (default : [], can be empty)
41
- #
42
- #Optional Arguments:
43
- #
44
- # none
45
- #
46
- def describe_addresses( options = {} )
47
-
48
- options = { :public_ip => [] }.merge(options)
49
-
50
- params = pathlist("PublicIp", options[:public_ip])
51
-
52
- return response_generator(:action => "DescribeAddresses", :params => params)
53
-
54
- end
55
-
56
- #Amazon Developer Guide Docs:
57
- #
58
- # The ReleaseAddress operation releases an elastic IP address associated with your account.
59
- #
60
- # If you run this operation on an elastic IP address that is already released, the address
61
- # might be assigned to another account which will cause Amazon EC2 to return an error.
62
- #
63
- # Note : Releasing an IP address automatically disassociates it from any instance
64
- # with which it is associated. For more information, see DisassociateAddress.
65
- #
66
- # Important! After releasing an elastic IP address, it is released to the IP
67
- # address pool and might no longer be available to your account. Make sure
68
- # to update your DNS records and any servers or devices that communicate
69
- # with the address.
70
- #
71
- #Required Arguments:
72
- #
73
- # :public_ip => String (default : '')
74
- #
75
- #Optional Arguments:
76
- #
77
- # none
78
- #
79
- def release_address( options = {} )
80
-
81
- options = { :public_ip => '' }.merge(options)
82
-
83
- raise ArgumentError, "No ':public_ip' provided" if options[:public_ip].nil? || options[:public_ip].empty?
84
-
85
- params = { "PublicIp" => options[:public_ip] }
86
-
87
- return response_generator(:action => "ReleaseAddress", :params => params)
88
-
89
- end
90
-
91
- #Amazon Developer Guide Docs:
92
- #
93
- # The AssociateAddress operation associates an elastic IP address with an instance.
94
- #
95
- # If the IP address is currently assigned to another instance, the IP address
96
- # is assigned to the new instance. This is an idempotent operation. If you enter
97
- # it more than once, Amazon EC2 does not return an error.
98
- #
99
- #Required Arguments:
100
- #
101
- # :instance_id => String (default : '')
102
- # :public_ip => String (default : '')
103
- #
104
- #Optional Arguments:
105
- #
106
- # none
107
- #
108
- def associate_address( options = {} )
109
-
110
- options = { :instance_id => '', :public_ip => '' }.merge(options)
111
-
112
- raise ArgumentError, "No ':instance_id' provided" if options[:instance_id].nil? || options[:instance_id].empty?
113
- raise ArgumentError, "No ':public_ip' provided" if options[:public_ip].nil? || options[:public_ip].empty?
114
-
115
- params = {
116
- "InstanceId" => options[:instance_id],
117
- "PublicIp" => options[:public_ip]
118
- }
119
-
120
- return response_generator(:action => "AssociateAddress", :params => params)
121
-
122
- end
123
-
124
- #Amazon Developer Guide Docs:
125
- #
126
- # The DisassociateAddress operation disassociates the specified elastic IP
127
- # address from the instance to which it is assigned. This is an idempotent
128
- # operation. If you enter it more than once, Amazon EC2 does not return
129
- # an error.
130
- #
131
- #Required Arguments:
132
- #
133
- # :public_ip => String (default : '')
134
- #
135
- #Optional Arguments:
136
- #
137
- # none
138
- #
139
- def disassociate_address( options = {} )
140
-
141
- options = { :public_ip => '' }.merge(options)
142
-
143
- raise ArgumentError, "No ':public_ip' provided" if options[:public_ip].nil? || options[:public_ip].empty?
144
-
145
- params = { "PublicIp" => options[:public_ip] }
146
-
147
- return response_generator(:action => "DisassociateAddress", :params => params)
148
-
149
- end
150
-
151
- end
152
-
153
- end
@@ -1,166 +0,0 @@
1
- #--
2
- # Amazon Web Services EC2 Query API Ruby library
3
- #
4
- # Ruby Gem Name:: amazon-ec2
5
- # Author:: Glenn Rempe (mailto:glenn@rempe.us)
6
- # Copyright:: Copyright (c) 2007-2008 Glenn Rempe
7
- # License:: Distributes under the same terms as Ruby
8
- # Home:: http://github.com/grempe/amazon-ec2/tree/master
9
- #++
10
-
11
- module EC2
12
-
13
- class Base
14
-
15
- #Amazon Developer Guide Docs:
16
- #
17
- # The ModifyImageAttribute operation modifies an attribute of an AMI. The following attributes may
18
- # currently be modified:
19
- #
20
- # 'launchPermission' : Controls who has permission to launch the AMI. Launch permissions can be
21
- # granted to specific users by adding userIds. The AMI can be made public by adding the 'all' group.
22
- #
23
- # 'productCodes' : Associates product codes with AMIs. This allows a developer to charge a user extra
24
- # for using the AMIs. productCodes is a write once attribute - once it has been set it can not be
25
- # changed or removed. Currently only one product code is supported per AMI.
26
- #
27
- #Required Arguments:
28
- #
29
- # :image_id => String (default : "")
30
- # :attribute => String ('launchPermission' or 'productCodes', default : "launchPermission")
31
- # :operation_type => String (default : "")
32
- #
33
- #Optional Arguments:
34
- #
35
- # :user_id => Array (default : [])
36
- # :group => Array (default : [])
37
- # :product_code => Array (default : [])
38
- #
39
- def modify_image_attribute( options = {} )
40
-
41
- # defaults
42
- options = { :image_id => "",
43
- :attribute => "launchPermission",
44
- :operation_type => "",
45
- :user_id => [],
46
- :group => [],
47
- :product_code => [] }.merge(options)
48
-
49
- raise ArgumentError, "No ':image_id' provided" if options[:image_id].nil? || options[:image_id].empty?
50
- raise ArgumentError, "No ':attribute' provided" if options[:attribute].nil? || options[:attribute].empty?
51
-
52
- # OperationType is not required if modifying a product code.
53
- unless options[:attribute] == 'productCodes'
54
- raise ArgumentError, "No ':operation_type' provided" if options[:operation_type].nil? || options[:operation_type].empty?
55
- end
56
-
57
- params = {
58
- "ImageId" => options[:image_id],
59
- "Attribute" => options[:attribute],
60
- "OperationType" => options[:operation_type]
61
- }
62
-
63
- # test options provided and make sure they are valid
64
- case options[:attribute]
65
- when "launchPermission"
66
-
67
- unless options[:operation_type] == "add" || options[:operation_type] == "remove"
68
- raise ArgumentError, ":operation_type was #{options[:operation_type].to_s} but must be either 'add' or 'remove'"
69
- end
70
-
71
- if (options[:user_id].nil? || options[:user_id].empty?) && (options[:group].nil? || options[:group].empty?)
72
- raise ArgumentError, "Option :attribute=>'launchPermission' requires ':user_id' or ':group' options to also be specified"
73
- end
74
- params.merge!(pathlist("UserId", options[:user_id])) unless options[:user_id].nil?
75
- params.merge!(pathlist("Group", options[:group])) unless options[:group].nil?
76
- when "productCodes"
77
- if (options[:product_code].nil? || options[:product_code].empty?)
78
- raise ArgumentError, "Option :attribute=>'productCodes' requires ':product_code' to be specified"
79
- end
80
- params.merge!(pathlist("ProductCode", options[:product_code])) unless options[:product_code].nil?
81
- else
82
- raise ArgumentError, "attribute : #{options[:attribute].to_s} is not an known attribute."
83
- end
84
-
85
- return response_generator(:action => "ModifyImageAttribute", :params => params)
86
-
87
- end
88
-
89
- #Amazon Developer Guide Docs:
90
- #
91
- # The DescribeImageAttribute operation returns information about an attribute of an AMI.
92
- #
93
- #Required Arguments:
94
- #
95
- # :image_id => String (default : "")
96
- # :attribute => String ("launchPermission" or "productCodes", default : "launchPermission")
97
- #
98
- #Optional Arguments:
99
- #
100
- # none
101
- #
102
- def describe_image_attribute( options = {} )
103
-
104
- # defaults
105
- options = {:image_id => "",
106
- :attribute => "launchPermission"
107
- }.merge(options)
108
-
109
- raise ArgumentError, "No ':image_id' provided" if options[:image_id].nil? || options[:image_id].empty?
110
- raise ArgumentError, "No ':attribute' provided" if options[:attribute].nil? || options[:attribute].empty?
111
-
112
- params = { "ImageId" => options[:image_id], "Attribute" => options[:attribute] }
113
-
114
- # test options provided and make sure they are valid
115
- case options[:attribute]
116
- when "launchPermission", "productCodes"
117
- # these args are ok
118
- else
119
- raise ArgumentError, "attribute : #{options[:attribute].to_s} is not an known attribute."
120
- end
121
-
122
- return response_generator(:action => "DescribeImageAttribute", :params => params)
123
-
124
- end
125
-
126
-
127
- #Amazon Developer Guide Docs:
128
- #
129
- # The ResetImageAttribute operation resets an attribute of an AMI to its default value.
130
- #
131
- #Required Arguments:
132
- #
133
- # :image_id => String (default : "")
134
- # :attribute => String (default : "launchPermission")
135
- #
136
- #Optional Arguments:
137
- #
138
- # none
139
- #
140
- def reset_image_attribute( options = {} )
141
-
142
- # defaults
143
- options = {:image_id => "",
144
- :attribute => "launchPermission"}.merge(options)
145
-
146
- raise ArgumentError, "No ':image_id' provided" if options[:image_id].nil? || options[:image_id].empty?
147
- raise ArgumentError, "No ':attribute' provided" if options[:attribute].nil? || options[:attribute].empty?
148
-
149
- params = {"ImageId" => options[:image_id],
150
- "Attribute" => options[:attribute] }
151
-
152
- # test options provided and make sure they are valid
153
- case options[:attribute]
154
- when "launchPermission"
155
- # these args are ok
156
- else
157
- raise ArgumentError, "attribute : #{options[:attribute].to_s} is not an known attribute."
158
- end
159
-
160
- return response_generator(:action => "ResetImageAttribute", :params => params)
161
-
162
- end
163
-
164
- end
165
-
166
- end
data/lib/EC2/images.rb DELETED
@@ -1,134 +0,0 @@
1
- #--
2
- # Amazon Web Services EC2 Query API Ruby library
3
- #
4
- # Ruby Gem Name:: amazon-ec2
5
- # Author:: Glenn Rempe (mailto:glenn@rempe.us)
6
- # Copyright:: Copyright (c) 2007-2008 Glenn Rempe
7
- # License:: Distributes under the same terms as Ruby
8
- # Home:: http://github.com/grempe/amazon-ec2/tree/master
9
- #++
10
-
11
- module EC2
12
-
13
- class Base
14
-
15
- #Amazon Developer Guide Docs:
16
- #
17
- # The RegisterImage operation registers an AMI with Amazon EC2. Images must be registered before
18
- # they can be launched. Each AMI is associated with an unique ID which is provided by the EC2
19
- # service via the Registerimage operation. As part of the registration process, Amazon EC2 will
20
- # retrieve the specified image manifest from Amazon S3 and verify that the image is owned by the
21
- # user requesting image registration. The image manifest is retrieved once and stored within the
22
- # Amazon EC2 network. Any modifications to an image in Amazon S3 invalidate this registration.
23
- # If you do have to make changes and upload a new image deregister the previous image and register
24
- # the new image.
25
- #
26
- #Required Arguments:
27
- #
28
- # :image_location => String (default : "")
29
- #
30
- #Optional Arguments:
31
- #
32
- # none
33
- #
34
- def register_image( options = {} )
35
-
36
- options = {:image_location => ""}.merge(options)
37
-
38
- raise ArgumentError, "No :image_location provided" if options[:image_location].nil? || options[:image_location].empty?
39
-
40
- params = { "ImageLocation" => options[:image_location] }
41
-
42
- return response_generator(:action => "RegisterImage", :params => params)
43
-
44
- end
45
-
46
- #Amazon Developer Guide Docs:
47
- #
48
- # The DescribeImages operation returns information about AMIs available for use by the user. This
49
- # includes both public AMIs (those available for any user to launch) and private AMIs (those owned by
50
- # the user making the request and those owned by other users that the user making the request has explicit
51
- # launch permissions for).
52
- #
53
- # The list of AMIs returned can be modified via optional lists of AMI IDs, owners or users with launch
54
- # permissions. If all three optional lists are empty all AMIs the user has launch permissions for are
55
- # returned. Launch permissions fall into three categories:
56
- #
57
- # Launch Permission Description
58
- #
59
- # public - The all group has launch permissions for the AMI. All users have launch permissions for these AMIs.
60
- # explicit - The owner of the AMIs has granted a specific user launch permissions for the AMI.
61
- # implicit - A user has implicit launch permissions for all AMIs he or she owns.
62
- #
63
- # If one or more of the lists are specified the result set is the intersection of AMIs matching the criteria of
64
- # the individual lists.
65
- #
66
- # Providing the list of AMI IDs requests information for those AMIs only. If no AMI IDs are provided,
67
- # information of all relevant AMIs will be returned. If an AMI is specified that does not exist a fault is
68
- # returned. If an AMI is specified that exists but the user making the request does not have launch
69
- # permissions for, then that AMI will not be included in the returned results.
70
- #
71
- # Providing the list of owners requests information for AMIs owned by the specified owners only. Only
72
- # AMIs the user has launch permissions for are returned. The items of the list may be account ids for
73
- # AMIs owned by users with those account ids, amazon for AMIs owned by Amazon or self for AMIs
74
- # owned by the user making the request.
75
- #
76
- # The executable list may be provided to request information for AMIs that only the specified users have
77
- # launch permissions for. The items of the list may be account ids for AMIs owned by the user making the
78
- # request that the users with the specified account ids have explicit launch permissions for, self for AMIs
79
- # the user making the request has explicit launch permissions for or all for public AMIs.
80
- #
81
- # Deregistered images will be included in the returned results for an unspecified interval subsequent to
82
- # deregistration.
83
- #
84
- #Required Arguments:
85
- #
86
- # none
87
- #
88
- #Optional Arguments:
89
- #
90
- # :image_id => Array (default : [])
91
- # :owner_id => Array (default : [])
92
- # :executable_by => Array (default : [])
93
- #
94
- def describe_images( options = {} )
95
-
96
- options = { :image_id => [], :owner_id => [], :executable_by => [] }.merge(options)
97
-
98
- params = pathlist( "ImageId", options[:image_id] )
99
- params.merge!(pathlist( "Owner", options[:owner_id] ))
100
- params.merge!(pathlist( "ExecutableBy", options[:executable_by] ))
101
-
102
- return response_generator(:action => "DescribeImages", :params => params)
103
-
104
- end
105
-
106
- #Amazon Developer Guide Docs:
107
- #
108
- # The DeregisterImage operation deregisters an AMI. Once deregistered, instances of the AMI may no
109
- # longer be launched.
110
- #
111
- #Required Arguments:
112
- #
113
- # :image_id => String (default : "")
114
- #
115
- #Optional Arguments:
116
- #
117
- # none
118
- #
119
- def deregister_image( options = {} )
120
-
121
- # defaults
122
- options = { :image_id => "" }.merge(options)
123
-
124
- raise ArgumentError, "No :image_id provided" if options[:image_id].nil? || options[:image_id].empty?
125
-
126
- params = { "ImageId" => options[:image_id] }
127
-
128
- return response_generator(:action => "DeregisterImage", :params => params)
129
-
130
- end
131
-
132
- end
133
-
134
- end