newrelic-amazon-ec2 0.6.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +8 -0
- data/.yardopts +1 -0
- data/ChangeLog +293 -0
- data/LICENSE +66 -0
- data/README.rdoc +354 -0
- data/README_dev.rdoc +12 -0
- data/Rakefile +101 -0
- data/VERSION +1 -0
- data/amazon-ec2.gemspec +134 -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 +28 -0
- data/deps.rip +1 -0
- data/lib/AWS.rb +292 -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 +89 -0
- data/lib/AWS/EC2.rb +33 -0
- data/lib/AWS/EC2/availability_zones.rb +21 -0
- data/lib/AWS/EC2/console.rb +23 -0
- data/lib/AWS/EC2/elastic_ips.rb +81 -0
- data/lib/AWS/EC2/image_attributes.rb +133 -0
- data/lib/AWS/EC2/images.rb +101 -0
- data/lib/AWS/EC2/instances.rb +212 -0
- data/lib/AWS/EC2/keypairs.rb +61 -0
- data/lib/AWS/EC2/products.rb +21 -0
- data/lib/AWS/EC2/security_groups.rb +183 -0
- data/lib/AWS/EC2/snapshots.rb +59 -0
- data/lib/AWS/EC2/volumes.rb +115 -0
- data/lib/AWS/ELB.rb +71 -0
- data/lib/AWS/ELB/load_balancers.rb +178 -0
- data/lib/AWS/exceptions.rb +122 -0
- data/lib/AWS/responses.rb +21 -0
- data/newrelic-amazon-ec2.gemspec +136 -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 +336 -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 +197 -0
- data/test/test_EC2_instances.rb +429 -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_volumes.rb +142 -0
- data/test/test_ELB_load_balancers.rb +239 -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
- metadata +218 -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,89 @@
|
|
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
|
+
"EndTime" => options[:end_time].iso8601,
|
62
|
+
"MeasureName" => options[:measure_name],
|
63
|
+
"Namespace" => options[:namespace],
|
64
|
+
"Period" => options[:period].to_s,
|
65
|
+
"StartTime" => options[:start_time].iso8601,
|
66
|
+
"Unit" => options[:unit]
|
67
|
+
}
|
68
|
+
|
69
|
+
options[:statistics].each_index do |x|
|
70
|
+
params['Statistics.member.' + (x + 1).to_s] = options[:statistics][x]
|
71
|
+
end
|
72
|
+
|
73
|
+
index = 1
|
74
|
+
options[:dimensions].each_pair do |k, v|
|
75
|
+
params['Dimensions.member.' + index.to_s + '.Name'] = k
|
76
|
+
params['Dimensions.member.' + index.to_s + '.Value'] = v
|
77
|
+
index += 1
|
78
|
+
end
|
79
|
+
|
80
|
+
return response_generator(:action => 'GetMetricStatistics', :params => params)
|
81
|
+
|
82
|
+
end
|
83
|
+
|
84
|
+
end
|
85
|
+
|
86
|
+
end
|
87
|
+
|
88
|
+
end
|
89
|
+
|
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://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-07-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
|
33
|
+
|
@@ -0,0 +1,21 @@
|
|
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
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module AWS
|
2
|
+
module EC2
|
3
|
+
class Base < AWS::Base
|
4
|
+
|
5
|
+
# The GetConsoleOutput operation retrieves console output that has been posted for the specified instance.
|
6
|
+
#
|
7
|
+
# Instance console output is buffered and posted shortly after instance boot, reboot and once the instance
|
8
|
+
# is terminated. Only the most recent 64 KB of posted output is available. Console output is available for
|
9
|
+
# at least 1 hour after the most recent post.
|
10
|
+
#
|
11
|
+
# @option options [String] :instance_id ("") an Instance ID
|
12
|
+
#
|
13
|
+
def get_console_output( options = {} )
|
14
|
+
options = {:instance_id => ""}.merge(options)
|
15
|
+
raise ArgumentError, "No instance ID provided" if options[:instance_id].nil? || options[:instance_id].empty?
|
16
|
+
params = { "InstanceId" => options[:instance_id] }
|
17
|
+
return response_generator(:action => "GetConsoleOutput", :params => params)
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
@@ -0,0 +1,81 @@
|
|
1
|
+
module AWS
|
2
|
+
module EC2
|
3
|
+
class Base < AWS::Base
|
4
|
+
|
5
|
+
# The AllocateAddress operation acquires an elastic IP address for use with your account.
|
6
|
+
#
|
7
|
+
def allocate_address
|
8
|
+
return response_generator(:action => "AllocateAddress")
|
9
|
+
end
|
10
|
+
|
11
|
+
# The DescribeAddresses operation lists elastic IP addresses assigned to your account.
|
12
|
+
#
|
13
|
+
# @option options [Array] :public_ip ([]) an IP address to be described
|
14
|
+
#
|
15
|
+
def describe_addresses( options = {} )
|
16
|
+
options = { :public_ip => [] }.merge(options)
|
17
|
+
params = pathlist("PublicIp", options[:public_ip])
|
18
|
+
return response_generator(:action => "DescribeAddresses", :params => params)
|
19
|
+
end
|
20
|
+
|
21
|
+
# The ReleaseAddress operation releases an elastic IP address associated with your account.
|
22
|
+
#
|
23
|
+
# If you run this operation on an elastic IP address that is already released, the address
|
24
|
+
# might be assigned to another account which will cause Amazon EC2 to return an error.
|
25
|
+
#
|
26
|
+
# Note : Releasing an IP address automatically disassociates it from any instance
|
27
|
+
# with which it is associated. For more information, see DisassociateAddress.
|
28
|
+
#
|
29
|
+
# Important! After releasing an elastic IP address, it is released to the IP
|
30
|
+
# address pool and might no longer be available to your account. Make sure
|
31
|
+
# to update your DNS records and any servers or devices that communicate
|
32
|
+
# with the address.
|
33
|
+
#
|
34
|
+
# @option options [String] :public_ip ('') an IP address to be released.
|
35
|
+
#
|
36
|
+
def release_address( options = {} )
|
37
|
+
options = { :public_ip => '' }.merge(options)
|
38
|
+
raise ArgumentError, "No ':public_ip' provided" if options[:public_ip].nil? || options[:public_ip].empty?
|
39
|
+
params = { "PublicIp" => options[:public_ip] }
|
40
|
+
return response_generator(:action => "ReleaseAddress", :params => params)
|
41
|
+
end
|
42
|
+
|
43
|
+
# The AssociateAddress operation associates an elastic IP address with an instance.
|
44
|
+
#
|
45
|
+
# If the IP address is currently assigned to another instance, the IP address
|
46
|
+
# is assigned to the new instance. This is an idempotent operation. If you enter
|
47
|
+
# it more than once, Amazon EC2 does not return an error.
|
48
|
+
#
|
49
|
+
# @option options [String] :instance_id ('') the instance ID to associate an IP with.
|
50
|
+
# @option options [String] :public_ip ('') the public IP to associate an instance with.
|
51
|
+
#
|
52
|
+
def associate_address( options = {} )
|
53
|
+
options = { :instance_id => '', :public_ip => '' }.merge(options)
|
54
|
+
raise ArgumentError, "No ':instance_id' provided" if options[:instance_id].nil? || options[:instance_id].empty?
|
55
|
+
raise ArgumentError, "No ':public_ip' provided" if options[:public_ip].nil? || options[:public_ip].empty?
|
56
|
+
params = {
|
57
|
+
"InstanceId" => options[:instance_id],
|
58
|
+
"PublicIp" => options[:public_ip]
|
59
|
+
}
|
60
|
+
return response_generator(:action => "AssociateAddress", :params => params)
|
61
|
+
end
|
62
|
+
|
63
|
+
# The DisassociateAddress operation disassociates the specified elastic IP
|
64
|
+
# address from the instance to which it is assigned. This is an idempotent
|
65
|
+
# operation. If you enter it more than once, Amazon EC2 does not return
|
66
|
+
# an error.
|
67
|
+
#
|
68
|
+
# @option options [String] :public_ip ('') the public IP to be dis-associated.
|
69
|
+
#
|
70
|
+
def disassociate_address( options = {} )
|
71
|
+
options = { :public_ip => '' }.merge(options)
|
72
|
+
raise ArgumentError, "No ':public_ip' provided" if options[:public_ip].nil? || options[:public_ip].empty?
|
73
|
+
params = { "PublicIp" => options[:public_ip] }
|
74
|
+
return response_generator(:action => "DisassociateAddress", :params => params)
|
75
|
+
end
|
76
|
+
|
77
|
+
end
|
78
|
+
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
@@ -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,101 @@
|
|
1
|
+
module AWS
|
2
|
+
module EC2
|
3
|
+
|
4
|
+
class Base < AWS::Base
|
5
|
+
|
6
|
+
# The RegisterImage operation registers an AMI with Amazon EC2. Images must be registered before
|
7
|
+
# they can be launched. Each AMI is associated with an unique ID which is provided by the EC2
|
8
|
+
# service via the Registerimage operation. As part of the registration process, Amazon EC2 will
|
9
|
+
# retrieve the specified image manifest from Amazon S3 and verify that the image is owned by the
|
10
|
+
# user requesting image registration. The image manifest is retrieved once and stored within the
|
11
|
+
# Amazon EC2 network. Any modifications to an image in Amazon S3 invalidate this registration.
|
12
|
+
# If you do have to make changes and upload a new image deregister the previous image and register
|
13
|
+
# the new image.
|
14
|
+
#
|
15
|
+
# @option options [String] :image_location ("")
|
16
|
+
#
|
17
|
+
def register_image( options = {} )
|
18
|
+
|
19
|
+
options = {:image_location => ""}.merge(options)
|
20
|
+
|
21
|
+
raise ArgumentError, "No :image_location provided" if options[:image_location].nil? || options[:image_location].empty?
|
22
|
+
|
23
|
+
params = { "ImageLocation" => options[:image_location] }
|
24
|
+
|
25
|
+
return response_generator(:action => "RegisterImage", :params => params)
|
26
|
+
|
27
|
+
end
|
28
|
+
|
29
|
+
# The DescribeImages operation returns information about AMIs available for use by the user. This
|
30
|
+
# includes both public AMIs (those available for any user to launch) and private AMIs (those owned by
|
31
|
+
# the user making the request and those owned by other users that the user making the request has explicit
|
32
|
+
# launch permissions for).
|
33
|
+
#
|
34
|
+
# The list of AMIs returned can be modified via optional lists of AMI IDs, owners or users with launch
|
35
|
+
# permissions. If all three optional lists are empty all AMIs the user has launch permissions for are
|
36
|
+
# returned. Launch permissions fall into three categories:
|
37
|
+
#
|
38
|
+
# Launch Permission Description
|
39
|
+
#
|
40
|
+
# public - The all group has launch permissions for the AMI. All users have launch permissions for these AMIs.
|
41
|
+
# explicit - The owner of the AMIs has granted a specific user launch permissions for the AMI.
|
42
|
+
# implicit - A user has implicit launch permissions for all AMIs he or she owns.
|
43
|
+
#
|
44
|
+
# If one or more of the lists are specified the result set is the intersection of AMIs matching the criteria of
|
45
|
+
# the individual lists.
|
46
|
+
#
|
47
|
+
# Providing the list of AMI IDs requests information for those AMIs only. If no AMI IDs are provided,
|
48
|
+
# information of all relevant AMIs will be returned. If an AMI is specified that does not exist a fault is
|
49
|
+
# returned. If an AMI is specified that exists but the user making the request does not have launch
|
50
|
+
# permissions for, then that AMI will not be included in the returned results.
|
51
|
+
#
|
52
|
+
# Providing the list of owners requests information for AMIs owned by the specified owners only. Only
|
53
|
+
# AMIs the user has launch permissions for are returned. The items of the list may be account ids for
|
54
|
+
# AMIs owned by users with those account ids, amazon for AMIs owned by Amazon or self for AMIs
|
55
|
+
# owned by the user making the request.
|
56
|
+
#
|
57
|
+
# The executable list may be provided to request information for AMIs that only the specified users have
|
58
|
+
# launch permissions for. The items of the list may be account ids for AMIs owned by the user making the
|
59
|
+
# request that the users with the specified account ids have explicit launch permissions for, self for AMIs
|
60
|
+
# the user making the request has explicit launch permissions for or all for public AMIs.
|
61
|
+
#
|
62
|
+
# Deregistered images will be included in the returned results for an unspecified interval subsequent to
|
63
|
+
# deregistration.
|
64
|
+
#
|
65
|
+
# @option options [Array] :image_id ([])
|
66
|
+
# @option options [Array] :owner_id ([])
|
67
|
+
# @option options [Array] :executable_by ([])
|
68
|
+
#
|
69
|
+
def describe_images( options = {} )
|
70
|
+
|
71
|
+
options = { :image_id => [], :owner_id => [], :executable_by => [] }.merge(options)
|
72
|
+
|
73
|
+
params = pathlist( "ImageId", options[:image_id] )
|
74
|
+
params.merge!(pathlist( "Owner", options[:owner_id] ))
|
75
|
+
params.merge!(pathlist( "ExecutableBy", options[:executable_by] ))
|
76
|
+
|
77
|
+
return response_generator(:action => "DescribeImages", :params => params)
|
78
|
+
|
79
|
+
end
|
80
|
+
|
81
|
+
# The DeregisterImage operation deregisters an AMI. Once deregistered, instances of the AMI may no
|
82
|
+
# longer be launched.
|
83
|
+
#
|
84
|
+
# @option options [String] :image_id ("")
|
85
|
+
#
|
86
|
+
def deregister_image( options = {} )
|
87
|
+
|
88
|
+
options = { :image_id => "" }.merge(options)
|
89
|
+
|
90
|
+
raise ArgumentError, "No :image_id provided" if options[:image_id].nil? || options[:image_id].empty?
|
91
|
+
|
92
|
+
params = { "ImageId" => options[:image_id] }
|
93
|
+
|
94
|
+
return response_generator(:action => "DeregisterImage", :params => params)
|
95
|
+
|
96
|
+
end
|
97
|
+
|
98
|
+
end
|
99
|
+
|
100
|
+
end
|
101
|
+
end
|