fog-aws 0.12.0 → 0.13.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +2 -0
  3. data/CHANGELOG.md +29 -1
  4. data/Gemfile +6 -2
  5. data/gemfiles/Gemfile-edge +1 -1
  6. data/lib/fog/aws.rb +3 -1
  7. data/lib/fog/aws/efs.rb +177 -0
  8. data/lib/fog/aws/models/auto_scaling/group.rb +2 -0
  9. data/lib/fog/aws/models/compute/image.rb +2 -0
  10. data/lib/fog/aws/models/compute/images.rb +3 -1
  11. data/lib/fog/aws/models/compute/vpc.rb +4 -0
  12. data/lib/fog/aws/models/efs/file_system.rb +42 -0
  13. data/lib/fog/aws/models/efs/file_systems.rb +23 -0
  14. data/lib/fog/aws/models/efs/mount_target.rb +59 -0
  15. data/lib/fog/aws/models/efs/mount_targets.rb +25 -0
  16. data/lib/fog/aws/parsers/auto_scaling/describe_auto_scaling_groups.rb +8 -0
  17. data/lib/fog/aws/parsers/cloud_formation/describe_change_set.rb +1 -1
  18. data/lib/fog/aws/parsers/compute/describe_images.rb +3 -1
  19. data/lib/fog/aws/parsers/rds/modify_db_subnet_group.rb +24 -0
  20. data/lib/fog/aws/rds.rb +1 -1
  21. data/lib/fog/aws/requests/auto_scaling/create_auto_scaling_group.rb +1 -0
  22. data/lib/fog/aws/requests/auto_scaling/put_scaling_policy.rb +1 -1
  23. data/lib/fog/aws/requests/cloud_formation/create_change_set.rb +5 -0
  24. data/lib/fog/aws/requests/compute/describe_availability_zones.rb +4 -0
  25. data/lib/fog/aws/requests/compute/describe_images.rb +2 -0
  26. data/lib/fog/aws/requests/efs/create_file_system.rb +51 -0
  27. data/lib/fog/aws/requests/efs/create_mount_target.rb +69 -0
  28. data/lib/fog/aws/requests/efs/delete_file_system.rb +41 -0
  29. data/lib/fog/aws/requests/efs/delete_mount_target.rb +38 -0
  30. data/lib/fog/aws/requests/efs/describe_file_systems.rb +62 -0
  31. data/lib/fog/aws/requests/efs/describe_mount_target_security_groups.rb +34 -0
  32. data/lib/fog/aws/requests/efs/describe_mount_targets.rb +61 -0
  33. data/lib/fog/aws/requests/efs/modify_mount_target_security_groups.rb +39 -0
  34. data/lib/fog/aws/requests/rds/modify_db_subnet_group.rb +27 -0
  35. data/lib/fog/aws/requests/storage/delete_multiple_objects.rb +1 -1
  36. data/lib/fog/aws/requests/sts/assume_role.rb +25 -0
  37. data/lib/fog/aws/version.rb +1 -1
  38. data/tests/helper.rb +3 -2
  39. data/tests/models/efs/file_system_tests.rb +12 -0
  40. data/tests/models/efs/mount_target_tests.rb +43 -0
  41. data/tests/models/efs/mount_targets_tests.rb +30 -0
  42. data/tests/requests/auto_scaling/helper.rb +1 -0
  43. data/tests/requests/compute/image_tests.rb +3 -1
  44. data/tests/requests/efs/file_system_tests.rb +152 -0
  45. data/tests/requests/efs/helper.rb +42 -0
  46. data/tests/requests/storage/object_tests.rb +4 -0
  47. metadata +23 -2
@@ -0,0 +1,25 @@
1
+ require 'fog/aws/models/efs/mount_target'
2
+
3
+ module Fog
4
+ module AWS
5
+ class EFS
6
+ class MountTargets < Fog::Collection
7
+ attribute :file_system_id
8
+
9
+ model Fog::AWS::EFS::MountTarget
10
+
11
+ def all
12
+ data = service.describe_mount_targets(:file_system_id => self.file_system_id).body["MountTargets"]
13
+ load(data)
14
+ end
15
+
16
+ def get(identity)
17
+ data = service.describe_mount_targets(:id => identity).body["MountTargets"].first
18
+ new(data)
19
+ rescue Fog::AWS::EFS::NotFound
20
+ nil
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
@@ -21,6 +21,7 @@ module Fog
21
21
  'LoadBalancerNames' => [],
