fog 0.0.67 → 0.0.68

Sign up to get free protection for your applications and to get access to all the features.
Files changed (57) hide show
  1. data/README.rdoc +1 -1
  2. data/VERSION.yml +1 -1
  3. data/fog.gemspec +24 -6
  4. data/lib/fog/aws/ec2.rb +48 -47
  5. data/lib/fog/aws/requests/ec2/describe_instances.rb +1 -1
  6. data/lib/fog/aws/requests/ec2/describe_snapshots.rb +3 -3
  7. data/lib/fog/aws/requests/ec2/run_instances.rb +2 -3
  8. data/lib/fog/aws/s3.rb +18 -17
  9. data/lib/fog/aws/simpledb.rb +11 -10
  10. data/lib/fog/bin.rb +12 -4
  11. data/lib/fog/rackspace/files.rb +16 -15
  12. data/lib/fog/rackspace/requests/servers/get_image_details.rb +35 -0
  13. data/lib/fog/rackspace/servers.rb +26 -24
  14. data/lib/fog/slicehost.rb +18 -17
  15. data/lib/fog/slicehost/models/flavors.rb +11 -3
  16. data/lib/fog/slicehost/models/images.rb +14 -4
  17. data/lib/fog/slicehost/models/servers.rb +10 -2
  18. data/lib/fog/terremark.rb +83 -17
  19. data/lib/fog/terremark/parsers/get_public_Ips.rb +28 -0
  20. data/lib/fog/terremark/parsers/internet_service.rb +63 -0
  21. data/lib/fog/terremark/parsers/node_service.rb +30 -0
  22. data/lib/fog/terremark/requests/add_internet_service.rb +63 -0
  23. data/lib/fog/terremark/requests/add_node_service.rb +63 -0
  24. data/lib/fog/terremark/requests/create_internet_service.rb +63 -0
  25. data/lib/fog/terremark/requests/delete_internet_service.rb +40 -0
  26. data/lib/fog/terremark/requests/delete_node_service.rb +40 -0
  27. data/lib/fog/terremark/requests/deploy_vapp.rb +2 -2
  28. data/lib/fog/terremark/requests/get_public_ips.rb +37 -0
  29. data/lib/fog/terremark/requests/get_task.rb +1 -1
  30. data/lib/fog/terremark/requests/get_tasks_list.rb +1 -1
  31. data/lib/fog/terremark/requests/get_vapp.rb +1 -1
  32. data/lib/fog/terremark/requests/instantiate_vapp_template.rb +4 -8
  33. data/lib/fog/terremark/requests/power_off.rb +1 -1
  34. data/lib/fog/terremark/requests/power_on.rb +1 -1
  35. data/lib/fog/terremark/requests/reset.rb +1 -1
  36. data/lib/fog/terremark/requests/shutdown.rb +1 -1
  37. data/tests/{test_helper.rb → helper.rb} +8 -7
  38. data/tests/{test_helper_tests.rb → helper_tests.rb} +7 -9
  39. data/tests/rackspace/helper.rb +64 -0
  40. data/tests/rackspace/requests/servers/create_image_tests.rb +22 -0
  41. data/tests/rackspace/requests/servers/create_server_tests.rb +19 -0
  42. data/tests/rackspace/requests/servers/delete_image_tests.rb +32 -0
  43. data/tests/rackspace/requests/servers/delete_server_tests.rb +26 -0
  44. data/tests/rackspace/requests/servers/get_flavor_details_tests.rb +25 -0
  45. data/tests/rackspace/requests/servers/get_image_details_tests.rb +25 -0
  46. data/tests/rackspace/requests/servers/get_server_details_tests.rb +31 -0
  47. data/tests/slicehost/{slicehost_helper.rb → helper.rb} +0 -0
  48. data/tests/slicehost/requests/create_slice_tests.rb +1 -1
  49. data/tests/slicehost/requests/get_backups_tests.rb +1 -1
  50. data/tests/slicehost/requests/get_flavor_tests.rb +5 -2
  51. data/tests/slicehost/requests/get_flavors_tests.rb +5 -2
  52. data/tests/slicehost/requests/get_image_tests.rb +5 -2
  53. data/tests/slicehost/requests/get_images_tests.rb +5 -2
  54. data/tests/slicehost/requests/get_slice_tests.rb +2 -2
  55. data/tests/slicehost/requests/get_slices_tests.rb +5 -2
  56. data/tests/slicehost/requests/reboot_slice_tests.rb +1 -1
  57. metadata +24 -6
