fog 0.0.42 → 0.0.43
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +1 -1
- data/Rakefile +1 -0
- data/VERSION.yml +2 -2
- data/bin/fog +23 -102
- data/fog.gemspec +48 -2
- data/lib/fog.rb +17 -46
- data/lib/fog/aws.rb +10 -4
- data/lib/fog/aws/bin.rb +69 -0
- data/lib/fog/aws/ec2.rb +82 -86
- data/lib/fog/aws/requests/ec2/authorize_security_group_ingress.rb +20 -16
- data/lib/fog/aws/requests/ec2/revoke_security_group_ingress.rb +19 -15
- data/lib/fog/aws/requests/s3/get_object.rb +4 -0
- data/lib/fog/aws/requests/simpledb/select.rb +42 -24
- data/lib/fog/aws/s3.rb +28 -25
- data/lib/fog/aws/simpledb.rb +21 -17
- data/lib/fog/bin.rb +79 -0
- data/lib/fog/collection.rb +20 -9
- data/lib/fog/model.rb +9 -4
- data/lib/fog/rackspace.rb +10 -3
- data/lib/fog/rackspace/bin.rb +44 -0
- data/lib/fog/rackspace/files.rb +16 -9
- data/lib/fog/rackspace/requests/files/delete_container.rb +2 -1
- data/lib/fog/rackspace/requests/files/delete_object.rb +2 -1
- data/lib/fog/rackspace/requests/files/get_container.rb +2 -1
- data/lib/fog/rackspace/requests/files/get_containers.rb +2 -1
- data/lib/fog/rackspace/requests/files/head_container.rb +2 -1
- data/lib/fog/rackspace/requests/files/head_containers.rb +2 -1
- data/lib/fog/rackspace/requests/files/put_container.rb +2 -1
- data/lib/fog/rackspace/requests/files/put_object.rb +2 -1
- data/lib/fog/rackspace/requests/servers/get_flavor_details.rb +1 -0
- data/lib/fog/rackspace/requests/servers/list_flavors.rb +1 -0
- data/lib/fog/rackspace/requests/servers/list_flavors_detail.rb +1 -0
- data/lib/fog/rackspace/requests/servers/list_images.rb +0 -1
- data/lib/fog/rackspace/requests/servers/reboot_server.rb +2 -1
- data/lib/fog/rackspace/servers.rb +31 -26
- data/lib/fog/slicehost.rb +35 -17
- data/lib/fog/slicehost/bin.rb +42 -0
- data/lib/fog/slicehost/models/flavor.rb +41 -0
- data/lib/fog/slicehost/models/flavors.rb +33 -0
- data/lib/fog/slicehost/models/image.rb +13 -0
- data/lib/fog/slicehost/models/images.rb +35 -0
- data/lib/fog/slicehost/models/server.rb +55 -0
- data/lib/fog/slicehost/models/servers.rb +37 -0
- data/lib/fog/slicehost/parsers/get_flavor.rb +24 -0
- data/lib/fog/slicehost/parsers/get_image.rb +24 -0
- data/lib/fog/slicehost/parsers/get_slice.rb +29 -0
- data/lib/fog/slicehost/requests/create_slice.rb +2 -1
- data/lib/fog/slicehost/requests/delete_slice.rb +2 -1
- data/lib/fog/slicehost/requests/get_backups.rb +1 -0
- data/lib/fog/slicehost/requests/get_flavor.rb +42 -0
- data/lib/fog/slicehost/requests/get_flavors.rb +1 -0
- data/lib/fog/slicehost/requests/get_image.rb +40 -0
- data/lib/fog/slicehost/requests/get_images.rb +1 -0
- data/lib/fog/slicehost/requests/get_slice.rb +48 -0
- data/lib/fog/slicehost/requests/get_slices.rb +1 -0
- data/lib/fog/slicehost/requests/reboot_slice.rb +49 -0
- data/lib/fog/terremark.rb +71 -0
- data/lib/fog/terremark/bin.rb +30 -0
- data/lib/fog/terremark/parsers/get_catalog.rb +43 -0
- data/lib/fog/terremark/parsers/get_catalog_item.rb +44 -0
- data/lib/fog/terremark/parsers/get_organization.rb +44 -0
- data/lib/fog/terremark/parsers/get_organizations.rb +26 -0
- data/lib/fog/terremark/parsers/get_vapp_template.rb +44 -0
- data/lib/fog/terremark/parsers/get_vdc.rb +105 -0
- data/lib/fog/terremark/requests/get_catalog.rb +44 -0
- data/lib/fog/terremark/requests/get_catalog_item.rb +47 -0
- data/lib/fog/terremark/requests/get_organization.rb +46 -0
- data/lib/fog/terremark/requests/get_organizations.rb +42 -0
- data/lib/fog/terremark/requests/get_vapp_template.rb +47 -0
- data/lib/fog/terremark/requests/get_vdc.rb +47 -0
- data/spec/slicehost/models/server_spec.rb +51 -0
- data/spec/slicehost/models/servers_spec.rb +22 -0
- data/spec/slicehost/requests/get_flavor_spec.rb +24 -0
- data/spec/slicehost/requests/get_image_spec.rb +24 -0
- data/spec/slicehost/requests/get_slice_spec.rb +41 -0
- data/spec/slicehost/requests/get_slices_spec.rb +20 -9
- data/spec/slicehost/requests/reboot_slice_spec.rb +41 -0
- data/spec/spec_helper.rb +10 -0
- 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
|
data/lib/fog/collection.rb
CHANGED
@@ -69,16 +69,27 @@ module Fog
|
|
69
69
|
end
|
70
70
|
|
71
71
|
def inspect
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
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
|
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
|
-
|
60
|
-
|
61
|
-
|
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
|
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
|
-
|
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
|
data/lib/fog/rackspace/files.rb
CHANGED
@@ -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
|
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
|
-
|
101
|
+
|
102
|
+
Fog::Rackspace::Files.dependencies.each {|dependency| require(dependency)}
|
@@ -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.
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
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
|
-
|
88
|
+
|
89
|
+
Fog::Rackspace::Servers.dependencies.each {|dependency| require(dependency)}
|