22
22
  'SuspendedProcesses' => [],
23
23
  'Tags' => [],
24
+ 'TargetGroupARNs' => [],
24
25
  'TerminationPolicies' => []
25
26
  }
26
27
  end
@@ -57,6 +58,8 @@ module Fog
57
58
  @in_suspended_processes = true
58
59
  when 'Tags'
59
60
  @in_tags = true
61
+ when 'TargetGroupARNs'
62
+ @in_target_groups = true
60
63
  when 'TerminationPolicies'
61
64
  @in_termination_policies = true
62
65
  end
@@ -81,6 +84,8 @@ module Fog
81
84
  elsif @in_tags
82
85
  @auto_scaling_group['Tags'] << @tag
83
86
  reset_tag
87
+ elsif @in_target_groups
88
+ @auto_scaling_group['TargetGroupARNs'] << value
84
89
  elsif @in_termination_policies
85
90
  @auto_scaling_group['TerminationPolicies'] << value
86
91
  else
@@ -116,6 +121,9 @@ module Fog
116
121
  when 'Tags'
117
122
  @in_tags = false
118
123
 
124
+ when 'TargetGroupARNs'
125
+ @in_target_groups = false
126
+
119
127
  when 'TerminationPolicies'
120
128
  @in_termination_policies = false
121
129
 
@@ -62,7 +62,7 @@ module Fog
62
62
 
63
63
  def end_element(name)
64
64
  case name
65
- when 'ChangeSetId', 'ChangeSetName', 'Description', 'ExecutionStatus', 'StackId', 'StackName', 'StatusReason'
65
+ when 'ChangeSetId', 'ChangeSetName', 'Description', 'ExecutionStatus', 'StackId', 'StackName', 'StatusReason', 'Status'
66
66
  @response[name] = value
67
67
  when 'CreationTime'
68
68
  @response[name] = Time.parse(value)
@@ -68,12 +68,14 @@ module Fog
68
68
  case name
69
69
  when 'architecture', 'description', 'hypervisor', 'imageId', 'imageLocation', 'imageOwnerAlias', 'imageOwnerId', 'imageState', 'imageType', 'kernelId', 'name', 'platform', 'ramdiskId', 'rootDeviceType','rootDeviceName','virtualizationType'
70
70
  @image[name] = value
71
- when 'isPublic'
71
+ when 'isPublic','enaSupport'
72
72
  if value == 'true'
73
73
  @image[name] = true
74
74
  else
75
75
  @image[name] = false
76
76
  end
77
+ when 'creationDate'
78
+ @image[name] = Time.parse(value)
77
79
  when 'item'
78
80
  @response['imagesSet'] << @image
79
81
  @image = { 'blockDeviceMapping' => [], 'productCodes' => [], 'stateReason' => {}, 'tagSet' => {} }
@@ -0,0 +1,24 @@
1
+ module Fog
2
+ module Parsers
3
+ module AWS
4
+ module RDS
5
+ class ModifyDBSubnetGroup < Fog::Parsers::Base
6
+ def reset
7
+ @response = { 'ModifyDBSubnetGrouptAttributeResult' => {}, 'ResponseMetadata' => {} }
8
+ end
9
+
10
+ def start_element(name, attrs = [])
11
+ super
12
+ end
13
+
14
+ def end_element(name)
15
+ case name
16
+ when 'RequestId'
17
+ @response['ResponseMetadata'][name] = value
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
@@ -51,7 +51,7 @@ module Fog
51
51
  request :create_db_subnet_group
52
52
  request :describe_db_subnet_groups
53
53
  request :delete_db_subnet_group
54
- # TODO: :modify_db_subnet_group
54
+ request :modify_db_subnet_group
55
55
 
56
56
  request :describe_orderable_db_instance_options
57
57
 
@@ -123,6 +123,7 @@ module Fog
123
123
  'PlacementGroup' => nil,
124
124
  'SuspendedProcesses' => [],
125
125
  'Tags' => [],
126
+ 'TargetGroupARNs' => [],
126
127
  'TerminationPolicies' => ['Default'],
127
128
  'VPCZoneIdentifier' => nil
128
129
  }.merge!(options)
@@ -23,7 +23,7 @@ module Fog
23
23
  # Auto Scaling group size). A positive increment adds to the current
24
24
  # capacity and a negative value removes from the current capacity.