@@ -0,0 +1,63 @@
1
+ module Fog
2
+ module Terremark
3
+ class Real
4
+
5
+ require 'fog/terremark/parsers/internet_service'
6
+
7
+ # Reserve requested resources and deploy vApp
8
+ #
9
+ # ==== Parameters
10
+ # * vdc_id<~Integer> - Id of vDc to add internet service to
11
+ # * name<~String> - Name of service
12
+ # * protocol<~String> - Protocol of service
13
+ # * port<~Integer> - Port of service
14
+ # * options<~Hash>:
15
+ # * Enabled<~Boolean>: defaults to true
16
+ # * Description<~String>: optional description
17
+ #
18
+ # ==== Returns
19
+ # * response<~Excon::Response>:
20
+ # * body<~Hash>:
21
+ # * 'endTime'<~String> - endTime of task
22
+ # * 'href'<~String> - link to task
23
+ # * 'startTime'<~String> - startTime of task
24
+ # * 'status'<~String> - status of task
25
+ # * 'type'<~String> - type of task
26
+ # * 'Owner'<~String> -
27
+ # * 'href'<~String> - href of owner
28
+ # * 'name'<~String> - name of owner
29
+ # * 'type'<~String> - type of owner
30
+ def create_internet_service(vdc_id, name, protocol, port, options = {})
31
+ unless options.has_key?('Enabled')
32
+ options['Enabled'] = true
33
+ end
34
+ data = <<-DATA
35
+ <InternetService xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="urn:tmrk:vCloudExpress-1.0:request:createInternetService">
36
+ <Name>#{name}</Name>
37
+ <Protocol>#{protocol.upcase}</Protocol>
38
+ <Port>#{port}</Port>
39
+ <Enabled>#{options['Enabled']}</Enabled>
40
+ <Description>#{options['Description']}</Description>
41
+ </InternetService>
42
+ DATA
43
+ request(
44
+ :body => data,
45
+ :expects => 200,
46
+ :headers => {'Content-Type' => 'application/xml'},
47
+ :method => 'POST',
48
+ :parser => Fog::Parsers::Terremark::InternetService.new,
49
+ :path => "vdc/#{vdc_id}/internetServices"
50
+ )
51
+ end
52
+
53
+ end
54
+
55
+ class Mock
56
+
57
+ def create_internet_service(vdc_id)
58
+ raise MockNotImplemented.new("Contributions welcome!")
59
+ end
60
+
61
+ end
62
+ end
63
+ end
@@ -0,0 +1,40 @@
1
+ module Fog
2
+ module Terremark
3
+ class Real
4
+
5
+ # Destroy an internet service
6
+ #
7
+ # ==== Parameters
8
+ # * internet_service_id<~Integer> - Id of service to destroy
9
+ #
10
+ # ==== Returns
11
+ # * response<~Excon::Response>:
12
+ # * body<~Hash>:
13
+
14
+ # FIXME
15
+
16
+ # * 'CatalogItems'<~Array>
17
+ # * 'href'<~String> - linke to item
18
+ # * 'name'<~String> - name of item
19
+ # * 'type'<~String> - type of item
20
+ # * 'description'<~String> - Description of catalog
21
+ # * 'name'<~String> - Name of catalog
22
+ def delete_internet_service(internet_service_id)
23
+ request(
24
+ :expects => 200,
25
+ :method => 'DELETE',
26
+ :path => "InternetServices/#{internet_service_id}"
27
+ )
28
+ end
29
+
30
+ end
31
+
32
+ class Mock
33
+
34
+ def delete_internet_service(internet_service_id)
35
+ raise MockNotImplemented.new("Contributions welcome!")
36
+ end
37
+
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,40 @@
1
+ module Fog
2
+ module Terremark
3
+ class Real
4
+
5
+ # Destroy a node
6
+ #
7
+ # ==== Parameters
8
+ # * node_service_id<~Integer> - Id of node to destroy
9
+ #
10
+ # ==== Returns
11
+ # * response<~Excon::Response>:
12
+ # * body<~Hash>:
13
+
14
+ # FIXME
15
+
16
+ # * 'CatalogItems'<~Array>
17
+ # * 'href'<~String> - linke to item
18
+ # * 'name'<~String> - name of item
19
+ # * 'type'<~String> - type of item
20
+ # * 'description'<~String> - Description of catalog
21
+ # * 'name'<~String> - Name of catalog
22
+ def delete_node_service(node_service_id)
23
+ request(
24
+ :expects => 200,
25
+ :method => 'DELETE',
26
+ :path => "nodeServices/#{node_service_id}"
27
+ )
28
+ end
29
+
30
+ end
31
+
32
+ class Mock
33
+
34
+ def delete_node_service(node_id)
35
+ raise MockNotImplemented.new("Contributions welcome!")
36
+ end
37
+
38
+ end
39
+ end
40
+ end
@@ -26,7 +26,7 @@ module Fog
26
26
  :expects => 202,
