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.
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
@@ -30,6 +30,7 @@ else
30
30
  class Slicehost
31
31
 
32
32
  def get_backups
33
+ raise MockNotImplemented.new("Contributions welcome!")
33
34
  end
34
35
 
35
36
  end
@@ -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
@@ -30,6 +30,7 @@ else
30
30
  class Slicehost
31
31
 
32
32
  def get_flavors
33
+ raise MockNotImplemented.new("Contributions welcome!")
33
34
  end
34
35
 
35
36
  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
@@ -28,6 +28,7 @@ else
28
28
  class Slicehost
29
29
 
30
30
  def get_images
31
+ raise MockNotImplemented.new("Contributions welcome!")
31
32
  end
32
33
 
33
34
  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
@@ -36,6 +36,7 @@ else
36
36
  class Slicehost
37
37
 
38
38
  def get_slices
39
+ raise MockNotImplemented.new("Contributions welcome!")
39
40
  end
40
41
 
41
42
  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