19
20
21
22
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
|
# File 'lib/fog/oraclecloud/models/soa/instances.rb', line 19
def create(attributes = {}, db_attributes = {})
if attributes[:db_service_name].nil?
db_name = db_attributes[:service_name] || "#{attributes[:service_name]}-DB"
db_attributes.merge!({
:service_name => "#{attributes[:service_name]}-DB",
:edition => 'EE',
:ssh_key => attributes[:ssh_key],
:shape => 'oc3',
:version => '12.1.0.2',
:admin_password => attributes[:admin_password],
:backup_destination => 'BOTH'
}) { |key, v1, v2| v1 }
begin
db = Fog::OracleCloud[:database].instances.get(db_name)
rescue Fog::OracleCloud::Database::NotFound => error
db = Fog::OracleCloud[:database].instances.create(db_attributes)
db.wait_for { ready? }
end
attributes.merge!({
:dba_name => 'SYS',
:dba_password => db_attributes[:admin_password],
:db_service_name => db_name
})
end
object = new(attributes)
object.save
object
end
|