fog-oraclecloud 0.1.12 → 0.1.13

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 (142) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +12 -10
  3. data/Gemfile +4 -4
  4. data/LICENSE +20 -20
  5. data/README.md +153 -153
  6. data/Rakefile +2 -2
  7. data/bin/console +14 -14
  8. data/bin/setup +8 -8
  9. data/fog-oracle.gemspec +32 -31
  10. data/lib/fog/oraclecloud.rb +29 -29
  11. data/lib/fog/oraclecloud/compute.rb +184 -184
  12. data/lib/fog/oraclecloud/database.rb +129 -129
  13. data/lib/fog/oraclecloud/java.rb +123 -115
  14. data/lib/fog/oraclecloud/models/compute/image.rb +43 -43
  15. data/lib/fog/oraclecloud/models/compute/image_list.rb +39 -39
  16. data/lib/fog/oraclecloud/models/compute/image_lists.rb +22 -22
  17. data/lib/fog/oraclecloud/models/compute/images.rb +22 -22
  18. data/lib/fog/oraclecloud/models/compute/instance.rb +74 -69
  19. data/lib/fog/oraclecloud/models/compute/instances.rb +22 -22
  20. data/lib/fog/oraclecloud/models/compute/object_plan.rb +16 -16
  21. data/lib/fog/oraclecloud/models/compute/object_plans.rb +12 -12
  22. data/lib/fog/oraclecloud/models/compute/orchestration.rb +89 -89
  23. data/lib/fog/oraclecloud/models/compute/orchestrations.rb +20 -20
  24. data/lib/fog/oraclecloud/models/compute/security_application.rb +42 -42
  25. data/lib/fog/oraclecloud/models/compute/security_applications.rb +22 -22
  26. data/lib/fog/oraclecloud/models/compute/security_list.rb +26 -26
  27. data/lib/fog/oraclecloud/models/compute/security_lists.rb +22 -22
  28. data/lib/fog/oraclecloud/models/compute/security_rule.rb +41 -41
  29. data/lib/fog/oraclecloud/models/compute/security_rules.rb +22 -22
  30. data/lib/fog/oraclecloud/models/compute/ssh_key.rb +37 -37
  31. data/lib/fog/oraclecloud/models/compute/ssh_keys.rb +22 -22
  32. data/lib/fog/oraclecloud/models/compute/volume.rb +47 -47
  33. data/lib/fog/oraclecloud/models/compute/volumes.rb +20 -20
  34. data/lib/fog/oraclecloud/models/database/backup.rb +37 -37
  35. data/lib/fog/oraclecloud/models/database/backups.rb +30 -30
  36. data/lib/fog/oraclecloud/models/database/instance.rb +331 -331
  37. data/lib/fog/oraclecloud/models/database/instances.rb +25 -25
  38. data/lib/fog/oraclecloud/models/database/patch.rb +34 -34
  39. data/lib/fog/oraclecloud/models/database/patches.rb +18 -18
  40. data/lib/fog/oraclecloud/models/database/recoveries.rb +26 -26
  41. data/lib/fog/oraclecloud/models/database/recovery.rb +43 -43
  42. data/lib/fog/oraclecloud/models/database/server.rb +28 -28
  43. data/lib/fog/oraclecloud/models/database/servers.rb +18 -18
  44. data/lib/fog/oraclecloud/models/database/snapshot.rb +60 -60
  45. data/lib/fog/oraclecloud/models/database/snapshots.rb +22 -22
  46. data/lib/fog/oraclecloud/models/java/database.rb +17 -17
  47. data/lib/fog/oraclecloud/models/java/databases.rb +17 -17
  48. data/lib/fog/oraclecloud/models/java/instance.rb +269 -265
  49. data/lib/fog/oraclecloud/models/java/instances.rb +23 -23
  50. data/lib/fog/oraclecloud/models/java/server.rb +62 -62
  51. data/lib/fog/oraclecloud/models/java/servers.rb +25 -25
  52. data/lib/fog/oraclecloud/models/soa/instance.rb +163 -163
  53. data/lib/fog/oraclecloud/models/soa/instances.rb +54 -54
  54. data/lib/fog/oraclecloud/models/storage/container.rb +33 -33
  55. data/lib/fog/oraclecloud/models/storage/containers.rb +24 -24
  56. data/lib/fog/oraclecloud/models/storage/object.rb +27 -27
  57. data/lib/fog/oraclecloud/models/storage/objects.rb +27 -27
  58. data/lib/fog/oraclecloud/requests/compute/create_image.rb +30 -30
  59. data/lib/fog/oraclecloud/requests/compute/create_image_list.rb +27 -27
  60. data/lib/fog/oraclecloud/requests/compute/create_instance.rb +53 -53
  61. data/lib/fog/oraclecloud/requests/compute/create_orchestration.rb +82 -82
  62. data/lib/fog/oraclecloud/requests/compute/create_security_application.rb +28 -28
  63. data/lib/fog/oraclecloud/requests/compute/create_security_rule.rb +29 -29
  64. data/lib/fog/oraclecloud/requests/compute/create_ssh_key.rb +46 -46
  65. data/lib/fog/oraclecloud/requests/compute/create_volume.rb +28 -28
  66. data/lib/fog/oraclecloud/requests/compute/delete_image.rb +19 -19
  67. data/lib/fog/oraclecloud/requests/compute/delete_image_list.rb +19 -19
  68. data/lib/fog/oraclecloud/requests/compute/delete_instance.rb +33 -33
  69. data/lib/fog/oraclecloud/requests/compute/delete_orchestration.rb +36 -36
  70. data/lib/fog/oraclecloud/requests/compute/delete_security_application.rb +20 -20
  71. data/lib/fog/oraclecloud/requests/compute/delete_security_rule.rb +20 -20
  72. data/lib/fog/oraclecloud/requests/compute/delete_ssh_key.rb +32 -32
  73. data/lib/fog/oraclecloud/requests/compute/get_image.rb +21 -21
  74. data/lib/fog/oraclecloud/requests/compute/get_image_list.rb +21 -21
  75. data/lib/fog/oraclecloud/requests/compute/get_instance.rb +45 -45
  76. data/lib/fog/oraclecloud/requests/compute/get_orchestration.rb +39 -39
  77. data/lib/fog/oraclecloud/requests/compute/get_security_application.rb +20 -20
  78. data/lib/fog/oraclecloud/requests/compute/get_security_rule.rb +20 -20
  79. data/lib/fog/oraclecloud/requests/compute/get_ssh_key.rb +39 -39
  80. data/lib/fog/oraclecloud/requests/compute/list_image_lists.rb +29 -29
  81. data/lib/fog/oraclecloud/requests/compute/list_images.rb +16 -16
  82. data/lib/fog/oraclecloud/requests/compute/list_instances.rb +28 -28
  83. data/lib/fog/oraclecloud/requests/compute/list_orchestrations.rb +28 -28
  84. data/lib/fog/oraclecloud/requests/compute/list_security_applications.rb +21 -21
  85. data/lib/fog/oraclecloud/requests/compute/list_security_lists.rb +16 -16
  86. data/lib/fog/oraclecloud/requests/compute/list_security_rules.rb +21 -21
  87. data/lib/fog/oraclecloud/requests/compute/list_ssh_keys.rb +29 -29
  88. data/lib/fog/oraclecloud/requests/compute/list_volumes.rb +16 -16
  89. data/lib/fog/oraclecloud/requests/compute/start_orchestration.rb +39 -39
  90. data/lib/fog/oraclecloud/requests/compute/stop_orchestration.rb +39 -39
  91. data/lib/fog/oraclecloud/requests/compute/update_image.rb +27 -27
  92. data/lib/fog/oraclecloud/requests/compute/update_image_list.rb +27 -27
  93. data/lib/fog/oraclecloud/requests/compute/update_orchestration.rb +80 -80
  94. data/lib/fog/oraclecloud/requests/compute/update_ssh_key.rb +49 -49
  95. data/lib/fog/oraclecloud/requests/database/backup_instance.rb +45 -45
  96. data/lib/fog/oraclecloud/requests/database/create_instance.rb +101 -101
  97. data/lib/fog/oraclecloud/requests/database/create_snapshot.rb +50 -50
  98. data/lib/fog/oraclecloud/requests/database/delete_instance.rb +26 -26
  99. data/lib/fog/oraclecloud/requests/database/delete_snapshot.rb +26 -26
  100. data/lib/fog/oraclecloud/requests/database/get_instance.rb +62 -62
  101. data/lib/fog/oraclecloud/requests/database/get_instance_from_job.rb +31 -31
  102. data/lib/fog/oraclecloud/requests/database/get_snapshot.rb +43 -43
  103. data/lib/fog/oraclecloud/requests/database/list_backups.rb +39 -39
  104. data/lib/fog/oraclecloud/requests/database/list_instances.rb +29 -29
  105. data/lib/fog/oraclecloud/requests/database/list_patches.rb +51 -51
  106. data/lib/fog/oraclecloud/requests/database/list_recoveries.rb +40 -40
  107. data/lib/fog/oraclecloud/requests/database/list_servers.rb +27 -27
  108. data/lib/fog/oraclecloud/requests/database/list_snapshots.rb +27 -27
  109. data/lib/fog/oraclecloud/requests/database/recover_instance.rb +83 -83
  110. data/lib/fog/oraclecloud/requests/database/scale_instance.rb +40 -40
  111. data/lib/fog/oraclecloud/requests/java/create_instance.rb +156 -87
  112. data/lib/fog/oraclecloud/requests/java/delete_instance.rb +37 -37
  113. data/lib/fog/oraclecloud/requests/java/get_instance.rb +43 -43
  114. data/lib/fog/oraclecloud/requests/java/get_server.rb +42 -42
  115. data/lib/fog/oraclecloud/requests/java/list_instances.rb +29 -29
  116. data/lib/fog/oraclecloud/requests/java/list_servers.rb +30 -30
  117. data/lib/fog/oraclecloud/requests/java/scale_a_node.rb +45 -45
  118. data/lib/fog/oraclecloud/requests/java/scale_in_a_cluster.rb +35 -35
  119. data/lib/fog/oraclecloud/requests/java/scale_out_a_cluster.rb +38 -38
  120. data/lib/fog/oraclecloud/requests/soa/create_instance.rb +71 -71
  121. data/lib/fog/oraclecloud/requests/soa/delete_instance.rb +35 -35
  122. data/lib/fog/oraclecloud/requests/soa/get_instance.rb +42 -42
  123. data/lib/fog/oraclecloud/requests/soa/get_job_status.rb +22 -22
  124. data/lib/fog/oraclecloud/requests/soa/list_instances.rb +29 -29
  125. data/lib/fog/oraclecloud/requests/storage/create_container.rb +41 -41
  126. data/lib/fog/oraclecloud/requests/storage/delete_container.rb +15 -15
  127. data/lib/fog/oraclecloud/requests/storage/get_container.rb +63 -63
  128. data/lib/fog/oraclecloud/requests/storage/list_containers.rb +27 -27
  129. data/lib/fog/oraclecloud/soa.rb +106 -106
  130. data/lib/fog/oraclecloud/storage.rb +98 -98
  131. data/lib/fog/oraclecloud/version.rb +5 -5
  132. data/tests/helper.rb +5 -3
  133. data/tests/helpers/mock_helper.rb +14 -14
  134. data/tests/requests/compute_tests.rb +9 -9
  135. data/tests/requests/database_tests.rb +241 -241
  136. data/tests/requests/instance_tests.rb +68 -61
  137. data/tests/requests/java_tests.rb +149 -109
  138. data/tests/requests/orchestrations_tests.rb +90 -90
  139. data/tests/requests/soa_tests.rb +151 -151
  140. data/tests/requests/ssh_keys_tests.rb +53 -53
  141. data/tests/requests/storage_tests.rb +54 -54
  142. metadata +17 -3
