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/slicehost.rb
CHANGED
@@ -10,28 +10,45 @@ module Fog
|
|
10
10
|
end
|
11
11
|
end
|
12
12
|
|
13
|
-
def self.
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
13
|
+
def self.dependencies
|
14
|
+
[
|
15
|
+
"fog/slicehost/models/flavor.rb",
|
16
|
+
"fog/slicehost/models/flavors.rb",
|
17
|
+
"fog/slicehost/models/image.rb",
|
18
|
+
"fog/slicehost/models/images.rb",
|
19
|
+
"fog/slicehost/models/server.rb",
|
20
|
+
"fog/slicehost/models/servers.rb",
|
21
|
+
"fog/slicehost/parsers/create_slice.rb",
|
22
|
+
"fog/slicehost/parsers/get_backups.rb",
|
23
|
+
"fog/slicehost/parsers/get_flavor.rb",
|
24
|
+
"fog/slicehost/parsers/get_flavors.rb",
|
25
|
+
"fog/slicehost/parsers/get_image.rb",
|
26
|
+
"fog/slicehost/parsers/get_images.rb",
|
27
|
+
"fog/slicehost/parsers/get_slice.rb",
|
28
|
+
"fog/slicehost/parsers/get_slices.rb",
|
29
|
+
"fog/slicehost/requests/create_slice.rb",
|
30
|
+
"fog/slicehost/requests/delete_slice.rb",
|
31
|
+
"fog/slicehost/requests/get_backups.rb",
|
32
|
+
"fog/slicehost/requests/get_flavor.rb",
|
33
|
+
"fog/slicehost/requests/get_flavors.rb",
|
34
|
+
"fog/slicehost/requests/get_image.rb",
|
35
|
+
"fog/slicehost/requests/get_images.rb",
|
36
|
+
"fog/slicehost/requests/get_slice.rb",
|
37
|
+
"fog/slicehost/requests/get_slices.rb",
|
38
|
+
"fog/slicehost/requests/reboot_slice.rb"
|
39
|
+
]
|
40
|
+
end
|
26
41
|
|
42
|
+
def self.reload
|
43
|
+
self.dependencies.each {|dependency| load(dependency)}
|
27
44
|
if Fog.mocking?
|
28
45
|
reset_data
|
29
46
|
end
|
30
47
|
end
|
31
48
|
|
32
49
|
def initialize(options={})
|
33
|
-
unless @
|
34
|
-
raise ArgumentError.new('
|
50
|
+
unless @slicehost_password = options[:slicehost_password]
|
51
|
+
raise ArgumentError.new('slicehost_password is required to access slicehost')
|
35
52
|
end
|
36
53
|
@host = options[:host] || "api.slicehost.com"
|
37
54
|
@port = options[:port] || 443
|
@@ -41,7 +58,7 @@ module Fog
|
|
41
58
|
def request(params)
|
42
59
|
@connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}")
|
43
60
|
headers = {
|
44
|
-
'Authorization' => "Basic #{Base64.encode64(@
|
61
|
+
'Authorization' => "Basic #{Base64.encode64(@slicehost_password).chomp!}"
|
45
62
|
}
|
46
63
|
case params[:method]
|
47
64
|
when 'DELETE', 'GET', 'HEAD'
|
@@ -59,10 +76,11 @@ module Fog
|
|
59
76
|
:parser => params[:parser],
|
60
77
|
:path => params[:path]
|
61
78
|
})
|
79
|
+
|
62
80
|
response
|
63
81
|
end
|
64
82
|
|
65
83
|
end
|
66
84
|
end
|
67
85
|
|
68
|
-
Fog::Slicehost.
|
86
|
+
Fog::Slicehost.dependencies.each {|dependency| require(dependency)}
|
@@ -0,0 +1,42 @@
|
|
1
|
+
module Slicehost
|
2
|
+
class << self
|
3
|
+
if Fog.credentials[:slicehost_password]
|
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
|
+
![:slicehost_password].include?(k)
|
13
|
+
end
|
14
|
+
hash[key] = case key
|
15
|
+
when :slices
|
16
|
+
Fog::Slicehost.new(credentials)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
@@connections[service]
|
20
|
+
end
|
21
|
+
|
22
|
+
def flavors
|
23
|
+
self[:slices].flavors
|
24
|
+
end
|
25
|
+
|
26
|
+
def images
|
27
|
+
self[:slices].images
|
28
|
+
end
|
29
|
+
|
30
|
+
def servers
|
31
|
+
self[:slices].servers
|
32
|
+
end
|
33
|
+
|
34
|
+
else
|
35
|
+
|
36
|
+
def initialized?
|
37
|
+
false
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
module Fog
|
2
|
+
class Slicehost
|
3
|
+
|
4
|
+
class Flavor < Fog::Model
|
5
|
+
|
6
|
+
identity :id
|
7
|
+
|
8
|
+
attribute :name
|
9
|
+
attribute :price
|
10
|
+
attribute :ram
|
11
|
+
|
12
|
+
def bits
|
13
|
+
# 64
|
14
|
+
raise StandardError.new("Figure me out!?!")
|
15
|
+
end
|
16
|
+
|
17
|
+
def cores
|
18
|
+
# # 2 quad-cores >= 2Ghz = 8 cores
|
19
|
+
# 8 * case ram
|
20
|
+
# when 256
|
21
|
+
# 1/64.0
|
22
|
+
# when 512
|
23
|
+
# 1/32.0
|
24
|
+
# when 1024
|
25
|
+
# 1/16.0
|
26
|
+
# when 2048
|
27
|
+
# 1/8.0
|
28
|
+
# when 4096
|
29
|
+
# 1/4.0
|
30
|
+
# when 8192
|
31
|
+
# 1/2.0
|
32
|
+
# when 15872
|
33
|
+
# 1
|
34
|
+
# end
|
35
|
+
raise StandardError.new("Figure me out!?!")
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module Fog
|
2
|
+
class Slicehost
|
3
|
+
|
4
|
+
def flavors
|
5
|
+
Fog::Slicehost::Flavors.new(:connection => self)
|
6
|
+
end
|
7
|
+
|
8
|
+
class Flavors < Fog::Collection
|
9
|
+
|
10
|
+
model Fog::Slicehost::Flavor
|
11
|
+
|
12
|
+
def all
|
13
|
+
if @loaded
|
14
|
+
clear
|
15
|
+
end
|
16
|
+
@loaded = true
|
17
|
+
data = connection.get_flavors.body
|
18
|
+
for flavor in data['flavors']
|
19
|
+
self << new(flavor)
|
20
|
+
end
|
21
|
+
self
|
22
|
+
end
|
23
|
+
|
24
|
+
def get(flavor_id)
|
25
|
+
connection.get_flavor(flavor_id)
|
26
|
+
rescue Excon::Errors::Forbidden
|
27
|
+
nil
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module Fog
|
2
|
+
class Slicehost
|
3
|
+
|
4
|
+
def images(attributes = {})
|
5
|
+
Fog::Slicehost::Images.new({
|
6
|
+
:connection => self
|
7
|
+
}.merge!(attributes))
|
8
|
+
end
|
9
|
+
|
10
|
+
class Images < Fog::Collection
|
11
|
+
|
12
|
+
model Fog::Slicehost::Image
|
13
|
+
|
14
|
+
def all
|
15
|
+
if @loaded
|
16
|
+
clear
|
17
|
+
end
|
18
|
+
@loaded = true
|
19
|
+
data = connection.get_images.body
|
20
|
+
for image in data['images']
|
21
|
+
self << new(image)
|
22
|
+
end
|
23
|
+
self
|
24
|
+
end
|
25
|
+
|
26
|
+
def get(image_id)
|
27
|
+
connection.get_image(image_id)
|
28
|
+
rescue Excon::Errors::Forbidden
|
29
|
+
nil
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
module Fog
|
2
|
+
class Slicehost
|
3
|
+
|
4
|
+
class Server < Fog::Model
|
5
|
+
|
6
|
+
identity :id
|
7
|
+
|
8
|
+
attribute :addresses
|
9
|
+
attribute :backup_id, 'backup-id'
|
10
|
+
attribute :bandwidth_in, 'bw-in'
|
11
|
+
attribute :bandwidth_out, 'bw-out'
|
12
|
+
attribute :flavor_id, 'flavor-id'
|
13
|
+
attribute :image_id, 'image-id'
|
14
|
+
attribute :name
|
15
|
+
attribute :password, 'root-password'
|
16
|
+
attribute :progress
|
17
|
+
attribute :status
|
18
|
+
|
19
|
+
def destroy
|
20
|
+
requires :id
|
21
|
+
connection.delete_slice(@id)
|
22
|
+
true
|
23
|
+
end
|
24
|
+
|
25
|
+
def flavor
|
26
|
+
requires :flavor_id
|
27
|
+
connection.flavors.get(@flavor_id)
|
28
|
+
end
|
29
|
+
|
30
|
+
def image
|
31
|
+
requires :image_id
|
32
|
+
connection.images.get(@image_id)
|
33
|
+
end
|
34
|
+
|
35
|
+
def ready?
|
36
|
+
@status == 'active'
|
37
|
+
end
|
38
|
+
|
39
|
+
def reboot(type = 'SOFT')
|
40
|
+
requires :id
|
41
|
+
connection.reboot_server(@id, type)
|
42
|
+
true
|
43
|
+
end
|
44
|
+
|
45
|
+
def save
|
46
|
+
requires :flavor_id, :image_id, :name
|
47
|
+
data = connection.create_slice(@flavor_id, @image_id, @name)
|
48
|
+
merge_attributes(data.body)
|
49
|
+
true
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module Fog
|
2
|
+
class Slicehost
|
3
|
+
|
4
|
+
def servers
|
5
|
+
Fog::Slicehost::Servers.new(:connection => self)
|
6
|
+
end
|
7
|
+
|
8
|
+
class Servers < Fog::Collection
|
9
|
+
|
10
|
+
model Fog::Slicehost::Server
|
11
|
+
|
12
|
+
def all
|
13
|
+
if @loaded
|
14
|
+
clear
|
15
|
+
end
|
16
|
+
@loaded = true
|
17
|
+
data = connection.get_slices.body['slices']
|
18
|
+
for server in data
|
19
|
+
self << new(server)
|
20
|
+
end
|
21
|
+
self
|
22
|
+
end
|
23
|
+
|
24
|
+
def get(server_id)
|
25
|
+
if server_id && server = connection.get_slice(server_id).body
|
26
|
+
new(server)
|
27
|
+
elsif !server_id
|
28
|
+
nil
|
29
|
+
end
|
30
|
+
rescue Excon::Errors::Forbidden
|
31
|
+
nil
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module Fog
|
2
|
+
module Parsers
|
3
|
+
module Slicehost
|
4
|
+
|
5
|
+
class GetFlavor < Fog::Parsers::Base
|
6
|
+
|
7
|
+
def reset
|
8
|
+
@response = {}
|
9
|
+
end
|
10
|
+
|
11
|
+
def end_element(name)
|
12
|
+
case name
|
13
|
+
when 'id', 'price', 'ram'
|
14
|
+
@response[name] = @value.to_i
|
15
|
+
when 'name'
|
16
|
+
@response[name] = @value
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module Fog
|
2
|
+
module Parsers
|
3
|
+
module Slicehost
|
4
|
+
|
5
|
+
class GetImage < Fog::Parsers::Base
|
6
|
+
|
7
|
+
def reset
|
8
|
+
@response = {}
|
9
|
+
end
|
10
|
+
|
11
|
+
def end_element(name)
|
12
|
+
case name
|
13
|
+
when 'id'
|
14
|
+
@response[name] = @value.to_i
|
15
|
+
when 'name'
|
16
|
+
@response[name] = @value
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module Fog
|
2
|
+
module Parsers
|
3
|
+
module Slicehost
|
4
|
+
|
5
|
+
class GetSlice < Fog::Parsers::Base
|
6
|
+
|
7
|
+
def reset
|
8
|
+
@response = {}
|
9
|
+
end
|
10
|
+
|
11
|
+
def end_element(name)
|
12
|
+
case name
|
13
|
+
when 'address'
|
14
|
+
@response['addresses'] ||= []
|
15
|
+
@response['addresses'] << @value
|
16
|
+
when 'backup-id', 'flavor-id', 'id', 'image-id', 'progress'
|
17
|
+
@response[name] = @value.to_i
|
18
|
+
when 'bw-in', 'bw-out'
|
19
|
+
@response[name] = @value.to_f
|
20
|
+
when 'name', 'status'
|
21
|
+
@response[name] = @value
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|