geemus-fog 0.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (153) hide show
  1. data/.document +5 -0
  2. data/.gitignore +6 -0
  3. data/LICENSE +20 -0
  4. data/README.rdoc +7 -0
  5. data/Rakefile +94 -0
  6. data/VERSION +1 -0
  7. data/benchs/fog_vs.rb +76 -0
  8. data/benchs/headers_split_vs_match.rb +18 -0
  9. data/benchs/params.rb +43 -0
  10. data/benchs/parse_vs_push.rb +60 -0
  11. data/benchs/stripping.rb +26 -0
  12. data/lib/fog/aws/ec2.rb +159 -0
  13. data/lib/fog/aws/parsers/ec2/allocate_address.rb +19 -0
  14. data/lib/fog/aws/parsers/ec2/attach_volume.rb +22 -0
  15. data/lib/fog/aws/parsers/ec2/basic.rb +25 -0
  16. data/lib/fog/aws/parsers/ec2/create_key_pair.rb +20 -0
  17. data/lib/fog/aws/parsers/ec2/create_snapshot.rb +22 -0
  18. data/lib/fog/aws/parsers/ec2/create_volume.rb +24 -0
  19. data/lib/fog/aws/parsers/ec2/describe_addresses.rb +30 -0
  20. data/lib/fog/aws/parsers/ec2/describe_availability_zones.rb +30 -0
  21. data/lib/fog/aws/parsers/ec2/describe_images.rb +49 -0
  22. data/lib/fog/aws/parsers/ec2/describe_instances.rb +73 -0
  23. data/lib/fog/aws/parsers/ec2/describe_key_pairs.rb +30 -0
  24. data/lib/fog/aws/parsers/ec2/describe_regions.rb +30 -0
  25. data/lib/fog/aws/parsers/ec2/describe_security_groups.rb +75 -0
  26. data/lib/fog/aws/parsers/ec2/describe_snapshots.rb +30 -0
  27. data/lib/fog/aws/parsers/ec2/describe_volumes.rb +57 -0
  28. data/lib/fog/aws/parsers/ec2/detach_volume.rb +22 -0
  29. data/lib/fog/aws/parsers/ec2/get_console_output.rb +28 -0
  30. data/lib/fog/aws/parsers/ec2/run_instances.rb +65 -0
  31. data/lib/fog/aws/parsers/ec2/terminate_instances.rb +55 -0
  32. data/lib/fog/aws/parsers/s3/copy_object.rb +22 -0
  33. data/lib/fog/aws/parsers/s3/get_bucket.rb +46 -0
  34. data/lib/fog/aws/parsers/s3/get_bucket_location.rb +20 -0
  35. data/lib/fog/aws/parsers/s3/get_request_payment.rb +20 -0
  36. data/lib/fog/aws/parsers/s3/get_service.rb +32 -0
  37. data/lib/fog/aws/parsers/simpledb/basic.rb +31 -0
  38. data/lib/fog/aws/parsers/simpledb/domain_metadata.rb +30 -0
  39. data/lib/fog/aws/parsers/simpledb/get_attributes.rb +34 -0
  40. data/lib/fog/aws/parsers/simpledb/list_domains.rb +28 -0
  41. data/lib/fog/aws/parsers/simpledb/select.rb +39 -0
  42. data/lib/fog/aws/requests/ec2/allocate_address.rb +50 -0
  43. data/lib/fog/aws/requests/ec2/associate_address.rb +26 -0
  44. data/lib/fog/aws/requests/ec2/attach_volume.rb +32 -0
  45. data/lib/fog/aws/requests/ec2/authorize_security_group_ingress.rb +32 -0
  46. data/lib/fog/aws/requests/ec2/create_key_pair.rb +60 -0
  47. data/lib/fog/aws/requests/ec2/create_security_group.rb +61 -0
  48. data/lib/fog/aws/requests/ec2/create_snapshot.rb +28 -0
  49. data/lib/fog/aws/requests/ec2/create_volume.rb +66 -0
  50. data/lib/fog/aws/requests/ec2/delete_key_pair.rb +49 -0
  51. data/lib/fog/aws/requests/ec2/delete_security_group.rb +52 -0
  52. data/lib/fog/aws/requests/ec2/delete_snapshot.rb +24 -0
  53. data/lib/fog/aws/requests/ec2/delete_volume.rb +55 -0
  54. data/lib/fog/aws/requests/ec2/describe_addresses.rb +61 -0
  55. data/lib/fog/aws/requests/ec2/describe_availability_zones.rb +27 -0
  56. data/lib/fog/aws/requests/ec2/describe_images.rb +41 -0
  57. data/lib/fog/aws/requests/ec2/describe_instances.rb +48 -0
  58. data/lib/fog/aws/requests/ec2/describe_key_pairs.rb +63 -0
  59. data/lib/fog/aws/requests/ec2/describe_regions.rb +26 -0
  60. data/lib/fog/aws/requests/ec2/describe_security_groups.rb +71 -0
  61. data/lib/fog/aws/requests/ec2/describe_snapshots.rb +29 -0
  62. data/lib/fog/aws/requests/ec2/describe_volumes.rb +85 -0
  63. data/lib/fog/aws/requests/ec2/detach_volume.rb +32 -0
  64. data/lib/fog/aws/requests/ec2/disassociate_address.rb +24 -0
  65. data/lib/fog/aws/requests/ec2/get_console_output.rb +26 -0
  66. data/lib/fog/aws/requests/ec2/reboot_instances.rb +24 -0
  67. data/lib/fog/aws/requests/ec2/release_address.rb +50 -0
  68. data/lib/fog/aws/requests/ec2/revoke_security_group_ingress.rb +32 -0
  69. data/lib/fog/aws/requests/ec2/run_instances.rb +74 -0
  70. data/lib/fog/aws/requests/ec2/terminate_instances.rb +31 -0
  71. data/lib/fog/aws/requests/s3/copy_object.rb +80 -0
  72. data/lib/fog/aws/requests/s3/delete_bucket.rb +49 -0
  73. data/lib/fog/aws/requests/s3/delete_object.rb +52 -0
  74. data/lib/fog/aws/requests/s3/get_bucket.rb +92 -0
  75. data/lib/fog/aws/requests/s3/get_bucket_location.rb +53 -0
  76. data/lib/fog/aws/requests/s3/get_object.rb +81 -0
  77. data/lib/fog/aws/requests/s3/get_request_payment.rb +53 -0
  78. data/lib/fog/aws/requests/s3/get_service.rb +58 -0
  79. data/lib/fog/aws/requests/s3/head_object.rb +61 -0
  80. data/lib/fog/aws/requests/s3/put_bucket.rb +69 -0
  81. data/lib/fog/aws/requests/s3/put_object.rb +75 -0
  82. data/lib/fog/aws/requests/s3/put_request_payment.rb +56 -0
  83. data/lib/fog/aws/requests/simpledb/batch_put_attributes.rb +31 -0
  84. data/lib/fog/aws/requests/simpledb/create_domain.rb +25 -0
  85. data/lib/fog/aws/requests/simpledb/delete_attributes.rb +34 -0
  86. data/lib/fog/aws/requests/simpledb/delete_domain.rb +25 -0
  87. data/lib/fog/aws/requests/simpledb/domain_metadata.rb +30 -0
  88. data/lib/fog/aws/requests/simpledb/get_attributes.rb +35 -0
  89. data/lib/fog/aws/requests/simpledb/list_domains.rb +30 -0
  90. data/lib/fog/aws/requests/simpledb/put_attributes.rb +29 -0
  91. data/lib/fog/aws/requests/simpledb/select.rb +29 -0
  92. data/lib/fog/aws/s3.rb +143 -0
  93. data/lib/fog/aws/simpledb.rb +157 -0
  94. data/lib/fog/aws.rb +127 -0
  95. data/lib/fog/connection.rb +122 -0
  96. data/lib/fog/errors.rb +131 -0
  97. data/lib/fog/parser.rb +30 -0
  98. data/lib/fog/response.rb +12 -0
  99. data/lib/fog.rb +22 -0
  100. data/spec/aws/ec2/allocate_address_spec.rb +20 -0
  101. data/spec/aws/ec2/associate_address_spec.rb +22 -0
  102. data/spec/aws/ec2/attach_volume_spec.rb +33 -0
  103. data/spec/aws/ec2/authorize_security_group_ingress_spec.rb +25 -0
  104. data/spec/aws/ec2/create_key_pair_spec.rb +27 -0
  105. data/spec/aws/ec2/create_security_group_spec.rb +25 -0
  106. data/spec/aws/ec2/create_snapshot_spec.rb +27 -0
  107. data/spec/aws/ec2/create_volume_spec.rb +25 -0
  108. data/spec/aws/ec2/delete_key_pair_spec.rb +20 -0
  109. data/spec/aws/ec2/delete_security_group_spec.rb +22 -0
  110. data/spec/aws/ec2/delete_snapshot_spec.rb +25 -0
  111. data/spec/aws/ec2/delete_volume_spec.rb +22 -0
  112. data/spec/aws/ec2/describe_addresses_spec.rb +34 -0
  113. data/spec/aws/ec2/describe_availability_zones_spec.rb +25 -0
  114. data/spec/aws/ec2/describe_images_spec.rb +41 -0
  115. data/spec/aws/ec2/describe_instances_spec.rb +76 -0
  116. data/spec/aws/ec2/describe_key_pairs_spec.rb +38 -0
  117. data/spec/aws/ec2/describe_regions_spec.rb +23 -0
  118. data/spec/aws/ec2/describe_security_groups_spec.rb +47 -0
  119. data/spec/aws/ec2/describe_snapshot_spec.rb +44 -0
  120. data/spec/aws/ec2/describe_volumes_spec.rb +46 -0
  121. data/spec/aws/ec2/detach_volume_spec.rb +33 -0
  122. data/spec/aws/ec2/disassociate_address_spec.rb +23 -0
  123. data/spec/aws/ec2/get_console_output_spec.rb +22 -0
  124. data/spec/aws/ec2/reboot_instances_spec.rb +20 -0
  125. data/spec/aws/ec2/release_address_spec.rb +22 -0
  126. data/spec/aws/ec2/revoke_security_group_ingress_spec.rb +31 -0
  127. data/spec/aws/ec2/run_instances_spec.rb +43 -0
  128. data/spec/aws/ec2/terminate_instances_spec.rb +25 -0
  129. data/spec/aws/s3/copy_object_spec.rb +57 -0
  130. data/spec/aws/s3/delete_bucket_spec.rb +21 -0
  131. data/spec/aws/s3/delete_object_spec.rb +31 -0
  132. data/spec/aws/s3/get_bucket_location_spec.rb +30 -0
  133. data/spec/aws/s3/get_bucket_spec.rb +42 -0
  134. data/spec/aws/s3/get_object_spec.rb +40 -0
  135. data/spec/aws/s3/get_request_payment_spec.rb +26 -0
  136. data/spec/aws/s3/get_service_spec.rb +32 -0
  137. data/spec/aws/s3/head_object_spec.rb +27 -0
  138. data/spec/aws/s3/put_bucket_spec.rb +22 -0
  139. data/spec/aws/s3/put_object_spec.rb +34 -0
  140. data/spec/aws/s3/put_request_payment_spec.rb +25 -0
  141. data/spec/aws/simpledb/batch_put_attributes_spec.rb +21 -0
  142. data/spec/aws/simpledb/create_domain_spec.rb +20 -0
  143. data/spec/aws/simpledb/delete_attributes_spec.rb +21 -0
  144. data/spec/aws/simpledb/delete_domain_spec.rb +20 -0
  145. data/spec/aws/simpledb/domain_metadata_spec.rb +42 -0
  146. data/spec/aws/simpledb/get_attributes_spec.rb +30 -0
  147. data/spec/aws/simpledb/list_domains_spec.rb +29 -0
  148. data/spec/aws/simpledb/put_attributes_spec.rb +21 -0
  149. data/spec/aws/simpledb/select_spec.rb +7 -0
  150. data/spec/lorem.txt +1 -0
  151. data/spec/spec.opts +1 -0
  152. data/spec/spec_helper.rb +74 -0
  153. metadata +256 -0
