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,101 +1,101 @@
|
|
1
|
-
module Fog
|
2
|
-
module OracleCloud
|
3
|
-
class Database
|
4
|
-
class Real
|
5
|
-
|
6
|
-
def create_instance(config, options)
|
7
|
-
parameters = options.select{|key, value| [:admin_password, :backup_destination, :charset, :cloud_storage_container, :cloud_storage_pwd, :cloud_storage_user, :cloud_storage_if_missing, :disaster_recovery, :failover_database, :golden_gate, :is_rac, :ncharset, :pdb_name, :sid, :timezone, :usable_storage, :create_storage_container_if_missing].include?(key)}
|
8
|
-
params = {
|
9
|
-
'type' => 'db'
|
10
|
-
}
|
11
|
-
parameters.each { |key, value|
|
12
|
-
if !value.nil? then
|
13
|
-
if key == :cloud_storage_container then
|
14
|
-
if !value.start_with?("Storage-") then
|
15
|
-
value = "Storage-#{@identity_domain}/#{value}"
|
16
|
-
end
|
17
|
-
end
|
18
|
-
new_key = key.to_s.split('_').collect(&:capitalize).join
|
19
|
-
new_key = new_key[0,1].downcase + new_key[1..-1]
|
20
|
-
params[new_key] = value
|
21
|
-
end
|
22
|
-
}
|
23
|
-
body_data = {
|
24
|
-
'serviceName' => config[:service_name],
|
25
|
-
'version' => config[:version],
|
26
|
-
'level' => config[:level],
|
27
|
-
'edition' => config[:edition],
|
28
|
-
'subscriptionType' => config[:subscription_type],
|
29
|
-
'description' => config[:description],
|
30
|
-
'shape' => config[:shape],
|
31
|
-
'vmPublicKeyText' => config[:ssh_key],
|
32
|
-
'parameters' => [params]
|
33
|
-
}
|
34
|
-
body_data = body_data.reject {|key, value| value.nil?}
|
35
|
-
|
36
|
-
request(
|
37
|
-
:method => 'POST',
|
38
|
-
:expects => 202,
|
39
|
-
:path => "/paas/service/dbcs/api/v1.1/instances/#{@identity_domain}",
|
40
|
-
:body => Fog::JSON.encode(body_data),
|
41
|
-
#:headers => {
|
42
|
-
# 'Content-Type'=>'application/vnd.com.oracle.oracloud.provisioning.Service+json'
|
43
|
-
#}
|
44
|
-
)
|
45
|
-
end
|
46
|
-
|
47
|
-
end
|
48
|
-
|
49
|
-
class Mock
|
50
|
-
def create_instance(config, options)
|
51
|
-
response = Excon::Response.new
|
52
|
-
job_id = rand(10000).to_s
|
53
|
-
data = {
|
54
|
-
'serviceName' => config[:service_name],
|
55
|
-
'shape' => config[:shape],
|
56
|
-
'edition' => config[:edition],
|
57
|
-
'version' => config[:version],
|
58
|
-
'status' => 'Starting Provisioning', # Not a valid status, but we use it to simulate the time that the Oracle Cloud takes to add this to the list of instances
|
59
|
-
'charset' => 'AL32UTF8',
|
60
|
-
'ncharset' => 'AL16UTF16',
|
61
|
-
'pdbName' => 'pdb1', # Note this is only valid for 12c instances. Too hard to fix for mocking
|
62
|
-
'timezone' => 'UTC',
|
63
|
-
'creation_job_id' => job_id,
|
64
|
-
'totalSharedStorage' => options[:usable_storage],
|
65
|
-
'domainName' => @identity_domain,
|
66
|
-
'creation_date'=>Time.now.strftime('%Y-%b-%dT%H:%M:%S'),
|
67
|
-
'serviceType'=>'DBaaS',
|
68
|
-
'creator'=>@username
|
69
|
-
}
|
70
|
-
.merge(config.select {|key, value| [:description, :level, :subscription_type].include?(key) })
|
71
|
-
.merge(options.select {|key, value| [:backup_destination, :failover_database, :cloud_storage_container, :is_rac, :ncharset, :pdb_name, :sid, :timezone].include?(key) })
|
72
|
-
|
73
|
-
self.data[:instances][config[:service_name]] = data
|
74
|
-
self.data[:created_at][config[:service_name]] = Time.now
|
75
|
-
|
76
|
-
# Also create some compute nodes
|
77
|
-
node = {
|
78
|
-
"status"=>"Running",
|
79
|
-
"creation_job_id"=>"5495118",
|
80
|
-
"creation_time"=>"Tue Jun 28 23:52:45 UTC 2016",
|
81
|
-
"created_by"=>"dbaasadmin",
|
82
|
-
"shape"=>"oc4",
|
83
|
-
"sid"=>"ORCL1",
|
84
|
-
"pdbName"=>"PDB1",
|
85
|
-
"listenerPort"=> 1521,
|
86
|
-
"connect_descriptor"=>"(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=db12c-xp-rac2)(PORT=1521))(ADDRESS=(PROTOCOL=TCP)(HOST=db12c-xp-rac1)(PORT=1521))(LOAD_BALANCE=ON)(FAILOVER=ON))(CONNECT_DATA=(SERVICE_NAME=PDB1.usexample.oraclecloud.internal)))",
|
87
|
-
"connect_descriptor_with_public_ip"=>"(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=129.144.23.176)(PORT=1521))(ADDRESS=(PROTOCOL=TCP)(HOST=129.144.23.112)(PORT=1521))(LOAD_BALANCE=ON)(FAILOVER=ON))(CONNECT_DATA=(SERVICE_NAME=PDB1.usexample.oraclecloud.internal)))",
|
88
|
-
"initialPrimary"=> true,
|
89
|
-
"storageAllocated"=> 97280,
|
90
|
-
"reservedIP"=>"129.144.23.112",
|
91
|
-
"hostname"=>"db12c-xp-rac1"
|
92
|
-
}
|
93
|
-
self.data[:servers][config[:service_name]] = [node]
|
94
|
-
response.headers['Location'] = "https://dbaas.oraclecloud.com:443/paas/service/dbcs/api/v1.1/instances/#{@identity_domain}/status/create/job/#{job_id}"
|
95
|
-
response.status = 202
|
96
|
-
response
|
97
|
-
end
|
98
|
-
end
|
99
|
-
end
|
100
|
-
end
|
101
|
-
end
|
1
|
+
module Fog
|
2
|
+
module OracleCloud
|
3
|
+
class Database
|
4
|
+
class Real
|
5
|
+
|
6
|
+
def create_instance(config, options)
|
7
|
+
parameters = options.select{|key, value| [:admin_password, :backup_destination, :charset, :cloud_storage_container, :cloud_storage_pwd, :cloud_storage_user, :cloud_storage_if_missing, :disaster_recovery, :failover_database, :golden_gate, :is_rac, :ncharset, :pdb_name, :sid, :timezone, :usable_storage, :create_storage_container_if_missing].include?(key)}
|
8
|
+
params = {
|
9
|
+
'type' => 'db'
|
10
|
+
}
|
11
|
+
parameters.each { |key, value|
|
12
|
+
if !value.nil? then
|
13
|
+
if key == :cloud_storage_container then
|
14
|
+
if !value.start_with?("Storage-") then
|
15
|
+
value = "Storage-#{@identity_domain}/#{value}"
|
16
|
+
end
|
17
|
+
end
|
18
|
+
new_key = key.to_s.split('_').collect(&:capitalize).join
|
19
|
+
new_key = new_key[0,1].downcase + new_key[1..-1]
|
20
|
+
params[new_key] = value
|
21
|
+
end
|
22
|
+
}
|
23
|
+
body_data = {
|
24
|
+
'serviceName' => config[:service_name],
|
25
|
+
'version' => config[:version],
|
26
|
+
'level' => config[:level],
|
27
|
+
'edition' => config[:edition],
|
28
|
+
'subscriptionType' => config[:subscription_type],
|
29
|
+
'description' => config[:description],
|
30
|
+
'shape' => config[:shape],
|
31
|
+
'vmPublicKeyText' => config[:ssh_key],
|
32
|
+
'parameters' => [params]
|
33
|
+
}
|
34
|
+
body_data = body_data.reject {|key, value| value.nil?}
|
35
|
+
|
36
|
+
request(
|
37
|
+
:method => 'POST',
|
38
|
+
:expects => 202,
|
39
|
+
:path => "/paas/service/dbcs/api/v1.1/instances/#{@identity_domain}",
|
40
|
+
:body => Fog::JSON.encode(body_data),
|
41
|
+
#:headers => {
|
42
|
+
# 'Content-Type'=>'application/vnd.com.oracle.oracloud.provisioning.Service+json'
|
43
|
+
#}
|
44
|
+
)
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
48
|
+
|
49
|
+
class Mock
|
50
|
+
def create_instance(config, options)
|
51
|
+
response = Excon::Response.new
|
52
|
+
job_id = rand(10000).to_s
|
53
|
+
data = {
|
54
|
+
'serviceName' => config[:service_name],
|
55
|
+
'shape' => config[:shape],
|
56
|
+
'edition' => config[:edition],
|
57
|
+
'version' => config[:version],
|
58
|
+
'status' => 'Starting Provisioning', # Not a valid status, but we use it to simulate the time that the Oracle Cloud takes to add this to the list of instances
|
59
|
+
'charset' => 'AL32UTF8',
|
60
|
+
'ncharset' => 'AL16UTF16',
|
61
|
+
'pdbName' => 'pdb1', # Note this is only valid for 12c instances. Too hard to fix for mocking
|
62
|
+
'timezone' => 'UTC',
|
63
|
+
'creation_job_id' => job_id,
|
64
|
+
'totalSharedStorage' => options[:usable_storage],
|
65
|
+
'domainName' => @identity_domain,
|
66
|
+
'creation_date'=>Time.now.strftime('%Y-%b-%dT%H:%M:%S'),
|
67
|
+
'serviceType'=>'DBaaS',
|
68
|
+
'creator'=>@username
|
69
|
+
}
|
70
|
+
.merge(config.select {|key, value| [:description, :level, :subscription_type].include?(key) })
|
71
|
+
.merge(options.select {|key, value| [:backup_destination, :failover_database, :cloud_storage_container, :is_rac, :ncharset, :pdb_name, :sid, :timezone].include?(key) })
|
72
|
+
|
73
|
+
self.data[:instances][config[:service_name]] = data
|
74
|
+
self.data[:created_at][config[:service_name]] = Time.now
|
75
|
+
|
76
|
+
# Also create some compute nodes
|
77
|
+
node = {
|
78
|
+
"status"=>"Running",
|
79
|
+
"creation_job_id"=>"5495118",
|
80
|
+
"creation_time"=>"Tue Jun 28 23:52:45 UTC 2016",
|
81
|
+
"created_by"=>"dbaasadmin",
|
82
|
+
"shape"=>"oc4",
|
83
|
+
"sid"=>"ORCL1",
|
84
|
+
"pdbName"=>"PDB1",
|
85
|
+
"listenerPort"=> 1521,
|
86
|
+
"connect_descriptor"=>"(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=db12c-xp-rac2)(PORT=1521))(ADDRESS=(PROTOCOL=TCP)(HOST=db12c-xp-rac1)(PORT=1521))(LOAD_BALANCE=ON)(FAILOVER=ON))(CONNECT_DATA=(SERVICE_NAME=PDB1.usexample.oraclecloud.internal)))",
|
87
|
+
"connect_descriptor_with_public_ip"=>"(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=129.144.23.176)(PORT=1521))(ADDRESS=(PROTOCOL=TCP)(HOST=129.144.23.112)(PORT=1521))(LOAD_BALANCE=ON)(FAILOVER=ON))(CONNECT_DATA=(SERVICE_NAME=PDB1.usexample.oraclecloud.internal)))",
|
88
|
+
"initialPrimary"=> true,
|
89
|
+
"storageAllocated"=> 97280,
|
90
|
+
"reservedIP"=>"129.144.23.112",
|
91
|
+
"hostname"=>"db12c-xp-rac1"
|
92
|
+
}
|
93
|
+
self.data[:servers][config[:service_name]] = [node]
|
94
|
+
response.headers['Location'] = "https://dbaas.oraclecloud.com:443/paas/service/dbcs/api/v1.1/instances/#{@identity_domain}/status/create/job/#{job_id}"
|
95
|
+
response.status = 202
|
96
|
+
response
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
@@ -1,50 +1,50 @@
|
|
1
|
-
module Fog
|
2
|
-
module OracleCloud
|
3
|
-
class Database
|
4
|
-
class Real
|
5
|
-
|
6
|
-
def create_snapshot(name, description, database_id)
|
7
|
-
body_data = {
|
8
|
-
'name' => name,
|
9
|
-
'description' => description
|
10
|
-
}
|
11
|
-
body_data = body_data.reject {|key, value| value.nil?}
|
12
|
-
|
13
|
-
response = request(
|
14
|
-
:method => 'POST',
|
15
|
-
:expects => 202,
|
16
|
-
:path => "/paas/api/v1.1/instancemgmt/#{@identity_domain}/services/dbaas/instances/#{database_id}/snapshots",
|
17
|
-
:body => Fog::JSON.encode(body_data),
|
18
|
-
)
|
19
|
-
# Store the database reference in the model, so that we can use it later
|
20
|
-
response.database_id = service_name
|
21
|
-
response
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
class Mock
|
26
|
-
def create_snapshot(name, description, database_id)
|
27
|
-
response = Excon::Response.new
|
28
|
-
|
29
|
-
data = {
|
30
|
-
'name' => name,
|
31
|
-
'description' => description,
|
32
|
-
'creationTime' => Time.now,
|
33
|
-
'clonedServicesSize' => 1,
|
34
|
-
'status'=>'In Progress',
|
35
|
-
'database_id'=>database_id,
|
36
|
-
'clonedServices'=>[{
|
37
|
-
'clonedServiceName'=>'ClonedService1',
|
38
|
-
'clonedServiceCreationTime'=> Time.now
|
39
|
-
}]
|
40
|
-
}
|
41
|
-
if !self.data[:snapshots].key?(database_id) then self.data[:snapshots][database_id] = {} end
|
42
|
-
self.data[:snapshots][database_id][name] = data
|
43
|
-
self.data[:created_at][name] = Time.now
|
44
|
-
response.status = 202
|
45
|
-
response
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
1
|
+
module Fog
|
2
|
+
module OracleCloud
|
3
|
+
class Database
|
4
|
+
class Real
|
5
|
+
|
6
|
+
def create_snapshot(name, description, database_id)
|
7
|
+
body_data = {
|
8
|
+
'name' => name,
|
9
|
+
'description' => description
|
10
|
+
}
|
11
|
+
body_data = body_data.reject {|key, value| value.nil?}
|
12
|
+
|
13
|
+
response = request(
|
14
|
+
:method => 'POST',
|
15
|
+
:expects => 202,
|
16
|
+
:path => "/paas/api/v1.1/instancemgmt/#{@identity_domain}/services/dbaas/instances/#{database_id}/snapshots",
|
17
|
+
:body => Fog::JSON.encode(body_data),
|
18
|
+
)
|
19
|
+
# Store the database reference in the model, so that we can use it later
|
20
|
+
response.database_id = service_name
|
21
|
+
response
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
class Mock
|
26
|
+
def create_snapshot(name, description, database_id)
|
27
|
+
response = Excon::Response.new
|
28
|
+
|
29
|
+
data = {
|
30
|
+
'name' => name,
|
31
|
+
'description' => description,
|
32
|
+
'creationTime' => Time.now,
|
33
|
+
'clonedServicesSize' => 1,
|
34
|
+
'status'=>'In Progress',
|
35
|
+
'database_id'=>database_id,
|
36
|
+
'clonedServices'=>[{
|
37
|
+
'clonedServiceName'=>'ClonedService1',
|
38
|
+
'clonedServiceCreationTime'=> Time.now
|
39
|
+
}]
|
40
|
+
}
|
41
|
+
if !self.data[:snapshots].key?(database_id) then self.data[:snapshots][database_id] = {} end
|
42
|
+
self.data[:snapshots][database_id][name] = data
|
43
|
+
self.data[:created_at][name] = Time.now
|
44
|
+
response.status = 202
|
45
|
+
response
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -1,26 +1,26 @@
|
|
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(name)
|
17
|
-
response = Excon::Response.new
|
18
|
-
self.data[:instances][name]['status'] = 'Terminating'
|
19
|
-
self.data[:deleted_at][name] = Time.now
|
20
|
-
response.status = 204
|
21
|
-
response
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
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(name)
|
17
|
+
response = Excon::Response.new
|
18
|
+
self.data[:instances][name]['status'] = 'Terminating'
|
19
|
+
self.data[:deleted_at][name] = Time.now
|
20
|
+
response.status = 204
|
21
|
+
response
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -1,26 +1,26 @@
|
|
1
|
-
module Fog
|
2
|
-
module OracleCloud
|
3
|
-
class Database
|
4
|
-
class Real
|
5
|
-
|
6
|
-
def delete_snapshot(db_name, snapshot_name)
|
7
|
-
request(
|
8
|
-
:method => 'DELETE',
|
9
|
-
:expects => 202,
|
10
|
-
:path => "/paas/api/v1.1/instancemgmt/#{@identity_domain}/services/dbaas/instances/#{db_name}/snapshots/#{snapshot_name}"
|
11
|
-
)
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
class Mock
|
16
|
-
def delete_snapshot(db_name, snapshot_name)
|
17
|
-
response = Excon::Response.new
|
18
|
-
self.data[:snapshots][db_name][snapshot_name]['status'] = 'Terminating'
|
19
|
-
self.data[:deleted_at][snapshot_name] = Time.now
|
20
|
-
response.status = 204
|
21
|
-
response
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
1
|
+
module Fog
|
2
|
+
module OracleCloud
|
3
|
+
class Database
|
4
|
+
class Real
|
5
|
+
|
6
|
+
def delete_snapshot(db_name, snapshot_name)
|
7
|
+
request(
|
8
|
+
:method => 'DELETE',
|
9
|
+
:expects => 202,
|
10
|
+
:path => "/paas/api/v1.1/instancemgmt/#{@identity_domain}/services/dbaas/instances/#{db_name}/snapshots/#{snapshot_name}"
|
11
|
+
)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
class Mock
|
16
|
+
def delete_snapshot(db_name, snapshot_name)
|
17
|
+
response = Excon::Response.new
|
18
|
+
self.data[:snapshots][db_name][snapshot_name]['status'] = 'Terminating'
|
19
|
+
self.data[:deleted_at][snapshot_name] = Time.now
|
20
|
+
response.status = 204
|
21
|
+
response
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -1,63 +1,63 @@
|
|
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(name)
|
18
|
-
response = Excon::Response.new
|
19
|
-
|
20
|
-
if instance = self.data[:instances][name]
|
21
|
-
case instance['status']
|
22
|
-
when 'Starting Provisioning'
|
23
|
-
self.data[:instances][name]['status'] = 'In Progress'
|
24
|
-
# This simulates the few seconds the Oracle Cloud takes to add this instance to the GET request after creating
|
25
|
-
raise(
|
26
|
-
Excon::Errors.status_error(
|
27
|
-
{ :expects => 200 },
|
28
|
-
Excon::Response.new({
|
29
|
-
:status => 404,
|
30
|
-
:body => 'No such service exists, check domain and service name'
|
31
|
-
})
|
32
|
-
)
|
33
|
-
)
|
34
|
-
when 'Terminating'
|
35
|
-
if Time.now - self.data[:deleted_at][name] >= Fog::Mock.delay
|
36
|
-
self.data[:deleted_at].delete(name)
|
37
|
-
self.data[:instances].delete(name)
|
38
|
-
end
|
39
|
-
when 'In Progress'
|
40
|
-
if Time.now - self.data[:created_at][name] >= Fog::Mock.delay
|
41
|
-
self.data[:instances][name]['status'] = 'Running'
|
42
|
-
instance = self.data[:instances][name]
|
43
|
-
self.data[:created_at].delete(name)
|
44
|
-
end
|
45
|
-
when 'Maintenance'
|
46
|
-
info = self.data[:maintenance_at][name]
|
47
|
-
if Time.now - info['time'] >= Fog::Mock.delay
|
48
|
-
self.data[:instances][name]['status'] = 'Running'
|
49
|
-
self.data[:instances][name][info['attribute']] = info['value']
|
50
|
-
self.data[:maintenance_at].delete(name)
|
51
|
-
end
|
52
|
-
end
|
53
|
-
response.status = 200
|
54
|
-
response.body = instance
|
55
|
-
response
|
56
|
-
else
|
57
|
-
raise Fog::OracleCloud::Database::NotFound.new("Database #{name} does not exist");
|
58
|
-
end
|
59
|
-
end
|
60
|
-
end
|
61
|
-
end
|
62
|
-
end
|
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(name)
|
18
|
+
response = Excon::Response.new
|
19
|
+
|
20
|
+
if instance = self.data[:instances][name]
|
21
|
+
case instance['status']
|
22
|
+
when 'Starting Provisioning'
|
23
|
+
self.data[:instances][name]['status'] = 'In Progress'
|
24
|
+
# This simulates the few seconds the Oracle Cloud takes to add this instance to the GET request after creating
|
25
|
+
raise(
|
26
|
+
Excon::Errors.status_error(
|
27
|
+
{ :expects => 200 },
|
28
|
+
Excon::Response.new({
|
29
|
+
:status => 404,
|
30
|
+
:body => 'No such service exists, check domain and service name'
|
31
|
+
})
|
32
|
+
)
|
33
|
+
)
|
34
|
+
when 'Terminating'
|
35
|
+
if Time.now - self.data[:deleted_at][name] >= Fog::Mock.delay
|
36
|
+
self.data[:deleted_at].delete(name)
|
37
|
+
self.data[:instances].delete(name)
|
38
|
+
end
|
39
|
+
when 'In Progress'
|
40
|
+
if Time.now - self.data[:created_at][name] >= Fog::Mock.delay
|
41
|
+
self.data[:instances][name]['status'] = 'Running'
|
42
|
+
instance = self.data[:instances][name]
|
43
|
+
self.data[:created_at].delete(name)
|
44
|
+
end
|
45
|
+
when 'Maintenance'
|
46
|
+
info = self.data[:maintenance_at][name]
|
47
|
+
if Time.now - info['time'] >= Fog::Mock.delay
|
48
|
+
self.data[:instances][name]['status'] = 'Running'
|
49
|
+
self.data[:instances][name][info['attribute']] = info['value']
|
50
|
+
self.data[:maintenance_at].delete(name)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
response.status = 200
|
54
|
+
response.body = instance
|
55
|
+
response
|
56
|
+
else
|
57
|
+
raise Fog::OracleCloud::Database::NotFound.new("Database #{name} does not exist");
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
63
|
end
|