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,23 +1,23 @@
1
- module Fog
2
- module OracleCloud
3
- class SOA
4
- class Real
5
-
6
- def get_job_status(type, job_id)
7
- response = request(
8
- :expects => 200,
9
- :method => 'GET',
10
- :path => "/paas/service/soa/api/v1.1/instances/#{@identity_domain}/status/#{type}/job/#{job_id}"
11
- )
12
- response.body['message']
13
- end
14
- end
15
-
16
- class Mock
17
- def get_job_status(type, job_id)
18
- ['Creation job succeded']
19
- end
20
- end
21
- end
22
- end
1
+ module Fog
2
+ module OracleCloud
3
+ class SOA
4
+ class Real
5
+
6
+ def get_job_status(type, job_id)
7
+ response = request(
8
+ :expects => 200,
9
+ :method => 'GET',
10
+ :path => "/paas/service/soa/api/v1.1/instances/#{@identity_domain}/status/#{type}/job/#{job_id}"
11
+ )
12
+ response.body['message']
13
+ end
14
+ end
15
+
16
+ class Mock
17
+ def get_job_status(type, job_id)
18
+ ['Creation job succeded']
19
+ end
20
+ end
21
+ end
22
+ end
23
23
  end
@@ -1,29 +1,29 @@
1
- module Fog
2
- module OracleCloud
3
- class SOA
4
- class Real
5
- def list_instances
6
- response = request(
7
- :expects => 200,
8
- :method => 'GET',
9
- :path => "/paas/service/soa/api/v1.1/instances/#{@identity_domain}?outputLevel=verbose"
10
- )
11
- response
12
- end
13
- end
14
-
15
- class Mock
16
- def list_instances
17
- response = Excon::Response.new
18
-
19
- instances = self.data[:instances].values
20
-
21
- response.body = {
22
- 'services' => instances
23
- }
24
- response
25
- end
26
- end
27
- end
28
- end
29
- end
1
+ module Fog
2
+ module OracleCloud
3
+ class SOA
4
+ class Real
5
+ def list_instances
6
+ response = request(
7
+ :expects => 200,
8
+ :method => 'GET',
9
+ :path => "/paas/service/soa/api/v1.1/instances/#{@identity_domain}?outputLevel=verbose"
10
+ )
11
+ response
12
+ end
13
+ end
14
+
15
+ class Mock
16
+ def list_instances
17
+ response = Excon::Response.new
18
+
19
+ instances = self.data[:instances].values
20
+
21
+ response.body = {
22
+ 'services' => instances
23
+ }
24
+ response
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
@@ -1,41 +1,41 @@
1
- require 'securerandom'
2
-
3
- module Fog
4
- module Storage
5
- class OracleCloud
6
- class Real
7
-
8
- def create_container(name)
9
- request({
10
- :method => 'PUT',
11
- :expects => [201,202],
12
- :path => "/v1/Storage-#{@identity_domain}/#{name}"
13
- }, false)
14
- end
15
-
16
- end
17
-
18
- class Mock
19
- def create_container (name)
20
- response = Excon::Response.new
21
-
22
- self.data[:containers][name] = {
23
- 'name' => name,
24
- 'count' => 0,
25
- 'bytes' => 0
26
- }
27
- response.status = 201
28
- response.headers = {
29
- 'Content-Length' => 0,
30
- 'X-Container-Bytes-Used' => 0,
31
- 'X-Container-Object-Count' => 0,
32
- 'Date'=>Time.now.strftime('%Y-%m-%dT%H:%M:%S'),
33
- 'X-Timestamp'=>Time.now.to_i,
34
- 'X-Trans-id'=>SecureRandom.uuid
35
- }
36
- response
37
- end
38
- end
39
- end
40
- end
41
- end
1
+ require 'securerandom'
2
+
3
+ module Fog
4
+ module Storage
5
+ class OracleCloud
6
+ class Real
7
+
8
+ def create_container(name)
9
+ request({
10
+ :method => 'PUT',
11
+ :expects => [201,202],
12
+ :path => "/v1/Storage-#{@identity_domain}/#{name}"
13
+ }, false)
14
+ end
15
+
16
+ end
17
+
18
+ class Mock
19
+ def create_container (name)
20
+ response = Excon::Response.new
21
+
22
+ self.data[:containers][name] = {
23
+ 'name' => name,
24
+ 'count' => 0,
25
+ 'bytes' => 0
26
+ }
27
+ response.status = 201
28
+ response.headers = {
29
+ 'Content-Length' => 0,
30
+ 'X-Container-Bytes-Used' => 0,
31
+ 'X-Container-Object-Count' => 0,
32
+ 'Date'=>Time.now.strftime('%Y-%m-%dT%H:%M:%S'),
33
+ 'X-Timestamp'=>Time.now.to_i,
34
+ 'X-Trans-id'=>SecureRandom.uuid
35
+ }
36
+ response
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
@@ -1,15 +1,15 @@
1
- module Fog
2
- module Storage
3
- class OracleCloud
4
- class Real
5
- def delete_container (name)
6
- request(
7
- :method => 'DELETE',
8
- :expects => 204,
9
- :path => "/v1/Storage-#{@identity_domain}/#{name}"
10
- )
11
- end
12
- end
13
- end
14
- end
15
- end
1
+ module Fog
2
+ module Storage
3
+ class OracleCloud
4
+ class Real
5
+ def delete_container (name)
6
+ request(
7
+ :method => 'DELETE',
8
+ :expects => 204,
9
+ :path => "/v1/Storage-#{@identity_domain}/#{name}"
10
+ )
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
@@ -1,63 +1,63 @@
1
- module Fog
2
- module Storage
3
- class OracleCloud
4
- class Real
5
- def get_container(name)
6
- response = request(
7
- :expects => [204],
8
- :method => 'HEAD',
9
- :path => "/v1/Storage-#{@identity_domain}/#{name}"
10
- )
11
- response
12
- end
13
- def get_container_with_objects(name)
14
- response = request(
15
- :expects => [204,200],
16
- :method => 'GET',
17
- :path => "/v1/Storage-#{@identity_domain}/#{name}?format=json"
18
- )
19
- response
20
- end
21
- end
22
-
23
- class Mock
24
- def get_container(name)
25
- response = Excon::Response.new
26
-
27
- if container = self.data[:containers][name]
28
- response.status = 200
29
- response.body = container
30
- response
31
- else;
32
- raise Fog::Compute::OracleCloud::NotFound.new("Storage Container #{name} does not exist");
33
- end
34
- end
35
-
36
- def get_container_with_objects(name)
37
- response = Excon::Response.new
38
-
39
- if container = self.data[:containers][name]
40
- response.status = 200
41
- response.body = [{
42
- "hash": "aea0077f346227c91cd68e955721e262",
43
- "last_modified": "2016-07-30T03:39:24.477480",
44
- "bytes": 513,
45
- "name": "Ausemon/1df0886e-3133-498f-9472-79632485b311/logs/web.1/36322757-7666-429a-87cc-3c320caf8afa/server.out.zip",
46
- "content_type": "application/zip"
47
- },
48
- {
49
- "hash": "2c35a8adaf8e7a3375e1354264135f94",
50
- "last_modified": "2016-07-30T12:51:26.124600",
51
- "bytes": 6524,
52
- "name": "Ausemon/1df0886e-3133-498f-9472-79632485b311/logs/web.1/6ad56533-791f-4a79-8e5d-bbef854a2b50/server.out.zip",
53
- "content_type": "application/zip"
54
- }]
55
- response
56
- else;
57
- raise Fog::Compute::OracleCloud::NotFound.new("Storage Container #{name} does not exist");
58
- end
59
- end
60
- end
61
- end
62
- end
63
- end
1
+ module Fog
2
+ module Storage
3
+ class OracleCloud
4
+ class Real
5
+ def get_container(name)
6
+ response = request(
7
+ :expects => [204],
8
+ :method => 'HEAD',
9
+ :path => "/v1/Storage-#{@identity_domain}/#{name}"
10
+ )
11
+ response
12
+ end
13
+ def get_container_with_objects(name)
14
+ response = request(
15
+ :expects => [204,200],
16
+ :method => 'GET',
17
+ :path => "/v1/Storage-#{@identity_domain}/#{name}?format=json"
18
+ )
19
+ response
20
+ end
21
+ end
22
+
23
+ class Mock
24
+ def get_container(name)
25
+ response = Excon::Response.new
26
+
27
+ if container = self.data[:containers][name]
28
+ response.status = 200
29
+ response.body = container
30
+ response
31
+ else;
32
+ raise Fog::Compute::OracleCloud::NotFound.new("Storage Container #{name} does not exist");
33
+ end
34
+ end
35
+
36
+ def get_container_with_objects(name)
37
+ response = Excon::Response.new
38
+
39
+ if container = self.data[:containers][name]
40
+ response.status = 200
41
+ response.body = [{
42
+ "hash": "aea0077f346227c91cd68e955721e262",
43
+ "last_modified": "2016-07-30T03:39:24.477480",
44
+ "bytes": 513,
45
+ "name": "Ausemon/1df0886e-3133-498f-9472-79632485b311/logs/web.1/36322757-7666-429a-87cc-3c320caf8afa/server.out.zip",
46
+ "content_type": "application/zip"
47
+ },
48
+ {
49
+ "hash": "2c35a8adaf8e7a3375e1354264135f94",
50
+ "last_modified": "2016-07-30T12:51:26.124600",
51
+ "bytes": 6524,
52
+ "name": "Ausemon/1df0886e-3133-498f-9472-79632485b311/logs/web.1/6ad56533-791f-4a79-8e5d-bbef854a2b50/server.out.zip",
53
+ "content_type": "application/zip"
54
+ }]
55
+ response
56
+ else;
57
+ raise Fog::Compute::OracleCloud::NotFound.new("Storage Container #{name} does not exist");
58
+ end
59
+ end
60
+ end
61
+ end
62
+ end
63
+ end
@@ -1,27 +1,27 @@
1
- module Fog
2
- module Storage
3
- class OracleCloud
4
- class Real
5
- def list_containers
6
- response = request(
7
- :expects => 200,
8
- :method => 'GET',
9
- :path => "/v1/Storage-#{@identity_domain}?format=json"
10
- )
11
- response
12
- end
13
- end
14
-
15
- class Mock
16
- def list_containers
17
- response = Excon::Response.new
18
-
19
- containers = self.data[:containers].values
20
-
21
- response.body = containers
22
- response
23
- end
24
- end
25
- end
26
- end
27
- end
1
+ module Fog
2
+ module Storage
3
+ class OracleCloud
4
+ class Real
5
+ def list_containers
6
+ response = request(
7
+ :expects => 200,
8
+ :method => 'GET',
9
+ :path => "/v1/Storage-#{@identity_domain}?format=json"
10
+ )
11
+ response
12
+ end
13
+ end
14
+
15
+ class Mock
16
+ def list_containers
17
+ response = Excon::Response.new
18
+
19
+ containers = self.data[:containers].values
20
+
21
+ response.body = containers
22
+ response
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
@@ -1,106 +1,106 @@
1
- module Fog
2
- module OracleCloud
3
- class SOA < Fog::Service
4
- requires :oracle_username, :oracle_password, :oracle_domain
5
- recognizes :oracle_region
6
-
7
- model_path 'fog/oraclecloud/models/soa'
8
- model :instance
9
- collection :instances
10
-
11
- request_path 'fog/oraclecloud/requests/soa'
12
- request :list_instances
13
- request :create_instance
14
- request :get_instance
15
- request :delete_instance
16
- request :get_job_status
17
-
18
- class Real
19
-
20
- def initialize(options={})
21
- @username = options[:oracle_username]
22
- @password = options[:oracle_password]
23
- @identity_domain = options[:oracle_domain]
24
- region_url = options[:oracle_region] == 'emea' ? 'https://jcs.emea.oraclecloud.com' : 'https://jaas.oraclecloud.com'
25
- Excon.ssl_verify_peer = false
26
-
27
- @connection = Fog::XML::Connection.new(region_url)
28
- end
29
-
30
- def username
31
- @username
32
- end
33
-
34
- def password
35
- @password
36
- end
37
-
38
- def auth_header
39
- auth_header ||= 'Basic ' + Base64.encode64("#{@username}:#{@password}").gsub("\n",'')
40
- end
41
-
42
- def request(params, parse_json = true, &block)
43
-
44
- begin
45
- response = @connection.request(params.merge!({
46
- :headers => {
47
- 'Authorization' => auth_header,
48
- 'X-ID-TENANT-NAME' => @identity_domain,
49
- 'Content-Type' => 'application/json',
50
- 'Accept' => 'application/json'
51
- }.merge!(params[:headers] || {})
52
- }), &block)
53
- rescue Excon::Errors::HTTPStatusError => error
54
- raise case error
55
- when Excon::Errors::NotFound
56
- Fog::OracleCloud::SOA::NotFound.slurp(error)
57
- else
58
- error
59
- end
60
- end
61
- if !response.body.empty? && parse_json
62
- # The Oracle Cloud doesn't return the Content-Type header as application/json, rather as application/vnd.com.oracle.oracloud.provisioning.Pod+json
63
- # Should add check here to validate, but not sure if this might change in future
64
- response.body = Fog::JSON.decode(response.body)
65
- end
66
- response
67
- end
68
- end
69
-
70
- class Mock
71
-
72
- def initialize(options={})
73
- @username = options[:oracle_username]
74
- @password = options[:oracle_password]
75
- @identity_domain = options[:oracle_domain]
76
- @region_url = options[:oracle_region] == 'emea' ? 'https://jcs.emea.oraclecloud.com' : 'https://jaas.oraclecloud.com'
77
- end
78
-
79
- def username
80
- @username
81
- end
82
-
83
- def password
84
- @password
85
- end
86
-
87
- def self.data
88
- @data ||= {
89
- :instances => {},
90
- :servers => {},
91
- :deleted_at => {},
92
- :created_at => {}
93
- }
94
- end
95
-
96
- def self.reset
97
- @data = nil
98
- end
99
-
100
- def data
101
- self.class.data
102
- end
103
- end
104
- end
105
- end
106
- end
1
+ module Fog
2
+ module OracleCloud
3
+ class SOA < Fog::Service
4
+ requires :oracle_username, :oracle_password, :oracle_domain
5
+ recognizes :oracle_region
6
+
7
+ model_path 'fog/oraclecloud/models/soa'
8
+ model :instance
9
+ collection :instances
10
+
11
+ request_path 'fog/oraclecloud/requests/soa'
12
+ request :list_instances
13
+ request :create_instance
14
+ request :get_instance
15
+ request :delete_instance
16
+ request :get_job_status
17
+
18
+ class Real
19
+
20
+ def initialize(options={})
21
+ @username = options[:oracle_username]
22
+ @password = options[:oracle_password]
23
+ @identity_domain = options[:oracle_domain]
24
+ region_url = options[:oracle_region] == 'emea' ? 'https://jcs.emea.oraclecloud.com' : 'https://jaas.oraclecloud.com'
25
+ Excon.ssl_verify_peer = false
26
+
27
+ @connection = Fog::XML::Connection.new(region_url)
28
+ end
29
+
30
+ def username
31
+ @username
32
+ end
33
+
34
+ def password
35
+ @password
36
+ end
37
+
38
+ def auth_header
39
+ auth_header ||= 'Basic ' + Base64.encode64("#{@username}:#{@password}").gsub("\n",'')
40
+ end
41
+
42
+ def request(params, parse_json = true, &block)
43
+
44
+ begin
45
+ response = @connection.request(params.merge!({
46
+ :headers => {
47
+ 'Authorization' => auth_header,
48
+ 'X-ID-TENANT-NAME' => @identity_domain,
49
+ 'Content-Type' => 'application/json',
50
+ 'Accept' => 'application/json'
51
+ }.merge!(params[:headers] || {})
52
+ }), &block)
53
+ rescue Excon::Errors::HTTPStatusError => error
54
+ raise case error
55
+ when Excon::Errors::NotFound
56
+ Fog::OracleCloud::SOA::NotFound.slurp(error)
57
+ else
58
+ error
59
+ end
60
+ end
61
+ if !response.body.empty? && parse_json
62
+ # The Oracle Cloud doesn't return the Content-Type header as application/json, rather as application/vnd.com.oracle.oracloud.provisioning.Pod+json
63
+ # Should add check here to validate, but not sure if this might change in future
64
+ response.body = Fog::JSON.decode(response.body)
65
+ end
66
+ response
67
+ end
68
+ end
69
+
70
+ class Mock
71
+
72
+ def initialize(options={})
73
+ @username = options[:oracle_username]
74
+ @password = options[:oracle_password]
75
+ @identity_domain = options[:oracle_domain]
76
+ @region_url = options[:oracle_region] == 'emea' ? 'https://jcs.emea.oraclecloud.com' : 'https://jaas.oraclecloud.com'
77
+ end
78
+
79
+ def username
80
+ @username
81
+ end
82
+
83
+ def password
84
+ @password
85
+ end
86
+
87
+ def self.data
88
+ @data ||= {
89
+ :instances => {},
90
+ :servers => {},
91
+ :deleted_at => {},
92
+ :created_at => {}
93
+ }
94
+ end
95
+
96
+ def self.reset
97
+ @data = nil
98
+ end
99
+
100
+ def data
101
+ self.class.data
102
+ end
103
+ end
104
+ end
105
+ end
106
+ end