fog 0.0.42 → 0.0.43

Sign up to get free protection for your applications and to get access to all the features.
Files changed (79) hide show
  1. data/README.rdoc +1 -1
  2. data/Rakefile +1 -0
  3. data/VERSION.yml +2 -2
  4. data/bin/fog +23 -102
  5. data/fog.gemspec +48 -2
  6. data/lib/fog.rb +17 -46
  7. data/lib/fog/aws.rb +10 -4
  8. data/lib/fog/aws/bin.rb +69 -0
  9. data/lib/fog/aws/ec2.rb +82 -86
  10. data/lib/fog/aws/requests/ec2/authorize_security_group_ingress.rb +20 -16
  11. data/lib/fog/aws/requests/ec2/revoke_security_group_ingress.rb +19 -15
  12. data/lib/fog/aws/requests/s3/get_object.rb +4 -0
  13. data/lib/fog/aws/requests/simpledb/select.rb +42 -24
  14. data/lib/fog/aws/s3.rb +28 -25
  15. data/lib/fog/aws/simpledb.rb +21 -17
  16. data/lib/fog/bin.rb +79 -0
  17. data/lib/fog/collection.rb +20 -9
  18. data/lib/fog/model.rb +9 -4
  19. data/lib/fog/rackspace.rb +10 -3
  20. data/lib/fog/rackspace/bin.rb +44 -0
  21. data/lib/fog/rackspace/files.rb +16 -9
  22. data/lib/fog/rackspace/requests/files/delete_container.rb +2 -1
  23. data/lib/fog/rackspace/requests/files/delete_object.rb +2 -1
  24. data/lib/fog/rackspace/requests/files/get_container.rb +2 -1
  25. data/lib/fog/rackspace/requests/files/get_containers.rb +2 -1
  26. data/lib/fog/rackspace/requests/files/head_container.rb +2 -1
  27. data/lib/fog/rackspace/requests/files/head_containers.rb +2 -1
  28. data/lib/fog/rackspace/requests/files/put_container.rb +2 -1
  29. data/lib/fog/rackspace/requests/files/put_object.rb +2 -1
  30. data/lib/fog/rackspace/requests/servers/get_flavor_details.rb +1 -0
  31. data/lib/fog/rackspace/requests/servers/list_flavors.rb +1 -0
  32. data/lib/fog/rackspace/requests/servers/list_flavors_detail.rb +1 -0
  33. data/lib/fog/rackspace/requests/servers/list_images.rb +0 -1
  34. data/lib/fog/rackspace/requests/servers/reboot_server.rb +2 -1
  35. data/lib/fog/rackspace/servers.rb +31 -26
  36. data/lib/fog/slicehost.rb +35 -17
  37. data/lib/fog/slicehost/bin.rb +42 -0
  38. data/lib/fog/slicehost/models/flavor.rb +41 -0
  39. data/lib/fog/slicehost/models/flavors.rb +33 -0
  40. data/lib/fog/slicehost/models/image.rb +13 -0
  41. data/lib/fog/slicehost/models/images.rb +35 -0
  42. data/lib/fog/slicehost/models/server.rb +55 -0
  43. data/lib/fog/slicehost/models/servers.rb +37 -0
  44. data/lib/fog/slicehost/parsers/get_flavor.rb +24 -0
  45. data/lib/fog/slicehost/parsers/get_image.rb +24 -0
  46. data/lib/fog/slicehost/parsers/get_slice.rb +29 -0
  47. data/lib/fog/slicehost/requests/create_slice.rb +2 -1
  48. data/lib/fog/slicehost/requests/delete_slice.rb +2 -1
  49. data/lib/fog/slicehost/requests/get_backups.rb +1 -0
  50. data/lib/fog/slicehost/requests/get_flavor.rb +42 -0
  51. data/lib/fog/slicehost/requests/get_flavors.rb +1 -0
  52. data/lib/fog/slicehost/requests/get_image.rb +40 -0
  53. data/lib/fog/slicehost/requests/get_images.rb +1 -0
  54. data/lib/fog/slicehost/requests/get_slice.rb +48 -0
  55. data/lib/fog/slicehost/requests/get_slices.rb +1 -0
  56. data/lib/fog/slicehost/requests/reboot_slice.rb +49 -0
  57. data/lib/fog/terremark.rb +71 -0
  58. data/lib/fog/terremark/bin.rb +30 -0
  59. data/lib/fog/terremark/parsers/get_catalog.rb +43 -0
  60. data/lib/fog/terremark/parsers/get_catalog_item.rb +44 -0
  61. data/lib/fog/terremark/parsers/get_organization.rb +44 -0
  62. data/lib/fog/terremark/parsers/get_organizations.rb +26 -0
  63. data/lib/fog/terremark/parsers/get_vapp_template.rb +44 -0
  64. data/lib/fog/terremark/parsers/get_vdc.rb +105 -0
  65. data/lib/fog/terremark/requests/get_catalog.rb +44 -0
  66. data/lib/fog/terremark/requests/get_catalog_item.rb +47 -0
  67. data/lib/fog/terremark/requests/get_organization.rb +46 -0
  68. data/lib/fog/terremark/requests/get_organizations.rb +42 -0
  69. data/lib/fog/terremark/requests/get_vapp_template.rb +47 -0
  70. data/lib/fog/terremark/requests/get_vdc.rb +47 -0
  71. data/spec/slicehost/models/server_spec.rb +51 -0
  72. data/spec/slicehost/models/servers_spec.rb +22 -0
  73. data/spec/slicehost/requests/get_flavor_spec.rb +24 -0
  74. data/spec/slicehost/requests/get_image_spec.rb +24 -0
  75. data/spec/slicehost/requests/get_slice_spec.rb +41 -0
  76. data/spec/slicehost/requests/get_slices_spec.rb +20 -9
  77. data/spec/slicehost/requests/reboot_slice_spec.rb +41 -0
  78. data/spec/spec_helper.rb +10 -0
  79. metadata +55 -2
