fog 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (89) hide show
  1. data/fog.gemspec +1 -1
  2. data/lib/fog.rb +15 -4
  3. data/lib/fog/aws/ec2.rb +10 -2
  4. data/lib/fog/aws/models/ec2/addresses.rb +1 -1
  5. data/lib/fog/aws/models/ec2/images.rb +1 -1
  6. data/lib/fog/aws/models/ec2/key_pairs.rb +1 -1
  7. data/lib/fog/aws/models/ec2/security_groups.rb +1 -1
  8. data/lib/fog/aws/models/ec2/servers.rb +1 -1
  9. data/lib/fog/aws/models/ec2/snapshots.rb +1 -1
  10. data/lib/fog/aws/models/ec2/volumes.rb +1 -1
  11. data/lib/fog/aws/requests/ec2/describe_reserved_instances.rb +1 -1
  12. data/lib/fog/aws/requests/ec2/modify_image_attributes.rb +1 -1
  13. data/lib/fog/aws/requests/elb/create_load_balancer.rb +1 -1
  14. data/lib/fog/aws/requests/elb/delete_load_balancer.rb +1 -1
  15. data/lib/fog/aws/requests/elb/deregister_instances_from_load_balancer.rb +1 -1
  16. data/lib/fog/aws/requests/elb/describe_instance_health.rb +1 -1
  17. data/lib/fog/aws/requests/elb/describe_load_balancers.rb +1 -1
  18. data/lib/fog/aws/requests/elb/disable_availability_zones_for_load_balancer.rb +1 -1
  19. data/lib/fog/aws/requests/elb/enable_availability_zones_for_load_balancer.rb +1 -1
  20. data/lib/fog/aws/requests/elb/register_instances_with_load_balancer.rb +1 -1
  21. data/lib/fog/aws/requests/s3/get_bucket_acl.rb +1 -1
  22. data/lib/fog/aws/requests/s3/get_bucket_logging.rb +1 -1
  23. data/lib/fog/aws/requests/s3/get_bucket_object_versions.rb +1 -1
  24. data/lib/fog/aws/requests/s3/get_bucket_versioning.rb +1 -1
  25. data/lib/fog/aws/requests/s3/get_object_acl.rb +1 -1
  26. data/lib/fog/aws/requests/s3/get_object_torrent.rb +1 -1
  27. data/lib/fog/aws/requests/s3/put_bucket_acl.rb +1 -1
  28. data/lib/fog/aws/requests/s3/put_bucket_logging.rb +1 -1
  29. data/lib/fog/aws/requests/s3/put_bucket_versioning.rb +1 -1
  30. data/lib/fog/aws/requests/simpledb/select.rb +1 -1
  31. data/lib/fog/rackspace/requests/files/delete_container.rb +1 -1
  32. data/lib/fog/rackspace/requests/files/delete_object.rb +1 -1
  33. data/lib/fog/rackspace/requests/files/get_container.rb +1 -1
  34. data/lib/fog/rackspace/requests/files/get_containers.rb +1 -1
  35. data/lib/fog/rackspace/requests/files/get_object.rb +1 -1
  36. data/lib/fog/rackspace/requests/files/head_container.rb +1 -1
  37. data/lib/fog/rackspace/requests/files/head_containers.rb +1 -1
  38. data/lib/fog/rackspace/requests/files/head_object.rb +1 -1
  39. data/lib/fog/rackspace/requests/files/put_container.rb +1 -1
  40. data/lib/fog/rackspace/requests/files/put_object.rb +1 -1
  41. data/lib/fog/rackspace/requests/servers/get_flavor_details.rb +1 -1
  42. data/lib/fog/rackspace/requests/servers/get_image_details.rb +1 -1
  43. data/lib/fog/rackspace/requests/servers/list_flavors.rb +1 -1
  44. data/lib/fog/rackspace/requests/servers/list_flavors_detail.rb +1 -1
  45. data/lib/fog/rackspace/requests/servers/reboot_server.rb +1 -1
  46. data/lib/fog/slicehost/requests/create_slice.rb +1 -1
  47. data/lib/fog/slicehost/requests/delete_slice.rb +1 -1
  48. data/lib/fog/slicehost/requests/get_backups.rb +1 -1
  49. data/lib/fog/slicehost/requests/get_flavor.rb +1 -1
  50. data/lib/fog/slicehost/requests/get_flavors.rb +1 -1
  51. data/lib/fog/slicehost/requests/get_image.rb +1 -1
  52. data/lib/fog/slicehost/requests/get_images.rb +1 -1
  53. data/lib/fog/slicehost/requests/get_slice.rb +1 -1
  54. data/lib/fog/slicehost/requests/get_slices.rb +1 -1
  55. data/lib/fog/slicehost/requests/reboot_slice.rb +1 -1
  56. data/lib/fog/ssh.rb +1 -1
  57. data/lib/fog/terremark/requests/shared/add_internet_service.rb +1 -1
  58. data/lib/fog/terremark/requests/shared/add_node_service.rb +1 -1
  59. data/lib/fog/terremark/requests/shared/create_internet_service.rb +1 -1
  60. data/lib/fog/terremark/requests/shared/delete_internet_service.rb +1 -1
  61. data/lib/fog/terremark/requests/shared/delete_node_service.rb +1 -1
  62. data/lib/fog/terremark/requests/shared/delete_public_ip.rb +1 -1
  63. data/lib/fog/terremark/requests/shared/delete_vapp.rb +1 -1
  64. data/lib/fog/terremark/requests/shared/deploy_vapp.rb +1 -1
  65. data/lib/fog/terremark/requests/shared/get_catalog.rb +1 -1
  66. data/lib/fog/terremark/requests/shared/get_catalog_item.rb +1 -1
  67. data/lib/fog/terremark/requests/shared/get_internet_services.rb +1 -1
  68. data/lib/fog/terremark/requests/shared/get_network_ips.rb +1 -1
  69. data/lib/fog/terremark/requests/shared/get_node_services.rb +1 -1
  70. data/lib/fog/terremark/requests/shared/get_public_ip.rb +1 -1
  71. data/lib/fog/terremark/requests/shared/get_task.rb +1 -1
  72. data/lib/fog/terremark/requests/shared/get_tasks_list.rb +1 -1
  73. data/lib/fog/terremark/requests/shared/get_vapp.rb +1 -1
  74. data/lib/fog/terremark/requests/shared/get_vapp_template.rb +1 -1
  75. data/lib/fog/terremark/requests/shared/instantiate_vapp_template.rb +1 -1
  76. data/lib/fog/terremark/requests/shared/power_off.rb +1 -1
  77. data/lib/fog/terremark/requests/shared/power_on.rb +1 -1
  78. data/lib/fog/terremark/requests/shared/power_reset.rb +1 -1
  79. data/lib/fog/terremark/requests/shared/power_shutdown.rb +1 -1
  80. data/tests/aws/helper.rb +0 -89
  81. data/tests/aws/requests/ec2/address_tests.rb +10 -2
  82. data/tests/aws/requests/ec2/availability_zone_tests.rb +11 -2
  83. data/tests/aws/requests/ec2/key_pair_tests.rb +18 -3
  84. data/tests/aws/requests/ec2/region_tests.rb +10 -2
  85. data/tests/aws/requests/ec2/security_group_tests.rb +18 -2
  86. data/tests/aws/requests/ec2/snapshot_tests.rb +21 -4
  87. data/tests/aws/requests/ec2/volume_tests.rb +43 -8
  88. data/tests/helper_tests.rb +7 -36
  89. metadata +2 -2
