fog-ecloud 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (63) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +1048 -11
  3. data/Rakefile +6 -4
  4. data/lib/fog/compute/ecloud.rb +18 -3
  5. data/lib/fog/compute/ecloud/errors.rb +91 -0
  6. data/lib/fog/compute/ecloud/models/admin_organizations.rb +2 -1
  7. data/lib/fog/compute/ecloud/models/api_keys.rb +2 -1
  8. data/lib/fog/compute/ecloud/models/associations.rb +2 -1
  9. data/lib/fog/compute/ecloud/models/authentication_levels.rb +2 -1
  10. data/lib/fog/compute/ecloud/models/backup_internet_services.rb +2 -1
  11. data/lib/fog/compute/ecloud/models/catalog.rb +3 -2
  12. data/lib/fog/compute/ecloud/models/catalog_configurations.rb +2 -1
  13. data/lib/fog/compute/ecloud/models/compute_pools.rb +2 -1
  14. data/lib/fog/compute/ecloud/models/cpu_usage_detail_summary.rb +2 -1
  15. data/lib/fog/compute/ecloud/models/detached_disks.rb +3 -2
  16. data/lib/fog/compute/ecloud/models/environments.rb +2 -1
  17. data/lib/fog/compute/ecloud/models/firewall_acls.rb +2 -1
  18. data/lib/fog/compute/ecloud/models/groups.rb +2 -1
  19. data/lib/fog/compute/ecloud/models/guest_processes.rb +2 -1
  20. data/lib/fog/compute/ecloud/models/hardware_configurations.rb +2 -1
  21. data/lib/fog/compute/ecloud/models/internet_services.rb +7 -6
  22. data/lib/fog/compute/ecloud/models/ip_addresses.rb +2 -1
  23. data/lib/fog/compute/ecloud/models/layouts.rb +2 -1
  24. data/lib/fog/compute/ecloud/models/locations.rb +2 -1
  25. data/lib/fog/compute/ecloud/models/login_banners.rb +2 -1
  26. data/lib/fog/compute/ecloud/models/memory_usage_detail_summary.rb +2 -1
  27. data/lib/fog/compute/ecloud/models/monitors.rb +2 -1
  28. data/lib/fog/compute/ecloud/models/networks.rb +3 -2
  29. data/lib/fog/compute/ecloud/models/nodes.rb +3 -2
  30. data/lib/fog/compute/ecloud/models/operating_system_families.rb +2 -1
  31. data/lib/fog/compute/ecloud/models/operating_systems.rb +2 -1
  32. data/lib/fog/compute/ecloud/models/organizations.rb +2 -1
  33. data/lib/fog/compute/ecloud/models/password_complexity_rules.rb +2 -1
  34. data/lib/fog/compute/ecloud/models/physical_devices.rb +2 -1
  35. data/lib/fog/compute/ecloud/models/public_ips.rb +3 -2
  36. data/lib/fog/compute/ecloud/models/rnats.rb +2 -1
  37. data/lib/fog/compute/ecloud/models/roles.rb +2 -1
  38. data/lib/fog/compute/ecloud/models/rows.rb +2 -1
  39. data/lib/fog/compute/ecloud/models/server.rb +40 -41
  40. data/lib/fog/compute/ecloud/models/server_configuration_options.rb +2 -1
  41. data/lib/fog/compute/ecloud/models/servers.rb +10 -9
  42. data/lib/fog/compute/ecloud/models/ssh_keys.rb +3 -2
  43. data/lib/fog/compute/ecloud/models/storage_usage_detail_summary.rb +2 -1
  44. data/lib/fog/compute/ecloud/models/support_tickets.rb +2 -1
  45. data/lib/fog/compute/ecloud/models/tags.rb +2 -1
  46. data/lib/fog/compute/ecloud/models/tasks.rb +2 -1
  47. data/lib/fog/compute/ecloud/models/templates.rb +2 -1
  48. data/lib/fog/compute/ecloud/models/trusted_network_groups.rb +2 -1
  49. data/lib/fog/compute/ecloud/models/users.rb +2 -1
  50. data/lib/fog/compute/ecloud/models/virtual_machine_assigned_ips.rb +5 -4
  51. data/lib/fog/compute/ecloud/requests/get_admin_organization.rb +4 -2
  52. data/lib/fog/compute/ecloud/requests/get_compute_pool.rb +4 -2
  53. data/lib/fog/compute/ecloud/requests/get_environment.rb +5 -3
  54. data/lib/fog/compute/ecloud/requests/get_ip_address.rb +5 -3
  55. data/lib/fog/compute/ecloud/requests/get_network.rb +4 -2
  56. data/lib/fog/compute/ecloud/requests/get_operating_system.rb +5 -3
  57. data/lib/fog/compute/ecloud/requests/get_ssh_key.rb +3 -1
  58. data/lib/fog/compute/ecloud/requests/get_template.rb +5 -3
  59. data/lib/fog/compute/ecloud/requests/ssh_key_edit.rb +2 -1
  60. data/lib/fog/ecloud/version.rb +1 -1
  61. data/tests/compute/livespec/auth_tests.rb +101 -0
  62. data/tests/compute/models/ssh_key_tests.rb +12 -11
  63. metadata +4 -2