@@ -0,0 +1,24 @@
1
+ module Fog
2
+ module AWS
3
+ class EC2
4
+
5
+ # Delete a snapshot of an EBS volume that you own
6
+ #
7
+ # ==== Parameters
8
+ # * snapshot_id<~String> - ID of snapshot to delete
9
+ # ==== Returns
10
+ # ==== Returns
11
+ # * response<~Fog::AWS::Response>:
12
+ # * body<~Hash>:
13
+ # * 'requestId'<~String> - Id of request
14
+ # * 'return'<~Boolean> - success?
15
+ def delete_snapshot(snapshot_id)
16
+ request({
17
+ 'Action' => 'DeleteSnapshot',
18
+ 'SnapshotId' => snapshot_id
19
+ }, Fog::Parsers::AWS::EC2::Basic.new)
20
+ end
21
+
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,55 @@
1
+ unless Fog.mocking?
2
+
3
+ module Fog
4
+ module AWS
5
+ class EC2
6
+
7
+ # Delete an EBS volume
8
+ #
9
+ # ==== Parameters
10
+ # * volume_id<~String> - Id of volume to delete.
11
+ #
12
+ # ==== Returns
13
+ # * response<~Fog::AWS::Response>:
14
+ # * body<~Hash>:
15
+ # * 'requestId'<~String> - Id of request
16
+ # * 'return'<~Boolean> - success?
17
+ def delete_volume(volume_id)
18
+ request({
19
+ 'Action' => 'DeleteVolume',
20
+ 'VolumeId' => volume_id
21
+ }, Fog::Parsers::AWS::EC2::Basic.new)
22
+ end
23
+
24
+ end
25
+ end
26
+ end
27
+
28
+ else
29
+
30
+ module Fog
31
+ module AWS
32
+ class EC2
33
+
34
+ def delete_volume(volume_id)
35
+ response = Fog::Response.new
36
+ if volume = @data[:volumes][volume_id]
37
+ @data[:deleted_at][volume['volumeId']] = Time.now
38
+ volume['status'] = 'deleting'
39
+ response.status = 200
40
+ response.body = {
41
+ 'requestId' => Fog::AWS::Mock.request_id,
42
+ 'return' => true
43
+ }
44
+ else
45
+ response.status = 400
46
+ raise(Fog::Errors.status_error(200, 400, response))
47
+ end
48
+ response
49
+ end
50
+
51
+ end
52
+ end
53
+ end
54
+
55
+ end
@@ -0,0 +1,61 @@
1
+ unless Fog.mocking?
2
+
3
+ module Fog
4
+ module AWS
5
+ class EC2
6
+
7
+ # Describe all or specified IP addresses.
8
+ #
9
+ # ==== Parameters
10
+ # * public_ip<~Array> - List of ips to describe, defaults to all
11
+ #
12
+ # ==== Returns
13
+ # * response<~Fog::AWS::Response>:
14
+ # * body<~Hash>:
15
+ # * 'requestId'<~String> - Id of request
16
+ # * 'addressesSet'<~Array>:
17
+ # * 'instanceId'<~String> - instance for ip address
18
+ # * 'publicIp'<~String> - ip address for instance
19
+ def describe_addresses(public_ip = [])
20
+ params = indexed_params('PublicIp', public_ip)
21
+ request({
22
+ 'Action' => 'DescribeAddresses'
23
+ }.merge!(params), Fog::Parsers::AWS::EC2::DescribeAddresses.new)
24
+ end
25
+
26
+ end
27
+ end
28
+ end
29
+
30
+ else
31
+
32
+ module Fog
33
+ module AWS
34
+ class EC2
35
+
36
+ def describe_addresses(public_ip = [])
37
+ public_ip = [*public_ip]
38
+ response = Fog::Response.new
39
+ if public_ip != []
40
+ addresses_set = @data[:addresses].reject {|key, value| !public_ip.include?(key)}.values
41
+ else
42
+ addresses_set = @data[:addresses].values
43
+ end
44
+ if public_ip.length == 0 || public_ip.length == addresses_set.length
45
+ response.status = 200
46
+ response.body = {
47
+ 'requestId' => Fog::AWS::Mock.request_id,
48
+ 'addressesSet' => addresses_set
49
+ }
50
+ else
51
+ response.status = 400
52
+ raise(Fog::Errors.status_error(200, 400, response))
53
+ end
54
+ response
55
+ end
56
+
57
+ end
58
+ end
59
+ end
60
+
61
+ end
@@ -0,0 +1,27 @@
1
+ module Fog
2
+ module AWS
3
+ class EC2
4
+
5
+ # Describe all or specified availability zones
6
+ #
7
+ # ==== Params
8
+ # * zone_name<~String> - List of availability zones to describe, defaults to all
9
+ #
10
+ # ==== Returns
11
+ # * response<~Fog::AWS::Response>:
12
+ # * body<~Hash>:
13
+ # * 'requestId'<~String> - Id of request
14
+ # * 'availabilityZoneInfo'<~Array>:
15
+ # * 'regionName'<~String> - Name of region
16
+ # * 'zoneName'<~String> - Name of zone
17
+ # * 'zoneState'<~String> - State of zone
18
+ def describe_availability_zones(zone_name = [])
19
+ params = indexed_params('ZoneName', zone_name)
20
+ request({
21
+ 'Action' => 'DescribeAvailabilityZones'
22
+ }.merge!(params), Fog::Parsers::AWS::EC2::DescribeAvailabilityZones.new)
23
+ end
24
+
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,41 @@
1
+ module Fog
2
+ module AWS
3
+ class EC2
4
+
5
+ # Describe all or specified images.
6
+ #
7
+ # ==== Params
8
+ # * options<~Hash> - Optional params
9
+ # * 'ExecutableBy'<~String> - Only return images that the executable_by
10
+ # user has explicit permission to launch
11
+ # * 'ImageId'<~Array> - Ids of images to describe
12
+ # * 'Owner'<~String> - Only return images belonging to owner.
13
+ #
14
+ # ==== Returns
15
+ # * response<~Fog::AWS::Response>:
16
+ # * body<~Hash>:
17
+ # * 'requestId'<~String> - Id of request
18
+ # * 'imagesSet'<~Array>:
19
+ # * 'architecture'<~String> - Architecture of the image
20
+ # * 'imageId'<~String> - Id of the image
21
+ # * 'imageLocation'<~String> - Location of the image
22
+ # * 'imageOwnerId'<~String> - Id of the owner of the image
23
+ # * 'imageState'<~String> - State of the image
24
+ # * 'imageType'<~String> - Type of the image
25
+ # * 'isPublic'<~Boolean> - Whether or not the image is public
26
+ # * 'kernelId'<~String> - Kernel id associated with image, if any
27
+ # * 'platform'<~String> - Operating platform of the image
28
+ # * 'productCodes'<~Array> - Product codes for the image
29
+ # * 'ramdiskId'<~String> - Ramdisk id associated with image, if any
30
+ def describe_images(options = {})
31
+ if image_id = options.delete('ImageId')
32
+ options.merge!(indexed_params('ImageId', image_id))
33
+ end
34
+ request({
35
+ 'Action' => 'DescribeImages'
36
+ }.merge!(options), Fog::Parsers::AWS::EC2::DescribeImages.new)
37
+ end
38
+
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,48 @@
1
+ module Fog
2
+ module AWS
3
+ class EC2
4
+
5
+ # Describe all or specified instances
6
+ #
7
+ # ==== Parameters
8
+ # * instance_id<~Array> - List of instance ids to describe, defaults to all
9
+ #
10
+ # ==== Returns
11
+ # * response<~Fog::AWS::Response>:
12
+ # * body<~Hash>:
13
+ # * 'requestId'<~String> - Id of request
14
+ # * 'reservationSet'<~Array>:
15
+ # * 'groupSet'<~Array> - Group names for reservation
16
+ # * 'ownerId'<~String> - AWS Access Key ID of reservation owner
17
+ # * 'reservationId'<~String> - Id of the reservation
18
+ # * 'instancesSet'<~Array>:
19
+ # * instance<~Hash>:
20
+ # * 'amiLaunchIndex'<~Integer> - reference to instance in launch group
21
+ # * 'dnsName'<~String> - public dns name, blank until instance is running
22
+ # * 'imageId'<~String> - image id of ami used to launch instance
23
+ # * 'instanceId'<~String> - id of the instance
24
+ # * 'instanceState'<~Hash>:
25
+ # * 'code'<~Integer> - current status code
26
+ # * 'name'<~String> - current status name
27
+ # * 'instanceType'<~String> - type of instance
28
+ # * 'kernelId'<~String> - Id of kernel used to launch instance
29
+ # * 'keyName'<~String> - name of key used launch instances or blank
30
+ # * 'launchTime'<~Time> - time instance was launched
31
+ # * 'monitoring'<~Hash>:
32
+ # * 'state'<~Boolean - state of monitoring
33
+ # * 'placement'<~Hash>:
34
+ # * 'availabilityZone'<~String> - Availability zone of the instance
35
+ # * 'productCodes'<~Array> - Product codes for the instance
36
+ # * 'privateDnsName'<~String> - private dns name, blank until instance is running
37
+ # * 'ramdiskId'<~String> - Id of ramdisk used to launch instance
38
+ # * 'reason'<~String> - reason for most recent state transition, or blank
39
+ def describe_instances(instance_id = [])
40
+ params = indexed_params('InstanceId', instance_id)
41
+ request({
42
+ 'Action' => 'DescribeInstances'
43
+ }.merge!(params), Fog::Parsers::AWS::EC2::DescribeInstances.new)
44
+ end
45
+
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,63 @@
1
+ unless Fog.mocking?
2
+
3
+ module Fog
4
+ module AWS
5
+ class EC2
6
+
7
+ # Describe all or specified key pairs
8
+ #
9
+ # ==== Parameters
10
+ # * key_name<~Array>:: List of key names to describe, defaults to all
11
+ #
12
+ # ==== Returns
13
+ # * response<~Fog::AWS::Response>:
14
+ # * body<~Hash>:
15
+ # * 'requestId'<~String> - Id of request
16
+ # * 'keySet'<~Array>:
17
+ # * 'keyName'<~String> - Name of key
18
+ # * 'keyFingerprint'<~String> - Fingerprint of key
19
+ def describe_key_pairs(key_name = [])
20
+ params = indexed_params('KeyName', key_name)
21
+ request({
22
+ 'Action' => 'DescribeKeyPairs'
23
+ }.merge!(params), Fog::Parsers::AWS::EC2::DescribeKeyPairs.new)
24
+ end
25
+
26
+ end
27
+ end
28
+ end
29
+
30
+ else
31
+
32
+ module Fog
33
+ module AWS
34
+ class EC2
35
+
36
+ def describe_key_pairs(key_name = [])
37
+ key_name = [*key_name]
38
+ response = Fog::Response.new
39
+ if key_name != []
40
+ key_set = @data[:key_pairs].reject {|key, value| !key_name.include?(key)}.values
41
+ else
42
+ key_set = @data[:key_pairs].values
43
+ end
44
+ if key_name.length == 0 || key_name.length == key_set.length
45
+ response.status = 200
46
+ response.body = {
47
+ 'requestId' => Fog::AWS::Mock.request_id,
48
+ 'keySet' => key_set.map do |key|
49
+ key.reject {|key,value| !['keyFingerprint', 'keyName'].include?(key)}
50
+ end
51
+ }
52
+ else
53
+ response.status = 400
54
+ raise(Fog::Errors.status_error(200, 400, response))
55
+ end
56
+ response
57
+ end
58
+
59
+ end
60
+ end
61
+ end
62
+
63
+ end
@@ -0,0 +1,26 @@
1
+ module Fog
2
+ module AWS
3
+ class EC2
4
+
5
+ # Describe all or specified regions
6
+ #
7
+ # ==== Params
8
+ # * region_name<~String> - List of regions to describe, defaults to all
9
+ #
10
+ # ==== Returns
11
+ # * response<~Fog::AWS::Response>:
12
+ # * body<~Hash>:
13
+ # * 'requestId'<~String> - Id of request
14
+ # * 'regionInfo'<~Array>:
15
+ # * 'regionName'<~String> - Name of region
16
+ # * 'regionEndpoint'<~String> - Service endpoint for region
17
+ def describe_regions(region_name = [])
18
+ params = indexed_params('RegionName', region_name)
19
+ request({
20
+ 'Action' => 'DescribeRegions'
21
+ }.merge!(params), Fog::Parsers::AWS::EC2::DescribeRegions.new)
22
+ end
23
+
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,71 @@
1
+ unless Fog.mocking?
2
+
3
+ module Fog
4
+ module AWS
5
+ class EC2
6
+
7
+ # Describe all or specified security groups
8
+ #
9
+ # ==== Parameters
10
+ # * group_name<~Array> - List of groups to describe, defaults to all
11
+ #
12
+ # === Returns
13
+ # * response<~Fog::AWS::Response>:
14
+ # * body<~Hash>:
15
+ # * 'requestId'<~String> - Id of request
16
+ # * 'securityGroupInfo'<~Array>:
17
+ # * 'groupDescription'<~String> - Description of security group
18
+ # * 'groupName'<~String> - Name of security group
19
+ # * 'ipPermissions'<~Array>:
20
+ # * 'fromPort'<~Integer> - Start of port range (or -1 for ICMP wildcard)
21
+ # * 'groups'<~Array>:
22
+ # * 'groupName'<~String> - Name of security group
23
+ # * 'userId'<~String> - AWS User Id of account
24
+ # * 'ipProtocol'<~String> - Ip protocol, must be in ['tcp', 'udp', 'icmp']
25
+ # * 'ipRanges'<~Array>:
26
+ # * 'cidrIp'<~String> - CIDR range
27
+ # * 'toPort'<~Integer> - End of port range (or -1 for ICMP wildcard)
28
+ # * 'ownerId'<~String> - AWS Access Key Id of the owner of the security group
29
+ def describe_security_groups(group_name = [])
30
+ params = indexed_params('GroupName', group_name)
31
+ request({
32
+ 'Action' => 'DescribeSecurityGroups',
33
+ }.merge!(params), Fog::Parsers::AWS::EC2::DescribeSecurityGroups.new)
34
+ end
35
+
36
+ end
37
+ end
38
+ end
39
+
40
+ else
41
+
42
+ module Fog
43
+ module AWS
44
+ class EC2
45
+
46
+ def describe_security_groups(group_name = [])
47
+ group_name = [*group_name]
48
+ response = Fog::Response.new
49
+ if group_name != []
50
+ security_group_info = @data[:security_groups].reject {|key, value| !group_name.include?(key)}.values
51
+ else
52
+ security_group_info = @data[:security_groups].values
53
+ end
54
+ if group_name.length == 0 || group_name.length == security_group_info.length
55
+ response.status = 200
56
+ response.body = {
57
+ 'requestId' => Fog::AWS::Mock.request_id,
58
+ 'securityGroupInfo' => security_group_info
59
+ }
60
+ else
61
+ response.status = 400
62
+ raise(Fog::Errors.status_error(200, 400, response))
63
+ end
64
+ response
65
+ end
66
+
67
+ end
68
+ end
69
+ end
70
+
71
+ end
@@ -0,0 +1,29 @@
1
+ module Fog
2
+ module AWS
3
+ class EC2
4
+
5
+ # Describe all or specified snapshots
6
+ #
7
+ # ==== Parameters
8
+ # * snapshot_id<~Array> - List of snapshots to describe, defaults to all
9
+ #
10
+ # ==== Returns
11
+ # * response<~Fog::AWS::Response>:
12
+ # * body<~Hash>:
13
+ # * 'requestId'<~String> - Id of request
14
+ # * 'snapshotSet'<~Array>:
15
+ # * 'progress'<~String>: The percentage progress of the snapshot
16
+ # * 'snapshotId'<~String>: Id of the snapshot
17
+ # * 'startTime'<~Time>: Timestamp of when snapshot was initiated
18
+ # * 'status'<~String>: Snapshot state, in ['pending', 'completed']
19
+ # * 'volumeId'<~String>: Id of volume that snapshot contains
20
+ def describe_snapshots(snapshot_id = [])
21
+ params = indexed_params('SnapshotId', snapshot_id)
22
+ request({
23
+ 'Action' => 'DescribeSnapshots'
24
+ }.merge!(params), Fog::Parsers::AWS::EC2::DescribeSnapshots.new)
25
+ end
26
+
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,85 @@
1
+ unless Fog.mocking?
2
+
3
+ module Fog
4
+ module AWS
5
+ class EC2
6
+
7
+ # Describe all or specified volumes.
8
+ #
9
+ # ==== Parameters
10
+ # * volume_id<~Array> - List of volumes to describe, defaults to all
11
+ #
12
+ # ==== Returns
13
+ # * response<~Fog::AWS::Response>:
14
+ # * body<~Hash>:
15
+ # * 'volumeSet'<~Array>:
16
+ # * 'availabilityZone'<~String> - Availability zone for volume
17
+ # * 'createTime'<~Time> - Timestamp for creation
18
+ # * 'size'<~Integer> - Size in GiBs for volume
19
+ # * 'snapshotId'<~String> - Snapshot volume was created from, if any
20
+ # * 'status'<~String> - State of volume
21
+ # * 'volumeId'<~String> - Reference to volume
22
+ # * 'attachmentSet'<~Array>:
23
+ # * 'attachmentTime'<~Time> - Timestamp for attachment
24
+ # * 'device'<~String> - How value is exposed to instance
25
+ # * 'instanceId'<~String> - Reference to attached instance
26
+ # * 'status'<~String> - Attachment state
27
+ # * 'volumeId'<~String> - Reference to volume
28
+ def describe_volumes(volume_id = [])
29
+ params = indexed_params('VolumeId', volume_id)
30
+ request({
31
+ 'Action' => 'DescribeVolumes'
32
+ }.merge!(params), Fog::Parsers::AWS::EC2::DescribeVolumes.new)
33
+ end
34
+
35
+ end
36
+ end
37
+ end
38
+
39
+ else
40
+
41
+ module Fog
42
+ module AWS
43
+ class EC2
44
+
45
+ def describe_volumes(volume_id = [])
46
+ volume_id = [*volume_id]
47
+ response = Fog::Response.new
48
+ if volume_id != []
49
+ volume_set = @data[:volumes].reject {|key,value| !volume_id.include?(key)}.values
50
+ else
51
+ volume_set = @data[:volumes].values
52
+ end
53
+
54
+ volume_set.each do |volume|
55
+ case volume['status']
56
+ when 'creating'
57
+ if Time.now - volume['createTime'] > 2
58
+ volume['status'] = 'available'
59
+ end
60
+ when 'deleting'
61
+ if Time.now - @data[:deleted_at][volume['volumeId']] > 2
62
+ @data[:deleted_at].delete(volume['volumeId'])
63
+ @data[:volumes].delete(volume['volumeId'])
64
+ end
65
+ end
66
+ end
67
+
68
+ if volume_id.length == 0 || volume_id.length == volume_set.length
69
+ response.status = 200
70
+ response.body = {
71
+ 'requestId' => Fog::AWS::Mock.request_id,
72
+ 'volumeSet' => volume_set
73
+ }
74
+ else
75
+ response.status = 400
76
+ raise(Fog::Errors.status_error(200, 400, response))
77
+ end
78
+ response
79
+ end
80
+
81
+ end
82
+ end
83
+ end
84
+
85
+ end
@@ -0,0 +1,32 @@
1
+ module Fog
2
+ module AWS
3
+ class EC2
4
+
5
+ # Detach an Amazon EBS volume from a running instance
6
+ #
7
+ # ==== Parameters
8
+ # * volume_id<~String> - Id of amazon EBS volume to associate with instance
9
+ # * options<~Hash>:
10
+ # * 'Device'<~String> - Specifies how the device is exposed to the instance (e.g. "/dev/sdh")
11
+ # * 'Force'<~Boolean> - If true forces detach, can cause data loss/corruption
12
+ # * 'InstanceId'<~String> - Id of instance to associate volume with
13
+ #
14
+ # ==== Returns
15
+ # * response<~Fog::AWS::Response>:
16
+ # * body<~Hash>:
17
+ # * 'attachTime'<~Time> - Time of attachment was initiated at
18
+ # * 'device'<~String> - Device as it is exposed to the instance
19
+ # * 'instanceId'<~String> - Id of instance for volume
20
+ # * 'requestId'<~String> - Id of request
21
+ # * 'status'<~String> - Status of volume
22
+ # * 'volumeId'<~String> - Reference to volume
23
+ def detach_volume(volume_id, options = {})
24
+ request({
25
+ 'Action' => 'DetachVolume',
26
+ 'VolumeId' => volume_id
27
+ }.merge!(options), Fog::Parsers::AWS::EC2::DetachVolume.new)
28
+ end
29
+
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,24 @@
1
+ module Fog
2
+ module AWS
3
+ class EC2
4
+
5
+ # Disassociate an elastic IP address from its instance (if any)
6
+ #
7
+ # ==== Parameters
8
+ # * public_ip<~String> - Public ip to assign to instance
9
+ #
10
+ # ==== Returns
11
+ # * response<~Fog::AWS::Response>:
12
+ # * body<~Hash>:
13
+ # * 'requestId'<~String> - Id of request
14
+ # * 'return'<~Boolean> - success?
15
+ def disassociate_address(public_ip)
16
+ request({
17
+ 'Action' => 'DisassociateAddress',
18
+ 'PublicIp' => public_ip
19
+ }, Fog::Parsers::AWS::EC2::Basic.new)
20
+ end
21
+
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,26 @@
1
+ module Fog
2
+ module AWS
3
+ class EC2
4
+
5
+ # Retrieve console output for specified instance
6
+ #
7
+ # ==== Parameters
8
+ # * instance_id<~String> - Id of instance to get console output from
9
+ #
10
+ # ==== Returns
11
+ # # * response<~Fog::AWS::Response>:
12
+ # * body<~Hash>:
13
+ # * 'instanceId'<~String> - Id of instance
14
+ # * 'output'<~String> - Console output
15
+ # * 'requestId'<~String> - Id of request
16
+ # * 'timestamp'<~Time> - Timestamp of last update to output
17
+ def get_console_output(instance_id)
18
+ request({
19
+ 'Action' => 'GetConsoleOutput',
20
+ 'InstanceId' => instance_id
21
+ }, Fog::Parsers::AWS::EC2::GetConsoleOutput.new)
22
+ end
23
+
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,24 @@
1
+ module Fog
2
+ module AWS
3
+ class EC2
4
+
5
+ # Reboot specified instances
6
+ #
7
+ # ==== Parameters
8
+ # * instance_id<~Array> - Ids of instances to reboot
9
+ #
10
+ # ==== Returns
11
+ # # * response<~Fog::AWS::Response>:
12
+ # * body<~Hash>:
13
+ # * 'requestId'<~String> - Id of request
14
+ # * 'return'<~Boolean> - success?
15
+ def reboot_instances(instance_id = [])
16
+ params = indexed_params('InstanceId', instance_id)
17
+ request({
18
+ 'Action' => 'RebootInstances'
19
+ }.merge!(params), Fog::Parsers::AWS::EC2::Basic.new)
20
+ end
21
+
22
+ end
23
+ end
24
+ end