fog 0.2.21 → 0.2.22

Sign up to get free protection for your applications and to get access to all the features.
@@ -7,8 +7,8 @@ Gem::Specification.new do |s|
7
7
  ## If your rubyforge_project name is different, then edit it and comment out
8
8
  ## the sub! line in the Rakefile
9
9
  s.name = 'fog'
10
- s.version = '0.2.21'
11
- s.date = '2010-07-29'
10
+ s.version = '0.2.22'
11
+ s.date = '2010-08-01'
12
12
  s.rubyforge_project = 'fog'
13
13
 
14
14
  ## Make sure your summary is short. The description may be as long
@@ -117,6 +117,7 @@ Gem::Specification.new do |s|
117
117
  lib/fog/aws/parsers/ec2/describe_volumes.rb
118
118
  lib/fog/aws/parsers/ec2/detach_volume.rb
119
119
  lib/fog/aws/parsers/ec2/get_console_output.rb
120
+ lib/fog/aws/parsers/ec2/register_image.rb
120
121
  lib/fog/aws/parsers/ec2/run_instances.rb
121
122
  lib/fog/aws/parsers/ec2/start_stop_instances.rb
122
123
  lib/fog/aws/parsers/ec2/terminate_instances.rb
@@ -170,7 +171,9 @@ Gem::Specification.new do |s|
170
171
  lib/fog/aws/requests/ec2/disassociate_address.rb
171
172
  lib/fog/aws/requests/ec2/get_console_output.rb
172
173
  lib/fog/aws/requests/ec2/modify_image_attributes.rb
174
+ lib/fog/aws/requests/ec2/modify_snapshot_attribute.rb
173
175
  lib/fog/aws/requests/ec2/reboot_instances.rb
176
+ lib/fog/aws/requests/ec2/register_image.rb
174
177
  lib/fog/aws/requests/ec2/release_address.rb
175
178
  lib/fog/aws/requests/ec2/revoke_security_group_ingress.rb
176
179
  lib/fog/aws/requests/ec2/run_instances.rb
data/lib/fog.rb CHANGED
@@ -41,7 +41,7 @@ require 'fog/vcloud'
41
41
  module Fog
42
42
 
43
43
  unless const_defined?(:VERSION)
44
- VERSION = '0.2.21'
44
+ VERSION = '0.2.22'
45
45
  end
46
46
 
47
47
  module Mock
@@ -1,4 +1,4 @@
1
- module Fog
1
+ module Fog
2
2
  module AWS
3
3
  module EC2
4
4
  extend Fog::Service
@@ -54,8 +54,10 @@ module Fog
54
54
  request 'disassociate_address'
55
55
  request 'get_console_output'
56
56
  request 'modify_image_attributes'
57
+ request 'modify_snapshot_attribute'
57
58
  request 'reboot_instances'
58
59
  request 'release_address'
60
+ request 'register_image'
59
61
  request 'revoke_security_group_ingress'
60
62
  request 'run_instances'
61
63
  request 'terminate_instances'