data/lib/fog/bin.rb ADDED
@@ -0,0 +1,79 @@
1
+ module Fog
2
+ class << self
3
+
4
+ def credential=(new_credential)
5
+ @credential = new_credential
6
+ @credentials = nil
7
+ end
8
+
9
+ def credential
10
+ @credential || :default
11
+ end
12
+
13
+ def credentials
14
+ @credentials ||= begin
15
+ path = File.expand_path('~/.fog')
16
+ credentials = if File.exists?(path)
17
+ File.open(path) do |file|
18
+ YAML.load(file.read)
19
+ end
20
+ else
21
+ nil
22
+ end
23
+ unless credentials && credentials[credential]
24
+ print("\n To run as '#{credential}', add the following to ~/.fog\n")
25
+ yml = <<-YML
26
+
27
+ :#{credential}:
28
+ :aws_access_key_id: INTENTIONALLY_LEFT_BLANK
29
+ :aws_secret_access_key: INTENTIONALLY_LEFT_BLANK
30
+ :rackspace_api_key: INTENTIONALLY_LEFT_BLANK
31
+ :rackspace_username: INTENTIONALLY_LEFT_BLANK
32
+ :slicehost_password: INTENTIONALLY_LEFT_BLANK
33
+ :terremark_username: INTENTIONALLY_LEFT_BLANK
34
+ :terremark_password: INTENTIONALLY_LEFT_BLANK
35
+
36
+ YML
37
+ print(yml)
38
+ raise(ArgumentError.new("Missing Credentials"))
39
+ end
40
+ credentials[credential]
41
+ end
42
+ end
43
+
44
+ def services
45
+ services = []
46
+ [::AWS, ::Rackspace, ::Slicehost, ::Terremark].each do |service|
47
+ if service.initialized?
48
+ services << service
49
+ end
50
+ end
51
+ services
52
+ end
53
+
54
+ def flavors
55
+ flavors = {}
56
+ services.each do |service|
57
+ flavors[service] = service.flavors
58
+ end
59
+ flavors
60
+ end
61
+
62
+ def images
63
+ images = {}
64
+ services.each do |service|
65
+ images[service] = service.images
66
+ end
67
+ images
68
+ end
69
+
70
+ def servers
71
+ servers = {}
72
+ services.each do |service|
73
+ servers[service] = service.servers
74
+ end
75
+ servers
76
+ end
77
+
78
+ end
79
+ end
@@ -69,16 +69,27 @@ module Fog
69
69
  end
70
70
 
71
71
  def inspect