27
27
  :method => 'POST',
28
28
  :parser => Fog::Parsers::Terremark::Task.new,
29
- :path => "/vApp/#{vapp_id}/action/deploy"
29
+ :path => "vApp/#{vapp_id}/action/deploy"
30
30
  )
31
31
  end
32
32
 
@@ -34,7 +34,7 @@ module Fog
34
34
 
35
35
  class Mock
36
36
 
37
- def deploy_vapp(task_id)
37
+ def deploy_vapp(vapp_id)
38
38
  raise MockNotImplemented.new("Contributions welcome!")
39
39
  end
40
40
 
@@ -0,0 +1,37 @@
1
+ module Fog
2
+ module Terremark
3
+ class Real
4
+
5
+ require 'fog/terremark/parsers/get_public_ips'
6
+
7
+ # Get list of public ips
8
+ #
9
+ # ==== Parameters
10
+ # * vdc_id<~Integer> - Id of vdc to find public ips for
11
+ #
12
+ # ==== Returns
13
+ # * response<~Excon::Response>:
14
+ # * body<~Hash>:
15
+ # * 'PublicIpAddresses'<~Array>
16
+ # * 'href'<~String> - linke to item
17
+ # * 'name'<~String> - name of item
18
+ def get_public_ips(vdc_id)
19
+ request(
20
+ :expects => 200,
21
+ :method => 'GET',
22
+ :parser => Fog::Parsers::Terremark::GetPublicIps.new,
23
+ :path => "vdc/#{vdc_id}/publicIps"
24
+ )
25
+ end
26
+
27
+ end
28
+
29
+ class Mock
30
+
31
+ def get_public_ips(vdc_id)
32
+ raise MockNotImplemented.new("Contributions welcome!")
33
+ end
34
+
35
+ end
36
+ end
37
+ end
@@ -30,7 +30,7 @@ module Fog
30
30
  :expects => 200,
31
31
  :method => 'GET',
32
32
  :parser => Fog::Parsers::Terremark::Task.new,
33
- :path => "/task/#{task_id}"
33
+ :path => "task/#{task_id}"
34
34
  )
35
35
  end
36
36
 
@@ -23,7 +23,7 @@ module Fog
23
23
  :expects => 200,
24
24
  :method => 'GET',
25
25
  :parser => Fog::Parsers::Terremark::GetTasksList.new,
26
- :path => "/tasksList/#{tasks_list_id}"
26
+ :path => "tasksList/#{tasks_list_id}"
27
27
  )
28
28
  end
29
29
 
@@ -33,7 +33,7 @@ module Fog
33
33
  :expects => 200,
34
34
  :method => 'GET',
35
35
  :parser => Fog::Parsers::Terremark::Vapp.new,
36
- :path => "/vapp/#{vapp_id}"
36
+ :path => "vapp/#{vapp_id}"
37
37
  )
38
38
  end
39
39
 