@@ -7,7 +7,7 @@ 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.1.3'
10
+ s.version = '0.1.4'
11
11
  s.date = '2010-05-26'
12
12
  s.rubyforge_project = 'fog'
13
13
 
data/lib/fog.rb CHANGED
@@ -26,7 +26,15 @@ require 'fog/parser'
26
26
  require 'fog/ssh'
27
27
 
28
28
  module Fog
29
- class Error < StandardError; end
29
+ module Errors
30
+
31
+ class Error < StandardError; end
32
+
33
+ class MockNotImplemented < Fog::Errors::Error; end
34
+
35
+ class NotFound < Fog::Errors::Error; end
36
+
37
+ end
30
38
  end
31
39
 
32
40
  require 'fog/aws'
@@ -38,10 +46,8 @@ require 'fog/vcloud'
38
46
 
39
47
  module Fog
40
48
 
41
- class MockNotImplemented < Fog::Error; end
42
-
43
49
  unless const_defined?(:VERSION)
44
- VERSION = '0.1.3'
50
+ VERSION = '0.1.4'
45
51
  end
46
52
 
47
53
  module Mock
@@ -54,6 +60,11 @@ module Fog
54
60
  raise ArgumentError, "delay must be non-negative" unless new_delay >= 0
55
61
  @delay = new_delay