@@ -1,99 +1,99 @@
1
- module Fog
2
- module Storage
3
- class OracleCloud < Fog::Service
4
- requires :oracle_username, :oracle_password, :oracle_domain, :oracle_storage_api
5
-
6
- model_path 'fog/oraclecloud/models/storage'
7
- collection :containers
8
- model :container
9
- collection :objects
10
- model :object
11
-
12
- request_path 'fog/oraclecloud/requests/storage'
13
- request :list_containers
14
- request :create_container
15
- request :get_container
16
- request :delete_container
17
-
18
- class Real
19
- def initialize(options={})
20
- @username = options[:oracle_username]
21
- @password = options[:oracle_password]
22
- @identity_domain = options[:oracle_domain]
23
- @api_endpoint = options[:oracle_storage_api]
24
-
25
- @connection = Fog::XML::Connection.new(@api_endpoint)
26
-
27
- # Get authentication token
28
- authenticate
29
- end
30
-
31
- def authenticate()
32
-
33
- begin
34
- response = @connection.request({
35
- :expects => 200,
36
- :method => 'GET',
37
- :path => "auth/v1.0",
38
- :headers => {
39
- 'X-Storage-User' => "Storage-#{@identity_domain}:#{@username}",
40
- 'X-Storage-Pass' => @password
41
- }
42
- })
43
- rescue Excon::Errors::HTTPStatusError => error
44
- error
45
- end
46
- if response.nil? || !response.headers['X-Auth-Token'] then
47
- raise Error.new('Could not authenticate to Storage Cloud Service. Check your athentication details in your config')
48
- end
49
- @auth_token = response.headers['X-Auth-Token']
50
- end
51
-
52
- def request(params, parse_json = true, &block)
53
- begin
54
- response = @connection.request(params.merge!({
55
- :headers => {
56
- 'X-Auth-Token' => @auth_token
57
- }.merge!(params[:headers] || {})
58
- }), &block)
59
- rescue Excon::Errors::HTTPStatusError => error
60
- raise case error
61
- when Excon::Errors::Conflict
62
- data = Fog::JSON.decode(error.response.body)
63
- raise Error.new(data['message'])
64
- else
65
- error
66
- end
67
- end
68
- if !response.body.empty? && parse_json
69
- response.body = Fog::JSON.decode(response.body)
70
- end
71
- response
72
- end
73
- end
74
-
75
- class Mock
76
- def initialize(options={})
77
- @username = options[:oracle_username]
78
- @password = options[:oracle_password]
79
- @identity_domain = options[:oracle_domain]
80
- @api_endpoint = options[:oracle_compute_api]
81
- end
82
-
83
- def self.data
84
- @data ||= {
85
- :containers => {}
86
- }
87
- end
88
-
89
- def self.reset
90
- @data = nil
91
- end
92
-
93
- def data
94
- self.class.data
95
- end
96
- end
97
- end
98
- end
1
+ module Fog
2
+ module Storage
3
+ class OracleCloud < Fog::Service
4
+ requires :oracle_username, :oracle_password, :oracle_domain, :oracle_storage_api
5
+
6
+ model_path 'fog/oraclecloud/models/storage'
7
+ collection :containers
8
+ model :container
9
+ collection :objects
10
+ model :object
11
+
12
+ request_path 'fog/oraclecloud/requests/storage'
13
+ request :list_containers
14
+ request :create_container
15
+ request :get_container
16
+ request :delete_container
17
+
18
+ class Real
19
+ def initialize(options={})
20
+ @username = options[:oracle_username]
21
+ @password = options[:oracle_password]
22
+ @identity_domain = options[:oracle_domain]
23
+ @api_endpoint = options[:oracle_storage_api]
24
+
25
+ @connection = Fog::XML::Connection.new(@api_endpoint)
26
+
27
+ # Get authentication token
28
+ authenticate
29
+ end
30
+
31
+ def authenticate()
32
+
33
+ begin
34
+ response = @connection.request({
35
+ :expects => 200,
36
+ :method => 'GET',
37
+ :path => "auth/v1.0",
38
+ :headers => {
39
+ 'X-Storage-User' => "Storage-#{@identity_domain}:#{@username}",
40
+ 'X-Storage-Pass' => @password
41
+ }
42
+ })
43
+ rescue Excon::Errors::HTTPStatusError => error
44
+ error
45
+ end
46
+ if response.nil? || !response.headers['X-Auth-Token'] then
47
+ raise Error.new('Could not authenticate to Storage Cloud Service. Check your athentication details in your config')
48
+ end
49
+ @auth_token = response.headers['X-Auth-Token']
50
+ end
51
+
52
+ def request(params, parse_json = true, &block)
53
+ begin
54
+ response = @connection.request(params.merge!({
55
+ :headers => {
56
+ 'X-Auth-Token' => @auth_token
57
+ }.merge!(params[:headers] || {})
58
+ }), &block)
59
+ rescue Excon::Errors::HTTPStatusError => error
60
+ raise case error
61
+ when Excon::Errors::Conflict
62
+ data = Fog::JSON.decode(error.response.body)
63
+ raise Error.new(data['message'])
64
+ else
65
+ error
66
+ end
67
+ end
68
+ if !response.body.empty? && parse_json
69
+ response.body = Fog::JSON.decode(response.body)
70
+ end
71
+ response
72
+ end
73
+ end
74
+
75
+ class Mock
76
+ def initialize(options={})
77
+ @username = options[:oracle_username]
78
+ @password = options[:oracle_password]
79
+ @identity_domain = options[:oracle_domain]
80
+ @api_endpoint = options[:oracle_compute_api]
81
+ end
82
+
83
+ def self.data
84
+ @data ||= {
85
+ :containers => {}
86
+ }
87
+ end
88
+
89
+ def self.reset
90
+ @data = nil
91
+ end
92
+
93
+ def data
94
+ self.class.data
95
+ end
96
+ end
97
+ end
98
+ end
99
99
  end