@@ -23,13 +23,9 @@ module Fog
23
23
  # * 'name'<~String> - Name of catalog
24
24
  def instantiate_vapp_template(name)
25
25
  # FIXME: much cheating to commence
26
-
27
- organization_id = get_organizations.body['OrgList'].first['href'].split('/').last
28
- organization = get_organization(organization_id).body
29
- vdc_id = organization['Links'].select {|link| link['type'] == 'application/vnd.vmware.vcloud.vdc+xml'}.first['href'].split('/').last
30
- vdc = get_vdc(vdc_id).body
31
- network_id = vdc['AvailableNetworks'].first['href'].split('/').last
32
- catalog_item = 12 # Ubuntu JeOS 9.10 (64-bit)
26
+ vdc_id = default_vdc_id
27
+ network_id = default_network_id
28
+ catalog_item = 12 # Ubuntu JeOS 9.10 (64-bit)
33
29
 
34
30
  # case UNRESOLVED:
35
31
  # return "0";
@@ -101,7 +97,7 @@ DATA
101
97
  :headers => { 'Content-Type' => 'application/vnd.vmware.vcloud.instantiateVAppTemplateParams+xml' },
102
98
  :method => 'POST',
103
99
  :parser => Fog::Parsers::Terremark::InstantiateVappTemplate.new,
104
- :path => "/vdc/#{vdc_id}/action/instantiatevAppTemplate"
100
+ :path => "vdc/#{vdc_id}/action/instantiatevAppTemplate"
105
101
  )
106
102
  end
107
103
 
@@ -26,7 +26,7 @@ module Fog
26
26
  :expects => 202,
27
27
  :method => 'POST',
28
28
  :parser => Fog::Parsers::Terremark::Task.new,
29
- :path => "/vApp/#{vapp_id}/power/action/powerOff"
29
+ :path => "vApp/#{vapp_id}/power/action/powerOff"
30
30
  )
31
31
  end
32
32
 
@@ -26,7 +26,7 @@ module Fog
26
26
  :expects => 202,
27
27
  :method => 'POST',
28
28
  :parser => Fog::Parsers::Terremark::Task.new,
29
- :path => "/vApp/#{vapp_id}/power/action/powerOn"
29
+ :path => "vApp/#{vapp_id}/power/action/powerOn"
30
30
  )
31
31
  end
32
32
 
@@ -26,7 +26,7 @@ module Fog
26
26
  :expects => 202,
27
27
  :method => 'POST',
28
28
  :parser => Fog::Parsers::Terremark::Task.new,
29
- :path => "/vApp/#{vapp_id}/power/action/reset"
29
+ :path => "vApp/#{vapp_id}/power/action/reset"
30
30
  )
31
31
  end
32
32
 
@@ -26,7 +26,7 @@ module Fog
26
26
  :expects => 202,
27
27
  :method => 'POST',
28
28
  :parser => Fog::Parsers::Terremark::Task.new,
29
- :path => "/vApp/#{vapp_id}/power/action/shutdown"
29
+ :path => "vApp/#{vapp_id}/power/action/shutdown"
30
30
  )
31
31
  end
32
32
 
@@ -1,8 +1,8 @@
1
1
  require File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib', 'fog'))
2
2
  require File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib', 'fog', 'bin'))
3
3
 
4
- # TODO: Currently is true even if some of the keys in format do not appear in
5
- def validate_data_format(original_data, format)
4
+ # TODO: Currently is true even if some of the keys in format do not appear
5
+ def validate_format(original_data, format)
6
6
  valid = true
7
7
  data = original_data.dup
8
8
  for key, value in format
@@ -14,22 +14,23 @@ def validate_data_format(original_data, format)
14
14
  for element in datum
15
15
  type = value.first
16
16
  if type.is_a?(Hash)
17
- valid &&= validate_data_format({:element => element}, {:element => type})
17
+ valid &&= validate_format({:element => element}, {:element => type})
18
18
  else
19
19
  valid &&= element.is_a?(type)
20
20
  end
21
21
  end
22
22
  when Hash
23
23
  valid &&= datum.is_a?(Hash)