56
62
  end
63
+
64
+ def self.not_implemented
65
+ raise Fog::Errors::MockNotImplemented.new("Contributions welcome!")
66
+ end
67
+
57
68
  end
58
69
 
59
70
  def self.mock!
@@ -2,7 +2,8 @@ module Fog
2
2
  module AWS
3
3
  module EC2
4
4
 
5
- class Error < Fog::Error; end
5
+ class Error < Fog::Errors::Error; end
6
+ class NotFound < Fog::Errors::NotFound; end
6
7
 
7
8
  def self.new(options={})
8
9
 
@@ -226,7 +227,14 @@ module Fog
226
227
  })
227
228
  rescue Excon::Errors::Error => error
228
229
  if match = error.message.match(/<Code>(.*)<\/Code><Message>(.*)<\/Message>/)
229
- raise Fog::AWS::EC2::Error.new("#{match[1]} => #{match[2]}")
230
+ new_error = case match[1].split('.').last
231
+ when 'NotFound'
232
+ Fog::AWS::EC2::NotFound.new(match[2])
233
+ else
234
+ Fog::AWS::EC2::Error.new("#{match[1]} => #{match[2]}")
235
+ end
236
+ new_error.set_backtrace(error.backtrace)
237
+ raise new_error
230
238
  else
231
239
  raise error
232
240
  end
@@ -51,7 +51,7 @@ module Fog
51
51
  if public_ip
52
52
  all(public_ip).first
53
53
  end
54
- rescue Excon::Errors::BadRequest
54
+ rescue Fog::Errors::NotFound
55
55
  nil
56
56
  end
57
57
 
@@ -38,7 +38,7 @@ module Fog
38
38
  if image_id
39
39
  all(image_id).first
40
40
  end
41
- rescue Excon::Errors::BadRequest
41
+ rescue Fog::Errors::NotFound
42
42
  nil
43
43
  end
44
44
  end
@@ -38,7 +38,7 @@ module Fog
38
38
  if key_name
39
39
  all(key_name).first
40
40
  end
41
- rescue Excon::Errors::BadRequest
41
+ rescue Fog::Errors::NotFound
42
42
  nil
43
43
  end
44
44
 
@@ -38,7 +38,7 @@ module Fog
38
38
  if group_name
39
39
  all(group_name).first
40
40
  end
41
- rescue Excon::Errors::BadRequest
41
+ rescue Fog::Errors::NotFound
42
42
  nil
43
43
  end
44
44
 
@@ -44,7 +44,7 @@ module Fog
44
44
  if server_id
45
45
  all(server_id).first
46
46
  end
47
- rescue Excon::Errors::BadRequest
47
+ rescue Fog::Errors::NotFound
48
48
  nil
49
49
  end
50
50
 
@@ -54,7 +54,7 @@ module Fog
54
54
  if snapshot_id
55
55
  all(snapshot_id).first
56
56
  end
57
- rescue Excon::Errors::BadRequest
57
+ rescue Fog::Errors::NotFound
58
58
  nil
59
59
  end
60
60
 
@@ -47,7 +47,7 @@ module Fog
47
47
  if volume_id
48
48
  all(volume_id).first
49
49
  end
50
- rescue Excon::Errors::BadRequest
50
+ rescue Fog::Errors::NotFound
51
51
  nil
52
52
  end
53
53
 
@@ -37,7 +37,7 @@ module Fog
37
37
  class Mock
38
38
 
39
39
  def describe_reserved_instances(reserved_instances_id = {})
40
- raise MockNotImplemented.new("Contributions welcome!")
40
+ Fog::Mock.not_implemented
41
41
  end
42
42
 
43
43
  end
@@ -30,7 +30,7 @@ module Fog
30
30
  class Mock
31
31
 
32
32
  def modify_image_attributes(image_id, attribute, operation_type, options = {})
33
- raise MockNotImplemented.new("Contributions welcome!")
33
+ Fog::Mock.not_implemented
34
34
  end
35
35
 
36
36
  end
@@ -47,7 +47,7 @@ module Fog
47
47
  class Mock
48
48
 
49
49
  def create_load_balancer(availability_zones, lb_name, listeners)
50
- raise MockNotImplemented.new("Contributions welcome!")
50
+ Fog::Mock.not_implemented
51
51
  end
52
52
 
53
53
  end