@@ -0,0 +1,20 @@
1
+ module Fog
2
+ module Parsers
3
+ module AWS
4
+ module EC2
5
+
6
+ class RegisterImage < Fog::Parsers::Base
7
+
8
+ def end_element(name)
9
+ case name
10
+ when 'requestId', 'imageId'
11
+ @response[name] = @value
12
+ end
13
+ end
14
+
15
+ end
16
+
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,38 @@
1
+ module Fog
2
+ module AWS
3
+ module EC2
4
+ class Real
5
+
6
+ # Modify snapshot attributes
7
+ #
8
+ # ==== Parameters
9
+ # * snapshot_id<~String> - Id of snapshot to modify
10
+ # * attribute<~String> - Attribute to modify, in ['createVolumePermission']
11
+ # * operation_type<~String> - Operation to perform on attribute, in ['add', 'remove']
12
+ #
13
+ def modify_snapshot_attribute(snapshot_id, attribute, operation_type, options = {})
14
+ params = {}
15
+ params.merge!(AWS.indexed_param('UserId', options['UserId'], 1))
16
+ params.merge!(AWS.indexed_param('UserGroup', options['UserGroup'], 1))
17
+ request({
18
+ 'Action' => 'ModifySnapshotAttribute',
19
+ 'Attribute' => attribute,
20
+ 'SnapshotId' => snapshot_id,
21
+ 'OperationType' => operation_type,
22
+ :idempotent => true,
23
+ :parser => Fog::Parsers::AWS::EC2::Basic.new
24
+ }.merge!(params))
25
+ end
26
+
27
+ end
28
+
29
+ class Mock
30
+
31
+ def modify_snapshot_attribute(snapshot_id, attribute, operation_type, options = {})
32
+ Fog::Mock.not_implemented
33
+ end
34
+
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,89 @@
1
+ module Fog
2
+ module AWS
3
+ module EC2
4
+ class Real
5
+
6
+ require 'fog/aws/parsers/ec2/register_image'
7
+
8
+ # register an image
9
+ #
10
+ # ==== Parameters
11
+ # * Name<~String> - Name of the AMI to be registered
12
+ # * Description<~String> - AMI description
13
+ # * Location<~String> - S3 manifest location (for S3 backed AMIs)
14
+ # or
15
+ # * RootDeviceName<~String> - Name of Root Device (for EBS snapshot backed AMIs)
16
+ # * BlockDevices<~Array>:
17
+ # * BlockDeviceOptions<~Hash>:
18
+ # * DeviceName<~String> - Name of the Block Device
19
+ # * VirtualName<~String> - Name of the Virtual Device
20
+ # * SnapshotId<~String> - id of the EBS Snapshot
21
+ # * VolumeSize<~Integer> - Size of the snapshot (optional)
22
+ # * NoDevice<~Boolean> - Do not use an ebs device (def: true)
23
+ # * DeleteOnTermation<~Boolean> - Delete EBS volume on instance term (def: true)
24
+ # * Options<~Hash>:
25
+ # * Architecture<~String> - i386 or x86_64
26
+ # * KernelId<~String> - kernelId
27
+ # * RamdiskId<~String> - ramdiskId
28
+ #
29
+ # ==== Returns
30
+ # * response<~Excon::Response>:
31
+ # * body<~Hash>:
32
+ # * 'imageId'<~String> - Id of newly created AMI
33
+
34
+ def register_image(name, description, location, block_devices=[], options={})
35
+ common_options = {
36
+ 'Action' => 'RegisterImage',
37
+ 'Name' => name,
38
+ 'Description' => description,
39
+ :parser => Fog::Parsers::AWS::EC2::RegisterImage.new
40
+ }
41
+
42
+ # This determines if we are doing a snapshot or a S3 backed AMI.
43
+ if(location =~ /^\/dev\/sd[a-p]\d{0,2}$/)
44
+ common_options['RootDeviceName'] = location
45
+ else
46
+ common_options['ImageLocation'] = location
47
+ end
48
+
49
+ bdi = 0
50
+ block_devices.each do |bd|
51
+ bdi += 1
52
+ ["DeviceName","VirtualName"].each do |n|
53
+ common_options["BlockDeviceMapping.#{bdi}.#{n}"] = bd["#{n}"] if bd["#{n}"]
54
+ end
55
+ ["SnapshotId","VolumeSize","NoDevice","DeleteOnTermination"].each do |n|
56
+ common_options["BlockDeviceMapping.#{bdi}.Ebs.#{n}"] = bd["#{n}"] if bd["#{n}"]
57
+ end
58
+
59
+ end
60
+
61
+ request(common_options.merge!(options))
62
+ end
63
+
64
+ end
65
+
66
+ class Mock
67
+
68
+ def register_image(name, description, location, block_devices=[], options={})
69
+ response = Excon::Response.new
70
+ if !name.empty?
71
+ response.status = 200
72
+ response.body = {
73
+ 'requestId' => Fog::AWS::Mock.request_id,
74
+ 'imageId' => Fog::AWS::Mock.image_id
75
+ }
76
+ response
77
+ else
78
+ message = 'MissingParameter => '
79
+ if name.empty?
80
+ message << 'The request must contain the parameter name'
81
+ end
82
+ raise Fog::AWS::EC2::Error.new(message)
83
+ end
84
+ end
85
+
86
+ end
87
+ end
88
+ end
89
+ end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 2
8
- - 21
9
- version: 0.2.21
8
+ - 22
9
+ version: 0.2.22
10
10
  platform: ruby
11
11
  authors:
12
12
  - geemus (Wesley Beary)
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-07-29 00:00:00 -07:00
17
+ date: 2010-08-01 00:00:00 -07:00
18
18
  default_executable: fog
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -211,6 +211,7 @@ files:
211
211
  - lib/fog/aws/parsers/ec2/describe_volumes.rb
212
212
  - lib/fog/aws/parsers/ec2/detach_volume.rb
213
213
  - lib/fog/aws/parsers/ec2/get_console_output.rb
214
+ - lib/fog/aws/parsers/ec2/register_image.rb
214
215
  - lib/fog/aws/parsers/ec2/run_instances.rb
215
216
  - lib/fog/aws/parsers/ec2/start_stop_instances.rb
216
217
  - lib/fog/aws/parsers/ec2/terminate_instances.rb
@@ -264,7 +265,9 @@ files:
264
265
  - lib/fog/aws/requests/ec2/disassociate_address.rb
265
266
  - lib/fog/aws/requests/ec2/get_console_output.rb
266
267
  - lib/fog/aws/requests/ec2/modify_image_attributes.rb
268
+ - lib/fog/aws/requests/ec2/modify_snapshot_attribute.rb
267
269
  - lib/fog/aws/requests/ec2/reboot_instances.rb
270
+ - lib/fog/aws/requests/ec2/register_image.rb
268
271
  - lib/fog/aws/requests/ec2/release_address.rb
269
272
  - lib/fog/aws/requests/ec2/revoke_security_group_ingress.rb
270
273
  - lib/fog/aws/requests/ec2/run_instances.rb