fog 0.0.42 → 0.0.43
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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
@@ -0,0 +1,42 @@
|
|
1
|
+
unless Fog.mocking?
|
2
|
+
|
3
|
+
module Fog
|
4
|
+
class Slicehost
|
5
|
+
|
6
|
+
# Get details of a flavor
|
7
|
+
#
|
8
|
+
# ==== Parameters
|
9
|
+
# * flavor_id<~Integer> - Id of flavor to lookup
|
10
|
+
#
|
11
|
+
# ==== Returns
|
12
|
+
# * response<~Excon::Response>:
|
13
|
+
# * body<~Array>:
|
14
|
+
# * 'id'<~Integer> - Id of the flavor
|
15
|
+
# * 'name'<~String> - Name of the flavor
|
16
|
+
# * 'price'<~Integer> - Price in cents
|
17
|
+
# * 'ram'<~Integer> - Amount of ram for the flavor
|
18
|
+
def get_flavor(flavor_id)
|
19
|
+
request(
|
20
|
+
:expects => 200,
|
21
|
+
:method => 'GET',
|
22
|
+
:parser => Fog::Parsers::Slicehost::GetFlavor.new,
|
23
|
+
:path => "flavors/#{flavor_id}.xml"
|
24
|
+
)
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
else
|
31
|
+
|
32
|
+
module Fog
|
33
|
+
class Slicehost
|
34
|
+
|
35
|
+
def get_flavor(flavor_id)
|
36
|
+
raise MockNotImplemented.new("Contributions welcome!")
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
unless Fog.mocking?
|
2
|
+
|
3
|
+
module Fog
|
4
|
+
class Slicehost
|
5
|
+
|
6
|
+
# Get details of an image
|
7
|
+
#
|
8
|
+
# ==== Parameters
|
9
|
+
# * image_id<~Integer> - Id of image to lookup
|
10
|
+
#
|
11
|
+
# ==== Returns
|
12
|
+
# * response<~Excon::Response>:
|
13
|
+
# * body<~Array>:
|
14
|
+
# * 'id'<~Integer> - Id of the image
|
15
|
+
# * 'name'<~String> - Name of the image
|
16
|
+
def get_image(image_id)
|
17
|
+
request(
|
18
|
+
:expects => 200,
|
19
|
+
:method => 'GET',
|
20
|
+
:parser => Fog::Parsers::Slicehost::GetImage.new,
|
21
|
+
:path => "images/#{image_id}.xml"
|
22
|
+
)
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
else
|
29
|
+
|
30
|
+
module Fog
|
31
|
+
class Slicehost
|
32
|
+
|
33
|
+
def get_image(image_id)
|
34
|
+
raise MockNotImplemented.new("Contributions welcome!")
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
unless Fog.mocking?
|
2
|
+
|
3
|
+
module Fog
|
4
|
+
class Slicehost
|
5
|
+
|
6
|
+
# Get details of a slice
|
7
|
+
#
|
8
|
+
# ==== Parameters
|
9
|
+
# * slice_id<~Integer> - Id of slice to lookup
|
10
|
+
#
|
11
|
+
# ==== Returns
|
12
|
+
# * response<~Excon::Response>:
|
13
|
+
# * body<~Hash>:
|
14
|
+
# * 'addresses'<~Array> - Ip addresses for the slice
|
15
|
+
# * 'backup-id'<~Integer> - Id of backup slice was booted from
|
16
|
+
# * 'bw-in'<~Float> - Incoming bandwidth total for current billing cycle, in Gigabytes
|
17
|
+
# * 'bw-out'<~Float> - Outgoing bandwidth total for current billing cycle, in Gigabytes
|
18
|
+
# * 'flavor_id'<~Integer> - Id of flavor slice was booted from
|
19
|
+
# * 'id'<~Integer> - Id of the slice
|
20
|
+
# * 'image-id'<~Integer> - Id of image slice was booted from
|
21
|
+
# * 'name'<~String> - Name of the slice
|
22
|
+
# * 'progress'<~Integer> - Progress of current action, in percentage
|
23
|
+
# * 'status'<~String> - Current status of the slice
|
24
|
+
def get_slice(slice_id)
|
25
|
+
request(
|
26
|
+
:expects => 200,
|
27
|
+
:method => 'GET',
|
28
|
+
:parser => Fog::Parsers::Slicehost::GetSlice.new,
|
29
|
+
:path => "/slices/#{slice_id}.xml"
|
30
|
+
)
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
else
|
37
|
+
|
38
|
+
module Fog
|
39
|
+
class Slicehost
|
40
|
+
|
41
|
+
def get_slice(id)
|
42
|
+
raise MockNotImplemented.new("Contributions welcome!")
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
unless Fog.mocking?
|
2
|
+
|
3
|
+
module Fog
|
4
|
+
class Slicehost
|
5
|
+
|
6
|
+
# Reboot slice
|
7
|
+
# ==== Parameters
|
8
|
+
# * slice_id<~Integer> - Id of server to reboot
|
9
|
+
# * type<~String> - Type of reboot, must be in ['HARD', 'SOFT']
|
10
|
+
#
|
11
|
+
# ==== Returns
|
12
|
+
# * response<~Excon::Response>:
|
13
|
+
# * body<~Hash>:
|
14
|
+
# * 'addresses'<~Array> - Ip addresses for the slice
|
15
|
+
# * 'backup-id'<~Integer> - Id of backup slice was booted from
|
16
|
+
# * 'bw-in'<~Float> - Incoming bandwidth total for current billing cycle, in Gigabytes
|
17
|
+
# * 'bw-out'<~Float> - Outgoing bandwidth total for current billing cycle, in Gigabytes
|
18
|
+
# * 'flavor_id'<~Integer> - Id of flavor slice was booted from
|
19
|
+
# * 'id'<~Integer> - Id of the slice
|
20
|
+
# * 'image-id'<~Integer> - Id of image slice was booted from
|
21
|
+
# * 'name'<~String> - Name of the slice
|
22
|
+
# * 'progress'<~Integer> - Progress of current action, in percentage
|
23
|
+
# * 'status'<~String> - Current status of the slice
|
24
|
+
def reboot_slice(slice_id, type = 'SOFT')
|
25
|
+
request(
|
26
|
+
:body => '', # Gives a 411 Length Required without this
|
27
|
+
:expects => 200,
|
28
|
+
:method => 'PUT',
|
29
|
+
:parser => Fog::Parsers::Slicehost::GetSlice.new,
|
30
|
+
:path => "/slices/#{slice_id}/#{'hard_' if type == 'HARD'}reboot.xml"
|
31
|
+
)
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
else
|
38
|
+
|
39
|
+
module Fog
|
40
|
+
class Slicehost
|
41
|
+
|
42
|
+
def get_slice(id)
|
43
|
+
raise MockNotImplemented.new("Contributions welcome!")
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
@@ -0,0 +1,71 @@
|
|
1
|
+
module Fog
|
2
|
+
class Terremark
|
3
|
+
|
4
|
+
def self.dependencies
|
5
|
+
[
|
6
|
+
'fog/terremark/parsers/get_catalog.rb',
|
7
|
+
'fog/terremark/parsers/get_catalog_item.rb',
|
8
|
+
'fog/terremark/parsers/get_organization.rb',
|
9
|
+
'fog/terremark/parsers/get_organizations.rb',
|
10
|
+
'fog/terremark/parsers/get_vapp_template.rb',
|
11
|
+
'fog/terremark/parsers/get_vdc.rb',
|
12
|
+
'fog/terremark/requests/get_catalog.rb',
|
13
|
+
'fog/terremark/requests/get_catalog_item.rb',
|
14
|
+
'fog/terremark/requests/get_organization.rb',
|
15
|
+
'fog/terremark/requests/get_organizations.rb',
|
16
|
+
'fog/terremark/requests/get_vapp_template.rb',
|
17
|
+
'fog/terremark/requests/get_vdc.rb'
|
18
|
+
]
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.reload
|
22
|
+
self.dependencies.each {|dependency| load(dependency)}
|
23
|
+
end
|
24
|
+
|
25
|
+
def initialize(options={})
|
26
|
+
unless @terremark_password = options[:terremark_password]
|
27
|
+
raise ArgumentError.new('terremark_password is required to access terremark')
|
28
|
+
end
|
29
|
+
unless @terremark_username = options[:terremark_username]
|
30
|
+
raise ArgumentError.new('terremark_username is required to access terremark')
|
31
|
+
end
|
32
|
+
@host = options[:host] || "services.vcloudexpress.terremark.com"
|
33
|
+
@path = options[:path] || "/api/v0.8"
|
34
|
+
@port = options[:port] || 443
|
35
|
+
@scheme = options[:scheme] || 'https'
|
36
|
+
|
37
|
+
@cookie = get_organizations.headers['Set-Cookie']
|
38
|
+
end
|
39
|
+
|
40
|
+
private
|
41
|
+
|
42
|
+
def request(params)
|
43
|
+
@connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}")
|
44
|
+
headers = {}
|
45
|
+
if @cookie
|
46
|
+
headers.merge!('Cookie' => @cookie)
|
47
|
+
end
|
48
|
+
response = @connection.request({
|
49
|
+
:body => params[:body],
|
50
|
+
:expects => params[:expects],
|
51
|
+
:headers => headers.merge!(params[:headers] || {}),
|
52
|
+
:host => @host,
|
53
|
+
:method => params[:method],
|
54
|
+
:parser => params[:parser],
|
55
|
+
:path => "#{@path}/#{params[:path]}"
|
56
|
+
})
|
57
|
+
end
|
58
|
+
|
59
|
+
if Fog.mocking?
|
60
|
+
|
61
|
+
srand(Time.now.to_i)
|
62
|
+
|
63
|
+
class Mock
|
64
|
+
end
|
65
|
+
|
66
|
+
end
|
67
|
+
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
Fog::Terremark.dependencies.each {|dependency| require(dependency)}
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module Terremark
|
2
|
+
class << self
|
3
|
+
if Fog.credentials[:terremark_password] && Fog.credentials[:terremark_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
|
+
![:terremark_username, :terremark_password].include?(k)
|
13
|
+
end
|
14
|
+
hash[key] = case key
|
15
|
+
when :vcloud
|
16
|
+
Fog::Terremark.new(credentials)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
@@connections[service]
|
20
|
+
end
|
21
|
+
|
22
|
+
else
|
23
|
+
|
24
|
+
def initialized?
|
25
|
+
false
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
module Fog
|
2
|
+
module Parsers
|
3
|
+
module Terremark
|
4
|
+
|
5
|
+
class GetCatalog < Fog::Parsers::Base
|
6
|
+
|
7
|
+
def reset
|
8
|
+
@response = { 'CatalogItems' => [] }
|
9
|
+
end
|
10
|
+
|
11
|
+
def start_element(name, attributes)
|
12
|
+
@value = ''
|
13
|
+
case name
|
14
|
+
when 'CatalogItem'
|
15
|
+
catalog_item = {}
|
16
|
+
until attributes.empty?
|
17
|
+
catalog_item[attributes.shift] = attributes.shift
|
18
|
+
end
|
19
|
+
@response['CatalogItems'] << catalog_item
|
20
|
+
when 'Catalog'
|
21
|
+
catalog = {}
|
22
|
+
until attributes.empty?
|
23
|
+
if attributes.first.is_a?(Array)
|
24
|
+
catalog[attributes.first.first] = attributes.shift.last
|
25
|
+
else
|
26
|
+
catalog[attributes.shift] = attributes.shift
|
27
|
+
end
|
28
|
+
end
|
29
|
+
@response['name'] = catalog['name']
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def end_element(name)
|
34
|
+
if name == 'Description'
|
35
|
+
@response[name] = @value
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
module Fog
|
2
|
+
module Parsers
|
3
|
+
module Terremark
|
4
|
+
|
5
|
+
class GetCatalogItem < Fog::Parsers::Base
|
6
|
+
|
7
|
+
def reset
|
8
|
+
@property_key
|
9
|
+
@response = { 'Entity' => {}, 'Properties' => {} }
|
10
|
+
end
|
11
|
+
|
12
|
+
def start_element(name, attributes)
|
13
|
+
@value = ''
|
14
|
+
case name
|
15
|
+
when 'Entity'
|
16
|
+
until attributes.empty?
|
17
|
+
@response['Entity'][attributes.shift] = attributes.shift
|
18
|
+
end
|
19
|
+
when 'CatalogItem'
|
20
|
+
catalog_item = {}
|
21
|
+
until attributes.empty?
|
22
|
+
if attributes.first.is_a?(Array)
|
23
|
+
catalog_item[attributes.first.first] = attributes.shift.last
|
24
|
+
else
|
25
|
+
catalog_item[attributes.shift] = attributes.shift
|
26
|
+
end
|
27
|
+
end
|
28
|
+
@response['name'] = catalog_item['name']
|
29
|
+
when 'Property'
|
30
|
+
@property_key = attributes.last
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def end_element(name)
|
35
|
+
if name == 'Property'
|
36
|
+
@response['Properties'][@property_key] = @value
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
module Fog
|
2
|
+
module Parsers
|
3
|
+
module Terremark
|
4
|
+
|
5
|
+
class GetOrganization < Fog::Parsers::Base
|
6
|
+
|
7
|
+
def reset
|
8
|
+
@response = { 'Links' => [] }
|
9
|
+
end
|
10
|
+
|
11
|
+
def start_element(name, attributes)
|
12
|
+
@value = ''
|
13
|
+
case name
|
14
|
+
when 'Link'
|
15
|
+
link = {}
|
16
|
+
until attributes.empty?
|
17
|
+
link[attributes.shift] = attributes.shift
|
18
|
+
end
|
19
|
+
@response['Links'] << link
|
20
|
+
when 'Org'
|
21
|
+
org = {}
|
22
|
+
until attributes.empty?
|
23
|
+
if attributes.first.is_a?(Array)
|
24
|
+
org[attributes.first.first] = attributes.shift.last
|
25
|
+
else
|
26
|
+
org[attributes.shift] = attributes.shift
|
27
|
+
end
|
28
|
+
end
|
29
|
+
@response['href'] = org['href']
|
30
|
+
@response['name'] = org['name']
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def end_element(name)
|
35
|
+
if name == 'Description'
|
36
|
+
@response[name] = @value
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|