@@ -17,7 +17,8 @@ module Fog
17
17
  if data = service.get_support_ticket(uri)
18
18
  new(data.body)
19
19
  end
20
- rescue Fog::Errors::NotFound
20
+ rescue ServiceError => e
21
+ raise e unless e.status_code == 404
21
22
  nil
22
23
  end
23
24
  end
@@ -17,7 +17,8 @@ module Fog
17
17
  if data = service.get_tag(uri)
18
18
  new(data.body)
19
19
  end
20
- rescue Fog::Errors::NotFound
20
+ rescue ServiceError => e
21
+ raise e unless e.status_code == 404
21
22
  nil
22
23
  end
23
24
  end
@@ -20,7 +20,8 @@ module Fog
20
20
  if data = service.get_task(uri)
21
21
  new(data.body)
22
22
  end
23
- rescue Fog::Errors::NotFound
23
+ rescue ServiceError => e
24
+ raise e unless e.status_code == 404
24
25
  nil
25
26
  end
26
27
  end
@@ -32,7 +32,8 @@ module Fog
32
32
  if data = service.get_template(uri)
33
33
  new(data.body)
34
34
  end
35
- rescue Fog::Errors::NotFound
35
+ rescue ServiceError => e
36
+ raise e unless e.status_code == 404
36
37
  nil
37
38
  end
38
39
  end
@@ -18,7 +18,8 @@ module Fog
18
18
  if data = service.get_trusted_network_group(uri)
19
19
  new(data.body)
20
20
  end
21
- rescue Fog::Errors::NotFound
21
+ rescue ServiceError => e
22
+ raise e unless e.status_code == 404
22
23
  nil
23
24
  end
24
25
  end
@@ -17,7 +17,8 @@ module Fog
17
17
  if data = service.get_user(uri)
18
18
  new(data.body)
19
19
  end
20
- rescue Fog::Errors::NotFound
20
+ rescue ServiceError => e
21
+ raise e unless e.status_code == 404
21
22
  nil
22
23
  end
23
24
  end
@@ -9,15 +9,16 @@ module Fog
9
9
  model Fog::Compute::Ecloud::VirtualMachineAssignedIp
10
10
 
11
11
  def all
12
- data = service.get_virtual_machine_assigned_ips(self.identity).body
12
+ data = service.get_virtual_machine_assigned_ips(identity).body
13
13
  load(data)
14
14
  end
15
15
 
16
- def get(uri)
17
- if data = service.get_virtual_machine_assigned_ip(self.identity)
16
+ def get
17
+ if data = service.get_virtual_machine_assigned_ip(identity)
18
18
  new(data.body)
19
19
  end
20
- rescue Fog::Errors::NotFound
20
+ rescue ServiceError => e
21
+ raise e unless e.status_code == 404
21
22
  nil
22
23
  end
23
24
  end
@@ -8,13 +8,15 @@ module Fog
8
8
  class Mock
9
9
  def get_admin_organization(uri)