72
- data = "#<#{self.class.name}"
73
- for attribute in self.class.attributes
74
- data << " #{attribute}=#{send(attribute).inspect}"
75
- end
76
- data << " ["
77
- for member in self
78
- data << "#{member.inspect},"
72
+ Thread.current[:formatador] ||= Formatador.new
73
+ data = "#{Thread.current[:formatador].indentation}<#{self.class.name}\n"
74
+ Thread.current[:formatador].indent do
75
+ unless self.class.attributes.empty?
76
+ data << "#{Thread.current[:formatador].indentation}"
77
+ data << self.class.attributes.map {|attribute| "#{attribute}=#{send(attribute).inspect}"}.join(",\n#{Thread.current[:formatador].indentation}")
78
+ data << "\n"
79
+ end
80
+ data << "#{Thread.current[:formatador].indentation}["
81
+ unless self.empty?
82
+ data << "\n"
83
+ Thread.current[:formatador].indent do
84
+ data << self.map {|member| member.inspect}.join(",\n")
85
+ data << "\n"
86
+ end
87
+ data << Thread.current[:formatador].indentation
88
+ end
89
+ data << "]\n"
79
90
  end
80
- data.chop! unless self.empty?
81
- data << "]>"
91
+ data << "#{Thread.current[:formatador].indentation}>"
92
+ data
82
93
  end
83
94
 
84
95
  def model
data/lib/fog/model.rb CHANGED
@@ -56,11 +56,16 @@ module Fog
56
56
  end
57
57
 
58
58
  def inspect
59
- data = "#<#{self.class.name}"
60
- for attribute in self.class.attributes
61
- data << " #{attribute}=#{send(attribute).inspect}"
59
+ Thread.current[:formatador] ||= Formatador.new
60
+ data = "#{Thread.current[:formatador].indentation}<#{self.class.name}"
61
+ Thread.current[:formatador].indent do
62
+ unless self.class.attributes.empty?
63
+ data << "\n#{Thread.current[:formatador].indentation}"
64
+ data << self.class.attributes.map {|attribute| "#{attribute}=#{send(attribute).inspect}"}.join(",\n#{Thread.current[:formatador].indentation}")
65
+ end
62
66
  end
63
- data << ">"
67
+ data << "\n#{Thread.current[:formatador].indentation}>"
68
+ data
64
69
  end
65
70
 
66
71
  def merge_attributes(new_attributes = {})
data/lib/fog/rackspace.rb CHANGED
@@ -1,9 +1,15 @@
1
1
  module Fog
2
2
  module Rackspace
3
3
 
4
+ def self.dependencies
5
+ [
6
+ 'fog/rackspace/files.rb',
7
+ 'fog/rackspace/servers.rb'
8
+ ]
9
+ end
10
+
4
11
  def self.reload
5
- load 'fog/rackspace/files.rb'
6
- load 'fog/rackspace/servers.rb'
12
+ self.dependencies.each {|dependency| load(dependency)}
7
13
  end
8
14
 
9
15
  unless Fog.mocking?
@@ -51,4 +57,5 @@ module Fog
51
57
 
52
58
  end
53
59
  end
54
- Fog::Rackspace.reload
60
+
61
+ Fog::Rackspace.dependencies.each {|dependency| require(dependency)}
@@ -0,0 +1,44 @@
1
+ module Rackspace
2
+ class << self
3
+ if Fog.credentials[:rackspace_api_key] && Fog.credentials[:rackspace_username]
4
+
5
+ def initialized?
6
+ true
7
+ end
8
+
9
+ def [](service)
10
+ @@connections ||= Hash.new do |hash, key|
11
+ credentials = Fog.credentials.reject do |k,v|
12
+ ![:rackspace_api_key, :rackspace_username].include?(k)
13
+ end
14
+ hash[key] = case key
15
+ when :files
16
+ Fog::Rackspace::Files.new(credentials)
17
+ when :servers
18
+ Fog::Rackspace::Servers.new(credentials)
19
+ end
20
+ end
21
+ @@connections[service]
22
+ end
23
+
24
+ def flavors
25
+ self[:servers].flavors
26
+ end
27
+
28
+ def images
29
+ self[:servers].images
30
+ end
31
+
32
+ def servers
33
+ self[:servers].servers
34
+ end
35
+
36
+ else
37
+
38
+ def initialized?
39
+ false
40
+ end
41
+
42
+ end
43
+ end
44
+ end
@@ -2,15 +2,21 @@ module Fog
2
2
  module Rackspace
3
3
  class Files
4
4
 
5
+ def self.dependencies
6
+ [
7
+ "fog/rackspace/requests/files/delete_container.rb",
8
+ "fog/rackspace/requests/files/delete_object.rb",
9
+ "fog/rackspace/requests/files/get_container.rb",
10
+ "fog/rackspace/requests/files/get_containers.rb",
11
+ "fog/rackspace/requests/files/head_container.rb",
12
+ "fog/rackspace/requests/files/head_containers.rb",
13
+ "fog/rackspace/requests/files/put_container.rb",
14
+ "fog/rackspace/requests/files/put_object.rb"
15
+ ]
16
+ end
17
+
5
18
  def self.reload
