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.
- checksums.yaml +4 -4
- data/.gitignore +12 -10
- data/Gemfile +4 -4
- data/LICENSE +20 -20
- data/README.md +153 -153
- data/Rakefile +2 -2
- data/bin/console +14 -14
- data/bin/setup +8 -8
- data/fog-oracle.gemspec +32 -31
- data/lib/fog/oraclecloud.rb +29 -29
- data/lib/fog/oraclecloud/compute.rb +184 -184
- data/lib/fog/oraclecloud/database.rb +129 -129
- data/lib/fog/oraclecloud/java.rb +123 -115
- data/lib/fog/oraclecloud/models/compute/image.rb +43 -43
- data/lib/fog/oraclecloud/models/compute/image_list.rb +39 -39
- data/lib/fog/oraclecloud/models/compute/image_lists.rb +22 -22
- data/lib/fog/oraclecloud/models/compute/images.rb +22 -22
- data/lib/fog/oraclecloud/models/compute/instance.rb +74 -69
- data/lib/fog/oraclecloud/models/compute/instances.rb +22 -22
- data/lib/fog/oraclecloud/models/compute/object_plan.rb +16 -16
- data/lib/fog/oraclecloud/models/compute/object_plans.rb +12 -12
- data/lib/fog/oraclecloud/models/compute/orchestration.rb +89 -89
- data/lib/fog/oraclecloud/models/compute/orchestrations.rb +20 -20
- data/lib/fog/oraclecloud/models/compute/security_application.rb +42 -42
- data/lib/fog/oraclecloud/models/compute/security_applications.rb +22 -22
- data/lib/fog/oraclecloud/models/compute/security_list.rb +26 -26
- data/lib/fog/oraclecloud/models/compute/security_lists.rb +22 -22
- data/lib/fog/oraclecloud/models/compute/security_rule.rb +41 -41
- data/lib/fog/oraclecloud/models/compute/security_rules.rb +22 -22
- data/lib/fog/oraclecloud/models/compute/ssh_key.rb +37 -37
- data/lib/fog/oraclecloud/models/compute/ssh_keys.rb +22 -22
- data/lib/fog/oraclecloud/models/compute/volume.rb +47 -47
- data/lib/fog/oraclecloud/models/compute/volumes.rb +20 -20
- data/lib/fog/oraclecloud/models/database/backup.rb +37 -37
- data/lib/fog/oraclecloud/models/database/backups.rb +30 -30
- data/lib/fog/oraclecloud/models/database/instance.rb +331 -331
- data/lib/fog/oraclecloud/models/database/instances.rb +25 -25
- data/lib/fog/oraclecloud/models/database/patch.rb +34 -34
- data/lib/fog/oraclecloud/models/database/patches.rb +18 -18
- data/lib/fog/oraclecloud/models/database/recoveries.rb +26 -26
- data/lib/fog/oraclecloud/models/database/recovery.rb +43 -43
- data/lib/fog/oraclecloud/models/database/server.rb +28 -28
- data/lib/fog/oraclecloud/models/database/servers.rb +18 -18
- data/lib/fog/oraclecloud/models/database/snapshot.rb +60 -60
- data/lib/fog/oraclecloud/models/database/snapshots.rb +22 -22
- data/lib/fog/oraclecloud/models/java/database.rb +17 -17
- data/lib/fog/oraclecloud/models/java/databases.rb +17 -17
- data/lib/fog/oraclecloud/models/java/instance.rb +269 -265
- data/lib/fog/oraclecloud/models/java/instances.rb +23 -23
- data/lib/fog/oraclecloud/models/java/server.rb +62 -62
- data/lib/fog/oraclecloud/models/java/servers.rb +25 -25
- data/lib/fog/oraclecloud/models/soa/instance.rb +163 -163
- data/lib/fog/oraclecloud/models/soa/instances.rb +54 -54
- data/lib/fog/oraclecloud/models/storage/container.rb +33 -33
- data/lib/fog/oraclecloud/models/storage/containers.rb +24 -24
- data/lib/fog/oraclecloud/models/storage/object.rb +27 -27
- data/lib/fog/oraclecloud/models/storage/objects.rb +27 -27
- data/lib/fog/oraclecloud/requests/compute/create_image.rb +30 -30
- data/lib/fog/oraclecloud/requests/compute/create_image_list.rb +27 -27
- data/lib/fog/oraclecloud/requests/compute/create_instance.rb +53 -53
- data/lib/fog/oraclecloud/requests/compute/create_orchestration.rb +82 -82
- data/lib/fog/oraclecloud/requests/compute/create_security_application.rb +28 -28
- data/lib/fog/oraclecloud/requests/compute/create_security_rule.rb +29 -29
- data/lib/fog/oraclecloud/requests/compute/create_ssh_key.rb +46 -46
- data/lib/fog/oraclecloud/requests/compute/create_volume.rb +28 -28
- data/lib/fog/oraclecloud/requests/compute/delete_image.rb +19 -19
- data/lib/fog/oraclecloud/requests/compute/delete_image_list.rb +19 -19
- data/lib/fog/oraclecloud/requests/compute/delete_instance.rb +33 -33
- data/lib/fog/oraclecloud/requests/compute/delete_orchestration.rb +36 -36
- data/lib/fog/oraclecloud/requests/compute/delete_security_application.rb +20 -20
- data/lib/fog/oraclecloud/requests/compute/delete_security_rule.rb +20 -20
- data/lib/fog/oraclecloud/requests/compute/delete_ssh_key.rb +32 -32
- data/lib/fog/oraclecloud/requests/compute/get_image.rb +21 -21
- data/lib/fog/oraclecloud/requests/compute/get_image_list.rb +21 -21
- data/lib/fog/oraclecloud/requests/compute/get_instance.rb +45 -45
- data/lib/fog/oraclecloud/requests/compute/get_orchestration.rb +39 -39
- data/lib/fog/oraclecloud/requests/compute/get_security_application.rb +20 -20
- data/lib/fog/oraclecloud/requests/compute/get_security_rule.rb +20 -20
- data/lib/fog/oraclecloud/requests/compute/get_ssh_key.rb +39 -39
- data/lib/fog/oraclecloud/requests/compute/list_image_lists.rb +29 -29
- data/lib/fog/oraclecloud/requests/compute/list_images.rb +16 -16
- data/lib/fog/oraclecloud/requests/compute/list_instances.rb +28 -28
- data/lib/fog/oraclecloud/requests/compute/list_orchestrations.rb +28 -28
- data/lib/fog/oraclecloud/requests/compute/list_security_applications.rb +21 -21
- data/lib/fog/oraclecloud/requests/compute/list_security_lists.rb +16 -16
- data/lib/fog/oraclecloud/requests/compute/list_security_rules.rb +21 -21
- data/lib/fog/oraclecloud/requests/compute/list_ssh_keys.rb +29 -29
- data/lib/fog/oraclecloud/requests/compute/list_volumes.rb +16 -16
- data/lib/fog/oraclecloud/requests/compute/start_orchestration.rb +39 -39
- data/lib/fog/oraclecloud/requests/compute/stop_orchestration.rb +39 -39
- data/lib/fog/oraclecloud/requests/compute/update_image.rb +27 -27
- data/lib/fog/oraclecloud/requests/compute/update_image_list.rb +27 -27
- data/lib/fog/oraclecloud/requests/compute/update_orchestration.rb +80 -80
- data/lib/fog/oraclecloud/requests/compute/update_ssh_key.rb +49 -49
- data/lib/fog/oraclecloud/requests/database/backup_instance.rb +45 -45
- data/lib/fog/oraclecloud/requests/database/create_instance.rb +101 -101
- data/lib/fog/oraclecloud/requests/database/create_snapshot.rb +50 -50
- data/lib/fog/oraclecloud/requests/database/delete_instance.rb +26 -26
- data/lib/fog/oraclecloud/requests/database/delete_snapshot.rb +26 -26
- data/lib/fog/oraclecloud/requests/database/get_instance.rb +62 -62
- data/lib/fog/oraclecloud/requests/database/get_instance_from_job.rb +31 -31
- data/lib/fog/oraclecloud/requests/database/get_snapshot.rb +43 -43
- data/lib/fog/oraclecloud/requests/database/list_backups.rb +39 -39
- data/lib/fog/oraclecloud/requests/database/list_instances.rb +29 -29
- data/lib/fog/oraclecloud/requests/database/list_patches.rb +51 -51
- data/lib/fog/oraclecloud/requests/database/list_recoveries.rb +40 -40
- data/lib/fog/oraclecloud/requests/database/list_servers.rb +27 -27
- data/lib/fog/oraclecloud/requests/database/list_snapshots.rb +27 -27
- data/lib/fog/oraclecloud/requests/database/recover_instance.rb +83 -83
- data/lib/fog/oraclecloud/requests/database/scale_instance.rb +40 -40
- data/lib/fog/oraclecloud/requests/java/create_instance.rb +156 -87
- data/lib/fog/oraclecloud/requests/java/delete_instance.rb +37 -37
- data/lib/fog/oraclecloud/requests/java/get_instance.rb +43 -43
- data/lib/fog/oraclecloud/requests/java/get_server.rb +42 -42
- data/lib/fog/oraclecloud/requests/java/list_instances.rb +29 -29
- data/lib/fog/oraclecloud/requests/java/list_servers.rb +30 -30
- data/lib/fog/oraclecloud/requests/java/scale_a_node.rb +45 -45
- data/lib/fog/oraclecloud/requests/java/scale_in_a_cluster.rb +35 -35
- data/lib/fog/oraclecloud/requests/java/scale_out_a_cluster.rb +38 -38
- data/lib/fog/oraclecloud/requests/soa/create_instance.rb +71 -71
- data/lib/fog/oraclecloud/requests/soa/delete_instance.rb +35 -35
- data/lib/fog/oraclecloud/requests/soa/get_instance.rb +42 -42
- data/lib/fog/oraclecloud/requests/soa/get_job_status.rb +22 -22
- data/lib/fog/oraclecloud/requests/soa/list_instances.rb +29 -29
- data/lib/fog/oraclecloud/requests/storage/create_container.rb +41 -41
- data/lib/fog/oraclecloud/requests/storage/delete_container.rb +15 -15
- data/lib/fog/oraclecloud/requests/storage/get_container.rb +63 -63
- data/lib/fog/oraclecloud/requests/storage/list_containers.rb +27 -27
- data/lib/fog/oraclecloud/soa.rb +106 -106
- data/lib/fog/oraclecloud/storage.rb +98 -98
- data/lib/fog/oraclecloud/version.rb +5 -5
- data/tests/helper.rb +5 -3
- data/tests/helpers/mock_helper.rb +14 -14
- data/tests/requests/compute_tests.rb +9 -9
- data/tests/requests/database_tests.rb +241 -241
- data/tests/requests/instance_tests.rb +68 -61
- data/tests/requests/java_tests.rb +149 -109
- data/tests/requests/orchestrations_tests.rb +90 -90
- data/tests/requests/soa_tests.rb +151 -151
- data/tests/requests/ssh_keys_tests.rb +53 -53
- data/tests/requests/storage_tests.rb +54 -54
- metadata +17 -3
@@ -1,129 +1,129 @@
|
|
1
|
-
module Fog
|
2
|
-
module OracleCloud
|
3
|
-
class Database < Fog::Service
|
4
|
-
requires :oracle_username, :oracle_password, :oracle_domain
|
5
|
-
recognizes :oracle_region
|
6
|
-
|
7
|
-
model_path 'fog/oraclecloud/models/database'
|
8
|
-
model :instance
|
9
|
-
collection :instances
|
10
|
-
model :backup
|
11
|
-
collection :backups
|
12
|
-
model :recovery
|
13
|
-
collection :recoveries
|
14
|
-
model :snapshot
|
15
|
-
collection :snapshots
|
16
|
-
model :server
|
17
|
-
collection :servers
|
18
|
-
model :patch
|
19
|
-
collection :patches
|
20
|
-
|
21
|
-
request_path 'fog/oraclecloud/requests/database'
|
22
|
-
request :list_instances
|
23
|
-
request :get_instance
|
24
|
-
request :get_instance_from_job
|
25
|
-
request :create_instance
|
26
|
-
request :delete_instance
|
27
|
-
request :list_backups
|
28
|
-
request :list_recoveries
|
29
|
-
request :list_snapshots
|
30
|
-
request :get_snapshot
|
31
|
-
request :create_snapshot
|
32
|
-
request :delete_snapshot
|
33
|
-
request :list_servers
|
34
|
-
request :scale_instance
|
35
|
-
request :backup_instance
|
36
|
-
request :recover_instance
|
37
|
-
request :list_patches
|
38
|
-
|
39
|
-
class Real
|
40
|
-
|
41
|
-
def initialize(options={})
|
42
|
-
@username = options[:oracle_username]
|
43
|
-
@password = options[:oracle_password]
|
44
|
-
@identity_domain = options[:oracle_domain]
|
45
|
-
region_url = options[:oracle_region] == 'emea' ? 'https://dbcs.emea.oraclecloud.com' : 'https://dbaas.oraclecloud.com'
|
46
|
-
Excon.ssl_verify_peer = false
|
47
|
-
|
48
|
-
@connection = Fog::XML::Connection.new(region_url)
|
49
|
-
end
|
50
|
-
|
51
|
-
def username
|
52
|
-
@username
|
53
|
-
end
|
54
|
-
|
55
|
-
def password
|
56
|
-
@password
|
57
|
-
end
|
58
|
-
|
59
|
-
def auth_header
|
60
|
-
auth_header ||= 'Basic ' + Base64.encode64("#{@username}:#{@password}").gsub("\n",'')
|
61
|
-
end
|
62
|
-
|
63
|
-
def request(params, parse_json = true, &block)
|
64
|
-
begin
|
65
|
-
response = @connection.request(params.merge!({
|
66
|
-
:headers => {
|
67
|
-
'Authorization' => auth_header,
|
68
|
-
'X-ID-TENANT-NAME' => @identity_domain,
|
69
|
-
'Content-Type' => 'application/json',
|
70
|
-
#'Accept' => 'application/json'
|
71
|
-
}.merge!(params[:headers] || {})
|
72
|
-
}), &block)
|
73
|
-
rescue Excon::Errors::HTTPStatusError => error
|
74
|
-
raise case error
|
75
|
-
when Excon::Errors::NotFound
|
76
|
-
Fog::OracleCloud::Database::NotFound.slurp(error)
|
77
|
-
else
|
78
|
-
error
|
79
|
-
end
|
80
|
-
end
|
81
|
-
#https://jaas.oraclecloud.com/paas/service/jcs/api/v1.1/instances/agriculture/status/create/job/2781084
|
82
|
-
if !response.body.empty? && parse_json
|
83
|
-
# The Oracle Cloud doesn't return the Content-Type header as application/json, rather as application/vnd.com.oracle.oracloud.provisioning.Pod+json
|
84
|
-
# Should add check here to validate, but not sure if this might change in future
|
85
|
-
response.body = Fog::JSON.decode(response.body)
|
86
|
-
end
|
87
|
-
response
|
88
|
-
end
|
89
|
-
end
|
90
|
-
|
91
|
-
class Mock
|
92
|
-
def initialize(options={})
|
93
|
-
@username = options[:oracle_username]
|
94
|
-
@password = options[:oracle_password]
|
95
|
-
@identity_domain = options[:oracle_domain]
|
96
|
-
end
|
97
|
-
|
98
|
-
def username
|
99
|
-
@username
|
100
|
-
end
|
101
|
-
|
102
|
-
def password
|
103
|
-
@password
|
104
|
-
end
|
105
|
-
|
106
|
-
def self.data
|
107
|
-
@data ||= {
|
108
|
-
:instances => {},
|
109
|
-
:snapshots => {},
|
110
|
-
:servers => {},
|
111
|
-
:backups => {},
|
112
|
-
:recoveries => {},
|
113
|
-
:deleted_at => {},
|
114
|
-
:created_at => {},
|
115
|
-
:maintenance_at => {}
|
116
|
-
}
|
117
|
-
end
|
118
|
-
|
119
|
-
def self.reset
|
120
|
-
@data = nil
|
121
|
-
end
|
122
|
-
|
123
|
-
def data
|
124
|
-
self.class.data
|
125
|
-
end
|
126
|
-
end
|
127
|
-
end
|
128
|
-
end
|
129
|
-
end
|
1
|
+
module Fog
|
2
|
+
module OracleCloud
|
3
|
+
class Database < Fog::Service
|
4
|
+
requires :oracle_username, :oracle_password, :oracle_domain
|
5
|
+
recognizes :oracle_region
|
6
|
+
|
7
|
+
model_path 'fog/oraclecloud/models/database'
|
8
|
+
model :instance
|
9
|
+
collection :instances
|
10
|
+
model :backup
|
11
|
+
collection :backups
|
12
|
+
model :recovery
|
13
|
+
collection :recoveries
|
14
|
+
model :snapshot
|
15
|
+
collection :snapshots
|
16
|
+
model :server
|
17
|
+
collection :servers
|
18
|
+
model :patch
|
19
|
+
collection :patches
|
20
|
+
|
21
|
+
request_path 'fog/oraclecloud/requests/database'
|
22
|
+
request :list_instances
|
23
|
+
request :get_instance
|
24
|
+
request :get_instance_from_job
|
25
|
+
request :create_instance
|
26
|
+
request :delete_instance
|
27
|
+
request :list_backups
|
28
|
+
request :list_recoveries
|
29
|
+
request :list_snapshots
|
30
|
+
request :get_snapshot
|
31
|
+
request :create_snapshot
|
32
|
+
request :delete_snapshot
|
33
|
+
request :list_servers
|
34
|
+
request :scale_instance
|
35
|
+
request :backup_instance
|
36
|
+
request :recover_instance
|
37
|
+
request :list_patches
|
38
|
+
|
39
|
+
class Real
|
40
|
+
|
41
|
+
def initialize(options={})
|
42
|
+
@username = options[:oracle_username]
|
43
|
+
@password = options[:oracle_password]
|
44
|
+
@identity_domain = options[:oracle_domain]
|
45
|
+
region_url = options[:oracle_region] == 'emea' ? 'https://dbcs.emea.oraclecloud.com' : 'https://dbaas.oraclecloud.com'
|
46
|
+
Excon.ssl_verify_peer = false
|
47
|
+
|
48
|
+
@connection = Fog::XML::Connection.new(region_url)
|
49
|
+
end
|
50
|
+
|
51
|
+
def username
|
52
|
+
@username
|
53
|
+
end
|
54
|
+
|
55
|
+
def password
|
56
|
+
@password
|
57
|
+
end
|
58
|
+
|
59
|
+
def auth_header
|
60
|
+
auth_header ||= 'Basic ' + Base64.encode64("#{@username}:#{@password}").gsub("\n",'')
|
61
|
+
end
|
62
|
+
|
63
|
+
def request(params, parse_json = true, &block)
|
64
|
+
begin
|
65
|
+
response = @connection.request(params.merge!({
|
66
|
+
:headers => {
|
67
|
+
'Authorization' => auth_header,
|
68
|
+
'X-ID-TENANT-NAME' => @identity_domain,
|
69
|
+
'Content-Type' => 'application/json',
|
70
|
+
#'Accept' => 'application/json'
|
71
|
+
}.merge!(params[:headers] || {})
|
72
|
+
}), &block)
|
73
|
+
rescue Excon::Errors::HTTPStatusError => error
|
74
|
+
raise case error
|
75
|
+
when Excon::Errors::NotFound
|
76
|
+
Fog::OracleCloud::Database::NotFound.slurp(error)
|
77
|
+
else
|
78
|
+
error
|
79
|
+
end
|
80
|
+
end
|
81
|
+
#https://jaas.oraclecloud.com/paas/service/jcs/api/v1.1/instances/agriculture/status/create/job/2781084
|
82
|
+
if !response.body.empty? && parse_json
|
83
|
+
# The Oracle Cloud doesn't return the Content-Type header as application/json, rather as application/vnd.com.oracle.oracloud.provisioning.Pod+json
|
84
|
+
# Should add check here to validate, but not sure if this might change in future
|
85
|
+
response.body = Fog::JSON.decode(response.body)
|
86
|
+
end
|
87
|
+
response
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
class Mock
|
92
|
+
def initialize(options={})
|
93
|
+
@username = options[:oracle_username]
|
94
|
+
@password = options[:oracle_password]
|
95
|
+
@identity_domain = options[:oracle_domain]
|
96
|
+
end
|
97
|
+
|
98
|
+
def username
|
99
|
+
@username
|
100
|
+
end
|
101
|
+
|
102
|
+
def password
|
103
|
+
@password
|
104
|
+
end
|
105
|
+
|
106
|
+
def self.data
|
107
|
+
@data ||= {
|
108
|
+
:instances => {},
|
109
|
+
:snapshots => {},
|
110
|
+
:servers => {},
|
111
|
+
:backups => {},
|
112
|
+
:recoveries => {},
|
113
|
+
:deleted_at => {},
|
114
|
+
:created_at => {},
|
115
|
+
:maintenance_at => {}
|
116
|
+
}
|
117
|
+
end
|
118
|
+
|
119
|
+
def self.reset
|
120
|
+
@data = nil
|
121
|
+
end
|
122
|
+
|
123
|
+
def data
|
124
|
+
self.class.data
|
125
|
+
end
|
126
|
+
end
|
127
|
+
end
|
128
|
+
end
|
129
|
+
end
|
data/lib/fog/oraclecloud/java.rb
CHANGED
@@ -1,115 +1,123 @@
|
|
1
|
-
module Fog
|
2
|
-
module OracleCloud
|
3
|
-
class Java < Fog::Service
|
4
|
-
requires :oracle_username, :oracle_password, :oracle_domain
|
5
|
-
recognizes :oracle_region
|
6
|
-
|
7
|
-
model_path 'fog/oraclecloud/models/java'
|
8
|
-
model :instance
|
9
|
-
collection :instances
|
10
|
-
model :server
|
11
|
-
collection :servers
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
request :
|
17
|
-
request :
|
18
|
-
request :
|
19
|
-
request :
|
20
|
-
request :
|
21
|
-
request :
|
22
|
-
request :
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
def
|
84
|
-
@username
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
end
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
end
|
1
|
+
module Fog
|
2
|
+
module OracleCloud
|
3
|
+
class Java < Fog::Service
|
4
|
+
requires :oracle_username, :oracle_password, :oracle_domain
|
5
|
+
recognizes :oracle_region
|
6
|
+
|
7
|
+
model_path 'fog/oraclecloud/models/java'
|
8
|
+
model :instance
|
9
|
+
collection :instances
|
10
|
+
model :server
|
11
|
+
collection :servers
|
12
|
+
model :access_rule
|
13
|
+
collection :access_rules
|
14
|
+
|
15
|
+
request_path 'fog/oraclecloud/requests/java'
|
16
|
+
request :list_instances
|
17
|
+
request :create_instance
|
18
|
+
request :get_instance
|
19
|
+
request :delete_instance
|
20
|
+
request :list_servers
|
21
|
+
request :get_server
|
22
|
+
request :scale_out_a_cluster
|
23
|
+
request :scale_in_a_cluster
|
24
|
+
request :scale_a_node
|
25
|
+
|
26
|
+
request :list_access_rules
|
27
|
+
request :create_access_rule
|
28
|
+
request :delete_access_rule
|
29
|
+
request :enable_access_rule
|
30
|
+
|
31
|
+
class Real
|
32
|
+
|
33
|
+
def initialize(options={})
|
34
|
+
@username = options[:oracle_username]
|
35
|
+
@password = options[:oracle_password]
|
36
|
+
@identity_domain = options[:oracle_domain]
|
37
|
+
region_url = options[:oracle_region] == 'emea' ? 'https://jcs.emea.oraclecloud.com' : 'https://jaas.oraclecloud.com'
|
38
|
+
Excon.ssl_verify_peer = false
|
39
|
+
@connection = Fog::XML::Connection.new(region_url)
|
40
|
+
end
|
41
|
+
|
42
|
+
def username
|
43
|
+
@username
|
44
|
+
end
|
45
|
+
|
46
|
+
def password
|
47
|
+
@password
|
48
|
+
end
|
49
|
+
|
50
|
+
|
51
|
+
def auth_header
|
52
|
+
auth_header ||= 'Basic ' + Base64.encode64("#{@username}:#{@password}").gsub("\n",'')
|
53
|
+
end
|
54
|
+
|
55
|
+
def request(params, parse_json = true, &block)
|
56
|
+
begin
|
57
|
+
response = @connection.request(params.merge!({
|
58
|
+
:headers => {
|
59
|
+
'Authorization' => auth_header,
|
60
|
+
'X-ID-TENANT-NAME' => @identity_domain,
|
61
|
+
'Content-Type' => 'application/json',
|
62
|
+
#'Accept' => 'application/json'
|
63
|
+
}.merge!(params[:headers] || {})
|
64
|
+
}), &block)
|
65
|
+
rescue Excon::Errors::HTTPStatusError => error
|
66
|
+
raise case error
|
67
|
+
when Excon::Errors::NotFound
|
68
|
+
Fog::OracleCloud::Java::NotFound.slurp(error)
|
69
|
+
else
|
70
|
+
error
|
71
|
+
end
|
72
|
+
end
|
73
|
+
if !response.body.empty? && parse_json
|
74
|
+
# The Oracle Cloud doesn't return the Content-Type header as application/json, rather as application/vnd.com.oracle.oracloud.provisioning.Pod+json
|
75
|
+
# Should add check here to validate, but not sure if this might change in future
|
76
|
+
response.body = Fog::JSON.decode(response.body)
|
77
|
+
end
|
78
|
+
response
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
class Mock
|
83
|
+
def initialize(options={})
|
84
|
+
@username = options[:oracle_username]
|
85
|
+
@password = options[:oracle_password]
|
86
|
+
@identity_domain = options[:oracle_domain]
|
87
|
+
@region_url = options[:oracle_region] == 'emea' ? 'https://jcs.emea.oraclecloud.com' : 'https://jaas.oraclecloud.com'
|
88
|
+
end
|
89
|
+
|
90
|
+
def username
|
91
|
+
@username
|
92
|
+
end
|
93
|
+
|
94
|
+
def password
|
95
|
+
@password
|
96
|
+
end
|
97
|
+
|
98
|
+
def region_url
|
99
|
+
@region_url
|
100
|
+
end
|
101
|
+
|
102
|
+
def self.data
|
103
|
+
@data ||= {
|
104
|
+
:instances => {},
|
105
|
+
:servers => {},
|
106
|
+
:access_rules => {},
|
107
|
+
:maintenance_at => {},
|
108
|
+
:deleted_at => {},
|
109
|
+
:created_at => {}
|
110
|
+
}
|
111
|
+
end
|
112
|
+
|
113
|
+
def self.reset
|
114
|
+
@data = nil
|
115
|
+
end
|
116
|
+
|
117
|
+
def data
|
118
|
+
self.class.data
|
119
|
+
end
|
120
|
+
end
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|