10
10
  organization_id = id_from_uri(uri)
11
- admin_organization = self.data[:admin_organizations][organization_id]
11
+ admin_organization = data[:admin_organizations][organization_id]
12
12
 
13
13
  if admin_organization
14
14
  body = Fog::Ecloud.slice(admin_organization, :id, :organization_id)
15
15
 
16
16
  response(:body => body)
17
- else response(:status => 404) # ?
17
+ else
18
+ body = "<Error message=\"Resource Not Found\" majorErrorCode=\"404\" minorErrorCode=\"ResourceNotFound\" />"
19
+ response(:body => body, :expects => 200, :status => 404)
18
20
  end
19
21
  end
20
22
  end
@@ -8,11 +8,13 @@ module Fog
8
8
  class Mock
9
9
  def get_compute_pool(uri)
10
10
  compute_pool_id = id_from_uri(uri)
11
- compute_pool = self.data[:compute_pools][compute_pool_id]
11
+ compute_pool = data[:compute_pools][compute_pool_id]
12
12
 
13
13
  if compute_pool
14
14
  response(:body => Fog::Ecloud.slice(compute_pool, :id, :environment))
15
- else response(:status => 404) # ?
15
+ else
16
+ body = "<Error message=\"Resource Not Found\" majorErrorCode=\"404\" minorErrorCode=\"ResourceNotFound\" />"
17
+ response(:body => body, :expects => 200, :status => 404)
16
18
  end
17
19
  end
18
20
  end
@@ -8,12 +8,12 @@ module Fog
8
8
  class Mock
9
9
  def get_environment(uri)
10
10
  environment_id = id_from_uri(uri)
11
- organizations = self.data[:organizations].values
11
+ organizations = data[:organizations].values
12
12
  environment = nil
13
13
  catch(:found) do
14
14
  organizations.each do |organization|
15
15
  organization[:Locations][:Location].each do |location|
16
- environment = location[:Environments][:Environment].find{|e| e[:id] == environment_id}
16
+ environment = location[:Environments][:Environment].detect { |e| e[:id] == environment_id }
17
17
  throw :found if environment
18
18
  end
19
19
  end
@@ -22,7 +22,9 @@ module Fog
22
22
  body = environment.dup
23
23
  body.delete(:id)
24
24
  response(:body => body)
25
- else response(:status => 404) # ?
25
+ else
26
+ body = "<Error message=\"Resource Not Found\" majorErrorCode=\"404\" minorErrorCode=\"ResourceNotFound\" />"
27
+ response(:body => body, :expects => 200, :status => 404)
26
28
  end
27
29
  end
28
30
  end
@@ -5,13 +5,15 @@ module Fog
5
5
  basic_request :get_ip_address
6
6
  end
7
7
 
8
- class Mock
8
+ class Mock
9
9
  def get_ip_address(uri)
10
10
  network_id, ip_address_id = uri.match(/\/networks\/(\d+)\/(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})$/).captures
11
- ip_address = self.data[:networks][network_id.to_i][:IpAddresses][:IpAddress].find{|ip| ip[:name] == ip_address_id }.dup
11
+ ip_address = data[:networks][network_id.to_i][:IpAddresses][:IpAddress].detect { |ip| ip[:name] == ip_address_id }.dup
12
12
  if ip_address
13
13
  response(:body => ip_address)
14
- else response(:status => 404) # ?
14
+ else
15
+ body = "<Error message=\"Resource Not Found\" majorErrorCode=\"404\" minorErrorCode=\"ResourceNotFound\" />"
16
+ response(:body => body, :expects => 200, :status => 404)
15
17
  end
16
18
  end
17
19
  end
@@ -8,11 +8,13 @@ module Fog
8
8
  class Mock
9
9
  def get_network(uri)
10
10
  network_id = id_from_uri(uri)
11
- network = self.data[:networks][network_id].dup
11
+ network = data[:networks][network_id].dup
12
12
 
13
13
  if network
14
14
  response(:body => Fog::Ecloud.slice(network, :id, :environment_id))