@@ -30,7 +30,7 @@ module Fog
30
30
  class Mock
31
31
 
32
32
  def delete_load_balancer(lb_name)
33
- raise MockNotImplemented.new("Contributions welcome!")
33
+ Fog::Mock.not_implemented
34
34
  end
35
35
 
36
36
  end
@@ -33,7 +33,7 @@ module Fog
33
33
  class Mock
34
34
 
35
35
  def deregister_instances_from_load_balancer(instance_ids, lb_name)
36
- raise MockNotImplemented.new("Contributions welcome!")
36
+ Fog::Mock.not_implemented
37
37
  end
38
38
 
39
39
  alias :deregister_instances :deregister_instances_from_load_balancer
@@ -34,7 +34,7 @@ module Fog
34
34
  class Mock
35
35
 
36
36
  def describe_instance_health(lb_name, instance_ids = [])
37
- raise MockNotImplemented.new("Contributions welcome!")
37
+ Fog::Mock.not_implemented
38
38
  end
39
39
 
40
40
  end
@@ -48,7 +48,7 @@ module Fog
48
48
  class Mock
49
49
 
50
50
  def describe_load_balancers(lb_name = [])
51
- raise MockNotImplemented.new("Contributions welcome!")
51
+ Fog::Mock.not_implemented
52
52
  end
53
53
 
54
54
  end
@@ -32,7 +32,7 @@ module Fog
32
32
  class Mock
33
33
 
34
34
  def disable_availability_zones_for_load_balancer(availability_zones, lb_name)
35
- raise MockNotImplemented.new("Contributions welcome!")
35
+ Fog::Mock.not_implemented
36
36
  end
37
37
 
38
38
  alias :disable_zones :disable_availability_zones_for_load_balancer
@@ -32,7 +32,7 @@ module Fog
32
32
  class Mock
33
33
 
34
34
  def enable_availability_zones_for_load_balancer(availability_zones, lb_name)
35
- raise MockNotImplemented.new("Contributions welcome!")
35
+ Fog::Mock.not_implemented
36
36
  end
37
37
 
38
38
  alias :enable_zones :enable_availability_zones_for_load_balancer
@@ -33,7 +33,7 @@ module Fog
33
33
  class Mock
34
34
 
35
35
  def register_instances_with_load_balancer(instance_ids, lb_name)
36
- raise MockNotImplemented.new("Contributions welcome!")
36
+ Fog::Mock.not_implemented
37
37
  end
38
38
 
39
39
  alias :register_instances :register_instances_with_load_balancer
@@ -44,7 +44,7 @@ module Fog
44
44
  class Mock
45
45
 
46
46
  def get_bucket_acl(bucket_name)
47
- raise MockNotImplemented.new("Contributions welcome!")
47
+ Fog::Mock.not_implemented
48
48
  end
49
49
 
50
50
  end
@@ -44,7 +44,7 @@ module Fog
44
44
  class Mock
45
45
 
46
46
  def get_bucket_logging(bucket_name)
47
- raise MockNotImplemented.new("Contributions welcome!")
47
+ Fog::Mock.not_implemented
48
48
  end
49
49
 
50
50
  end
@@ -74,7 +74,7 @@ module Fog
74
74
  class Mock
75
75
 
76
76
  def get_bucket_object_versions(bucket_name, options = {})
77
- raise MockNotImplemented.new("Contributions welcome!")
77
+ Fog::Mock.not_implemented
78
78
  end
79
79
 
80
80
  end
@@ -34,7 +34,7 @@ module Fog
34
34
  class Mock
35
35
 
36
36
  def get_bucket_versioning(bucket_name)
37
- raise MockNotImplemented.new("Contributions welcome!")
37
+ Fog::Mock.not_implemented
38
38
  end
39
39
 
40
40
  end
@@ -55,7 +55,7 @@ module Fog
55
55
  class Mock
56
56
 
57
57
  def get_object_acl(bucket_name, object_name)
58
- raise MockNotImplemented.new("Contributions welcome!")
58
+ Fog::Mock.not_implemented
59
59
  end
60
60
 
61
61
  end
@@ -46,7 +46,7 @@ module Fog
46
46
  class Mock
47
47
 
48
48
  def get_object_object(bucket_name, object_name)
49
- raise MockNotImplemented.new("Contributions welcome!")
49
+ Fog::Mock.not_implemented
50
50
  end
51
51
 
52
52
  end
@@ -71,7 +71,7 @@ DATA
71
71
  class Mock
