nirvdrum-amazon-ec2 0.7.9
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +9 -0
- data/.yardopts +1 -0
- data/ChangeLog +304 -0
- data/LICENSE +66 -0
- data/README.rdoc +359 -0
- data/README_dev.rdoc +10 -0
- data/Rakefile +70 -0
- data/VERSION +1 -0
- data/amazon-ec2.gemspec +142 -0
- data/bin/ec2-gem-example.rb +137 -0
- data/bin/ec2-gem-profile.rb +10 -0
- data/bin/ec2sh +62 -0
- data/bin/setup.rb +29 -0
- data/deps.rip +1 -0
- data/lib/AWS.rb +321 -0
- data/lib/AWS/Autoscaling.rb +70 -0
- data/lib/AWS/Autoscaling/autoscaling.rb +273 -0
- data/lib/AWS/Cloudwatch.rb +32 -0
- data/lib/AWS/Cloudwatch/monitoring.rb +80 -0
- data/lib/AWS/EC2.rb +33 -0
- data/lib/AWS/EC2/availability_zones.rb +29 -0
- data/lib/AWS/EC2/console.rb +25 -0
- data/lib/AWS/EC2/devpay.rb +18 -0
- data/lib/AWS/EC2/elastic_ips.rb +86 -0
- data/lib/AWS/EC2/image_attributes.rb +133 -0
- data/lib/AWS/EC2/images.rb +117 -0
- data/lib/AWS/EC2/instances.rb +234 -0
- data/lib/AWS/EC2/keypairs.rb +47 -0
- data/lib/AWS/EC2/products.rb +21 -0
- data/lib/AWS/EC2/security_groups.rb +164 -0
- data/lib/AWS/EC2/snapshots.rb +102 -0
- data/lib/AWS/EC2/spot_instance_requests.rb +105 -0
- data/lib/AWS/EC2/volumes.rb +100 -0
- data/lib/AWS/ELB.rb +71 -0
- data/lib/AWS/ELB/load_balancers.rb +178 -0
- data/lib/AWS/RDS.rb +73 -0
- data/lib/AWS/RDS/rds.rb +522 -0
- data/lib/AWS/exceptions.rb +200 -0
- data/lib/AWS/responses.rb +21 -0
- data/perftools/ec2prof +0 -0
- data/perftools/ec2prof-results.dot +132 -0
- data/perftools/ec2prof-results.txt +100 -0
- data/perftools/ec2prof.symbols +102 -0
- data/test/test_Autoscaling_groups.rb +337 -0
- data/test/test_EC2.rb +68 -0
- data/test/test_EC2_availability_zones.rb +49 -0
- data/test/test_EC2_console.rb +54 -0
- data/test/test_EC2_elastic_ips.rb +144 -0
- data/test/test_EC2_image_attributes.rb +238 -0
- data/test/test_EC2_images.rb +229 -0
- data/test/test_EC2_instances.rb +611 -0
- data/test/test_EC2_keypairs.rb +123 -0
- data/test/test_EC2_products.rb +48 -0
- data/test/test_EC2_responses.rb +53 -0
- data/test/test_EC2_s3_xmlsimple.rb +80 -0
- data/test/test_EC2_security_groups.rb +205 -0
- data/test/test_EC2_snapshots.rb +83 -0
- data/test/test_EC2_spot_instance_requests.rb +178 -0
- data/test/test_EC2_volumes.rb +142 -0
- data/test/test_ELB_load_balancers.rb +239 -0
- data/test/test_RDS.rb +354 -0
- data/test/test_helper.rb +23 -0
- data/wsdl/2007-08-29.ec2.wsdl +1269 -0
- data/wsdl/2008-02-01.ec2.wsdl +1614 -0
- data/wsdl/2008-05-05.ec2.wsdl +2052 -0
- data/wsdl/2008-12-01.ec2.wsdl +2354 -0
- data/wsdl/2009-10-31.ec2.wsdl +4261 -0
- data/wsdl/2009-11-30.ec2.wsdl +4668 -0
- metadata +199 -0
@@ -0,0 +1,32 @@
|
|
1
|
+
module AWS
|
2
|
+
module Cloudwatch
|
3
|
+
|
4
|
+
# Which host FQDN will we connect to for all API calls to AWS?
|
5
|
+
# If AWS_CLOUDWATCH_URL is defined in the users ENV we can override the default with that.
|
6
|
+
#
|
7
|
+
# @example
|
8
|
+
# export AWS_CLOUDWATCH_URL='https://montoring.amazonaws.com'
|
9
|
+
if ENV['AWS_CLOUDWATCH_URL']
|
10
|
+
AWS_CLOUDWATCH_URL = ENV['AWS_CLOUDWATCH_URL']
|
11
|
+
VALID_HOSTS = ['monitoring.amazonaws.com']
|
12
|
+
raise ArgumentError, "Invalid AWS_CLOUDWATCH_URL environment variable : #{AWS_CLOUDWATCH_URL}" unless VALID_HOSTS.include?(AWS_CLOUDWATCH_URL)
|
13
|
+
DEFAULT_HOST = URI.parse(AWS_CLOUDWATCH_URL).host
|
14
|
+
else
|
15
|
+
# Default US API endpoint
|
16
|
+
DEFAULT_HOST = 'monitoring.amazonaws.com'
|
17
|
+
end
|
18
|
+
|
19
|
+
API_VERSION = '2009-05-15'
|
20
|
+
|
21
|
+
class Base < AWS::Base
|
22
|
+
def api_version
|
23
|
+
API_VERSION
|
24
|
+
end
|
25
|
+
|
26
|
+
def default_host
|
27
|
+
DEFAULT_HOST
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,80 @@
|
|
1
|
+
module AWS
|
2
|
+
module Cloudwatch
|
3
|
+
class Base < AWS::Base
|
4
|
+
|
5
|
+
# This method call lists available Cloudwatch metrics attached to your EC2
|
6
|
+
# account. To get further information from the metrics, you'll then need to
|
7
|
+
# call get_metric_statistics.
|
8
|
+
#
|
9
|
+
# there are no options available to this method.
|
10
|
+
|
11
|
+
def list_metrics
|
12
|
+
raise ArgumentError, "Server must be monitoring.amazonaws.com" if server != 'monitoring.amazonaws.com'
|
13
|
+
return response_generator(:action => 'ListMetrics', :params => {})
|
14
|
+
end
|
15
|
+
|
16
|
+
# get_metric_statistics pulls a hashed array from Cloudwatch with the stats
|
17
|
+
# of your requested metric.
|
18
|
+
# Once you get the data out, if you assign the results into an object like:
|
19
|
+
# res = @mon.get_metric_statistics(:measure_name => 'RequestCount', \
|
20
|
+
# :statistics => 'Average', :namespace => 'AWS/ELB')
|
21
|
+
#
|
22
|
+
# This call gets the average request count against your ELB at each sampling period
|
23
|
+
# for the last 24 hours. You can then attach a block to the following iterator
|
24
|
+
# to do whatever you need to:
|
25
|
+
# res['GetMetricStatisticsResult']['Datapoints']['member'].each
|
26
|
+
#
|
27
|
+
# @option options [String] :custom_unit (nil) not currently available, placeholder
|
28
|
+
# @option options [String] :dimensions (nil) Option to filter your data on. Check the developer guide
|
29
|
+
# @option options [Time] :end_time (Time.now()) Outer bound of the date range you want to view
|
30
|
+
# @option options [String] :measure_name (nil) The measure you want to check. Must correspond to
|
31
|
+
# => provided options
|
32
|
+
# @option options [String] :namespace ('AWS/EC2') The namespace of your measure_name. Currently, 'AWS/EC2' and 'AWS/ELB' are available
|
33
|
+
# @option options [Integer] :period (60) Granularity in seconds of the returned datapoints. Multiples of 60 only
|
34
|
+
# @option options [String] :statistics (nil) The statistics to be returned for your metric. See the developer guide for valid options. Required.
|
35
|
+
# @option options [Time] :start_time (Time.now() - 86400) Inner bound of the date range you want to view. Defaults to 24 hours ago
|
36
|
+
# @option options [String] :unit (nil) Standard unit for a given Measure. See the developer guide for valid options.
|
37
|
+
|
38
|
+
|
39
|
+
def get_metric_statistics ( options ={} )
|
40
|
+
options = { :custom_unit => nil,
|
41
|
+
:dimensions => nil,
|
42
|
+
:end_time => Time.now(), #req
|
43
|
+
:measure_name => "", #req
|
44
|
+
:namespace => "AWS/EC2",
|
45
|
+
:period => 60,
|
46
|
+
:statistics => "", # req
|
47
|
+
:start_time => (Time.now() - 86400), # Default to yesterday
|
48
|
+
:unit => "" }.merge(options)
|
49
|
+
|
50
|
+
raise ArgumentError, ":end_time must be provided" if options[:end_time].nil?
|
51
|
+
raise ArgumentError, ":end_time must be a Time object" if options[:end_time].class != Time
|
52
|
+
raise ArgumentError, ":start_time must be provided" if options[:start_time].nil?
|
53
|
+
raise ArgumentError, ":start_time must be a Time object" if options[:start_time].class != Time
|
54
|
+
raise ArgumentError, "Server must be monitoring.amazonaws.com" if server != 'monitoring.amazonaws.com'
|
55
|
+
raise ArgumentError, ":start_time must be before :end_time" if options[:start_time] > options[:end_time]
|
56
|
+
raise ArgumentError, ":measure_name must be provided" if options[:measure_name].nil? || options[:measure_name].empty?
|
57
|
+
raise ArgumentError, ":statistics must be provided" if options[:statistics].nil? || options[:statistics].empty?
|
58
|
+
|
59
|
+
params = {
|
60
|
+
"CustomUnit" => options[:custom_unit],
|
61
|
+
"Dimensions" => options[:dimensions],
|
62
|
+
"EndTime" => options[:end_time].iso8601,
|
63
|
+
"MeasureName" => options[:measure_name],
|
64
|
+
"Namespace" => options[:namespace],
|
65
|
+
"Period" => options[:period].to_s,
|
66
|
+
"Statistics.member.1" => options[:statistics],
|
67
|
+
"StartTime" => options[:start_time].iso8601,
|
68
|
+
"Unit" => options[:unit]
|
69
|
+
}
|
70
|
+
|
71
|
+
return response_generator(:action => 'GetMetricStatistics', :params => params)
|
72
|
+
|
73
|
+
end
|
74
|
+
|
75
|
+
end
|
76
|
+
|
77
|
+
end
|
78
|
+
|
79
|
+
end
|
80
|
+
|
data/lib/AWS/EC2.rb
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
module AWS
|
2
|
+
module EC2
|
3
|
+
|
4
|
+
# Which host FQDN will we connect to for all API calls to AWS?
|
5
|
+
# If EC2_URL is defined in the users ENV we can override the default with that.
|
6
|
+
#
|
7
|
+
# @example
|
8
|
+
# export EC2_URL='https://ec2.amazonaws.com'
|
9
|
+
if ENV['EC2_URL']
|
10
|
+
EC2_URL = ENV['EC2_URL']
|
11
|
+
VALID_HOSTS = ['https://ec2.amazonaws.com', 'https://us-east-1.ec2.amazonaws.com', 'https://us-west-1.ec2.amazonaws.com', 'https://eu-west-1.ec2.amazonaws.com']
|
12
|
+
raise ArgumentError, "Invalid EC2_URL environment variable : #{EC2_URL}" unless VALID_HOSTS.include?(EC2_URL)
|
13
|
+
DEFAULT_HOST = URI.parse(EC2_URL).host
|
14
|
+
else
|
15
|
+
# Default US API endpoint
|
16
|
+
DEFAULT_HOST = 'ec2.amazonaws.com'
|
17
|
+
end
|
18
|
+
|
19
|
+
API_VERSION = '2009-11-30'
|
20
|
+
|
21
|
+
class Base < AWS::Base
|
22
|
+
def api_version
|
23
|
+
API_VERSION
|
24
|
+
end
|
25
|
+
|
26
|
+
def default_host
|
27
|
+
DEFAULT_HOST
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module AWS
|
2
|
+
module EC2
|
3
|
+
class Base < AWS::Base
|
4
|
+
|
5
|
+
# The DescribeAvailabilityZones operation describes availability zones that are currently
|
6
|
+
# available to the account and their states.
|
7
|
+
#
|
8
|
+
# An optional list of zone names can be passed.
|
9
|
+
#
|
10
|
+
# @option options [optional, String] :zone_name ([]) an Array of zone names
|
11
|
+
#
|
12
|
+
def describe_availability_zones( options = {} )
|
13
|
+
options = { :zone_name => [] }.merge(options)
|
14
|
+
params = pathlist("ZoneName", options[:zone_name] )
|
15
|
+
return response_generator(:action => "DescribeAvailabilityZones", :params => params)
|
16
|
+
end
|
17
|
+
|
18
|
+
# Not yet implemented
|
19
|
+
#
|
20
|
+
# @todo Implement this method
|
21
|
+
#
|
22
|
+
def describe_regions( options = {} )
|
23
|
+
raise "Not yet implemented"
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module AWS
|
2
|
+
module EC2
|
3
|
+
class Base < AWS::Base
|
4
|
+
|
5
|
+
|
6
|
+
# The GetConsoleOutput operation retrieves console output that has been posted for the specified instance.
|
7
|
+
#
|
8
|
+
# Instance console output is buffered and posted shortly after instance boot, reboot and once the instance
|
9
|
+
# is terminated. Only the most recent 64 KB of posted output is available. Console output is available for
|
10
|
+
# at least 1 hour after the most recent post.
|
11
|
+
#
|
12
|
+
# @option options [String] :instance_id ("") an Instance ID
|
13
|
+
#
|
14
|
+
def get_console_output( options = {} )
|
15
|
+
options = {:instance_id => ""}.merge(options)
|
16
|
+
raise ArgumentError, "No instance ID provided" if options[:instance_id].nil? || options[:instance_id].empty?
|
17
|
+
params = { "InstanceId" => options[:instance_id] }
|
18
|
+
return response_generator(:action => "GetConsoleOutput", :params => params)
|
19
|
+
end
|
20
|
+
|
21
|
+
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
@@ -0,0 +1,86 @@
|
|
1
|
+
module AWS
|
2
|
+
module EC2
|
3
|
+
class Base < AWS::Base
|
4
|
+
|
5
|
+
|
6
|
+
# The AllocateAddress operation acquires an elastic IP address for use with your account.
|
7
|
+
#
|
8
|
+
def allocate_address
|
9
|
+
return response_generator(:action => "AllocateAddress")
|
10
|
+
end
|
11
|
+
|
12
|
+
|
13
|
+
# The AssociateAddress operation associates an elastic IP address with an instance.
|
14
|
+
#
|
15
|
+
# If the IP address is currently assigned to another instance, the IP address
|
16
|
+
# is assigned to the new instance. This is an idempotent operation. If you enter
|
17
|
+
# it more than once, Amazon EC2 does not return an error.
|
18
|
+
#
|
19
|
+
# @option options [String] :instance_id ('') the instance ID to associate an IP with.
|
20
|
+
# @option options [String] :public_ip ('') the public IP to associate an instance with.
|
21
|
+
#
|
22
|
+
def associate_address( options = {} )
|
23
|
+
options = { :instance_id => '', :public_ip => '' }.merge(options)
|
24
|
+
raise ArgumentError, "No ':instance_id' provided" if options[:instance_id].nil? || options[:instance_id].empty?
|
25
|
+
raise ArgumentError, "No ':public_ip' provided" if options[:public_ip].nil? || options[:public_ip].empty?
|
26
|
+
params = {
|
27
|
+
"InstanceId" => options[:instance_id],
|
28
|
+
"PublicIp" => options[:public_ip]
|
29
|
+
}
|
30
|
+
return response_generator(:action => "AssociateAddress", :params => params)
|
31
|
+
end
|
32
|
+
|
33
|
+
|
34
|
+
# The DescribeAddresses operation lists elastic IP addresses assigned to your account.
|
35
|
+
#
|
36
|
+
# @option options [Array] :public_ip ([]) an IP address to be described
|
37
|
+
#
|
38
|
+
def describe_addresses( options = {} )
|
39
|
+
options = { :public_ip => [] }.merge(options)
|
40
|
+
params = pathlist("PublicIp", options[:public_ip])
|
41
|
+
return response_generator(:action => "DescribeAddresses", :params => params)
|
42
|
+
end
|
43
|
+
|
44
|
+
|
45
|
+
# The DisassociateAddress operation disassociates the specified elastic IP
|
46
|
+
# address from the instance to which it is assigned. This is an idempotent
|
47
|
+
# operation. If you enter it more than once, Amazon EC2 does not return
|
48
|
+
# an error.
|
49
|
+
#
|
50
|
+
# @option options [String] :public_ip ('') the public IP to be dis-associated.
|
51
|
+
#
|
52
|
+
def disassociate_address( options = {} )
|
53
|
+
options = { :public_ip => '' }.merge(options)
|
54
|
+
raise ArgumentError, "No ':public_ip' provided" if options[:public_ip].nil? || options[:public_ip].empty?
|
55
|
+
params = { "PublicIp" => options[:public_ip] }
|
56
|
+
return response_generator(:action => "DisassociateAddress", :params => params)
|
57
|
+
end
|
58
|
+
|
59
|
+
|
60
|
+
# The ReleaseAddress operation releases an elastic IP address associated with your account.
|
61
|
+
#
|
62
|
+
# If you run this operation on an elastic IP address that is already released, the address
|
63
|
+
# might be assigned to another account which will cause Amazon EC2 to return an error.
|
64
|
+
#
|
65
|
+
# Note : Releasing an IP address automatically disassociates it from any instance
|
66
|
+
# with which it is associated. For more information, see DisassociateAddress.
|
67
|
+
#
|
68
|
+
# Important! After releasing an elastic IP address, it is released to the IP
|
69
|
+
# address pool and might no longer be available to your account. Make sure
|
70
|
+
# to update your DNS records and any servers or devices that communicate
|
71
|
+
# with the address.
|
72
|
+
#
|
73
|
+
# @option options [String] :public_ip ('') an IP address to be released.
|
74
|
+
#
|
75
|
+
def release_address( options = {} )
|
76
|
+
options = { :public_ip => '' }.merge(options)
|
77
|
+
raise ArgumentError, "No ':public_ip' provided" if options[:public_ip].nil? || options[:public_ip].empty?
|
78
|
+
params = { "PublicIp" => options[:public_ip] }
|
79
|
+
return response_generator(:action => "ReleaseAddress", :params => params)
|
80
|
+
end
|
81
|
+
|
82
|
+
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
@@ -0,0 +1,133 @@
|
|
1
|
+
module AWS
|
2
|
+
module EC2
|
3
|
+
class Base < AWS::Base
|
4
|
+
|
5
|
+
# The ModifyImageAttribute operation modifies an attribute of an AMI. The following attributes may
|
6
|
+
# currently be modified:
|
7
|
+
#
|
8
|
+
# 'launchPermission' : Controls who has permission to launch the AMI. Launch permissions can be
|
9
|
+
# granted to specific users by adding userIds. The AMI can be made public by adding the 'all' group.
|
10
|
+
#
|
11
|
+
# 'productCodes' : Associates product codes with AMIs. This allows a developer to charge a user extra
|
12
|
+
# for using the AMIs. productCodes is a write once attribute - once it has been set it can not be
|
13
|
+
# changed or removed. Currently only one product code is supported per AMI.
|
14
|
+
#
|
15
|
+
# @option options [String] :image_id ("")
|
16
|
+
# @option options [String] :attribute ("launchPermission") An attribute to modify, "launchPermission" or "productCodes"
|
17
|
+
# @option options [String] :operation_type ("")
|
18
|
+
# @option options [optional, Array] :user_id ([])
|
19
|
+
# @option options [optional, Array] :group ([])
|
20
|
+
# @option options [optional, Array] :product_code ([])
|
21
|
+
#
|
22
|
+
def modify_image_attribute( options = {} )
|
23
|
+
|
24
|
+
# defaults
|
25
|
+
options = { :image_id => "",
|
26
|
+
:attribute => "launchPermission",
|
27
|
+
:operation_type => "",
|
28
|
+
:user_id => [],
|
29
|
+
:group => [],
|
30
|
+
:product_code => [] }.merge(options)
|
31
|
+
|
32
|
+
raise ArgumentError, "No ':image_id' provided" if options[:image_id].nil? || options[:image_id].empty?
|
33
|
+
raise ArgumentError, "No ':attribute' provided" if options[:attribute].nil? || options[:attribute].empty?
|
34
|
+
|
35
|
+
# OperationType is not required if modifying a product code.
|
36
|
+
unless options[:attribute] == 'productCodes'
|
37
|
+
raise ArgumentError, "No ':operation_type' provided" if options[:operation_type].nil? || options[:operation_type].empty?
|
38
|
+
end
|
39
|
+
|
40
|
+
params = {
|
41
|
+
"ImageId" => options[:image_id],
|
42
|
+
"Attribute" => options[:attribute],
|
43
|
+
"OperationType" => options[:operation_type]
|
44
|
+
}
|
45
|
+
|
46
|
+
# test options provided and make sure they are valid
|
47
|
+
case options[:attribute]
|
48
|
+
when "launchPermission"
|
49
|
+
|
50
|
+
unless options[:operation_type] == "add" || options[:operation_type] == "remove"
|
51
|
+
raise ArgumentError, ":operation_type was #{options[:operation_type].to_s} but must be either 'add' or 'remove'"
|
52
|
+
end
|
53
|
+
|
54
|
+
if (options[:user_id].nil? || options[:user_id].empty?) && (options[:group].nil? || options[:group].empty?)
|
55
|
+
raise ArgumentError, "Option :attribute=>'launchPermission' requires ':user_id' or ':group' options to also be specified"
|
56
|
+
end
|
57
|
+
params.merge!(pathlist("UserId", options[:user_id])) unless options[:user_id].nil?
|
58
|
+
params.merge!(pathlist("Group", options[:group])) unless options[:group].nil?
|
59
|
+
when "productCodes"
|
60
|
+
if (options[:product_code].nil? || options[:product_code].empty?)
|
61
|
+
raise ArgumentError, "Option :attribute=>'productCodes' requires ':product_code' to be specified"
|
62
|
+
end
|
63
|
+
params.merge!(pathlist("ProductCode", options[:product_code])) unless options[:product_code].nil?
|
64
|
+
else
|
65
|
+
raise ArgumentError, "attribute : #{options[:attribute].to_s} is not an known attribute."
|
66
|
+
end
|
67
|
+
|
68
|
+
return response_generator(:action => "ModifyImageAttribute", :params => params)
|
69
|
+
|
70
|
+
end
|
71
|
+
|
72
|
+
# The DescribeImageAttribute operation returns information about an attribute of an AMI.
|
73
|
+
#
|
74
|
+
# @option options [String] :image_id ("")
|
75
|
+
# @option options [String] :attribute ("launchPermission") An attribute to describe, "launchPermission" or "productCodes"
|
76
|
+
#
|
77
|
+
def describe_image_attribute( options = {} )
|
78
|
+
|
79
|
+
# defaults
|
80
|
+
options = {:image_id => "",
|
81
|
+
:attribute => "launchPermission"
|
82
|
+
}.merge(options)
|
83
|
+
|
84
|
+
raise ArgumentError, "No ':image_id' provided" if options[:image_id].nil? || options[:image_id].empty?
|
85
|
+
raise ArgumentError, "No ':attribute' provided" if options[:attribute].nil? || options[:attribute].empty?
|
86
|
+
|
87
|
+
params = { "ImageId" => options[:image_id], "Attribute" => options[:attribute] }
|
88
|
+
|
89
|
+
# test options provided and make sure they are valid
|
90
|
+
case options[:attribute]
|
91
|
+
when "launchPermission", "productCodes"
|
92
|
+
# these args are ok
|
93
|
+
else
|
94
|
+
raise ArgumentError, "attribute : #{options[:attribute].to_s} is not an known attribute."
|
95
|
+
end
|
96
|
+
|
97
|
+
return response_generator(:action => "DescribeImageAttribute", :params => params)
|
98
|
+
|
99
|
+
end
|
100
|
+
|
101
|
+
|
102
|
+
# The ResetImageAttribute operation resets an attribute of an AMI to its default value.
|
103
|
+
#
|
104
|
+
# @option options [String] :image_id ("")
|
105
|
+
# @option options [String] :attribute ("launchPermission") An attribute to reset
|
106
|
+
#
|
107
|
+
def reset_image_attribute( options = {} )
|
108
|
+
|
109
|
+
# defaults
|
110
|
+
options = {:image_id => "",
|
111
|
+
:attribute => "launchPermission"}.merge(options)
|
112
|
+
|
113
|
+
raise ArgumentError, "No ':image_id' provided" if options[:image_id].nil? || options[:image_id].empty?
|
114
|
+
raise ArgumentError, "No ':attribute' provided" if options[:attribute].nil? || options[:attribute].empty?
|
115
|
+
|
116
|
+
params = {"ImageId" => options[:image_id],
|
117
|
+
"Attribute" => options[:attribute] }
|
118
|
+
|
119
|
+
# test options provided and make sure they are valid
|
120
|
+
case options[:attribute]
|
121
|
+
when "launchPermission"
|
122
|
+
# these args are ok
|
123
|
+
else
|
124
|
+
raise ArgumentError, "attribute : #{options[:attribute].to_s} is not an known attribute."
|
125
|
+
end
|
126
|
+
|
127
|
+
return response_generator(:action => "ResetImageAttribute", :params => params)
|
128
|
+
|
129
|
+
end
|
130
|
+
|
131
|
+
end
|
132
|
+
end
|
133
|
+
end
|
@@ -0,0 +1,117 @@
|
|
1
|
+
module AWS
|
2
|
+
module EC2
|
3
|
+
|
4
|
+
class Base < AWS::Base
|
5
|
+
|
6
|
+
# Creates an AMI that uses an Amazon EBS root device from a "running" or "stopped" instance.
|
7
|
+
#
|
8
|
+
# AMIs that use an Amazon EBS root device boot faster than AMIs that use instance stores.
|
9
|
+
# They can be up to 1 TiB in size, use storage that persists on instance failure, and can be
|
10
|
+
# stopped and started.
|
11
|
+
#
|
12
|
+
# @option options [String] :instance_id ("") The ID of the instance.
|
13
|
+
# @option options [String] :name ("") The name of the AMI that was provided during image creation. Constraints 3-128 alphanumeric characters, parenthesis (()), commas (,), slashes (/), dashes (-), or underscores(_)
|
14
|
+
# @option options [optional,String] :description ("") The description of the AMI that was provided during image creation.
|
15
|
+
# @option options [optional,Boolean] :no_reboot (false) By default this property is set to false, which means Amazon EC2 attempts to cleanly shut down the instance before image creation and reboots the instance afterwards. When set to true, Amazon EC2 does not shut down the instance before creating the image. When this option is used, file system integrity on the created image cannot be guaranteed.
|
16
|
+
#
|
17
|
+
def create_image( options = {} )
|
18
|
+
options = { :instance_id => "", :name => "" }.merge(options)
|
19
|
+
raise ArgumentError, "No :instance_id provided" if options.does_not_have? :instance_id
|
20
|
+
raise ArgumentError, "No :name provided" if options.does_not_have? :name
|
21
|
+
raise ArgumentError, "Invalid string length for :name provided" if options[:name] && options[:name].size < 3 || options[:name].size > 128
|
22
|
+
raise ArgumentError, "Invalid string length for :description provided (too long)" if options[:description] && options[:description].size > 255
|
23
|
+
raise ArgumentError, ":no_reboot option must be a Boolean" unless options[:no_reboot].nil? || [true, false].include?(options[:no_reboot])
|
24
|
+
params = {}
|
25
|
+
params["InstanceId"] = options[:instance_id].to_s
|
26
|
+
params["Name"] = options[:name].to_s
|
27
|
+
params["Description"] = options[:description].to_s
|
28
|
+
params["NoReboot"] = options[:no_reboot].to_s
|
29
|
+
return response_generator(:action => "CreateImage", :params => params)
|
30
|
+
end
|
31
|
+
|
32
|
+
|
33
|
+
# The DeregisterImage operation deregisters an AMI. Once deregistered, instances of the AMI may no
|
34
|
+
# longer be launched.
|
35
|
+
#
|
36
|
+
# @option options [String] :image_id ("")
|
37
|
+
#
|
38
|
+
def deregister_image( options = {} )
|
39
|
+
options = { :image_id => "" }.merge(options)
|
40
|
+
raise ArgumentError, "No :image_id provided" if options[:image_id].nil? || options[:image_id].empty?
|
41
|
+
params = { "ImageId" => options[:image_id] }
|
42
|
+
return response_generator(:action => "DeregisterImage", :params => params)
|
43
|
+
end
|
44
|
+
|
45
|
+
|
46
|
+
# The RegisterImage operation registers an AMI with Amazon EC2. Images must be registered before
|
47
|
+
# they can be launched. Each AMI is associated with an unique ID which is provided by the EC2
|
48
|
+
# service via the Registerimage operation. As part of the registration process, Amazon EC2 will
|
49
|
+
# retrieve the specified image manifest from Amazon S3 and verify that the image is owned by the
|
50
|
+
# user requesting image registration. The image manifest is retrieved once and stored within the
|
51
|
+
# Amazon EC2 network. Any modifications to an image in Amazon S3 invalidate this registration.
|
52
|
+
# If you do have to make changes and upload a new image deregister the previous image and register
|
53
|
+
# the new image.
|
54
|
+
#
|
55
|
+
# @option options [String] :image_location ("")
|
56
|
+
#
|
57
|
+
def register_image( options = {} )
|
58
|
+
options = {:image_location => ""}.merge(options)
|
59
|
+
raise ArgumentError, "No :image_location provided" if options[:image_location].nil? || options[:image_location].empty?
|
60
|
+
params = { "ImageLocation" => options[:image_location] }
|
61
|
+
return response_generator(:action => "RegisterImage", :params => params)
|
62
|
+
end
|
63
|
+
|
64
|
+
|
65
|
+
# The DescribeImages operation returns information about AMIs available for use by the user. This
|
66
|
+
# includes both public AMIs (those available for any user to launch) and private AMIs (those owned by
|
67
|
+
# the user making the request and those owned by other users that the user making the request has explicit
|
68
|
+
# launch permissions for).
|
69
|
+
#
|
70
|
+
# The list of AMIs returned can be modified via optional lists of AMI IDs, owners or users with launch
|
71
|
+
# permissions. If all three optional lists are empty all AMIs the user has launch permissions for are
|
72
|
+
# returned. Launch permissions fall into three categories:
|
73
|
+
#
|
74
|
+
# Launch Permission Description
|
75
|
+
#
|
76
|
+
# public - The all group has launch permissions for the AMI. All users have launch permissions for these AMIs.
|
77
|
+
# explicit - The owner of the AMIs has granted a specific user launch permissions for the AMI.
|
78
|
+
# implicit - A user has implicit launch permissions for all AMIs he or she owns.
|
79
|
+
#
|
80
|
+
# If one or more of the lists are specified the result set is the intersection of AMIs matching the criteria of
|
81
|
+
# the individual lists.
|
82
|
+
#
|
83
|
+
# Providing the list of AMI IDs requests information for those AMIs only. If no AMI IDs are provided,
|
84
|
+
# information of all relevant AMIs will be returned. If an AMI is specified that does not exist a fault is
|
85
|
+
# returned. If an AMI is specified that exists but the user making the request does not have launch
|
86
|
+
# permissions for, then that AMI will not be included in the returned results.
|
87
|
+
#
|
88
|
+
# Providing the list of owners requests information for AMIs owned by the specified owners only. Only
|
89
|
+
# AMIs the user has launch permissions for are returned. The items of the list may be account ids for
|
90
|
+
# AMIs owned by users with those account ids, amazon for AMIs owned by Amazon or self for AMIs
|
91
|
+
# owned by the user making the request.
|
92
|
+
#
|
93
|
+
# The executable list may be provided to request information for AMIs that only the specified users have
|
94
|
+
# launch permissions for. The items of the list may be account ids for AMIs owned by the user making the
|
95
|
+
# request that the users with the specified account ids have explicit launch permissions for, self for AMIs
|
96
|
+
# the user making the request has explicit launch permissions for or all for public AMIs.
|
97
|
+
#
|
98
|
+
# Deregistered images will be included in the returned results for an unspecified interval subsequent to
|
99
|
+
# deregistration.
|
100
|
+
#
|
101
|
+
# @option options [Array] :image_id ([])
|
102
|
+
# @option options [Array] :owner_id ([])
|
103
|
+
# @option options [Array] :executable_by ([])
|
104
|
+
#
|
105
|
+
def describe_images( options = {} )
|
106
|
+
options = { :image_id => [], :owner_id => [], :executable_by => [] }.merge(options)
|
107
|
+
params = pathlist( "ImageId", options[:image_id] )
|
108
|
+
params.merge!(pathlist( "Owner", options[:owner_id] ))
|
109
|
+
params.merge!(pathlist( "ExecutableBy", options[:executable_by] ))
|
110
|
+
return response_generator(:action => "DescribeImages", :params => params)
|
111
|
+
end
|
112
|
+
|
113
|
+
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|