15
- else response(:status => 404) # ?
15
+ else
16
+ body = "<Error message=\"Resource Not Found\" majorErrorCode=\"404\" minorErrorCode=\"ResourceNotFound\" />"
17
+ response(:body => body, :expects => 200, :status => 404)
16
18
  end
17
19
  end
18
20
  end
@@ -10,12 +10,14 @@ module Fog
10
10
  os_name, compute_pool_id = uri.match(/operatingsystems\/(.*)\/computepools\/(\d+)$/).captures
11
11
  compute_pool_id = compute_pool_id.to_i
12
12
 
13
- operating_systems = self.data[:operating_systems].values.select{|os| os[:compute_pool_id] == compute_pool_id}
14
- operating_system = operating_systems.find{|os| os[:short_name] == os_name}
13
+ operating_systems = data[:operating_systems].values.select { |os| os[:compute_pool_id] == compute_pool_id }
14
+ operating_system = operating_systems.detect { |os| os[:short_name] == os_name }
15
15
 
16
16
  if operating_system
17
17
  response(:body => Fog::Ecloud.slice(operating_system, :id, :compute_pool_id, :short_name))
18
- else response(:status => 404) # ?
18
+ else
19
+ body = "<Error message=\"Resource Not Found\" majorErrorCode=\"404\" minorErrorCode=\"ResourceNotFound\" />"
20
+ response(:body => body, :expects => 200, :status => 404)
19
21
  end
20
22
  end
21
23
  end
@@ -12,7 +12,9 @@ module Fog
12
12
 
13
13
  if ssh_key
14
14
  response(:body => Fog::Ecloud.slice(ssh_key, :id, :admin_organization))
15
- else response(:expects => 200, :status => 404) # ?
15
+ else
16
+ body = "<Error message=\"Resource Not Found\" majorErrorCode=\"404\" minorErrorCode=\"ResourceNotFound\" />"
17
+ response(:body => body, :expects => 200, :status => 404)
16
18
  end
17
19
  end
18
20
  end
@@ -7,12 +7,14 @@ module Fog
7
7
 
8
8
  class Mock
9
9
  def get_template(uri)
10
- template_id, compute_pool_id = uri.match(/(\d+).*\/(\d+)$/).captures
11
- template = self.data[:templates][template_id.to_i]
10
+ template_id, _compute_pool_id = uri.match(/(\d+).*\/(\d+)$/).captures
11
+ template = data[:templates][template_id.to_i]
12
12
 
13
13
  if template
14
14
  response(:body => Fog::Ecloud.slice(template, :id, :environment))
15
- else response(:status => 404) # ?
15
+ else
16
+ body = "<Error message=\"Resource Not Found\" majorErrorCode=\"404\" minorErrorCode=\"ResourceNotFound\" />"
17
+ response(:body => body, :expects => 200, :status => 404)
16
18
  end
17
19
  end
18
20
  end
@@ -34,7 +34,8 @@ module Fog
34
34
  ssh_key = data[:ssh_keys][ssh_key_id]
35
35
  response(:body => Fog::Ecloud.slice(ssh_key, :id, :admin_organization)).body
36
36
  else
37
- response(:expects => 200, :status => 404)
37
+ body = "<Error message=\"Resource Not Found\" majorErrorCode=\"404\" minorErrorCode=\"ResourceNotFound\" />"
38
+ response(:body => body, :expects => 200, :status => 404)
38
39
  end
39
40
  end
40
41
  end
@@ -1,5 +1,5 @@
1
1
  module Fog
2
2
  module Ecloud
3
- VERSION = "0.2.0"
3
+ VERSION = "0.3.0"
4
4
  end
5
5
  end