@@ -1,5 +1,5 @@
1
- module Fog
2
- module OracleCloud
3
- VERSION = "0.1.12"
4
- end
5
- end
1
+ module Fog
2
+ module OracleCloud
3
+ VERSION = "0.1.13"
4
+ end
5
+ end
data/tests/helper.rb CHANGED
@@ -1,3 +1,5 @@
1
- require File.expand_path('../../lib/fog/oraclecloud', __FILE__)
2
-
3
- require File.expand_path(File.join(File.dirname(__FILE__), 'helpers', 'mock_helper'))
1
+ require File.expand_path('../../lib/fog/oraclecloud', __FILE__)
2
+
3
+ require File.expand_path(File.join(File.dirname(__FILE__), 'helpers', 'mock_helper'))
4
+
5
+ require 'byebug'
@@ -1,15 +1,15 @@
1
- # Use so you can run in mock mode from the command line
2
- #
3
- # FOG_MOCK=true fog
4
-
5
- if ENV["FOG_MOCK"] == "true"
6
- Fog.mock!
7
- end
8
-
9
- puts "Mock: #{Fog.mock?}"
10
- # if in mocked mode, fill in some fake credentials for us
11
- if Fog.mock?
12
- Fog.credentials = {
13
- :oracle_compute_api => 'https://api.compute.us0.oraclecloud.com'
14
- }.merge(Fog.credentials)
1
+ # Use so you can run in mock mode from the command line
2
+ #
3
+ # FOG_MOCK=true fog
4
+
5
+ if ENV["FOG_MOCK"] == "true"
6
+ Fog.mock!
7
+ end
8
+
9
+ puts "Mock: #{Fog.mock?}"
10
+ # if in mocked mode, fill in some fake credentials for us
11
+ if Fog.mock?
12
+ Fog.credentials = {
13
+ :oracle_compute_api => 'https://api.compute.us0.oraclecloud.com'
14
+ }.merge(Fog.credentials)
15
15
  end