6
- load "fog/rackspace/requests/files/delete_container.rb"
7
- load "fog/rackspace/requests/files/delete_object.rb"
8
- load "fog/rackspace/requests/files/get_container.rb"
9
- load "fog/rackspace/requests/files/get_containers.rb"
10
- load "fog/rackspace/requests/files/head_container.rb"
11
- load "fog/rackspace/requests/files/head_containers.rb"
12
- load "fog/rackspace/requests/files/put_container.rb"
13
- load "fog/rackspace/requests/files/put_object.rb"
19
+ self.dependencies.each {|dependency| load(dependency)}
14
20
  end
15
21
 
16
22
  def initialize(options={})
@@ -92,4 +98,5 @@ module Fog
92
98
  end
93
99
  end
94
100
  end
95
- Fog::Rackspace::Files.reload
101
+
102
+ Fog::Rackspace::Files.dependencies.each {|dependency| require(dependency)}
@@ -28,7 +28,8 @@ else
28
28
  module Rackspace
29
29
  class Servers
30
30
 
31
- def delete_container
31
+ def delete_container(name)
32
+ raise MockNotImplemented.new("Contributions welcome!")
32
33
  end
33
34
 
34
35
  end
@@ -29,7 +29,8 @@ else
29
29
  module Rackspace
30
30
  class Servers
31
31
 
32
- def delete_object
32
+ def delete_object(container, object)
33
+ raise MockNotImplemented.new("Contributions welcome!")
33
34
  end
34
35
 
35
36
  end
@@ -51,7 +51,8 @@ else
51
51
  module Rackspace
52
52
  class Servers
53
53
 
54
- def get_flavors
54
+ def get_container(container, options = {})
55
+ raise MockNotImplemented.new("Contributions welcome!")
55
56
  end
56
57
 
57
58
  end
@@ -44,7 +44,8 @@ else
44
44
  module Rackspace
45
45
  class Servers
46
46
 
47
- def get_flavors
47
+ def get_containers(options = {})
48
+ raise MockNotImplemented.new("Contributions welcome!")
48
49
  end
49
50
 
50
51
  end
@@ -34,7 +34,8 @@ else
34
34
  module Rackspace
35
35
  class Servers
36
36
 
37
- def get_flavors
37
+ def head_container(container)
38
+ raise MockNotImplemented.new("Contributions welcome!")
38
39
  end
39
40
 
40
41
  end
@@ -31,7 +31,8 @@ else
31
31
  module Rackspace
32
32
  class Servers
33
33
 
34
- def get_flavors
34
+ def head_containers
35
+ raise MockNotImplemented.new("Contributions welcome!")
35
36
  end
36
37
 
37
38
  end
@@ -28,7 +28,8 @@ else
28
28
  module Rackspace
29
29
  class Servers
30
30
 
31
- def put_container
31
+ def put_container(name)
32
+ raise MockNotImplemented.new("Contributions welcome!")
32
33
  end
33
34
 
34
35
  end
@@ -31,7 +31,8 @@ else
31
31
  module Rackspace
32
32
  class Servers
33
33
 
34
- def put_container
34
+ def put_object(container, object, data)
35
+ raise MockNotImplemented.new("Contributions welcome!")
35
36
  end
36
37
 
37
38
  end
@@ -32,6 +32,7 @@ else
32
32
  class Servers
33
33
 
34
34
  def get_flavor_details(flavor_id)
35
+ raise MockNotImplemented.new("Contributions welcome!")
35
36
  end
36
37
 
37
38
  end
@@ -30,6 +30,7 @@ else
30
30
  class Servers
31
31
 
32
32
  def list_flavors
33
+ raise MockNotImplemented.new("Contributions welcome!")
33
34
  end
34
35
 
35
36
  end
@@ -32,6 +32,7 @@ else
32
32
  class Servers
33
33
 
34
34
  def list_flavors_detail
35
+ raise MockNotImplemented.new("Contributions welcome!")
35
36
  end
36
37
 
37
38
  end
@@ -39,7 +39,6 @@ else
39
39
  response.status = [200, 203][rand(1)]
40
40
  response.body = { 'images' => images }
41
41
  response
42
-
43
42
  end
44
43
 
45
44
  end
@@ -10,7 +10,7 @@ unless Fog.mocking?
10
10
  # * server_id<~Integer> - Id of server to reboot