72
72
 
73
73
  def put_bucket_acl(bucket_name, acl)
74
- raise MockNotImplemented.new("Contributions welcome!")
74
+ Fog::Mock.not_implemented
75
75
  end
76
76
 
77
77
  end
@@ -78,7 +78,7 @@ DATA
78
78
  class Mock
79
79
 
80
80
  def put_bucket_logging(bucket_name, logging_status)
81
- raise MockNotImplemented.new("Contributions welcome!")
81
+ Fog::Mock.not_implemented
82
82
  end
83
83
 
84
84
  end
@@ -31,7 +31,7 @@ DATA
31
31
  class Mock
32
32
 
33
33
  def put_bucket_versioning(bucket_name, status)
34
- raise MockNotImplemented.new("Contributions welcome!")
34
+ Fog::Mock.not_implemented
35
35
  end
36
36
 
37
37
  end
@@ -31,7 +31,7 @@ module Fog
31
31
  class Mock
32
32
 
33
33
  def select(select_expression, next_token = nil)
34
- raise MockNotImplemented.new("Contributions welcome!")
34
+ Fog::Mock.not_implemented
35
35
  end
36
36
 
37
37
  end
@@ -22,7 +22,7 @@ module Fog
22
22
  class Mock
23
23
 
24
24
  def delete_container(name)
25
- raise MockNotImplemented.new("Contributions welcome!")
25
+ Fog::Mock.not_implemented
26
26
  end
27
27
 
28
28
  end
@@ -23,7 +23,7 @@ module Fog
23
23
  class Mock
24
24
 
25
25
  def delete_object(container, object)
26
- raise MockNotImplemented.new("Contributions welcome!")
26
+ Fog::Mock.not_implemented
27
27
  end
28
28
 
29
29
  end
@@ -48,7 +48,7 @@ module Fog
48
48
  class Mock
49
49
 
50
50
  def get_container(container, options = {})
51
- raise MockNotImplemented.new("Contributions welcome!")
51
+ Fog::Mock.not_implemented
52
52
  end
53
53
 
54
54
  end
@@ -38,7 +38,7 @@ module Fog
38
38
  class Mock
39
39
 
40
40
  def get_containers(options = {})
41
- raise MockNotImplemented.new("Contributions welcome!")
41
+ Fog::Mock.not_implemented
42
42
  end
43
43
 
44
44
  end
@@ -24,7 +24,7 @@ module Fog
24
24
  class Mock
25
25
 
26
26
  def get_object(container, object)
27
- raise MockNotImplemented.new("Contributions welcome!")
27
+ Fog::Mock.not_implemented
28
28
  end
29
29
 
30
30
  end
@@ -28,7 +28,7 @@ module Fog
28
28
  class Mock
29
29
 
30
30
  def head_container(container)
31
- raise MockNotImplemented.new("Contributions welcome!")
31
+ Fog::Mock.not_implemented
32
32
  end
33
33
 
34
34
  end
@@ -25,7 +25,7 @@ module Fog
25
25
  class Mock
26
26
 
27
27
  def head_containers
28
- raise MockNotImplemented.new("Contributions welcome!")
28
+ Fog::Mock.not_implemented
29
29
  end
30
30
 
31
31
  end
@@ -23,7 +23,7 @@ module Fog
23
23
  class Mock
24
24
 
25
25
  def head_object(container, object)
26
- raise MockNotImplemented.new("Contributions welcome!")
26
+ Fog::Mock.not_implemented
27
27
  end
28
28
 
29
29
  end
@@ -22,7 +22,7 @@ module Fog
22
22
  class Mock
23
23
 
24
24
  def put_container(name)
25
- raise MockNotImplemented.new("Contributions welcome!")
25
+ Fog::Mock.not_implemented
26
26
  end
27
27
 
28
28
  end
@@ -25,7 +25,7 @@ module Fog
25
25
  class Mock
26
26
 
27
27
  def put_object(container, object, data)
28
- raise MockNotImplemented.new("Contributions welcome!")
28
+ Fog::Mock.not_implemented
29
29
  end
30
30
 
31
31
  end
@@ -25,7 +25,7 @@ module Fog
25
25
  class Mock
26
26
 
27
27
  def get_flavor_details(flavor_id)
28
- raise MockNotImplemented.new("Contributions welcome!")
28
+ Fog::Mock.not_implemented
29
29
  end
30
30
 
31
31
  end