24
- valid &&= validate_data_format(datum, value)
24
+ valid &&= validate_format(datum, value)
25
25
  else
26
26
  valid &&= datum.is_a?(value)
27
27
  end
28
28
  end
29
- unless data.empty?
30
- p "validate_data_format did not validate [#{data.inspect}]"
31
- end
32
29
  valid &&= data.empty?
30
+ unless valid
31
+ @formatador.display_line("[red]#{original_data.inspect} does not match #{format.inspect}[/]")
32
+ end
33
+ valid
33
34
  end
34
35
 
35
36
  def wait_for(timeout = 600, &block)
@@ -1,20 +1,18 @@
1
- require File.expand_path(File.join(File.dirname(__FILE__), 'test_helper'))
2
-
3
- Shindo.tests('test_helper') do
1
+ Shindo.tests('test_helper', 'meta') do
4
2
  tests('#validate_data_format') do
5
3
 
6
4
  tests('returns true') do
7
5
 
8
6
  test('when format of value matches') do
9
- validate_data_format({:a => :b}, {:a => Symbol})
7
+ validate_format({:a => :b}, {:a => Symbol})
10
8
  end
11
9
 
12
10
  test('when format of nested array elements matches') do
13
- validate_data_format({:a => [:b, :c]}, {:a => [Symbol]})
11
+ validate_format({:a => [:b, :c]}, {:a => [Symbol]})
14
12
  end
15
13
 
16
14
  test('when format of nested hash matches') do
17
- validate_data_format({:a => {:b => :c}}, {:a => {:b => Symbol}})
15
+ validate_format({:a => {:b => :c}}, {:a => {:b => Symbol}})
18
16
  end
19
17
 
20
18
  end
@@ -22,15 +20,15 @@ Shindo.tests('test_helper') do
22
20
  tests('returns false') do
23
21
 
24
22
  test('when format of value does not match') do
25
- !validate_data_format({:a => :b}, {:a => String})
23
+ !validate_format({:a => :b}, {:a => String})
26
24
  end
27
25
 
28
26
  test('when not all keys are checked') do
29
- !validate_data_format({:a => :b}, {})
27
+ !validate_format({:a => :b}, {})
30
28
  end
31
29
 
32
30
  test('when some keys do not appear') do
33
- !validate_data_format({}, {:a => String})
31
+ !validate_format({}, {:a => String})
34
32
  end
35
33
 
36
34
  end
@@ -0,0 +1,64 @@
1
+ module Rackspace
2
+
3
+ def self.[](service)
4
+ @@connections ||= Hash.new do |hash, key|
5
+ credentials = Fog.credentials.reject do |k, v|
6
+ ![:rackspace_api_key, :rackspace_username].include?(k)
7
+ end
8
+ hash[key] = case key
9
+ when :files
10
+ Fog::Rackspace::Files.new(credentials)
11
+ when :servers
12
+ Fog::Rackspace::Servers.new(credentials)
13
+ end
14
+ end
15
+ @@connections[service]
16
+ end
17
+
18
+ module Files
19
+
20
+ module Formats
21
+
22
+ end
23
+
24
+ end
25
+
26
+ module Servers
27
+
28
+ module Formats
29
+
30
+ FLAVOR = {
31
+ 'disk' => Integer,
32
+ 'id' => Integer,
33
+ 'name' => String,
34
+ 'ram' => Integer
35
+ }
36
+
37
+ IMAGE = {
38
+ 'id' => Integer,
39
+ 'name' => String,
40
+ 'serverId' => Integer,
41
+ 'status' => String,
42
+ 'updated' => String
43
+ }
44
+
45
+ SERVER = {
46
+ 'addresses' => {
47
+ 'private' => [String],
48
+ 'public' => [String]
49
+ },
50
+ 'flavorId' => Integer,
51
+ 'hostId' => String,
52
+ 'id' => Integer,
53
+ 'imageId' => Integer,
54
+ 'metadata' => {},
55
+ 'name' => String,
56
+ 'progress' => Integer,
57
+ 'status' => String
58
+ }
59
+
60
+ end
61
+
62
+ end
63
+
64
+ end