@@ -1,10 +1,10 @@
1
- require 'pp'
2
-
3
- Shindo.tests('Fog::Compute[oraclecloud] | compute requests', 'compute') do
4
- tests("#image_lists") do
5
- images = Fog::Compute[:oraclecloud].image_lists.all
6
- test "get image list" do
7
- images.is_a? Array
8
- end
9
- end
1
+ require 'pp'
2
+
3
+ Shindo.tests('Fog::Compute[oraclecloud] | compute requests', 'compute') do
4
+ tests("#image_lists") do
5
+ images = Fog::Compute[:oraclecloud].image_lists.all
6
+ test "get image list" do
7
+ images.is_a? Array
8
+ end
9
+ end
10
10
  end
@@ -1,242 +1,242 @@
1
- require 'pp'
2
-
3
- Shindo.tests('Fog::Database[oraclecloud] | database requests', 'database') do
4
-
5
- tests("#database-create", "create") do
6
- db = Fog::OracleCloud[:database].instances.create(
7
- :service_name => 'TestDB',
8
- :description => 'A new database',
9
- :edition => 'SE',
10
- :ssh_key => 'ssh-rsa AAAAB3NzaC1yc2EAAAABJQAAAQEAkNNQ4ri2oUW46mBO/4CHMGCOALciumwGvFEMDLGNnlDbUSqU4IRrqgj+znLClfb29Oer0devdarM6DilsZVgZ2YbI5ZD5vICR/O9J0c28dArwbtFeIjcV2TCWyj5xKEXF1r+OrJMexHQa0fW1URGrU8QODpJNC/9eCVGcEXddL31xTZYpjoVOCVx66kNa6lSHEVV3T4zaCby9Oe5QI4gZe1+xyxHPNEW5wogwS3dlKSyL2CfBP0aUKOmJ5Nrl8+y0GqJQXdGjZ9FIknmwWueRW/6qPQvZocjOZ8YiPZgAP0RNy6lL+u8mnAazj/mrEdmB5QUzpDAllIr5Tn/xaddZQ==',
11
- :shape => 'oc3',
12
- :version => '12.1.0.2',
13
- :backup_destination => 'NONE',
14
- :admin_password => 'Welcome1#',
15
- :usable_storage => '15'
16
- )
17
-
18
- test "can create a database" do
19
- db.is_a? Fog::OracleCloud::Database::Instance
20
- end
21
-
22
- test "is being built" do
23
- !db.ready?
24
- end
25
- db.wait_for { ready? }
26
-
27
- test "is built" do
28
- db.ready?
29
- db.shape == 'oc3'
30
- end
31
-
32
- test "scale up instance" do
33
- db.scale('oc4')
34
- db.wait_for { ready? }
35
- db.shape == 'oc4'
36
- end
37
-
38
- test "can add extra storage" do
39
- db.add_storage(1)
40
- db.wait_for { ready? }
41
- db.ready?
42
- end
43
-
44
- test "can expand storage" do
45
- db.expand_storage(1)
46
- db.wait_for { ready? }
47
- db.ready?
48
- db.expand_storage(1, 'backup')
49
- db.wait_for { ready? }
50
- db.ready?
51
- end
52
-
53
- end
54
-
55
- tests("#database-attributes", "attributes") do
56
- tests("should check shape").raises(ArgumentError) do
57
- instance = Fog::OracleCloud[:database].instances.new({
58
- :shape => 'fsdfsdf'
59
- })
60
- end
61
- tests("should check service_name").raises(ArgumentError) do
62
- instance = Fog::OracleCloud[:database].instances.new({
63
- :service_name => 'Has_Underscore'
64
- })
65
- end
66
- end
67
-
68
- tests('#database-read') do
69
- instances = Fog::OracleCloud[:database].instances
70
- test "returns an Array" do
71
- instances.is_a? Array
72
- end
73
-
74
- test "should return records" do
75
- instances.size >= 1
76
- end
77
-
78
- test "should return a valid name" do
79
- instances.first.service_name.is_a? String
80
- end
81
-
82
- instance = Fog::OracleCloud[:database].instances.get(instances.first.service_name)
83
- test "should return an instance" do
84
- instance.service_name.is_a? String
85
- end
86
- servers = instance.servers
87
- test "should have compute nodes" do
88
- servers.is_a? Array
89
- servers.size >= 1
90
- servers.first.status.is_a? String
91
- end
92
-
93
- test "has special attributes" do
94
- instance.failover_database == 'no'
95
- end
96
- end
97
-
98
- tests("#database-backups-create", "create") do
99
- instance = Fog::OracleCloud[:database].instances.first
100
- instance.backup()
101
- test "backup created" do
102
- backups = instance.backups
103
- backups.is_a? Array
104
- backups.first.wait_for { completed? }
105
- backups.first.completed?
106
- end
107
- end
108
-
109
- tests("#database-backups", "backups") do
110
- instance = Fog::OracleCloud[:database].instances.first
111
- backups = instance.backups
112
- test "should have backups" do
113
- backups.is_a? Array
114
- end
115
- if backups.size >= 1 then
116
- test "one of them should have completed" do
117
- backups.size >= 1
118
- backups.first.completed?
119
- end
120
- end
121
- end
122
-
123
- tests("#database-recoveries-create", "create") do
124
- instance = Fog::OracleCloud[:database].instances.first
125
- tag = instance.backups.first.db_tag
126
- instance.recover('tag', tag)
127
- recoveries = instance.recoveries
128
- test "can recover by tag" do
129
- recoveries.is_a? Array
130
- rec = recoveries.find {|r| r.db_tag == tag}
131
- rec.is_a? Fog::OracleCloud::Database::Recovery
132
- rec.wait_for { completed? }
133
- rec.recovery_complete_date.is_a? String
134
- end
135
- test "can recover by latest" do
136
- instance.recover_latest()
137
- rec = instance.recoveries.find {|r| !r.latest.nil? }
138
- rec.is_a? Fog::OracleCloud::Database::Recovery
139
- rec.latest
140
- rec.wait_for { completed? }
141
- rec.recovery_complete_date.is_a? String
142
- end
143
- test "can recover by timestamp" do
144
- time = Time.now
145
- instance.recover('timestamp', time)
146
- rec = instance.recoveries.find {|r| !r.latest.nil? }
147
- rec.is_a? Fog::OracleCloud::Database::Recovery
148
- rec.timestamp == time
149
- rec.wait_for { completed? }
150
- rec.recovery_complete_date.is_a? String
151
- end
152
- # Need to test SCN. Not sure how to mock test this?
153
- end
154
-
155
- tests("#database-recoveries", "recoveries") do
156
- instances = Fog::OracleCloud[:database].instances
157
- recs = Fog::OracleCloud[:database].recoveries.all(instances.first.service_name)
158
- test "might have recoveries" do
159
- recs.is_a? Array
160
- end
161
- if recs.size >= 1 then
162
- test "one of them should have completed" do
163
- recs.first.completed?
164
- end
165
- end
166
- end
167
-
168
- tests("#database-snapshots-create", "create") do
169
- instances = Fog::OracleCloud[:database].instances
170
-
171
- snap = Fog::OracleCloud[:database].snapshots.create(
172
- :name => 'TestSnapshot',
173
- :description => 'A new snapshot',
174
- :database_id => instances.first.service_name
175
- )
176
- test "can create a snapshot" do
177
- snap.is_a? Fog::OracleCloud::Database::Snapshot
178
- end
179
-
180
- test "is being built" do
181
- !snap.completed?
182
- end
183
- snap.wait_for { completed? }
184
-
185
- test "is built" do
186
- snap.completed?
187
- end
188
- end
189
-
190
- tests("#database-snapshots", "snapshots") do
191
- instances = Fog::OracleCloud[:database].instances
192
- snaps = instances.first.snapshots
193
- test "might have snapshots" do
194
- snaps.is_a? Array
195
- end
196
- if snaps.size >= 1 then
197
- test "one of them should have completed" do
198
- snaps.first.completed?
199
- end
200
- test "can get snapshot" do
201
- snap = instances.first.get_snapshot(snaps.first.name)
202
- snap.name.is_a? String
203
- snap.cloned_services.is_a? Array
204
- snap.cloned_services.first['clonedServiceName'].is_a? String
205
- end
206
- end
207
- end
208
-
209
- tests("#database-shapshots-delete", "create") do
210
- db = Fog::OracleCloud[:database].instances.get('TestDB')
211
- snap = db.snapshots.first
212
- snap.destroy()
213
- snap.wait_for { deleting? }
214
- tests("should actually delete snapshot").raises(Fog::OracleCloud::Database::NotFound) do
215
- snap.wait_for { status == 'Stopped' }
216
- end
217
- end
218
-
219
- tests("database-patches") do
220
- instances = Fog::OracleCloud[:database].instances
221
- patches = instances.first.patches
222
- test "should have patches" do
223
- patches.is_a? Array
224
- end
225
- if patches.size >= 1 then
226
- test "has a patch id" do
227
- patches.first.id.is_a? String
228
- end
229
- end
230
- end
231
-
232
- tests("#database-delete", "create") do
233
- db = Fog::OracleCloud[:database].instances.get('TestDB')
234
- db.destroy()
235
- db.wait_for { stopping? }
236
- tests("should actually delete instance").raises(Fog::OracleCloud::Database::NotFound) do
237
- db.wait_for { stopped? }
238
- end
239
- end
240
-
241
-
1
+ require 'pp'
2
+
3
+ Shindo.tests('Fog::Database[oraclecloud] | database requests', 'database') do
4
+
5
+ tests("#database-create", "create") do
6
+ db = Fog::OracleCloud[:database].instances.create(
7
+ :service_name => 'TestDB',
8
+ :description => 'A new database',
9
+ :edition => 'SE',
10
+ :ssh_key => 'ssh-rsa AAAAB3NzaC1yc2EAAAABJQAAAQEAkNNQ4ri2oUW46mBO/4CHMGCOALciumwGvFEMDLGNnlDbUSqU4IRrqgj+znLClfb29Oer0devdarM6DilsZVgZ2YbI5ZD5vICR/O9J0c28dArwbtFeIjcV2TCWyj5xKEXF1r+OrJMexHQa0fW1URGrU8QODpJNC/9eCVGcEXddL31xTZYpjoVOCVx66kNa6lSHEVV3T4zaCby9Oe5QI4gZe1+xyxHPNEW5wogwS3dlKSyL2CfBP0aUKOmJ5Nrl8+y0GqJQXdGjZ9FIknmwWueRW/6qPQvZocjOZ8YiPZgAP0RNy6lL+u8mnAazj/mrEdmB5QUzpDAllIr5Tn/xaddZQ==',
11
+ :shape => 'oc3',
12
+ :version => '12.1.0.2',
13
+ :backup_destination => 'NONE',
14
+ :admin_password => 'Welcome1#',
15
+ :usable_storage => '15'
16
+ )
17
+
18
+ test "can create a database" do
19
+ db.is_a? Fog::OracleCloud::Database::Instance
20
+ end
21
+
22
+ test "is being built" do
23
+ !db.ready?
24
+ end
25
+ db.wait_for { ready? }
26
+
27
+ test "is built" do
28
+ db.ready?
29
+ db.shape == 'oc3'
30
+ end
31
+
32
+ test "scale up instance" do
33
+ db.scale('oc4')
34
+ db.wait_for { ready? }
35
+ db.shape == 'oc4'
36
+ end
37
+
38
+ test "can add extra storage" do
39
+ db.add_storage(1)
40
+ db.wait_for { ready? }
41
+ db.ready?
42
+ end
43
+
44
+ test "can expand storage" do
45
+ db.expand_storage(1)
46
+ db.wait_for { ready? }
47
+ db.ready?
48
+ db.expand_storage(1, 'backup')
49
+ db.wait_for { ready? }
50
+ db.ready?
51
+ end
52
+
53
+ end
54
+
55
+ tests("#database-attributes", "attributes") do
56
+ tests("should check shape").raises(ArgumentError) do
57
+ instance = Fog::OracleCloud[:database].instances.new({
58
+ :shape => 'fsdfsdf'
59
+ })
60
+ end
61
+ tests("should check service_name").raises(ArgumentError) do
62
+ instance = Fog::OracleCloud[:database].instances.new({
63
+ :service_name => 'Has_Underscore'
64
+ })
65
+ end
66
+ end
67
+
68
+ tests('#database-read') do
69
+ instances = Fog::OracleCloud[:database].instances
70
+ test "returns an Array" do
71
+ instances.is_a? Array
72
+ end
73
+
74
+ test "should return records" do
75
+ instances.size >= 1
76
+ end
77
+
78
+ test "should return a valid name" do
79
+ instances.first.service_name.is_a? String
80
+ end
81
+
82
+ instance = Fog::OracleCloud[:database].instances.get(instances.first.service_name)
83
+ test "should return an instance" do
84
+ instance.service_name.is_a? String
85
+ end
86
+ servers = instance.servers
87
+ test "should have compute nodes" do
88
+ servers.is_a? Array
89
+ servers.size >= 1
90
+ servers.first.status.is_a? String
91
+ end
92
+
93
+ test "has special attributes" do
94
+ instance.failover_database == 'no'
95
+ end
96
+ end
97
+
98
+ tests("#database-backups-create", "create") do
99
+ instance = Fog::OracleCloud[:database].instances.first
100
+ instance.backup()
101
+ test "backup created" do
102
+ backups = instance.backups
103
+ backups.is_a? Array
104
+ backups.first.wait_for { completed? }
105
+ backups.first.completed?
106
+ end
107
+ end
108
+
109
+ tests("#database-backups", "backups") do
110
+ instance = Fog::OracleCloud[:database].instances.first
111
+ backups = instance.backups
112
+ test "should have backups" do
113
+ backups.is_a? Array
114
+ end
115
+ if backups.size >= 1 then
116
+ test "one of them should have completed" do
117
+ backups.size >= 1
118
+ backups.first.completed?
119
+ end
120
+ end
121
+ end
122
+
123
+ tests("#database-recoveries-create", "create") do
124
+ instance = Fog::OracleCloud[:database].instances.first
125
+ tag = instance.backups.first.db_tag
126
+ instance.recover('tag', tag)
127
+ recoveries = instance.recoveries
128
+ test "can recover by tag" do
129
+ recoveries.is_a? Array
130
+ rec = recoveries.find {|r| r.db_tag == tag}
131
+ rec.is_a? Fog::OracleCloud::Database::Recovery
132
+ rec.wait_for { completed? }
133
+ rec.recovery_complete_date.is_a? String
134
+ end
135
+ test "can recover by latest" do
136
+ instance.recover_latest()
137
+ rec = instance.recoveries.find {|r| !r.latest.nil? }
138
+ rec.is_a? Fog::OracleCloud::Database::Recovery
139
+ rec.latest
140
+ rec.wait_for { completed? }
141
+ rec.recovery_complete_date.is_a? String
142
+ end
143
+ test "can recover by timestamp" do
144
+ time = Time.now
145
+ instance.recover('timestamp', time)
146
+ rec = instance.recoveries.find {|r| !r.latest.nil? }
147
+ rec.is_a? Fog::OracleCloud::Database::Recovery
148
+ rec.timestamp == time
149
+ rec.wait_for { completed? }
150
+ rec.recovery_complete_date.is_a? String
151
+ end
152
+ # Need to test SCN. Not sure how to mock test this?
153
+ end
154
+
155
+ tests("#database-recoveries", "recoveries") do
156
+ instances = Fog::OracleCloud[:database].instances
157
+ recs = Fog::OracleCloud[:database].recoveries.all(instances.first.service_name)
158
+ test "might have recoveries" do
159
+ recs.is_a? Array
160
+ end
161
+ if recs.size >= 1 then
162
+ test "one of them should have completed" do
163
+ recs.first.completed?
164
+ end
165
+ end
166
+ end
167
+
168
+ tests("#database-snapshots-create", "create") do
169
+ instances = Fog::OracleCloud[:database].instances
170
+
171
+ snap = Fog::OracleCloud[:database].snapshots.create(
172
+ :name => 'TestSnapshot',
173
+ :description => 'A new snapshot',
174
+ :database_id => instances.first.service_name
175
+ )
176
+ test "can create a snapshot" do
177
+ snap.is_a? Fog::OracleCloud::Database::Snapshot
178
+ end
179
+
180
+ test "is being built" do
181
+ !snap.completed?
182
+ end
183
+ snap.wait_for { completed? }
184
+
185
+ test "is built" do
186
+ snap.completed?
187
+ end
188
+ end
189
+
190
+ tests("#database-snapshots", "snapshots") do
191
+ instances = Fog::OracleCloud[:database].instances
192
+ snaps = instances.first.snapshots
193
+ test "might have snapshots" do
194
+ snaps.is_a? Array
195
+ end
196
+ if snaps.size >= 1 then
197
+ test "one of them should have completed" do
198
+ snaps.first.completed?
199
+ end
200
+ test "can get snapshot" do
201
+ snap = instances.first.get_snapshot(snaps.first.name)
202
+ snap.name.is_a? String
203
+ snap.cloned_services.is_a? Array
204
+ snap.cloned_services.first['clonedServiceName'].is_a? String
205
+ end
206
+ end
207
+ end
208
+
209
+ tests("#database-shapshots-delete", "create") do
210
+ db = Fog::OracleCloud[:database].instances.get('TestDB')
211
+ snap = db.snapshots.first
212
+ snap.destroy()
213
+ snap.wait_for { deleting? }
214
+ tests("should actually delete snapshot").raises(Fog::OracleCloud::Database::NotFound) do
215
+ snap.wait_for { status == 'Stopped' }
216
+ end
217
+ end
218
+
219
+ tests("database-patches") do
220
+ instances = Fog::OracleCloud[:database].instances
221
+ patches = instances.first.patches
222
+ test "should have patches" do
223
+ patches.is_a? Array
224
+ end
225
+ if patches.size >= 1 then
226
+ test "has a patch id" do
227
+ patches.first.id.is_a? String
228
+ end
229
+ end
230
+ end
231
+
232
+ tests("#database-delete", "create") do
233
+ db = Fog::OracleCloud[:database].instances.get('TestDB')
234
+ db.destroy()
235
+ db.wait_for { stopping? }
236
+ tests("should actually delete instance").raises(Fog::OracleCloud::Database::NotFound) do
237
+ db.wait_for { stopped? }
238
+ end
239
+ end
240
+
241
+
242
242
  end