fog-oraclecloud 0.1.9 → 0.1.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +124 -5
- data/fog-oracle.gemspec +1 -0
- data/lib/fog/oraclecloud/database.rb +1 -0
- data/lib/fog/oraclecloud/models/database/instance.rb +39 -3
- data/lib/fog/oraclecloud/models/database/instances.rb +3 -0
- data/lib/fog/oraclecloud/models/soa/instance.rb +40 -6
- data/lib/fog/oraclecloud/models/soa/instances.rb +33 -0
- data/lib/fog/oraclecloud/requests/database/create_instance.rb +7 -6
- data/lib/fog/oraclecloud/requests/database/get_instance.rb +12 -0
- data/lib/fog/oraclecloud/requests/database/get_instance_from_job.rb +32 -0
- data/lib/fog/oraclecloud/requests/soa/create_instance.rb +9 -9
- data/lib/fog/oraclecloud/requests/soa/get_job_status.rb +23 -0
- data/lib/fog/oraclecloud/requests/storage/delete_container.rb +1 -1
- data/lib/fog/oraclecloud/soa.rb +13 -4
- data/lib/fog/oraclecloud/version.rb +1 -1
- data/tests/requests/database_tests.rb +14 -1
- data/tests/requests/soa_tests.rb +90 -3
- metadata +18 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 42f3ec759406aebf8f527b45f0938a629ae4834b
|
4
|
+
data.tar.gz: 7a6926e91e7aaf4e14741f442c04f570a727b1e5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bfed58be742d9556b18c073599a64d0ff2a8271630aca564c23bfbb2a4450a44a11f10ff6d3e6fe045ecdbc1eab1e83375674dd7e10955631d19dd45596792ed
|
7
|
+
data.tar.gz: cf09714cc354e8193c1e01db4f4b5ff4d54fd15ca1602aeee96a2b4d722566f9e08d2a8f5cc85d83f249af1c8cc5ef78abbf9ba804dd43c6b359a2bc75748865
|
data/README.md
CHANGED
@@ -20,15 +20,134 @@ Or install it yourself as:
|
|
20
20
|
|
21
21
|
## Usage
|
22
22
|
|
23
|
-
|
23
|
+
Before you can use fog-aws, you must require it in your application:
|
24
24
|
|
25
|
-
|
25
|
+
```ruby
|
26
|
+
require 'fog/oraclecloud'
|
27
|
+
```
|
28
|
+
|
29
|
+
Since it's a bad practice to have your credentials in source code, you should load them from default fog configuration file: ```~/.fog```. This file could look like this:
|
30
|
+
|
31
|
+
```
|
32
|
+
default:
|
33
|
+
oracle_username: <USERNAME>
|
34
|
+
oracle_password: <PASSWORD>
|
35
|
+
oracle_domain: <IDENTITY DOMAIN>
|
36
|
+
oracle_region: <emea or remove if using US data centre>
|
37
|
+
oracle_compute_api: <COMPUTE API>
|
38
|
+
oracle_storage_api: <STORAGE_API>
|
39
|
+
```
|
26
40
|
|
27
|
-
|
41
|
+
### Example: Java Cloud Service
|
42
|
+
Get all Java Instances
|
43
|
+
```ruby
|
44
|
+
instances = Fog::OracleCloud[:java].instances
|
45
|
+
```
|
46
|
+
Create a Java Instance
|
47
|
+
```ruby
|
48
|
+
instance = Fog::OracleCloud[:java].instances.create(
|
49
|
+
:service_name => 'TestWLS',
|
50
|
+
:description => 'A new weblogic instance',
|
51
|
+
:dba_name => 'SYS',
|
52
|
+
:dba_password => 'password',
|
53
|
+
:db_service_name => 'TestDB',
|
54
|
+
:admin_password => 'Welcome1$',
|
55
|
+
:admin_username => 'weblogic',
|
56
|
+
:shape => 'oc3',
|
57
|
+
:version => '12.2.1',
|
58
|
+
:ssh_key => 'ssh-rsa AAAAB3NzaC1yc2...',
|
59
|
+
)
|
60
|
+
```
|
61
|
+
Delete an instance
|
62
|
+
```ruby
|
63
|
+
instance = Fog::OracleCloud[:java].instances.get('TestWLS')
|
64
|
+
# Have to add the database details in so that the tables in the database can be removed
|
65
|
+
instance.dba_name = 'Admin'
|
66
|
+
instance.dba_password = 'password'
|
67
|
+
instance.destroy()
|
68
|
+
```
|
28
69
|
|
29
|
-
|
70
|
+
## Supported Services
|
71
|
+
The following services are supported:
|
72
|
+
* Java Cloud Service
|
73
|
+
* create_instance
|
74
|
+
* delete_instance
|
75
|
+
* get_instance
|
76
|
+
* get_server
|
77
|
+
* list_instances
|
78
|
+
* list_servers
|
79
|
+
* SOA Cloud Service
|
80
|
+
* create_instance
|
81
|
+
* delete_instance
|
82
|
+
* get_instance
|
83
|
+
* list_instances
|
84
|
+
* Database Cloud Service
|
85
|
+
* backup_instance
|
86
|
+
* create_instance
|
87
|
+
* create_snapshot
|
88
|
+
* delete_instance
|
89
|
+
* delete_snapshot
|
90
|
+
* get_instance
|
91
|
+
* get_snapshot
|
92
|
+
* list_backups
|
93
|
+
* list_instances
|
94
|
+
* list_patches
|
95
|
+
* list_recoveries
|
96
|
+
* list_servers
|
97
|
+
* list_snapshots
|
98
|
+
* recover_instance
|
99
|
+
* scale_instance
|
100
|
+
* Compute Cloud Servcice
|
101
|
+
* create_image
|
102
|
+
* create_image_list
|
103
|
+
* create_instance
|
104
|
+
* create_orchestration
|
105
|
+
* create_security_application
|
106
|
+
* create_security_rule
|
107
|
+
* create_ssh_key
|
108
|
+
* create_volume
|
109
|
+
* delete_image_list
|
110
|
+
* delete_instance
|
111
|
+
* delete_orchestration
|
112
|
+
* delete_security_application
|
113
|
+
* delete_ssh_key
|
114
|
+
* get_image
|
115
|
+
* get_image_list
|
116
|
+
* get_instance
|
117
|
+
* get_orchestration
|
118
|
+
* get_security_application
|
119
|
+
* get_security_rule
|
120
|
+
* get_ssh_key
|
121
|
+
* list_image_lists
|
122
|
+
* list_images
|
123
|
+
* list_instances
|
124
|
+
* list_orchestrations
|
125
|
+
* list_security_applications
|
126
|
+
* list_security_lists
|
127
|
+
* list_security_rules
|
128
|
+
* list_ssh_keys
|
129
|
+
* list_volumes
|
130
|
+
* start_orchestration
|
131
|
+
* stop_orchestration
|
132
|
+
* update_image
|
133
|
+
* update_image_list
|
134
|
+
* update_orchestration
|
135
|
+
* update_ssh_key
|
136
|
+
* Storage Cloud Service
|
137
|
+
* create_container
|
138
|
+
* delete_container
|
139
|
+
* get_container
|
140
|
+
* list_containers
|
141
|
+
|
142
|
+
These basically align with the REST API documentation on docs.oracle.com. Check there for particulars around parameters, types etc.
|
143
|
+
|
144
|
+
**Note**: The APIs above are slightly modified from the Oracle cloud to provide consistency across requests. Keep in mind the following:
|
145
|
+
* All parameters are given in lower camel case (ie: service_name, not ServiceName)
|
146
|
+
* For IaaS services you don't need to provide the fully qualified names (ie: Compute/<identity_domain>/<name>). The system will prepend the configured user when necessary
|
147
|
+
* The Java and Database configuration has all the parameters as top level attributes (ie: don't configure parameters/content_port, use content_port)
|
148
|
+
* Smart defaults are included where possible. Check the code to see.
|
30
149
|
|
31
150
|
## Contributing
|
32
151
|
|
33
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
152
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/fog/fog-oraclecloud.
|
34
153
|
|
data/fog-oracle.gemspec
CHANGED
@@ -52,6 +52,14 @@ module Fog
|
|
52
52
|
attribute :golden_gate, :aliases=>'goldenGate'
|
53
53
|
attribute :usable_storage, :aliases=>'usableStorage'
|
54
54
|
|
55
|
+
def service_name=(value)
|
56
|
+
if value.include? '_'
|
57
|
+
raise ArgumentError, "Invalid service name. Names must be less than 50 characters; must start with a letter and can only contain letters, numbers and hyphens (-); can not end with a hyphen"
|
58
|
+
else
|
59
|
+
attributes[:service_name] = value
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
55
63
|
def edition=(value)
|
56
64
|
if %w(SE EE EE_HP EE_EP).include? value then
|
57
65
|
attributes[:edition]=value
|
@@ -144,6 +152,14 @@ module Fog
|
|
144
152
|
end
|
145
153
|
end
|
146
154
|
|
155
|
+
def admin_password=(value)
|
156
|
+
if !value.nil? and (!(value[0] =~ /[[:alpha:]]/) or value.size < 8 or value.size > 30 or !(value =~ /[_#$]/) or !(value =~ /[0-9]/))
|
157
|
+
raise ArgumentError, "Invalid admin password. Password must be between 8 and 30 characters in length; must start with a letter and can only contain letters, numbers and $, \#, _"
|
158
|
+
else
|
159
|
+
attributes[:admin_password] = value
|
160
|
+
end
|
161
|
+
end
|
162
|
+
|
147
163
|
|
148
164
|
def clean_name
|
149
165
|
name.sub %r{\/.*\/}, ''
|
@@ -274,9 +290,9 @@ module Fog
|
|
274
290
|
:charset => charset,
|
275
291
|
:backup_destination => backup_destination,
|
276
292
|
:cloud_storage_container => stor_name,
|
277
|
-
:cloud_storage_pwd =>
|
278
|
-
:cloud_storage_user =>
|
279
|
-
:
|
293
|
+
:cloud_storage_pwd => stor_pwd,
|
294
|
+
:cloud_storage_user => stor_user,
|
295
|
+
:create_storage_container_if_missing => cloud_storage_if_missing,
|
280
296
|
:disaster_recovery => disaster_recovery,
|
281
297
|
:failover_database => failover_database,
|
282
298
|
:golden_gate => golden_gate,
|
@@ -288,6 +304,26 @@ module Fog
|
|
288
304
|
:usable_storage => usable_storage || 25
|
289
305
|
}
|
290
306
|
data = service.create_instance(params, options)
|
307
|
+
# Get the Job Id out of the header
|
308
|
+
self.creation_job_id = /status\/create\/job\/([0-9]*)/.match(data.headers['Location'])[1]
|
309
|
+
end
|
310
|
+
|
311
|
+
def reload
|
312
|
+
requires :identity
|
313
|
+
data = begin
|
314
|
+
collection.get(identity)
|
315
|
+
rescue Excon::Errors::SocketError
|
316
|
+
nil
|
317
|
+
rescue Excon::Errors::NotFound
|
318
|
+
# Try using the creation job id (maybe it was just created)
|
319
|
+
collection.get_from_job(creation_job_id)
|
320
|
+
end
|
321
|
+
|
322
|
+
return unless data
|
323
|
+
|
324
|
+
new_attributes = data.attributes
|
325
|
+
merge_attributes(new_attributes)
|
326
|
+
self
|
291
327
|
end
|
292
328
|
end
|
293
329
|
end
|
@@ -41,6 +41,14 @@ module Fog
|
|
41
41
|
attribute :force_delete
|
42
42
|
attribute :skip_backup
|
43
43
|
|
44
|
+
def service_name=(value)
|
45
|
+
if value.include? '_' or !(value[0] =~ /[[:alpha:]]/) or value.size > 50 or !(value[/[a-zA-Z0-9-]+/] == value)
|
46
|
+
raise ArgumentError, "Invalid service name. Names must be less than 50 characters; must start with a letter and can only contain letters, numbers and hyphens (-); can not end with a hyphen"
|
47
|
+
else
|
48
|
+
attributes[:service_name] = value
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
44
52
|
def topology=(value)
|
45
53
|
if %w(osb soa soaosb b2b mft apim insight).include? value then
|
46
54
|
attributes[:topology]=value
|
@@ -66,6 +74,14 @@ module Fog
|
|
66
74
|
end
|
67
75
|
end
|
68
76
|
|
77
|
+
def admin_password=(value)
|
78
|
+
if !(value[0] =~ /[[:alpha:]]/) or value.size < 8 or value.size > 30 or !(value =~ /[_#$]/) or !(value =~ /[0-9]/)
|
79
|
+
raise ArgumentError, "Invalid admin password. Password must be between 8 and 30 characters in length; must start with a letter and can only contain letters, numbers and $, \#, _"
|
80
|
+
else
|
81
|
+
attributes[:admin_password] = value
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
69
85
|
def save
|
70
86
|
#identity ? update : create
|
71
87
|
create
|
@@ -83,28 +99,46 @@ module Fog
|
|
83
99
|
status == 'Stopped'
|
84
100
|
end
|
85
101
|
|
86
|
-
def destroy
|
87
|
-
requires :service_name
|
102
|
+
def destroy(dba_name, dba_password)
|
103
|
+
requires :service_name
|
88
104
|
service.delete_instance(service_name, dba_name, dba_password,
|
89
105
|
:force_delete => force_delete,
|
90
106
|
:skip_backup => skip_backup).body
|
91
107
|
end
|
92
108
|
|
109
|
+
def job_status
|
110
|
+
requires :creation_job_id
|
111
|
+
service.get_job_status('create', creation_job_id)
|
112
|
+
end
|
113
|
+
|
93
114
|
private
|
94
115
|
|
95
116
|
def create
|
96
|
-
requires :service_name, :dba_name, :dba_password, :db_service_name, :shape, :version, :ssh_key, :admin_password, :admin_username, :
|
117
|
+
requires :service_name, :dba_name, :dba_password, :db_service_name, :shape, :version, :ssh_key, :admin_password, :admin_username, :topology
|
97
118
|
|
98
119
|
stor_user = cloud_storage_user || service.username
|
99
120
|
stor_pwd = cloud_storage_pwd || service.password
|
100
121
|
|
122
|
+
if cloud_storage_container.nil? then
|
123
|
+
cloud_storage_container = "#{service_name}_Backup"
|
124
|
+
begin
|
125
|
+
container = Fog::Storage[:oraclecloud].containers.get(cloud_storage_container)
|
126
|
+
rescue Excon::Error::NotFound => error
|
127
|
+
# Doesn't exist, create it first
|
128
|
+
# The Oracle Cloud currently doesn't create a storage container for us, if it doesn't exist. Do it manually now
|
129
|
+
container = Fog::Storage[:oraclecloud].containers.create(
|
130
|
+
:name => cloud_storage_container,
|
131
|
+
)
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
101
135
|
params = {
|
102
136
|
:serviceName => service_name,
|
103
137
|
:cloudStorageContainer => cloud_storage_container,
|
104
|
-
:cloudStoragePassword =>
|
105
|
-
:cloudStorageUser =>
|
138
|
+
:cloudStoragePassword => stor_pwd,
|
139
|
+
:cloudStorageUser => stor_user,
|
106
140
|
:description => description,
|
107
|
-
:provisionOTD => provision_otd.nil? ?
|
141
|
+
:provisionOTD => provision_otd.nil? ? false : provision_otd,
|
108
142
|
:subscriptionType => 'MONTHLY',
|
109
143
|
:level => 'PAAS',
|
110
144
|
:topology => topology
|
@@ -15,6 +15,39 @@ module Fog
|
|
15
15
|
def get(id)
|
16
16
|
new(service.get_instance(id).body)
|
17
17
|
end
|
18
|
+
|
19
|
+
def create(attributes = {}, db_attributes = {})
|
20
|
+
if attributes[:db_service_name].nil?
|
21
|
+
# Attempt to create a database instance for them
|
22
|
+
db_name = db_attributes[:service_name] || "#{attributes[:service_name]}-DB"
|
23
|
+
db_attributes.merge!({
|
24
|
+
:service_name => "#{attributes[:service_name]}-DB",
|
25
|
+
:edition => 'EE',
|
26
|
+
:ssh_key => attributes[:ssh_key],
|
27
|
+
:shape => 'oc3',
|
28
|
+
:version => '12.1.0.2',
|
29
|
+
:admin_password => attributes[:admin_password],
|
30
|
+
:backup_destination => 'BOTH'
|
31
|
+
}) { |key, v1, v2| v1 }
|
32
|
+
# Check it doesn't exist already
|
33
|
+
begin
|
34
|
+
db = Fog::OracleCloud[:database].instances.get(db_name)
|
35
|
+
rescue Fog::OracleCloud::Database::NotFound => error
|
36
|
+
# Doesn't exist, create it first
|
37
|
+
db = Fog::OracleCloud[:database].instances.create(db_attributes)
|
38
|
+
db.wait_for { ready? }
|
39
|
+
end
|
40
|
+
attributes.merge!({
|
41
|
+
:dba_name => 'SYS',
|
42
|
+
:dba_password => db_attributes[:admin_password],
|
43
|
+
:db_service_name => db_name
|
44
|
+
})
|
45
|
+
end
|
46
|
+
# Now provision SOA
|
47
|
+
object = new(attributes)
|
48
|
+
object.save
|
49
|
+
object
|
50
|
+
end
|
18
51
|
end
|
19
52
|
end
|
20
53
|
end
|
@@ -4,15 +4,15 @@ module Fog
|
|
4
4
|
class Real
|
5
5
|
|
6
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].include?(key)}
|
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
8
|
params = {
|
9
9
|
'type' => 'db'
|
10
10
|
}
|
11
11
|
parameters.each { |key, value|
|
12
12
|
if !value.nil? then
|
13
13
|
if key == :cloud_storage_container then
|
14
|
-
if !value.start_with?("
|
15
|
-
value = "
|
14
|
+
if !value.start_with?("Storage-") then
|
15
|
+
value = "Storage-#{@identity_domain}/#{value}"
|
16
16
|
end
|
17
17
|
end
|
18
18
|
new_key = key.to_s.split('_').collect(&:capitalize).join
|
@@ -49,17 +49,18 @@ module Fog
|
|
49
49
|
class Mock
|
50
50
|
def create_instance(config, options)
|
51
51
|
response = Excon::Response.new
|
52
|
-
|
52
|
+
job_id = rand(10000).to_s
|
53
53
|
data = {
|
54
54
|
'serviceName' => config[:service_name],
|
55
55
|
'shape' => config[:shape],
|
56
56
|
'edition' => config[:edition],
|
57
57
|
'version' => config[:version],
|
58
|
-
'status' => '
|
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
59
|
'charset' => 'AL32UTF8',
|
60
60
|
'ncharset' => 'AL16UTF16',
|
61
61
|
'pdbName' => 'pdb1', # Note this is only valid for 12c instances. Too hard to fix for mocking
|
62
62
|
'timezone' => 'UTC',
|
63
|
+
'creation_job_id' => job_id,
|
63
64
|
'totalSharedStorage' => options[:usable_storage],
|
64
65
|
'domainName' => @identity_domain,
|
65
66
|
'creation_date'=>Time.now.strftime('%Y-%b-%dT%H:%M:%S'),
|
@@ -90,7 +91,7 @@ module Fog
|
|
90
91
|
"hostname"=>"db12c-xp-rac1"
|
91
92
|
}
|
92
93
|
self.data[:servers][config[:service_name]] = [node]
|
93
|
-
|
94
|
+
response.headers['Location'] = "https://dbaas.oraclecloud.com:443/paas/service/dbcs/api/v1.1/instances/#{@identity_domain}/status/create/job/#{job_id}"
|
94
95
|
response.status = 202
|
95
96
|
response
|
96
97
|
end
|
@@ -19,6 +19,18 @@ module Fog
|
|
19
19
|
|
20
20
|
if instance = self.data[:instances][name]
|
21
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
|
+
)
|
22
34
|
when 'Terminating'
|
23
35
|
if Time.now - self.data[:deleted_at][name] >= Fog::Mock.delay
|
24
36
|
self.data[:deleted_at].delete(name)
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module Fog
|
2
|
+
module OracleCloud
|
3
|
+
class Database
|
4
|
+
class Real
|
5
|
+
|
6
|
+
def get_instance_from_job(job_id)
|
7
|
+
response = request(
|
8
|
+
:expects => 200,
|
9
|
+
:method => 'GET',
|
10
|
+
:path => "/paas/service/dbcs/api/v1.1/instances/#{@identity_domain}/status/create/#{job_id}"
|
11
|
+
)
|
12
|
+
response
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
class Mock
|
17
|
+
def get_instance_from_job(job_id)
|
18
|
+
response = Excon::Response.new
|
19
|
+
|
20
|
+
instance = self.data[:instances].select { |k, v| v['creation_job_id'] == job_id }
|
21
|
+
if instance
|
22
|
+
response.status = 200
|
23
|
+
response.body = instance
|
24
|
+
response
|
25
|
+
else
|
26
|
+
raise Fog::OracleCloud::Database::NotFound.new("Database #{job_id} does not exist");
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -7,23 +7,23 @@ module Fog
|
|
7
7
|
config[:cloudStorageContainer] = "/Storage-#{@identity_domain}/#{config[:cloudStorageContainer]}"
|
8
8
|
end
|
9
9
|
|
10
|
-
|
11
|
-
|
10
|
+
parameters = options.select{|key, value| [:adminPassword, :adminPort, :adminUserName, :backupVolumeSize, :clusterName, :contentPort, :dbaName, :dbaPassword, :dbServiceName, :deploymentChannelPort, :domainMode, :domainName, :domainPartitionCount, :domainVolumeSize, :edition, :ipReservations, :managedServerCount, :msInitialHeapMB, :msJvmArgs, :msMaxHeapMB, :msMaxPermMB, :msPermMb, :nodeManagerPassword, :nodeManagerPort, :nodeManagerUserName, :overwriteMsJvmArgs, :pdbName, :securedAdminPort, :securedContentPort, :shape, :VMsPublicKey, :version].include?(key)}
|
11
|
+
parameters.reject! { |key,value| value.nil?}
|
12
12
|
config.reject! { |key,value| value.nil?}
|
13
13
|
# Currently only support weblogic
|
14
|
-
|
15
|
-
|
14
|
+
parameters[:type] = "weblogic"
|
15
|
+
config[:parameters] = [parameters]
|
16
16
|
body_data = config
|
17
17
|
|
18
|
-
request(
|
18
|
+
request({
|
19
19
|
:method => 'POST',
|
20
20
|
:expects => 202,
|
21
21
|
:path => "/paas/service/soa/api/v1.1/instances/#{@identity_domain}",
|
22
22
|
:body => Fog::JSON.encode(body_data),
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
)
|
23
|
+
:headers => {
|
24
|
+
'Content-Type'=>'application/json'
|
25
|
+
}
|
26
|
+
}, false)
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
@@ -0,0 +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
|
23
|
+
end
|
data/lib/fog/oraclecloud/soa.rb
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
module Fog
|
2
2
|
module OracleCloud
|
3
3
|
class SOA < Fog::Service
|
4
|
-
requires :oracle_username, :oracle_password, :oracle_domain
|
4
|
+
requires :oracle_username, :oracle_password, :oracle_domain
|
5
|
+
recognizes :oracle_region
|
5
6
|
|
6
7
|
model_path 'fog/oraclecloud/models/soa'
|
7
8
|
model :instance
|
@@ -12,6 +13,7 @@ module Fog
|
|
12
13
|
request :create_instance
|
13
14
|
request :get_instance
|
14
15
|
request :delete_instance
|
16
|
+
request :get_job_status
|
15
17
|
|
16
18
|
class Real
|
17
19
|
|
@@ -25,6 +27,14 @@ module Fog
|
|
25
27
|
@connection = Fog::XML::Connection.new(region_url)
|
26
28
|
end
|
27
29
|
|
30
|
+
def username
|
31
|
+
@username
|
32
|
+
end
|
33
|
+
|
34
|
+
def password
|
35
|
+
@password
|
36
|
+
end
|
37
|
+
|
28
38
|
def auth_header
|
29
39
|
auth_header ||= 'Basic ' + Base64.encode64("#{@username}:#{@password}").gsub("\n",'')
|
30
40
|
end
|
@@ -66,7 +76,7 @@ module Fog
|
|
66
76
|
@region_url = options[:oracle_region] == 'emea' ? 'https://jcs.emea.oraclecloud.com' : 'https://jaas.oraclecloud.com'
|
67
77
|
end
|
68
78
|
|
69
|
-
|
79
|
+
def username
|
70
80
|
@username
|
71
81
|
end
|
72
82
|
|
@@ -74,8 +84,7 @@ module Fog
|
|
74
84
|
@password
|
75
85
|
end
|
76
86
|
|
77
|
-
|
78
|
-
def self.data
|
87
|
+
def self.data
|
79
88
|
@data ||= {
|
80
89
|
:instances => {},
|
81
90
|
:servers => {},
|
@@ -11,7 +11,7 @@ Shindo.tests('Fog::Database[oraclecloud] | database requests', 'database') do
|
|
11
11
|
:shape => 'oc3',
|
12
12
|
:version => '12.1.0.2',
|
13
13
|
:backup_destination => 'NONE',
|
14
|
-
:admin_password => '
|
14
|
+
:admin_password => 'Welcome1#',
|
15
15
|
:usable_storage => '15'
|
16
16
|
)
|
17
17
|
|
@@ -52,6 +52,19 @@ Shindo.tests('Fog::Database[oraclecloud] | database requests', 'database') do
|
|
52
52
|
|
53
53
|
end
|
54
54
|
|
55
|
+
tests("#database-attributes", "attributes") do
|
56
|
+
tests("should check shape").raises(ArgumentError) do
|
57
|
+
instance = Fog::OracleCloud[:database].instances.new({
|
58
|
+
:shape => 'fsdfsdf'
|
59
|
+
})
|
60
|
+
end
|
61
|
+
tests("should check service_name").raises(ArgumentError) do
|
62
|
+
instance = Fog::OracleCloud[:database].instances.new({
|
63
|
+
:service_name => 'Has_Underscore'
|
64
|
+
})
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
55
68
|
tests('#database-read') do
|
56
69
|
instances = Fog::OracleCloud[:database].instances
|
57
70
|
test "returns an Array" do
|
data/tests/requests/soa_tests.rb
CHANGED
@@ -31,6 +31,87 @@ Shindo.tests('Fog::Soa[oraclecloud] | SOA requests', 'soa') do
|
|
31
31
|
end
|
32
32
|
end
|
33
33
|
|
34
|
+
tests("#soa-and-db-create", "create") do
|
35
|
+
instance = Fog::OracleCloud[:soa].instances.create({
|
36
|
+
:service_name => 'TestSOA2',
|
37
|
+
:description => 'A new weblogic instance',
|
38
|
+
:admin_password => 'Welcome1$',
|
39
|
+
:admin_username => 'weblogic',
|
40
|
+
:shape => 'oc3m',
|
41
|
+
:version => '12.2.1',
|
42
|
+
:ssh_key => 'ssh-rsa AAAAB3NzaC1yc2EAAAABJQAAAQEAkNNQ4ri2oUW46mBO/4CHMGCOALciumwGvFEMDLGNnlinstanceUSqU4IRrqgj+znLClfb29Oer0devdarM6DilsZVgZ2YbI5ZD5vICR/O9J0c28dArwbtFeIjcV2TCWyj5xKEXF1r+OrJMexHQa0fW1URGrU8QODpJNC/9eCVGcEXddL31xTZYpjoVOCVx66kNa6lSHEVV3T4zaCby9Oe5QI4gZe1+xyxHPNEW5wogwS3dlKSyL2CfBP0aUKOmJ5Nrl8+y0GqJQXdGjZ9FIknmwWueRW/6qPQvZocjOZ8YiPZgAP0RNy6lL+u8mnAazj/mrEdmB5QUzpDAllIr5Tn/xaddZQ==',
|
43
|
+
:topology => 'osb'
|
44
|
+
})
|
45
|
+
test "can create a soa instance" do
|
46
|
+
instance.is_a? Fog::OracleCloud::SOA::Instance
|
47
|
+
end
|
48
|
+
|
49
|
+
test "is being built" do
|
50
|
+
!instance.ready?
|
51
|
+
end
|
52
|
+
instance.wait_for { ready? }
|
53
|
+
|
54
|
+
test "is built" do
|
55
|
+
instance.ready?
|
56
|
+
end
|
57
|
+
|
58
|
+
test "shoud have created a database instance" do
|
59
|
+
db = Fog::OracleCloud[:database].instances.get('TestSOA2-DB')
|
60
|
+
db.is_a? Fog::OracleCloud::Database::Instance
|
61
|
+
end
|
62
|
+
|
63
|
+
test "should have created a storage container" do
|
64
|
+
container = Fog::Storage[:oraclecloud].containers.get('TestSOA2_Backup')
|
65
|
+
container.is_a? Fog::Storage::OracleCloud::Container
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
tests('#soa-validation') do
|
70
|
+
tests("should ensure service name doesn't have underscore").raises(ArgumentError) do
|
71
|
+
instance = Fog::OracleCloud[:soa].instances.new({
|
72
|
+
:service_name => 'Has_Underscore'
|
73
|
+
})
|
74
|
+
end
|
75
|
+
tests("should ensure service name doesn't have number as first letter").raises(ArgumentError) do
|
76
|
+
instance = Fog::OracleCloud[:soa].instances.new({
|
77
|
+
:service_name => '1NotFirstLetter'
|
78
|
+
})
|
79
|
+
end
|
80
|
+
tests("should ensure service name isn't too long").raises(ArgumentError) do
|
81
|
+
instance = Fog::OracleCloud[:soa].instances.new({
|
82
|
+
:service_name => 'ReallyReallyReallyReallyReallyReallyReallyReallyReallyReallyReallyReallyReallyReallyLongName'
|
83
|
+
})
|
84
|
+
end
|
85
|
+
tests("should ensure service name doesn't contain special characters").raises(ArgumentError) do
|
86
|
+
instance = Fog::OracleCloud[:soa].instances.new({
|
87
|
+
:service_name => 'Special$characters'
|
88
|
+
})
|
89
|
+
end
|
90
|
+
tests("should ensure admin password starts with a letter").raises(ArgumentError) do
|
91
|
+
instance = Fog::OracleCloud[:soa].instances.new({
|
92
|
+
:service_name => 'Test',
|
93
|
+
:admin_password => '1NotFirstLetter'
|
94
|
+
})
|
95
|
+
end
|
96
|
+
tests("should ensure admin password is not too long").raises(ArgumentError) do
|
97
|
+
instance = Fog::OracleCloud[:soa].instances.new({
|
98
|
+
:service_name => 'Test',
|
99
|
+
:admin_password => 'ReallyReallyReallyReallyReallyReallyReallyReallyPassword1$'
|
100
|
+
})
|
101
|
+
end
|
102
|
+
tests("should ensure admin password has special chars").raises(ArgumentError) do
|
103
|
+
instance = Fog::OracleCloud[:soa].instances.new({
|
104
|
+
:service_name => 'Test',
|
105
|
+
:admin_password => 'WelcomePassword1'
|
106
|
+
})
|
107
|
+
end
|
108
|
+
tests("should ensure admin password has numbers").raises(ArgumentError) do
|
109
|
+
instance = Fog::OracleCloud[:soa].instances.new({
|
110
|
+
:service_name => 'Test',
|
111
|
+
:admin_password => 'WelcomePassword$'
|
112
|
+
})
|
113
|
+
end
|
114
|
+
end
|
34
115
|
|
35
116
|
tests('#soa-read') do
|
36
117
|
instances = Fog::OracleCloud[:soa].instances
|
@@ -50,16 +131,22 @@ Shindo.tests('Fog::Soa[oraclecloud] | SOA requests', 'soa') do
|
|
50
131
|
test "should return an instance" do
|
51
132
|
instance.service_name.is_a? String
|
52
133
|
end
|
134
|
+
|
135
|
+
test "get job status" do
|
136
|
+
status = instance.job_status
|
137
|
+
status.is_a? Array
|
138
|
+
end
|
53
139
|
end
|
54
140
|
|
55
141
|
tests("#soa-delete", "create") do
|
56
142
|
instance = Fog::OracleCloud[:soa].instances.get('TestSOA')
|
57
|
-
instance.
|
58
|
-
instance.dba_password = 'password'
|
59
|
-
instance.destroy()
|
143
|
+
instance.destroy('SYS', 'password')
|
60
144
|
instance.wait_for { stopping? }
|
61
145
|
tests("should actually delete instance").raises(Fog::OracleCloud::SOA::NotFound) do
|
62
146
|
instance.wait_for { stopped? }
|
63
147
|
end
|
148
|
+
# Clean up
|
149
|
+
instance = Fog::OracleCloud[:soa].instances.get('TestSOA2')
|
150
|
+
instance.destroy('SYS', 'Welcome1$')
|
64
151
|
end
|
65
152
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fog-oraclecloud
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joel Nation
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-10-
|
11
|
+
date: 2016-10-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -108,6 +108,20 @@ dependencies:
|
|
108
108
|
- - "~>"
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: '0.8'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: mime-types
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :runtime
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
111
125
|
description: This library can be used as a module for `fog` or as standalone provider
|
112
126
|
to use the Oracle Cloud Service in applications.
|
113
127
|
email:
|
@@ -215,6 +229,7 @@ files:
|
|
215
229
|
- lib/fog/oraclecloud/requests/database/delete_instance.rb
|
216
230
|
- lib/fog/oraclecloud/requests/database/delete_snapshot.rb
|
217
231
|
- lib/fog/oraclecloud/requests/database/get_instance.rb
|
232
|
+
- lib/fog/oraclecloud/requests/database/get_instance_from_job.rb
|
218
233
|
- lib/fog/oraclecloud/requests/database/get_snapshot.rb
|
219
234
|
- lib/fog/oraclecloud/requests/database/list_backups.rb
|
220
235
|
- lib/fog/oraclecloud/requests/database/list_instances.rb
|
@@ -233,6 +248,7 @@ files:
|
|
233
248
|
- lib/fog/oraclecloud/requests/soa/create_instance.rb
|
234
249
|
- lib/fog/oraclecloud/requests/soa/delete_instance.rb
|
235
250
|
- lib/fog/oraclecloud/requests/soa/get_instance.rb
|
251
|
+
- lib/fog/oraclecloud/requests/soa/get_job_status.rb
|
236
252
|
- lib/fog/oraclecloud/requests/soa/list_instances.rb
|
237
253
|
- lib/fog/oraclecloud/requests/storage/create_container.rb
|
238
254
|
- lib/fog/oraclecloud/requests/storage/delete_container.rb
|