25
25
  # * options<~Hash>:
26
- # * 'CoolDown'<~Integer> - The amount of time, in seconds, after a
26
+ # * 'Cooldown'<~Integer> - The amount of time, in seconds, after a
27
27
  # scaling activity completes before any further trigger-related
28
28
  # scaling activities can start
29
29
  #
@@ -16,6 +16,7 @@ module Fog
16
16
  # * UsePreviousTemplate [Boolean] Reuse the template that is associated with the stack to create the change set.
17
17
  # * NotificationARNs [Array] List of SNS topics to publish events to.
18
18
  # * Parameters [Hash] Hash of providers to supply to template.
19
+ # * Capabilities [Array] List of capabilties the stack is granted. Currently CAPABILITY_IAM for allowing the creation of IAM resources.
19
20
  #
20
21
  # @return [Excon::Response]:
21
22
  # * body [Hash:
@@ -59,6 +60,10 @@ module Fog
59
60
  params['TemplateURL'] = options['TemplateURL']
60
61
  end
61
62
 
63
+ if options['Capabilities']
64
+ params.merge!(Fog::AWS.indexed_param("Capabilities.member", [*options['Capabilities']]))
65
+ end
66
+
62
67
  request({
63
68
  'Action' => 'CreateChangeSet',
64
69
  :parser => Fog::Parsers::AWS::CloudFormation::CreateChangeSet.new
@@ -49,6 +49,10 @@ module Fog
49
49
  {"messageSet" => [], "regionName" => "us-east-1", "zoneName" => "us-east-1d", "zoneState" => "available"},
50
50
  {"messageSet" => [], "regionName" => "us-east-1", "zoneName" => "us-east-1e", "zoneState" => "available"},
51
51
 
52
+ {"messageSet" => [], "regionName" => "us-east-2", "zoneName" => "us-east-2a", "zoneState" => "available"},
53
+ {"messageSet" => [], "regionName" => "us-east-2", "zoneName" => "us-east-2b", "zoneState" => "available"},
54
+ {"messageSet" => [], "regionName" => "us-east-2", "zoneName" => "us-east-2c", "zoneState" => "available"},
55
+
52
56
  {"messageSet" => [], "regionName" => "us-west-1", "zoneName" => "us-west-1a", "zoneState" => "available"},
53
57
  {"messageSet" => [], "regionName" => "us-west-1", "zoneName" => "us-west-1b", "zoneState" => "available"},
54
58
  {"messageSet" => [], "regionName" => "us-west-1", "zoneName" => "us-west-1c", "zoneState" => "available"},
@@ -36,6 +36,8 @@ module Fog
36
36
  # * 'rootDeviceName'<~String> - Root device name, e.g. /dev/sda1
37
37
  # * 'rootDeviceType'<~String> - Root device type, ebs or instance-store
38
38
  # * 'virtualizationType'<~String> - Type of virtualization
39
+ # * 'creationDate'time<~Datetime> - Date and time the image was created
40
+ # * 'enaSupport'<~Boolean> - whether or not the image supports enhanced networking
39
41
  #
40
42
  # {Amazon API Reference}[http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-DescribeImages.html]
41
43
  def describe_images(filters = {})
@@ -0,0 +1,51 @@
1
+ module Fog
2
+ module AWS
3
+ class EFS
4
+ class Real
5
+ # Create a new, empty file system
6
+ # http://docs.aws.amazon.com/efs/latest/ug/API_CreateFileSystem.html
7
+ # ==== Parameters
8
+ # * CreationToken <~String> - String of up to 64 ASCII characters. Amazon EFS uses this to ensure idempotent creation.
9
+ # * PerformanceMode <~String> - (Optional) The PerformanceMode of the file system. We recommend generalPurpose performance mode for most file systems. File systems using the maxIO performance mode can scale to higher levels of aggregate throughput and operations per second with a tradeoff of slightly higher latencies for most file operations. This can't be changed after the file system has been created.
10
+ # ==== Returns
11
+ # * response<~Excon::Response>
12
+ # * body<~Hash>
13
+ def create_file_system(creation_token, options={})
14
+ request({
15
+ :path => "file-systems",
16
+ :method => 'POST',
17
+ :expects => 201,
18
+ 'CreationToken' => creation_token,
19
+ 'PerformanceMode' => options[:peformance_mode] || 'generalPurpose'
20
+ })
21
+ end
22
+ end
23
+
24
+ class Mock
25
+ def create_file_system(creation_token, options={})
26
+ response = Excon::Response.new
27
+
28
+ id = "fs-#{Fog::Mock.random_letters(8)}"
29
+ file_system = {
30
+ "OwnerId" => Fog::AWS::Mock.owner_id,
31
+ "CreationToken" => creation_token,
32
+ "PerformanceMode" => options[:performance_mode] || "generalPurpose",
33
+ "FileSystemId" => id,
34
+ "CreationTime" => Time.now.to_i.to_f,
35
+ "LifeCycleState" => "creating",
36
+ "NumberOfMountTargets" => 0,
37
+ "SizeInBytes" => {
38
+ "Value" => 1024,
39
+ "Timestamp" => Time.now.to_i.to_f
40
+ }
41
+ }
42
+
43
+ self.data[:file_systems][id] = file_system
44
+ response.body = file_system
45
+ response.status = 201
46
+ response
47
+ end
48
+ end
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,69 @@
1
+ module Fog
2
+ module AWS
3
+ class EFS
4
+ class Real
5
+ # Create a mount target for a specified file system
6
+ # http://docs.aws.amazon.com/efs/latest/ug/API_CreateMountTarget.html
7
+ # ==== Parameters
8
+ # * FileSystemId <~String> - ID of the file system for which to create the mount target.
9
+ # * IpAddress <~String> - Valid IPv4 address within the address range of the specified subnet.
10
+ # * SecurityGroups <~Array> - Up to five VPC security group IDs, of the form sg-xxxxxxxx. These must be for the same VPC as subnet specified.
11
+ # * SubnetId <~String> - ID of the subnet to add the mount target in.
12
+ # ==== Returns
13
+ # * response<~Excon::Response>
14
+ # * body<~Hash>
15
+ def create_mount_target(file_system_id, subnet_id, options={})
16
+ request({
17
+ :path => "mount-targets",
18
+ :method => "POST",
19
+ 'FileSystemId' => file_system_id,
20
+ 'SubnetId' => subnet_id
21
+ }.merge(options))
22
+ end
23
+ end
24
+
25
+ class Mock
26
+ def create_mount_target(file_system_id, subnet_id, options={})
27
+ response = Excon::Response.new
28
+ default_security_group = mock_compute.data[:security_groups]['default']
29
+ security_groups = options["SecurityGroups"] || [default_security_group['groupId']]
30
+
31
+ unless file_system = self.data[:file_systems][file_system_id]
32
+ raise Fog::AWS::EFS::NotFound.new("invalid file system ID: #{file_system_id}")
33
+ end
34
+
35
+ unless file_system["LifeCycleState"] == 'available'
36
+ # this error doesn't include a message for some reason
37
+ raise Fog::AWS::EFS::IncorrectFileSystemLifeCycleState.new("")
38
+ end
39
+
40
+ unless subnet = mock_compute.subnets.get(subnet_id)
41
+ raise Fog::AWS::EFS::InvalidSubnet.new("invalid subnet ID: #{subnet_id}")
42
+ end
43
+
44
+ security_groups.each do |sg|
45
+ raise Fog::AWS::EFS::NotFound.new("invalid security group ID: #{sg}") unless mock_compute.data[:security_groups].values.detect { |sgd| sgd["groupId"] == sg }
46
+ end
47
+
48
+ id = "fsmt-#{Fog::Mock.random_letters(8)}"
49
+
50
+ mount_target = {
51
+ 'MountTargetId' => id,
52
+ 'FileSystemId' => file_system_id,
53
+ 'IpAddress' => Fog::AWS::Mock.ip_address,
54
+ 'OwnerId' => Fog::AWS::Mock.owner_id,
55
+ 'LifeCycleState' => 'creating',
56
+ 'NetworkInterfaceId' => "eni-#{Fog::Mock.random_hex(8)}",
57
+ 'SubnetId' => subnet.identity,
58
+ }
59
+
60
+ self.data[:mount_targets][id] = mount_target
61
+ self.data[:security_groups][id] = security_groups
62
+
63
+ response.body = mount_target
64
+ response
65
+ end
66
+ end
67
+ end
68
+ end
69
+ end
@@ -0,0 +1,41 @@
1
+ module Fog
2
+ module AWS
3
+ class EFS
4
+ class Real
5
+ # Delete a file system
6
+ # http://docs.aws.amazon.com/efs/latest/ug/API_DeleteFileSystem.html
7
+ # ==== Parameters
8
+ # * FileSystemId <~String> - ID of the file system you want to delete.
9
+ # ==== Returns
10
+ # * response<~Excon::Response>
11
+ # * body - Empty
12
+ # * status - 204
13
+ def delete_file_system(id)
14
+ request({
15
+ :path => "file-systems/#{id}",
16
+ :method => 'DELETE',
17
+ :expects => 204,
18
+ })
19
+ end
20
+ end
21
+
22
+ class Mock
23
+ def delete_file_system(id)
24
+ unless file_system = self.data[:file_systems][id]
25
+ raise Fog::AWS::EFS::NotFound.new("invalid file system ID: #{id}")
26
+ end
27
+
28
+ if file_system["NumberOfMountTargets"] > 0
29
+ raise Fog::AWS::EFS::FileSystemInUse.new("")
30
+ end
31
+
32
+ self.data[:file_systems].delete(id)
33
+
34
+ response = Excon::Response.new
35
+ response.status = 204
36
+ response
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,38 @@
1
+ module Fog
2
+ module AWS
3
+ class EFS
4
+ class Real
5
+ # Delete a mount target
6
+ # http://docs.aws.amazon.com/efs/latest/ug/API_DeleteMountTarget.html
7
+ # ==== Parameters
8
+ # * MountTargetId <~String> - ID of the mount target you want to delete
9
+ # ==== Returns
10
+ # * response<~Excon::Response>
11
+ # * body - Empty
12
+ # * status - 204
13
+ def delete_mount_target(id)
14
+ request(
15
+ :path => "mount-targets/#{id}",
16
+ :method => "DELETE",
17
+ :expects => 204
18
+ )
19
+ end
20
+ end
21
+
22
+ class Mock
23
+ def delete_mount_target(id)
24
+ response = Excon::Response.new
25
+
26
+ unless self.data[:mount_targets][id]
27
+ raise Fog::AWS::EFS::NotFound.new("invalid mount target ID: #{id}")
28
+ end
29
+
30
+ self.data[:mount_targets].delete(id)
31
+
32
+ response.status = 204
33
+ response
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,62 @@
1
+ module Fog
2
+ module AWS
3
+ class EFS
4
+ class Real
5
+ # Describe all or specified elastic file systems
6
+ # http://docs.aws.amazon.com/efs/latest/ug/API_DescribeFileSystems.html
7
+ # ==== Parameters
8
+ # * CreationToken <~String> - (Optional) Restricts the list to the file system with this creation token (String). You specify a creation token when you create an Amazon EFS file system.
9
+ # * FileSystemId <~String> - (Optional) ID of the file system whose description you want to retrieve (String).
10
+ # ==== Returns
11
+ # * response<~Excon::Response>:
12
+ # * body<~Hash>
13
+ def describe_file_systems(options={})
14
+ params = {}
15
+ if options[:marker]
16
+ params['Marker'] = options[:marker]
17
+ end
18
+ if options[:max_records]
19
+ params['MaxRecords'] = options[:max_records]
20
+ end
21
+ if options[:id]
22
+ params['FileSystemId'] = options[:id]
23
+ end
24
+ if options[:creation_token]
25
+ params['CreationToken'] = options[:creation_token]
26
+ end
27
+
28
+ request({
29
+ :path => "file-systems"
30
+ }.merge(params))
31
+ end
32
+ end
33
+
34
+ class Mock
35
+ def describe_file_systems(options={})
36
+ response = Excon::Response.new
37
+
38
+ file_systems = if id = options[:id]
39
+ if fs = self.data[:file_systems][id]
40
+ [fs]
41
+ else
42
+ raise Fog::AWS::EFS::NotFound.new("invalid file system ID: #{id}")
43
+ end
44
+ elsif creation_token = options[:creation_token]
45
+ fs = self.data[:file_systems].values.detect { |file_system| file_system["CreationToken"] == creation_token }
46
+ [fs]
47
+ else
48
+ self.data[:file_systems].values
49
+ end
50
+
51
+ file_systems.each do |file_system|
52
+ file_system['LifeCycleState'] = 'available'
53
+ self.data[:file_systems][file_system['FileSystemId']] = file_system
54
+ end
55
+
56
+ response.body = {"FileSystems" => file_systems}
57
+ response
58
+ end
59
+ end
60
+ end
61
+ end
62
+ end