@@ -0,0 +1,101 @@
1
+ provider = :ecloud
2
+
3
+ Shindo.tests("Fog::Compute[:#{provider}] | authentication", [provider.to_s, "livespec"]) do
4
+ raises(ArgumentError, "No authentication tokens supplied") do
5
+ _service = Fog::Compute::Ecloud.new(
6
+ :base_path => "/cloudapi/spec",
7
+ :ecloud_username => nil,
8
+ :ecloud_password => nil,
9
+ :ecloud_access_key => nil,
10
+ :ecloud_private_key => nil
11
+ )
12
+ end
13
+
14
+ raises(ArgumentError, "Basic Authentication only username supplied") do
15
+ _service = Fog::Compute::Ecloud.new(
16
+ :base_path => "/cloudapi/spec",
17
+ :ecloud_username => "somebody@somewhere.com",
18
+ :ecloud_password => nil,
19
+ :ecloud_access_key => nil,
20
+ :ecloud_private_key => nil
21
+ )
22
+ end
23
+
24
+ raises(ArgumentError, "Basic Authentication only password supplied") do
25
+ _service = Fog::Compute::Ecloud.new(
26
+ :base_path => "/cloudapi/spec",
27
+ :ecloud_username => nil,
28
+ :ecloud_password => "T3rr3m@rk",
29
+ :ecloud_access_key => nil,
30
+ :ecloud_private_key => nil
31
+ )
32
+ end
33
+
34
+ returns(Fog::Compute::Ecloud::Organization, "Basic Authentication, valid account") do
35
+ service = Fog::Compute::Ecloud.new(
36
+ :base_path => "/cloudapi/spec",
37
+ :ecloud_username => "somebody@somewhere.com",
38
+ :ecloud_password => "T3rr3m@rk",
39
+ :ecloud_access_key => nil,
40
+ :ecloud_private_key => nil
41
+ )
42
+ foo = service.organizations(:uri => "/organizations").first
43
+ foo.class
44
+ end
45
+
46
+ raises(Fog::Compute::Ecloud::ServiceError, "Basic Authentication, invalid account") do
47
+ service = Fog::Compute::Ecloud.new(
48
+ :base_path => "/cloudapi/spec",
49
+ :ecloud_username => "notfound@terremark.com",
50
+ :ecloud_password => "something",
51
+ :ecloud_access_key => nil,
52
+ :ecloud_private_key => nil
53
+ )
54
+ foo = service.organizations(:uri => "/organizations").first
55
+ foo.class
56
+ end
57
+
58
+ raises(ArgumentError, "API Key Authentication only access key supplied") do
59
+ _service = Fog::Compute::Ecloud.new(
60
+ :base_path => "/cloudapi/spec",
61
+ :ecloud_username => nil,
62
+ :ecloud_password => nil,
63
+ :ecloud_access_key => 33333333333333333333333333333333,
64
+ :ecloud_private_key => nil
65
+ )
66
+ end
67
+
68
+ raises(ArgumentError, "API Key Authentication only private key supplied") do
69
+ _service = Fog::Compute::Ecloud.new(
70
+ :base_path => "/cloudapi/spec",
71
+ :ecloud_username => nil,
72
+ :ecloud_password => nil,
73
+ :ecloud_access_key => nil,
74
+ :ecloud_private_key => 3333333333333333333333333333333333333333333333333333333333333333
75
+ )
76
+ end
77
+
78
+ returns(Fog::Compute::Ecloud::Organization, "API Key Authentication, valid key") do
79
+ service = Fog::Compute::Ecloud.new(
80
+ :base_path => "/cloudapi/spec",
81
+ :ecloud_username => nil,
82
+ :ecloud_password => nil,
83
+ :ecloud_access_key => 33333333333333333333333333333333,
84
+ :ecloud_private_key => 3333333333333333333333333333333333333333333333333333333333333333
85
+ )
86
+ foo = service.organizations(:uri => "/organizations").first
87
+ foo.class
88
+ end
89
+
90
+ raises(Fog::Compute::Ecloud::ServiceError, "API Key Authentication, invalid key") do
91
+ service = Fog::Compute::Ecloud.new(
92
+ :base_path => "/cloudapi/spec",
93
+ :ecloud_username => nil,
94
+ :ecloud_password => nil,
95
+ :ecloud_access_key => 99999999999999999999999999999999,
96
+ :ecloud_private_key => 9999999999999999999999999999999999999999999999999999999999999999
97
+ )
98
+ foo = service.organizations(:uri => "/organizations").first
99
+ foo.class
100
+ end
101
+ end
@@ -1,4 +1,4 @@
1
- provider, config = :ecloud, compute_providers[:ecloud]
1
+ provider = :ecloud
2
2
 
