fog-oraclecloud 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +10 -0
- data/Gemfile +4 -0
- data/LICENSE +21 -0
- data/README.md +34 -0
- data/Rakefile +2 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/fog-oracle.gemspec +30 -0
- data/lib/fog/oraclecloud/compute.rb +146 -0
- data/lib/fog/oraclecloud/database.rb +114 -0
- data/lib/fog/oraclecloud/java.rb +114 -0
- data/lib/fog/oraclecloud/models/compute/image.rb +43 -0
- data/lib/fog/oraclecloud/models/compute/image_list.rb +42 -0
- data/lib/fog/oraclecloud/models/compute/image_lists.rb +22 -0
- data/lib/fog/oraclecloud/models/compute/images.rb +22 -0
- data/lib/fog/oraclecloud/models/compute/instance.rb +65 -0
- data/lib/fog/oraclecloud/models/compute/instances.rb +22 -0
- data/lib/fog/oraclecloud/models/compute/object_plan.rb +16 -0
- data/lib/fog/oraclecloud/models/compute/object_plans.rb +12 -0
- data/lib/fog/oraclecloud/models/compute/orchestration.rb +89 -0
- data/lib/fog/oraclecloud/models/compute/orchestrations.rb +20 -0
- data/lib/fog/oraclecloud/models/compute/security_application.rb +42 -0
- data/lib/fog/oraclecloud/models/compute/security_applications.rb +22 -0
- data/lib/fog/oraclecloud/models/compute/security_list.rb +26 -0
- data/lib/fog/oraclecloud/models/compute/security_lists.rb +22 -0
- data/lib/fog/oraclecloud/models/compute/security_rule.rb +41 -0
- data/lib/fog/oraclecloud/models/compute/security_rules.rb +22 -0
- data/lib/fog/oraclecloud/models/compute/ssh_key.rb +37 -0
- data/lib/fog/oraclecloud/models/compute/ssh_keys.rb +22 -0
- data/lib/fog/oraclecloud/models/compute/volume.rb +47 -0
- data/lib/fog/oraclecloud/models/compute/volumes.rb +20 -0
- data/lib/fog/oraclecloud/models/database/instance.rb +84 -0
- data/lib/fog/oraclecloud/models/database/instances.rb +26 -0
- data/lib/fog/oraclecloud/models/java/instance.rb +107 -0
- data/lib/fog/oraclecloud/models/java/instances.rb +27 -0
- data/lib/fog/oraclecloud/models/java/server.rb +26 -0
- data/lib/fog/oraclecloud/models/java/servers.rb +17 -0
- data/lib/fog/oraclecloud/models/soa/instance.rb +65 -0
- data/lib/fog/oraclecloud/models/soa/instances.rb +25 -0
- data/lib/fog/oraclecloud/models/storage/container.rb +34 -0
- data/lib/fog/oraclecloud/models/storage/containers.rb +24 -0
- data/lib/fog/oraclecloud/models/storage/object.rb +27 -0
- data/lib/fog/oraclecloud/models/storage/objects.rb +27 -0
- data/lib/fog/oraclecloud/requests/compute/create_image.rb +30 -0
- data/lib/fog/oraclecloud/requests/compute/create_image_list.rb +27 -0
- data/lib/fog/oraclecloud/requests/compute/create_instance.rb +32 -0
- data/lib/fog/oraclecloud/requests/compute/create_orchestration.rb +46 -0
- data/lib/fog/oraclecloud/requests/compute/create_security_application.rb +28 -0
- data/lib/fog/oraclecloud/requests/compute/create_security_rule.rb +29 -0
- data/lib/fog/oraclecloud/requests/compute/create_ssh_key.rb +27 -0
- data/lib/fog/oraclecloud/requests/compute/create_volume.rb +29 -0
- data/lib/fog/oraclecloud/requests/compute/delete_image.rb +19 -0
- data/lib/fog/oraclecloud/requests/compute/delete_image_list.rb +19 -0
- data/lib/fog/oraclecloud/requests/compute/delete_instance.rb +22 -0
- data/lib/fog/oraclecloud/requests/compute/delete_orchestration.rb +22 -0
- data/lib/fog/oraclecloud/requests/compute/delete_security_application.rb +20 -0
- data/lib/fog/oraclecloud/requests/compute/delete_security_rule.rb +20 -0
- data/lib/fog/oraclecloud/requests/compute/delete_ssh_key.rb +22 -0
- data/lib/fog/oraclecloud/requests/compute/get_image.rb +21 -0
- data/lib/fog/oraclecloud/requests/compute/get_image_list.rb +21 -0
- data/lib/fog/oraclecloud/requests/compute/get_instance.rb +24 -0
- data/lib/fog/oraclecloud/requests/compute/get_orchestration.rb +24 -0
- data/lib/fog/oraclecloud/requests/compute/get_security_application.rb +20 -0
- data/lib/fog/oraclecloud/requests/compute/get_security_rule.rb +20 -0
- data/lib/fog/oraclecloud/requests/compute/get_ssh_key.rb +24 -0
- data/lib/fog/oraclecloud/requests/compute/list_image_lists.rb +16 -0
- data/lib/fog/oraclecloud/requests/compute/list_images.rb +16 -0
- data/lib/fog/oraclecloud/requests/compute/list_instances.rb +16 -0
- data/lib/fog/oraclecloud/requests/compute/list_orchestrations.rb +16 -0
- data/lib/fog/oraclecloud/requests/compute/list_security_applications.rb +21 -0
- data/lib/fog/oraclecloud/requests/compute/list_security_lists.rb +16 -0
- data/lib/fog/oraclecloud/requests/compute/list_security_rules.rb +21 -0
- data/lib/fog/oraclecloud/requests/compute/list_ssh_keys.rb +16 -0
- data/lib/fog/oraclecloud/requests/compute/list_volumes.rb +16 -0
- data/lib/fog/oraclecloud/requests/compute/start_orchestration.rb +22 -0
- data/lib/fog/oraclecloud/requests/compute/stop_orchestration.rb +22 -0
- data/lib/fog/oraclecloud/requests/compute/update_image.rb +27 -0
- data/lib/fog/oraclecloud/requests/compute/update_image_list.rb +27 -0
- data/lib/fog/oraclecloud/requests/compute/update_orchestration.rb +49 -0
- data/lib/fog/oraclecloud/requests/compute/update_ssh_key.rb +29 -0
- data/lib/fog/oraclecloud/requests/database/create_instance.rb +46 -0
- data/lib/fog/oraclecloud/requests/database/delete_instance.rb +31 -0
- data/lib/fog/oraclecloud/requests/database/get_instance.rb +36 -0
- data/lib/fog/oraclecloud/requests/database/list_instances.rb +16 -0
- data/lib/fog/oraclecloud/requests/java/create_instance.rb +51 -0
- data/lib/fog/oraclecloud/requests/java/delete_instance.rb +42 -0
- data/lib/fog/oraclecloud/requests/java/get_instance.rb +37 -0
- data/lib/fog/oraclecloud/requests/java/get_server.rb +0 -0
- data/lib/fog/oraclecloud/requests/java/list_instances.rb +16 -0
- data/lib/fog/oraclecloud/requests/java/list_servers.rb +29 -0
- data/lib/fog/oraclecloud/requests/soa/create_instance.rb +47 -0
- data/lib/fog/oraclecloud/requests/soa/delete_instance.rb +40 -0
- data/lib/fog/oraclecloud/requests/soa/get_instance.rb +36 -0
- data/lib/fog/oraclecloud/requests/soa/list_instances.rb +16 -0
- data/lib/fog/oraclecloud/requests/storage/create_container.rb +21 -0
- data/lib/fog/oraclecloud/requests/storage/delete_container.rb +15 -0
- data/lib/fog/oraclecloud/requests/storage/get_container.rb +24 -0
- data/lib/fog/oraclecloud/requests/storage/list_containers.rb +16 -0
- data/lib/fog/oraclecloud/soa.rb +80 -0
- data/lib/fog/oraclecloud/storage.rb +80 -0
- data/lib/fog/oraclecloud/version.rb +5 -0
- data/lib/fog/oraclecloud.rb +29 -0
- data/tests/helper.rb +1 -0
- data/tests/requests/database_tests.rb +52 -0
- data/tests/requests/instance_tests.rb +54 -0
- data/tests/requests/java_tests.rb +52 -0
- data/tests/requests/orchestrations_tests.rb +86 -0
- data/tests/requests/soa_tests.rb +52 -0
- data/tests/requests/ssh_keys_tests.rb +49 -0
- data/tests/requests/storage_tests.rb +54 -0
- metadata +253 -0
@@ -0,0 +1,31 @@
|
|
1
|
+
module Fog
|
2
|
+
module OracleCloud
|
3
|
+
class Database
|
4
|
+
class Real
|
5
|
+
|
6
|
+
def delete_instance(service_name)
|
7
|
+
request(
|
8
|
+
:method => 'DELETE',
|
9
|
+
:expects => 202,
|
10
|
+
:path => "/paas/service/dbcs/api/v1.1/instances/#{@identity_domain}/#{service_name}"
|
11
|
+
)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
class Mock
|
16
|
+
def delete_instance(service_name)
|
17
|
+
response = Excon::Response.new
|
18
|
+
# remove from memoreeeez.
|
19
|
+
self.data[:instances].delete service_name
|
20
|
+
response.body = {
|
21
|
+
'service_name' => service_name,
|
22
|
+
'status' => 'Terminating'
|
23
|
+
}
|
24
|
+
response.status = 202
|
25
|
+
|
26
|
+
response
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
module Fog
|
2
|
+
module OracleCloud
|
3
|
+
class Database
|
4
|
+
class Real
|
5
|
+
|
6
|
+
def get_instance(instance_id)
|
7
|
+
response = request(
|
8
|
+
:expects => 200,
|
9
|
+
:method => 'GET',
|
10
|
+
:path => "/paas/service/dbcs/api/v1.1/instances/#{@identity_domain}/#{instance_id}"
|
11
|
+
)
|
12
|
+
response
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
class Mock
|
17
|
+
def get_instance(instance_id)
|
18
|
+
response = Excon::Response.new
|
19
|
+
if instance_exists? instance_id
|
20
|
+
response.status = 200
|
21
|
+
response.body = self.data[:instances][instance_id]
|
22
|
+
else
|
23
|
+
raise Fog::Oracle::Database::NotFound
|
24
|
+
end
|
25
|
+
response
|
26
|
+
end
|
27
|
+
|
28
|
+
# Checks if an instance exists
|
29
|
+
def instance_exists?(instance_id)
|
30
|
+
self.data[:instances].key? instance_id
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Fog
|
2
|
+
module OracleCloud
|
3
|
+
class Database
|
4
|
+
class Real
|
5
|
+
def list_instances
|
6
|
+
response = request(
|
7
|
+
:expects => 200,
|
8
|
+
:method => 'GET',
|
9
|
+
:path => "/paas/service/dbcs/api/v1.1/instances/#{@identity_domain}?outputLevel=verbose"
|
10
|
+
)
|
11
|
+
response
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
module Fog
|
2
|
+
module OracleCloud
|
3
|
+
class Java
|
4
|
+
class Real
|
5
|
+
|
6
|
+
def create_instance(service_name, cloudStorageContainer, cloudStorageUser, cloudStoragePassword, parameters, options={})
|
7
|
+
if !cloudStorageContainer.start_with?("/Storage-") then
|
8
|
+
# They haven't provided a well formed container name, add their details in
|
9
|
+
name = "/Storage-#{@identity_domain}/#{@username}/#{cloudStorageContainer}"
|
10
|
+
end
|
11
|
+
body_data = {
|
12
|
+
'serviceName' => service_name,
|
13
|
+
'cloudStorageContainer' => cloudStorageContainer,
|
14
|
+
'cloudStorageUser' => cloudStorageUser,
|
15
|
+
'cloudStoragePassword' => cloudStoragePassword,
|
16
|
+
'parameters' => parameters,
|
17
|
+
'level' => options[:level],
|
18
|
+
'subscriptionType' => options[:subscriptionType],
|
19
|
+
'description' => options[:description],
|
20
|
+
'provisionOTD' => options[:provisionOTD],
|
21
|
+
'sampleAppDeploymentRequests' => options[:sampleAppDeploymentRequests]
|
22
|
+
}
|
23
|
+
body_data = body_data.reject {|key, value| value.nil?}
|
24
|
+
request(
|
25
|
+
:method => 'POST',
|
26
|
+
:expects => 202,
|
27
|
+
:path => "/paas/service/jcs/api/v1.1/instances/#{@identity_domain}",
|
28
|
+
:body => Fog::JSON.encode(body_data),
|
29
|
+
:headers => {
|
30
|
+
'Content-Type'=>'application/vnd.com.oracle.oracloud.provisioning.Service+json'
|
31
|
+
}
|
32
|
+
)
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
36
|
+
|
37
|
+
class Mock
|
38
|
+
def create_instance(service_name, cloudStorageContainer, cloudStorageUser, cloudStoragePassword, parameters, options={})
|
39
|
+
response = Excon::Response.new
|
40
|
+
|
41
|
+
instance = Fog::OracleCloud::Mock.create_java_instance(service_name, parameters)
|
42
|
+
self.data[:instances][service_name] = instance
|
43
|
+
|
44
|
+
response.status = 202
|
45
|
+
response.headers['Location'] = "https://jaas.oraclecloud.com/paas/service/jcs/api/v1.1/instances/agriculture/status/create/job/2781084"
|
46
|
+
response
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
module Fog
|
2
|
+
module OracleCloud
|
3
|
+
class Java
|
4
|
+
class Real
|
5
|
+
|
6
|
+
def delete_instance(service_name, dba_name, dba_password, options={})
|
7
|
+
body_data = {
|
8
|
+
'dbaName' => dba_name,
|
9
|
+
'dbaPassword' => dba_password,
|
10
|
+
'forceDelete' => options[:force_delete]
|
11
|
+
}
|
12
|
+
|
13
|
+
body_data = body_data.reject {|key, value| value.nil?}
|
14
|
+
request(
|
15
|
+
:method => 'PUT',
|
16
|
+
:expects => 202,
|
17
|
+
:path => "/paas/service/jcs/api/v1.1/instances/#{@identity_domain}/#{service_name}",
|
18
|
+
:body => Fog::JSON.encode(body_data),
|
19
|
+
:headers => {
|
20
|
+
'Content-Type'=>'application/vnd.com.oracle.oracloud.provisioning.Service+json'
|
21
|
+
}
|
22
|
+
)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
class Mock
|
27
|
+
def delete_instance(service_name, dba_name, dba_password, options={})
|
28
|
+
response = Excon::Response.new
|
29
|
+
# remove from memoreeeez.
|
30
|
+
self.data[:instances].delete service_name
|
31
|
+
response.body = {
|
32
|
+
'service_name' => service_name,
|
33
|
+
'status' => 'Terminating'
|
34
|
+
}
|
35
|
+
response.status = 202
|
36
|
+
|
37
|
+
response
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module Fog
|
2
|
+
module OracleCloud
|
3
|
+
class Java
|
4
|
+
class Real
|
5
|
+
|
6
|
+
def get_instance(service_name)
|
7
|
+
response = request(
|
8
|
+
:expects => 200,
|
9
|
+
:method => 'GET',
|
10
|
+
:path => "/paas/service/jcs/api/v1.1/instances/#{@identity_domain}/#{service_name}"
|
11
|
+
)
|
12
|
+
response
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
class Mock
|
17
|
+
def get_instance(instance_id)
|
18
|
+
|
19
|
+
response = Excon::Response.new
|
20
|
+
if instance_exists? instance_id
|
21
|
+
response.status = 200
|
22
|
+
response.body = self.data[:instances][instance_id]
|
23
|
+
else
|
24
|
+
raise Fog::OracleCloud::Java::NotFound
|
25
|
+
end
|
26
|
+
response
|
27
|
+
end
|
28
|
+
|
29
|
+
# Checks if an instance exists
|
30
|
+
def instance_exists?(instance_id)
|
31
|
+
self.data[:instances].key? instance_id
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
File without changes
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Fog
|
2
|
+
module OracleCloud
|
3
|
+
class Java
|
4
|
+
class Real
|
5
|
+
def list_instances
|
6
|
+
response = request(
|
7
|
+
:expects => 200,
|
8
|
+
:method => 'GET',
|
9
|
+
:path => "/paas/service/jcs/api/v1.1/instances/#{@identity_domain}?outputLevel=verbose"
|
10
|
+
)
|
11
|
+
response
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module Fog
|
2
|
+
module OracleCloud
|
3
|
+
class Java
|
4
|
+
class Real
|
5
|
+
def list_servers(service_name)
|
6
|
+
response = request(
|
7
|
+
:expects => 200,
|
8
|
+
:method => 'GET',
|
9
|
+
:path => "/paas/service/jcs/api/v1.1/instances/#{@identity_domain}/#{service_name}/servers"
|
10
|
+
)
|
11
|
+
response
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
class Mock
|
16
|
+
def list_servers(service_name)
|
17
|
+
# TODO: Remove, implement proper Mock
|
18
|
+
response = request(
|
19
|
+
:expects => 200,
|
20
|
+
:method => 'GET',
|
21
|
+
:path => "/paas/service/jcs/api/v1.1/instances/#{@identity_domain}/#{service_name}/servers"
|
22
|
+
)
|
23
|
+
response
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
module Fog
|
2
|
+
module OracleCloud
|
3
|
+
class SOA
|
4
|
+
class Real
|
5
|
+
|
6
|
+
def create_instance(service_name, topology, cloudStorageContainer, cloudStorageUser, cloudStoragePassword, parameters, options={})
|
7
|
+
body_data = {
|
8
|
+
'serviceName' => service_name,
|
9
|
+
'topology' => topology,
|
10
|
+
'cloudStorageContainer' => cloudStorageContainer,
|
11
|
+
'cloudStorageUser' => cloudStorageUser,
|
12
|
+
'cloudStoragePassword' => cloudStoragePassword,
|
13
|
+
'parameters' => parameters,
|
14
|
+
'level' => options[:level],
|
15
|
+
'subscriptionType' => options[:subscriptionType],
|
16
|
+
'description' => options[:description],
|
17
|
+
'sampleAppDeploymentRequests' => options[:sampleAppDeploymentRequests]
|
18
|
+
}
|
19
|
+
body_data = body_data.reject {|key, value| value.nil?}
|
20
|
+
request(
|
21
|
+
:method => 'POST',
|
22
|
+
:expects => 202,
|
23
|
+
:path => "/paas/service/soa/api/v1.1/instances/#{@identity_domain}",
|
24
|
+
:body => Fog::JSON.encode(body_data),
|
25
|
+
#:headers => {
|
26
|
+
# 'Content-Type'=>'application/vnd.com.oracle.oracloud.provisioning.Service+json'
|
27
|
+
#}
|
28
|
+
)
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
|
33
|
+
class Mock
|
34
|
+
def create_instance(service_name, topology, cloudStorageContainer, cloudStorageUser, cloudStoragePassword, parameters, options={})
|
35
|
+
response = Excon::Response.new
|
36
|
+
|
37
|
+
instance = Fog::OracleCloud::Mock.create_instance(service_name)
|
38
|
+
self.data[:instances][service_name] = instance
|
39
|
+
|
40
|
+
response.status = 202
|
41
|
+
response.headers['Location'] = "https://jaas.oraclecloud.com/paas/service/dbcs/api/v1.1/instances/agriculture/status/create/job/2781084"
|
42
|
+
response
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
module Fog
|
2
|
+
module OracleCloud
|
3
|
+
class SOA
|
4
|
+
class Real
|
5
|
+
|
6
|
+
def delete_instance(service_name, dba_name, dba_password, options={})
|
7
|
+
body_data = {
|
8
|
+
'dbaName' => dba_name,
|
9
|
+
'dbaPassword' => dba_password,
|
10
|
+
'forceDelete' => options[:force_delete],
|
11
|
+
'skipBackupOnTerminate' => options[:skip_backup]
|
12
|
+
}
|
13
|
+
|
14
|
+
body_data = body_data.reject {|key, value| value.nil?}
|
15
|
+
request(
|
16
|
+
:method => 'PUT',
|
17
|
+
:expects => 202,
|
18
|
+
:path => "/paas/service/soa/api/v1.1/instances/#{@identity_domain}/#{service_name}",
|
19
|
+
:body => Fog::JSON.encode(body_data)
|
20
|
+
)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
class Mock
|
25
|
+
def delete_instance(service_name, dba_name, dba_password, options={})
|
26
|
+
response = Excon::Response.new
|
27
|
+
# remove from memoreeeez.
|
28
|
+
self.data[:instances].delete service_name
|
29
|
+
response.body = {
|
30
|
+
'service_name' => service_name,
|
31
|
+
'status' => 'Terminating'
|
32
|
+
}
|
33
|
+
response.status = 202
|
34
|
+
|
35
|
+
response
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
module Fog
|
2
|
+
module OracleCloud
|
3
|
+
class SOA
|
4
|
+
class Real
|
5
|
+
|
6
|
+
def get_instance(instance_id)
|
7
|
+
response = request(
|
8
|
+
:expects => 200,
|
9
|
+
:method => 'GET',
|
10
|
+
:path => "/paas/service/soa/api/v1.1/instances/#{@identity_domain}/#{instance_id}"
|
11
|
+
)
|
12
|
+
response
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
class Mock
|
17
|
+
def get_instance(instance_id)
|
18
|
+
response = Excon::Response.new
|
19
|
+
if instance_exists? instance_id
|
20
|
+
response.status = 200
|
21
|
+
response.body = self.data[:instances][instance_id]
|
22
|
+
else
|
23
|
+
raise Fog::OracleCloud::SOA::NotFound
|
24
|
+
end
|
25
|
+
response
|
26
|
+
end
|
27
|
+
|
28
|
+
# Checks if an instance exists
|
29
|
+
def instance_exists?(instance_id)
|
30
|
+
self.data[:instances].key? instance_id
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,16 @@
|
|
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
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Fog
|
2
|
+
module Storage
|
3
|
+
class OracleCloud
|
4
|
+
class Real
|
5
|
+
|
6
|
+
def create_container(name)
|
7
|
+
request({
|
8
|
+
:method => 'PUT',
|
9
|
+
:expects => [201,202],
|
10
|
+
:path => "/v1/Storage-#{@identity_domain}/#{name}"
|
11
|
+
}, false)
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
15
|
+
|
16
|
+
class Mock
|
17
|
+
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,24 @@
|
|
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
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,16 @@
|
|
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
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,80 @@
|
|
1
|
+
module Fog
|
2
|
+
module OracleCloud
|
3
|
+
class SOA < Fog::Service
|
4
|
+
requires :oracle_username, :oracle_password, :oracle_domain, :oracle_region
|
5
|
+
|
6
|
+
model_path 'fog/oraclecloud/models/soa'
|
7
|
+
model :instance
|
8
|
+
collection :instances
|
9
|
+
|
10
|
+
request_path 'fog/oraclecloud/requests/soa'
|
11
|
+
request :list_instances
|
12
|
+
request :create_instance
|
13
|
+
request :get_instance
|
14
|
+
request :delete_instance
|
15
|
+
|
16
|
+
class Real
|
17
|
+
|
18
|
+
def initialize(options={})
|
19
|
+
@username = options[:oracle_username]
|
20
|
+
@password = options[:oracle_password]
|
21
|
+
@identity_domain = options[:oracle_domain]
|
22
|
+
region_url = options[:oracle_region] == 'emea' ? 'https://jcs.emea.oraclecloud.com' : 'https://jaas.oraclecloud.com'
|
23
|
+
Excon.ssl_verify_peer = false
|
24
|
+
|
25
|
+
@connection = Fog::XML::Connection.new(region_url)
|
26
|
+
end
|
27
|
+
|
28
|
+
def auth_header
|
29
|
+
auth_header ||= 'Basic ' + Base64.encode64("#{@username}:#{@password}").gsub("\n",'')
|
30
|
+
end
|
31
|
+
|
32
|
+
def request(params, parse_json = true, &block)
|
33
|
+
|
34
|
+
begin
|
35
|
+
response = @connection.request(params.merge!({
|
36
|
+
:headers => {
|
37
|
+
'Authorization' => auth_header,
|
38
|
+
'X-ID-TENANT-NAME' => @identity_domain,
|
39
|
+
'Content-Type' => 'application/json',
|
40
|
+
'Accept' => 'application/json'
|
41
|
+
}.merge!(params[:headers] || {})
|
42
|
+
}), &block)
|
43
|
+
rescue Excon::Errors::HTTPStatusError => error
|
44
|
+
raise case error
|
45
|
+
when Excon::Errors::NotFound
|
46
|
+
Fog::OracleCloud::SOA::NotFound.slurp(error)
|
47
|
+
else
|
48
|
+
error
|
49
|
+
end
|
50
|
+
end
|
51
|
+
if !response.body.empty? && parse_json
|
52
|
+
# The Oracle Cloud doesn't return the Content-Type header as application/json, rather as application/vnd.com.oracle.oracloud.provisioning.Pod+json
|
53
|
+
# Should add check here to validate, but not sure if this might change in future
|
54
|
+
response.body = Fog::JSON.decode(response.body)
|
55
|
+
end
|
56
|
+
response
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
class Mock
|
61
|
+
|
62
|
+
def initialize(options={})
|
63
|
+
|
64
|
+
end
|
65
|
+
|
66
|
+
def self.data
|
67
|
+
@data ||= Hash.new do |hash, key|
|
68
|
+
hash[key] = {
|
69
|
+
:instances => {}
|
70
|
+
}
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
def data
|
75
|
+
self.class.data[@oracle_username]
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
@@ -0,0 +1,80 @@
|
|
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
|
+
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|