11
11
  # * type<~String> - Type of reboot, must be in ['HARD', 'SOFT']
12
12
  #
13
- def reboot_server(server_id, type)
13
+ def reboot_server(server_id, type = 'SOFT')
14
14
  request(
15
15
  :body => { 'reboot' => { 'type' => type }}.to_json,
16
16
  :expects => 202,
@@ -30,6 +30,7 @@ else
30
30
  class Servers
31
31
 
32
32
  def reboot_server(server_id, type)
33
+ raise MockNotImplemented.new("Contributions welcome!")
33
34
  end
34
35
 
35
36
  end
@@ -18,32 +18,36 @@ module Fog
18
18
  end
19
19
  end
20
20
 
21
- def self.reload
22
- load "fog/rackspace/models/servers/flavor.rb"
23
- load "fog/rackspace/models/servers/flavors.rb"
24
- load "fog/rackspace/models/servers/image.rb"
25
- load "fog/rackspace/models/servers/images.rb"
26
- load "fog/rackspace/models/servers/server.rb"
27
- load "fog/rackspace/models/servers/servers.rb"
28
-
29
- load "fog/rackspace/requests/servers/create_image.rb"
30
- load "fog/rackspace/requests/servers/create_server.rb"
31
- load "fog/rackspace/requests/servers/delete_image.rb"
32
- load "fog/rackspace/requests/servers/delete_server.rb"
33
- load "fog/rackspace/requests/servers/get_flavor_details.rb"
34
- load "fog/rackspace/requests/servers/get_server_details.rb"
35
- load "fog/rackspace/requests/servers/list_addresses.rb"
36
- load "fog/rackspace/requests/servers/list_private_addresses.rb"
37
- load "fog/rackspace/requests/servers/list_public_addresses.rb"
38
- load "fog/rackspace/requests/servers/list_flavors.rb"
39
- load "fog/rackspace/requests/servers/list_flavors_detail.rb"
40
- load "fog/rackspace/requests/servers/list_images.rb"
41
- load "fog/rackspace/requests/servers/list_images_detail.rb"
42
- load "fog/rackspace/requests/servers/list_servers.rb"
43
- load "fog/rackspace/requests/servers/list_servers_detail.rb"
44
- load "fog/rackspace/requests/servers/reboot_server.rb"
45
- load "fog/rackspace/requests/servers/update_server.rb"
21
+ def self.dependencies
22
+ [
23
+ "fog/rackspace/models/servers/flavor.rb",
24
+ "fog/rackspace/models/servers/flavors.rb",
25
+ "fog/rackspace/models/servers/image.rb",
26
+ "fog/rackspace/models/servers/images.rb",
27
+ "fog/rackspace/models/servers/server.rb",
28
+ "fog/rackspace/models/servers/servers.rb",
29
+ "fog/rackspace/requests/servers/create_image.rb",
30
+ "fog/rackspace/requests/servers/create_server.rb",
31
+ "fog/rackspace/requests/servers/delete_image.rb",
32
+ "fog/rackspace/requests/servers/delete_server.rb",
33
+ "fog/rackspace/requests/servers/get_flavor_details.rb",
34
+ "fog/rackspace/requests/servers/get_server_details.rb",
35
+ "fog/rackspace/requests/servers/list_addresses.rb",
36
+ "fog/rackspace/requests/servers/list_private_addresses.rb",
37
+ "fog/rackspace/requests/servers/list_public_addresses.rb",
38
+ "fog/rackspace/requests/servers/list_flavors.rb",
39
+ "fog/rackspace/requests/servers/list_flavors_detail.rb",
40
+ "fog/rackspace/requests/servers/list_images.rb",
41
+ "fog/rackspace/requests/servers/list_images_detail.rb",
42
+ "fog/rackspace/requests/servers/list_servers.rb",
43
+ "fog/rackspace/requests/servers/list_servers_detail.rb",
44
+ "fog/rackspace/requests/servers/reboot_server.rb",
45
+ "fog/rackspace/requests/servers/update_server.rb"
46
+ ]
47
+ end
46
48
 
49
+ def self.reload
50
+ self.dependencies.each {|dependency| load(dependency)}
47
51
  if Fog.mocking?
48
52
  reset_data
49
53
  end
@@ -81,4 +85,5 @@ module Fog
81
85
  end
82
86
  end
83
87
  end
84
- Fog::Rackspace::Servers.reload
88
+
89
+ Fog::Rackspace::Servers.dependencies.each {|dependency| require(dependency)}