3
3
  Shindo.tests("Fog::Compute[:#{provider}] | ssh_keys", [provider.to_s]) do
4
4
  connection = Fog::Compute[provider]
@@ -8,41 +8,42 @@ Shindo.tests("Fog::Compute[:#{provider}] | ssh_keys", [provider.to_s]) do
8
8
  @ssh_keys = @admin_organization.ssh_keys
9
9
 
10
10
  tests("#all").succeeds do
11
- returns(false) { @ssh_keys.empty? }
11
+ returns(false, "#all - get all ssh keys") { @ssh_keys.empty? }
12
12
  end
13
13
 
14
14
  tests("#get").succeeds do
15
15
  ssh_key = @ssh_keys.first
16
16
 
17
- returns(false) { @ssh_keys.get(ssh_key.href).nil? }
18
- returns(false) { @ssh_keys.get("/notfound" + ssh_key.href).nil? }
17
+ returns(false, "#get - fetch an existing ssh key") { @ssh_keys.get(ssh_key.href).nil? }
18
+ returns(true, "#get - fetch a nonexistant ssh key") { @ssh_keys.get(ssh_key.href + "314159").nil? }
19
19
  end
20
20
 
21
21
  tests("#create").succeeds do
22
22
  new_key = @ssh_keys.create(:Name => "testing")
23
23
  @key_id = new_key.id || nil
24
- returns(false) { new_key.nil? }
25
- raises(ArgumentError) { @ssh_keys.create }
24
+ returns(false, "#create - create the testing key") { new_key.nil? }
25
+ raises(ArgumentError, "#create - attempt create with no args") { @ssh_keys.create }
26
26
  end
27
27
 
28
28
  tests("#edit").succeeds do
29
29
  the_key = @ssh_keys.get(@key_id)
30
- returns(false) { the_key.nil? }
30
+ returns(false, "#edit - fetch the key") { the_key.nil? }
31
31
 
32
32
  the_key.edit(:Name => "more testing")
33
33
  the_key.reload
34
- returns(false) { the_key.name != "more testing" }
34
+ returns(false, "#edit - change name") { the_key.name != "more testing" }
35
35
 
36
36
  the_key.edit(:Default => true)
37
37
  the_key.reload
38
- returns(true) { the_key.default }
38
+ returns(true, "#edit - change default") { the_key.default }
39
39
  end
40
40
 
41
41
  tests("#delete").succeeds do
42
42
  the_key = @ssh_keys.get(@key_id)
43
- returns(false) { the_key.nil? }
43
+ returns(false, "#delete - fetch the key") { the_key.nil? }
44
+
44
45
  the_key.delete
45
46
  the_key = @ssh_keys.get(@key_id)
46
- returns(false) { !the_key.nil? }
47
+ returns(false, "#delete - delete the key") { !the_key.nil? }
47
48
  end
48
49
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fog-ecloud
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Paulo Henrique Lopes Ribeiro
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-06-22 00:00:00.000000000 Z
11
+ date: 2015-06-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fog-core
@@ -161,6 +161,7 @@ files:
161
161
  - gemfiles/Gemfile.1.9.3+
162
162
  - lib/fog/bin/ecloud.rb
163
163
  - lib/fog/compute/ecloud.rb
164
+ - lib/fog/compute/ecloud/errors.rb
164
165
  - lib/fog/compute/ecloud/models/admin_organization.rb
165
166
  - lib/fog/compute/ecloud/models/admin_organizations.rb
166
167
  - lib/fog/compute/ecloud/models/api_key.rb
@@ -406,6 +407,7 @@ files:
406
407
  - lib/fog/ecloud/version.rb
407
408
  - spec/minitest_helper.rb
408
409
  - tests/compute/helper.rb
410
+ - tests/compute/livespec/auth_tests.rb
409
411
  - tests/compute/models/admin_organization_tests.rb
410
412
  - tests/compute/models/compute_pool_tests.rb
411
413
  - tests/compute/models/detached_disk_tests.rb