fog-oraclecloud 0.1.3 → 0.1.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a4517e556687acd69faa9807cc250d1830eb0624
4
- data.tar.gz: 86091d93411468a2face694fffbf86f883919910
3
+ metadata.gz: 6e4b239a1b6936caca8c4f0a8f3c89ff7d697254
4
+ data.tar.gz: 6c3243744a58ce2da4b0b70e60b477faf8316a65
5
5
  SHA512:
6
- metadata.gz: e9741aad0ade9bb060e7011f675c51bb9d12a1c56067abc405600b4d1057bc4d32c87e85a0fad0bee43300cfe3700a78fbacc03dcb4089156b814b098e6d0e03
7
- data.tar.gz: 8f3c6713655cb0f9f4594a752c396350bb9807b99ddd2174b1252d2673b7fed020e087dfa2ba2672a327185e4248ec92d9a9635f3e7a77257eb5b86bd9493108
6
+ metadata.gz: d3e67446447c21e58e428792e5ca5779f1474d21e9c97d6ddcb9209f3ac6aab85d5d81d96913a84a94d7e14657ea29d16c546a264ed6b42c77390a8ff66803d6
7
+ data.tar.gz: 99802541bd95b63e88779b049872c4f87c6cdd01ac4aca5625f87b9c2c1042a1e64f4c064d9144cb0f65a72b4095fc5720c0fddee2c44396fa10cce7ad289a23
@@ -46,6 +46,14 @@ module Fog
46
46
  @connection = Fog::XML::Connection.new(region_url)
47
47
  end
48
48
 
49
+ def username
50
+ @username
51
+ end
52
+
53
+ def password
54
+ @password
55
+ end
56
+
49
57
  def auth_header
50
58
  auth_header ||= 'Basic ' + Base64.encode64("#{@username}:#{@password}").gsub("\n",'')
51
59
  end
@@ -27,6 +27,15 @@ module Fog
27
27
  @connection = Fog::XML::Connection.new(region_url)
28
28
  end
29
29
 
30
+ def username
31
+ @username
32
+ end
33
+
34
+ def password
35
+ @password
36
+ end
37
+
38
+
30
39
  def auth_header
31
40
  auth_header ||= 'Basic ' + Base64.encode64("#{@username}:#{@password}").gsub("\n",'')
32
41
  end
@@ -63,11 +72,25 @@ module Fog
63
72
  @username = options[:oracle_username]
64
73
  @password = options[:oracle_password]
65
74
  @identity_domain = options[:oracle_domain]
75
+ @region_url = options[:oracle_region] == 'emea' ? 'https://jcs.emea.oraclecloud.com' : 'https://jaas.oraclecloud.com'
76
+ end
77
+
78
+ def username
79
+ @username
80
+ end
81
+
82
+ def password
83
+ @password
84
+ end
85
+
86
+ def region_url
87
+ @region_url
66
88
  end
67
89
 
68
90
  def self.data
69
91
  @data ||= {
70
92
  :instances => {},
93
+ :servers => {},
71
94
  :deleted_at => {},
72
95
  :created_at => {}
73
96
  }
@@ -4,30 +4,29 @@ module Fog
4
4
  module OracleCloud
5
5
  class Database
6
6
  class Instance < Fog::Model
7
- identity :service_name
7
+ identity :service_name, :aliases=>'serviceName'
8
8
 
9
9
  attribute :version
10
10
  attribute :status
11
- attribute :description
12
- attribute :identity_domain
13
- attribute :creation_time
11
+ attribute :description, :aliases=>'serviceDescription'
12
+ attribute :domain_name, :aliases=>'domainName'
13
+ attribute :creation_date
14
14
  attribute :last_modified_time
15
- attribute :created_by
15
+ attribute :created_by, :aliases=>'creator'
16
16
  attribute :sm_plugin_version
17
17
  attribute :service_uri
18
18
  attribute :num_nodes
19
- attribute :level
19
+ attribute :level, :aliases=>'serviceLevel'
20
20
  attribute :edition
21
21
  attribute :shape
22
- attribute :subscriptionType
22
+ attribute :subscription_type, :aliases=>['subscriptionType', 'subscription']
23
23
  attribute :creation_job_id
24
24
  attribute :num_ip_reservations
25
25
  attribute :backup_destination
26
- attribute :cloud_storage_container
26
+ attribute :cloud_storage_container, :aliases=>'cloudStorageContainer'
27
27
  attribute :failover_database
28
- attribute :rac_database
29
28
  attribute :sid
30
- attribute :pdbName
29
+ attribute :pdb_name, :aliases=>'pdbName'
31
30
  attribute :listenerPort
32
31
  attribute :timezone
33
32
  attribute :em_url
@@ -37,10 +36,110 @@ module Fog
37
36
  attribute :glassfish_url
38
37
  attribute :dbaasmonitor_url
39
38
  attribute :compute_site_name
39
+ attribute :charset
40
+ attribute :ncharset
41
+ attribute :is_rac, :aliases=>['isRac', 'rac_database']
42
+ attribute :total_shared_storage, :aliases=>'totalSharedStorage'
43
+ attribute :service_type, :aliases=>'serviceType'
44
+
45
+ # The following are only used to create an instance and are not returned in the list or get actions
46
+ attribute :ssh_key, :aliases=>'vmPublicKeyText'
47
+ attribute :admin_password
48
+ attribute :cloud_storage_pwd, :aliases=>'cloudStoragePwd'
49
+ attribute :cloud_storage_user, :aliases=>'cloudStorageUser'
50
+ attribute :cloud_storage_container_if_missing, :aliases=>'cloudStorageContainerIfMissing'
51
+ attribute :disaster_recovery, :aliases=>'disasterRecovery'
52
+ attribute :golden_gate, :aliases=>'goldenGate'
53
+ attribute :usable_storage, :aliases=>'usableStorage'
54
+
55
+ def edition=(value)
56
+ if %w(SE EE EE_HP EE_EP).include? value then
57
+ attributes[:edition]=value
58
+ else
59
+ raise ArgumentError, "Invalid Edition. Valid values - SE, EE, EE_HP, EE_EP"
60
+ end
61
+ end
62
+
63
+ def level=(value)
64
+ if %w(PAAS BASIC).include? value then
65
+ attributes[:level]=value
66
+ else
67
+ raise ArgumentError, "Invalid level. Valid values - PAAS or BASIC"
68
+ end
69
+ end
70
+
71
+ def shape=(value)
72
+ if %w(oc3 oc4 oc5 oc6 oc1m oc2m oc3m oc4m).include? value then
73
+ attributes[:shape]=value
74
+ else
75
+ raise ArgumentError, "Invalid Shape. Valid values - oc3, oc4, oc5, oc6, oc1m, oc2m, oc3m or oc4m"
76
+ end
77
+ end
78
+
79
+ def subscription_type=(value)
80
+ if %w(HOURLY MONTHLY).include? value then
81
+ attributes[:subscription_type]=value
82
+ else
83
+ raise ArgumentError, "Invalid subscription type. Valid values - HOURLY or MONTHLY"
84
+ end
85
+ end
86
+
87
+ def backup_destination=(value)
88
+ if %w(BOTH OSS NONE).include? value then
89
+ attributes[:backup_destination]=value
90
+ else
91
+ raise ArgumentError, "Invalid backup destination. Valid values - BOTH, OSS or NONE"
92
+ end
93
+ end
94
+
95
+ def disaster_recovery=(value)
96
+ if %w(yes no).include? value then
97
+ attributes[:disaster_recovery]=value
98
+ else
99
+ raise ArgumentError, "Invalid disaster recovery value"
100
+ end
101
+ end
102
+
103
+ def failover_database=(value)
104
+ if value == true
105
+ value = 'yes'
106
+ elsif value == false || value.nil?
107
+ value = 'no'
108
+ else
109
+ raise ArgumentError, "Invalid failover database value (#{value})"
110
+ end
111
+ attributes[:failover_database] = value
112
+ end
113
+
114
+ def is_rac=(value)
115
+ if value == true
116
+ value = 'yes'
117
+ elsif value == false || value.nil?
118
+ value = 'no'
119
+ else
120
+ raise ArgumentError, "Invalid is_rac value (#{value})"
121
+ end
122
+ attributes[:is_rac]=value
123
+ end
124
+
125
+ def ncharset=(value)
126
+ if value.nil? then
127
+ attributes[:ncharset] = 'AL16UTF16'
128
+ elsif %w(AL16UTF16 UTF8).include? value then
129
+ attributes[:ncharset]=value
130
+ else
131
+ raise ArgumentError, "Invalid ncharset"
132
+ end
133
+ end
134
+
135
+ def usable_storage=(value)
136
+ if value.to_f >= 15 && value.to_f <= 1000 then
137
+ attributes[:usable_storage]=value
138
+ else
139
+ raise ArgumentError, "Usable storage value is invalid: #{value.to_f}"
140
+ end
141
+ end
40
142
 
41
- # The following are only used to create an instance and are not returned in the list action
42
- attribute :vmPublicKey
43
- attribute :parameters
44
143
 
45
144
  def clean_name
46
145
  name.sub %r{\/.*\/}, ''
@@ -139,13 +238,52 @@ module Fog
139
238
  private
140
239
 
141
240
  def create
142
- requires :service_name, :edition, :vmPublicKey, :shape, :version
143
- data = service.create_instance(service_name, edition, vmPublicKey, shape, version,
144
- :level => level,
145
- :subscriptionType => subscriptionType,
146
- :description => description,
147
- :edition => edition)
241
+ requires :service_name, :edition, :ssh_key, :shape, :version, :admin_password, :backup_destination
242
+
243
+ if backup_destination != 'NONE' then
244
+ if cloud_storage_container.nil? then
245
+ cloud_storage_if_missing = true
246
+ stor_name = "#{service_name}_Backup"
247
+ else
248
+ stor_name = cloud_storage_container
249
+ end
250
+ stor_user = cloud_storage_user || service.username
251
+ stor_pwd = cloud_storage_pwd || service.password
252
+ end
253
+
254
+ if !disaster_recovery.nil? && (failover_database.nil? || failover_database == 'no') then raise ArgumentError, 'Can\'t set disaster recovery option without failover_database set to \'yes\'' end
255
+ if failover_database == 'yes' && golden_gate == 'yes' then raise ArgumentError, 'Can\'t set failover_database and golden_gate both to \'yes\'' end
256
+ if is_rac == 'yes' && (failover_database == 'yes' || golden_gate == 'yes') then raise ArgumentError, 'Can\'t set is_rac and failover_database or golden_gate both to \'yes\'' end
148
257
 
258
+ params = {
259
+ :service_name => service_name,
260
+ :edition => edition,
261
+ :ssh_key => ssh_key,
262
+ :shape => shape,
263
+ :version => version,
264
+ :level => level || 'PAAS',
265
+ :subscription_type => subscription_type || 'HOURLY',
266
+ :description => description
267
+ }
268
+ options = {
269
+ :admin_password => admin_password,
270
+ :charset => charset,
271
+ :backup_destination => backup_destination,
272
+ :cloud_storage_container => stor_name,
273
+ :cloud_storage_pwd => stor_user,
274
+ :cloud_storage_user => stor_pwd,
275
+ :cloud_storage_if_missing => cloud_storage_if_missing,
276
+ :disaster_recovery => disaster_recovery,
277
+ :failover_database => failover_database,
278
+ :golden_gate => golden_gate,
279
+ :is_rac => is_rac,
280
+ :ncharset => ncharset,
281
+ :pdb_name => pdb_name,
282
+ :sid => sid || 'ORCL',
283
+ :timezone => timezone,
284
+ :usable_storage => usable_storage || 25
285
+ }
286
+ data = service.create_instance(params, options)
149
287
  end
150
288
  end
151
289
  end
@@ -0,0 +1,17 @@
1
+ require 'fog/compute/models/server'
2
+
3
+ module Fog
4
+ module OracleCloud
5
+ class Java
6
+ class Database < Fog::Model
7
+ identity :service_name
8
+
9
+ attribute :infra
10
+ attribute :connect_string
11
+ attribute :version
12
+ attribute :pdb
13
+
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,17 @@
1
+ require 'fog/core/collection'
2
+
3
+ module Fog
4
+ module OracleCloud
5
+ class Java
6
+ class Databases < Fog::Collection
7
+
8
+ model Fog::OracleCloud::Java::Database
9
+
10
+ def all(service_name)
11
+ # data = service.list_databases(service_name).body['servers']
12
+ # load(data)
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -4,13 +4,13 @@ module Fog
4
4
  module OracleCloud
5
5
  class Java
6
6
  class Instance < Fog::Model
7
- identity :service_name, :aliases=>'name'
7
+ identity :service_name, :aliases=>['name', 'serviceName']
8
8
 
9
9
 
10
10
  attribute :created_by
11
11
 
12
12
  attribute :auto_update
13
- attribute :cluster_name
13
+ attribute :cluster_name, :aliases=>'clusterName'
14
14
  attribute :compliance_status
15
15
  attribute :compliance_status_desc
16
16
  attribute :compute_site_name
@@ -19,10 +19,10 @@ module Fog
19
19
  attribute :creation_time
20
20
  attribute :db_associations
21
21
  attribute :db_info
22
- attribute :db_servicename
22
+ attribute :db_service_name
23
23
  attribute :deletion_job_id
24
24
  attribute :description
25
- attribute :domain_mode
25
+ attribute :domain_mode, :aliases=>'domainMode'
26
26
  attribute :edition
27
27
  attribute :error_status_desc
28
28
  attribute :fmw_control_url
@@ -30,7 +30,7 @@ module Fog
30
30
  attribute :level
31
31
  attribute :lifecycle_control_job_id
32
32
  attribute :num_ip_reservations
33
- attribute :num_nodes
33
+ attribute :num_nodes, :aliases=>'managedServerCount'
34
34
  attribute :options
35
35
  attribute :otd_admin_url
36
36
  attribute :otd_provisioned
@@ -44,26 +44,101 @@ module Fog
44
44
  attribute :service_uri
45
45
  attribute :shape
46
46
  attribute :status
47
- attribute :subscription_type
47
+ attribute :subscription_type, :aliases=>['subscriptionType']
48
48
  attribute :uri
49
49
  attribute :version
50
50
  attribute :wls_admin_url
51
51
  attribute :wls_deployment_channel_port
52
52
  attribute :wls_version, :aliases=>'wlsVersion'
53
+ attribute :domain_name, :aliases=>'domainName'
54
+ attribute :pdb_name, :aliases=>['pdbName', 'pdb_service_name']
53
55
 
54
56
 
55
57
  # The following are only used to create an instance and are not returned in the list action
56
58
  attribute :cloud_storage_container, :aliases=>'cloudStorageContainer'
57
59
  attribute :cloud_storage_user, :aliases=>'cloudStorageUser'
58
- attribute :cloud_storage_password, :aliases=>'cloudStoragePassword'
59
- attribute :admin_user_name, :aliases=>'adminUserName'
60
- attribute :vm_public_key, :aliases=>'vmPublicKey'
60
+ attribute :cloud_storage_pwd, :aliases=>'cloudStoragePassword'
61
+ attribute :admin_username, :aliases=>'adminUserName'
62
+ attribute :admin_password, :aliases=>'adminPassword'
63
+ attribute :ssh_key, :aliases=>'vmPublicKey'
64
+ attribute :cloud_storage_container_if_missing, :aliases=>'cloudStorageContainerIfMissing'
65
+ attribute :enable_admin_console, :aliases=>'enableAdminConsole'
66
+ attribute :provision_otd, :aliases=>'provisionOTD'
67
+ attribute :sample_app_deployment_requested, :aliases=>'sampleAppDeploymentRequested'
68
+ attribute :admin_port, :aliases=>'adminPort'
69
+ attribute :app_dbs, :aliases=>'appDBs'
70
+ attribute :backup_volume_size, :aliases=>'backupVolumeSize'
71
+ attribute :content_port, :aliases=>'contentPort'
72
+ attribute :dba_name, :aliases=>'dbaName'
73
+ attribute :dba_password, :aliases=>'dbaPassword'
74
+ attribute :domain_partition_count, :aliases=>'domainPartitionCount'
75
+ attribute :domain_volume_size, :aliases=>'domainVolumeSize'
76
+ attribute :ip_reservations, :aliases=>'ipReservations'
77
+ attribute :ms_initial_heap_mb, :aliases=>'msInitialHeapMB'
78
+ attribute :ms_jvm_args, :aliases=>'msJvmArgs'
79
+ attribute :ms_max_heap_mb, :aliases=>'msMaxHeapMB'
80
+ attribute :ms_max_perm_mb, :aliases=>'msMaxPermMB'
81
+ attribute :ms_perm_mb, :aliases=>'msPermMb'
82
+ attribute :node_manager_password, :aliases=>'nodeManagerPassword'
83
+ attribute :node_manager_port, :aliases=>'nodeManagerPort'
84
+ attribute :node_manager_user_name, :aliases=>'nodeManagerUserName'
85
+ attribute :overwrite_ms_jvm_args, :aliases=>'overwriteMsJvmArgs'
86
+ attribute :secured_admin_port, :aliases=>'securedAdminPort'
87
+ attribute :secured_content_port, :aliases=>'securedContentPort'
61
88
 
62
89
  # The following are used to delete an instance and are not returned in the list action
63
- attribute :dba_name
64
- attribute :dba_password
65
90
  attribute :force_delete
66
91
 
92
+ def level=(value)
93
+ if %w(PAAS BASIC).include? value then
94
+ attributes[:level]=value
95
+ else
96
+ raise ArgumentError, "Invalid level. Valid values - PAAS or BASIC"
97
+ end
98
+ end
99
+
100
+ def subscription_type=(value)
101
+ if %w(HOURLY MONTHLY).include? value then
102
+ attributes[:subscription_type]=value
103
+ else
104
+ raise ArgumentError, "Invalid subscription type. Valid values - HOURLY or MONTHLY"
105
+ end
106
+ end
107
+
108
+ def domain_mode=(value)
109
+ if %w(DEVELOPMENT PRODUCTION).include? value then
110
+ attributes[:domain_mode]=value
111
+ else
112
+ raise ArgumentError, "Invalid domain mode. Valid values - DEVELOPMENT or PRODUCTION"
113
+ end
114
+ end
115
+
116
+ def edition=(value)
117
+ if %w(SE EE SUITE).include? value then
118
+ attributes[:edition]=value
119
+ else
120
+ raise ArgumentError, "Invalid edition. Valid values - SE, EE or SUITE"
121
+ end
122
+ end
123
+
124
+ def num_nodes=(value)
125
+ if [1, 2, 4, 8].include? value then
126
+ attributes[:num_nodes]=value
127
+ else
128
+ raise ArgumentError, "Invalid server count (#{value}). Valid values - 1, 2, 4 or 8"
129
+ end
130
+ end
131
+
132
+ def shape=(value)
133
+ if %w(oc3 oc4 oc5 oc6 oc1m oc2m oc3m oc4m).include? value then
134
+ attributes[:shape]=value
135
+ else
136
+ raise ArgumentError, "Invalid Shape. Valid values - oc3, oc4, oc5, oc6, oc1m, oc2m, oc3m or oc4m"
137
+ end
138
+ end
139
+
140
+
141
+
67
142
  def initialize(attributes={})
68
143
  level ||= 'PAAS'
69
144
  subscription_type ||= 'HOURLY'
@@ -93,7 +168,7 @@ module Fog
93
168
  service.servers.all(service_name)
94
169
  end
95
170
 
96
- def destroy
171
+ def destroy
97
172
  requires :service_name, :dba_name, :dba_password
98
173
  service.delete_instance(service_name, dba_name, dba_password, :force_delete => force_delete).body
99
174
  end
@@ -101,12 +176,79 @@ module Fog
101
176
  private
102
177
 
103
178
  def create
104
- requires :service_name, :cloud_storage_container, :cloud_storage_user, :cloud_storage_password
179
+ requires :service_name, :dba_name, :dba_password, :db_service_name, :shape, :version, :ssh_key
105
180
 
106
- data = service.create_instance(service_name, cloud_storage_container, cloud_storage_user, cloud_storage_password, dba_name, dba_password, db_servicename, shape, version, vm_public_key,
107
- :level => level,
108
- :subscriptionType => subscription_type,
109
- :description => description)
181
+ #data = service.create_instance(service_name, cloud_storage_container, cloud_storage_user, cloud_storage_password, dba_name, dba_password, db_servicename, shape, version, vm_public_key,
182
+ # :level => level,
183
+ # :subscriptionType => subscription_type,
184
+ # :description => description)
185
+
186
+ if cloud_storage_container.nil? then
187
+ cloud_storage_if_missing = true
188
+ stor_name = "#{service_name}_Backup"
189
+ else
190
+ stor_name = cloud_storage_container
191
+ end
192
+ stor_user = cloud_storage_user || service.username
193
+ stor_pwd = cloud_storage_pwd || service.password
194
+
195
+ params = {
196
+ :serviceName => service_name,
197
+ :cloudStorageContainer => stor_name,
198
+ :cloudStoragePassword => stor_user,
199
+ :cloudStorageUser => stor_pwd,
200
+ :cloudStorageContainerIfMissing => cloud_storage_if_missing,
201
+ :description => description,
202
+ :enableAdminConsole => enable_admin_console.nil? ? true : enable_admin_console,
203
+ :provisionOTD => provision_otd.nil? ? true : provision_otd,
204
+ :sampleAppDeploymentRequested => sample_app_deployment_requested.nil? ? true : sample_app_deployment_requested,
205
+ :subscriptionType => subscription_type || 'HOURLY',
206
+ :level => level || 'PAAS',
207
+ }
208
+ options = {
209
+ :adminPassword => admin_password,
210
+ :adminPort => admin_port,
211
+ :adminUserName => admin_username,
212
+ :backupVolumeSize => backup_volume_size,
213
+ :clusterName => cluster_name,
214
+ :contentPort => content_port,
215
+ :dbaName => dba_name,
216
+ :dbaPassword => dba_password,
217
+ :dbServiceName => db_service_name,
218
+ :deploymentChannelPort => wls_deployment_channel_port,
219
+ :domainMode => domain_mode,
220
+ :domainName => domain_name,
221
+ :domainPartitionCount => domain_partition_count,
222
+ :domainVolumeSize => domain_volume_size,
223
+ :edition => edition || 'EE',
224
+ :ipReservations => ip_reservations,
225
+ :managedServerCount => num_nodes || 1,
226
+ :msInitialHeapMB => ms_initial_heap_mb,
227
+ :msJvmArgs => ms_jvm_args,
228
+ :msMaxHeapMB => ms_max_heap_mb,
229
+ :msMaxPermMB => ms_max_perm_mb,
230
+ :msPermMb => ms_perm_mb,
231
+ :nodeManagerPassword => node_manager_password,
232
+ :nodeManagerPort => node_manager_port,
233
+ :nodeManagerUserName => node_manager_user_name,
234
+ :overwriteMsJvmArgs => overwrite_ms_jvm_args,
235
+ :pdbName => pdb_name,
236
+ :securedAdminPort => secured_admin_port,
237
+ :securedContentPort => secured_content_port,
238
+ :shape => shape,
239
+ :VMsPublicKey => ssh_key,
240
+ :version => version
241
+ }
242
+
243
+ if app_dbs and app_dbs.is_a? Array and app_dbs.size >= 1
244
+ options[:appDBs] = []
245
+ app_dbs.each { |db| options[:appDBs].push({
246
+ :dbaName => db.username,
247
+ :dbaPassword => db.password,
248
+ :dbServiceName => db.service_name,
249
+ }) }
250
+ end
251
+ data = service.create_instance(params, options)
110
252
 
111
253
  end
112
254
 
@@ -6,19 +6,19 @@ module Fog
6
6
  class Server < Fog::Model
7
7
  identity :name
8
8
 
9
- attribute :clusterName
9
+ attribute :cluster_name, :aliases=>'clusterName'
10
10
  attribute :name
11
11
  attribute :shape
12
- attribute :nodeType
13
- attribute :isAdmin
12
+ attribute :node_type, :aliases=>'nodeType'
13
+ attribute :is_admin, :aliases=>'is_admin'
14
14
  attribute :hostname
15
15
  attribute :status
16
- attribute :reservedIp
17
- attribute :storageAllocated
18
- attribute :creationDate
16
+ attribute :reserved_ip, :aliases=>'reserved_ip'
17
+ attribute :storage_allocated, :aliases=>'storageAllocated'
18
+ attribute :creation_date, :aliases=>'creationDate'
19
19
 
20
20
  def ip_addr
21
- reservedIp.blank? ? hostname : reservedIp
21
+ reserved_ip.blank? ? hostname : reserved_ip
22
22
  end
23
23
  end
24
24
  end
@@ -22,9 +22,8 @@ module Fog
22
22
  def backup_instance(service_name)
23
23
  response = Excon::Response.new
24
24
 
25
- if !self.data[:backups][service_name].is_a? Array then
25
+ if !self.data[:backups][service_name].is_a? Array
26
26
  self.data[:backups][service_name] = []
27
- self.data[:created_at][service_name] = []
28
27
  end
29
28
  self.data[:backups][service_name].push({
30
29
  'backupCompleteDate'=>Time.now.strftime('%d-%b-%Y %H:%M:%S UTC'),
@@ -32,7 +31,11 @@ module Fog
32
31
  'status'=>'IN PROGRESS',
33
32
  'database_id'=>service_name
34
33
  })
35
- self.data[:created_at][service_name].push(Time.now)
34
+ if !self.data[:created_at][:backups]
35
+ self.data[:created_at][:backups] = {}
36
+ self.data[:created_at][:backups][service_name] = []
37
+ end
38
+ self.data[:created_at][:backups][service_name].push(Time.now)
36
39
  response.status = 202
37
40
  response
38
41
  end
@@ -3,30 +3,43 @@ module Fog
3
3
  class Database
4
4
  class Real
5
5
 
6
- def create_instance(service_name, edition, vmPublicKey, shape, version, options={})
7
- body_data = {
8
- 'serviceName' => service_name,
9
- 'version' => options[:version],
10
- 'level' => options[:level],
11
- 'edition' => edition,
12
- 'subscriptionType' => options[:subscriptionType],
13
- 'description' => options[:description],
14
- 'shape' => options[:shape],
15
- 'vmPublicKeyText' => vmPublicKey,
16
- 'parameters' => {
17
- 'shape' => shape,
18
- 'version' => version
19
- }
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)}
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]
20
33
  }
21
34
  body_data = body_data.reject {|key, value| value.nil?}
22
-
35
+
23
36
  request(
24
37
  :method => 'POST',
25
38
  :expects => 202,
26
39
  :path => "/paas/service/dbcs/api/v1.1/instances/#{@identity_domain}",
27
40
  :body => Fog::JSON.encode(body_data),
28
41
  #:headers => {
29
- # 'Content-Type'=>'application/vnd.com.oracle.oracloud.provisioning.Service+json'
42
+ # 'Content-Type'=>'application/vnd.com.oracle.oracloud.provisioning.Service+json'
30
43
  #}
31
44
  )
32
45
  end
@@ -34,19 +47,30 @@ module Fog
34
47
  end
35
48
 
36
49
  class Mock
37
- def create_instance(service_name, edition, vmPublicKey, shape, version, options={})
38
- response = Excon::Response.new
50
+ def create_instance(config, options)
51
+ response = Excon::Response.new
39
52
 
40
53
  data = {
41
- 'service_name' => service_name,
42
- 'shape' => shape,
43
- 'edition' => edition,
44
- 'version' => version,
45
- 'status' => 'In Progress'
46
- }.merge(options.select {|key, value| ["description"].include?(key) })
54
+ 'serviceName' => config[:service_name],
55
+ 'shape' => config[:shape],
56
+ 'edition' => config[:edition],
57
+ 'version' => config[:version],
58
+ 'status' => 'In Progress',
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
+ 'totalSharedStorage' => options[:usable_storage],
64
+ 'domainName' => @identity_domain,
65
+ 'creation_date'=>Time.now.strftime('%Y-%b-%dT%H:%M:%S'),
66
+ 'serviceType'=>'DBaaS',
67
+ 'creator'=>@username
68
+ }
69
+ .merge(config.select {|key, value| [:description, :level, :subscription_type].include?(key) })
70
+ .merge(options.select {|key, value| [:backup_destination, :failover_database, :cloud_storage_container, :is_rac, :ncharset, :pdb_name, :sid, :timezone].include?(key) })
47
71
 
48
- self.data[:instances][service_name] = data
49
- self.data[:created_at][service_name] = Time.now
72
+ self.data[:instances][config[:service_name]] = data
73
+ self.data[:created_at][config[:service_name]] = Time.now
50
74
 
51
75
  # Also create some compute nodes
52
76
  node = {
@@ -65,11 +89,11 @@ module Fog
65
89
  "reservedIP"=>"129.144.23.112",
66
90
  "hostname"=>"db12c-xp-rac1"
67
91
  }
68
- self.data[:servers][service_name] = [node]
92
+ self.data[:servers][config[:service_name]] = [node]
69
93
 
70
94
  response.status = 202
71
95
  response
72
- end
96
+ end
73
97
  end
74
98
  end
75
99
  end
@@ -16,11 +16,13 @@ module Fog
16
16
  def list_backups(db_name)
17
17
  response = Excon::Response.new
18
18
 
19
+ if !self.data[:backups][db_name] then self.data[:backups][db_name] = [] end
19
20
  backups = self.data[:backups][db_name]
21
+
20
22
  backups.each_with_index { |b, i|
21
23
  if b['status'] = 'IN PROGRESS' then
22
- if Time.now - self.data[:created_at][db_name][i] >= Fog::Mock.delay
23
- self.data[:created_at][db_name].delete(i)
24
+ if Time.now - self.data[:created_at][:backups][db_name][i] >= Fog::Mock.delay
25
+ self.data[:created_at][:backups][db_name].delete(i)
24
26
  self.data[:backups][db_name][i]['status'] = 'COMPLETED'
25
27
  b = self.data[:backups][db_name][i]
26
28
  end
@@ -16,7 +16,9 @@ module Fog
16
16
  def list_recoveries(db_name)
17
17
  response = Excon::Response.new
18
18
 
19
+ if !self.data[:recoveries][db_name] then self.data[:recoveries][db_name] = [] end
19
20
  recoveries = self.data[:recoveries][db_name]
21
+
20
22
  recoveries.each_with_index { |r, i|
21
23
  if r['status'] = 'IN PROGRESS' then
22
24
  if Time.now - self.data[:created_at][:recoveries][db_name][i] >= Fog::Mock.delay
@@ -18,7 +18,9 @@ module Fog
18
18
 
19
19
  servers = self.data[:servers][db_name]
20
20
 
21
- response.body = servers
21
+ response.body = {
22
+ "servers" : [servers]
23
+ }
22
24
  response
23
25
  end
24
26
  end
@@ -26,6 +26,9 @@ module Fog
26
26
 
27
27
  if !self.data[:recoveries][service_name].is_a? Array then
28
28
  self.data[:recoveries][service_name] = []
29
+ end
30
+
31
+ if !self.data[:created_at][:recoveries]
29
32
  self.data[:created_at][:recoveries] = {}
30
33
  self.data[:created_at][:recoveries][service_name] = []
31
34
  end
@@ -3,50 +3,80 @@ module Fog
3
3
  class Java
4
4
  class Real
5
5
 
6
- def create_instance(service_name, cloudStorageContainer, cloudStorageUser, cloudStoragePassword, dbaName, dbaPassword, dbServiceName, shape, version, vmPublicKey, 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?}
6
+ def create_instance(config, options)
7
+
8
+ if !config[:cloudStorageContainer].start_with?("/Storage-")
9
+ config[:cloudStorageContainer] = "/Storage-#{@identity_domain}/#{config[:cloudStorageContainer]}"
10
+ end
11
+
12
+ config[: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].include?(key)}
13
+ config[:parameters].reject! { |key,value| value.nil?}
14
+ config.reject! { |key,value| value.nil?}
15
+ # Currently only support weblogic
16
+ config[:parameters][:type] = "weblogic"
17
+
18
+ body_data = config
19
+
24
20
  request(
25
21
  :method => 'POST',
26
22
  :expects => 202,
27
- :path => "/paas/service/jcs/api/v1.1/instances/#{@identity_domain}",
23
+ :path => "/paas/service/dbcs/api/v1.1/instances/#{@identity_domain}",
28
24
  :body => Fog::JSON.encode(body_data),
29
- :headers => {
30
- 'Content-Type'=>'application/vnd.com.oracle.oracloud.provisioning.Service+json'
31
- }
25
+ #:headers => {
26
+ # 'Content-Type'=>'application/vnd.com.oracle.oracloud.provisioning.Service+json'
27
+ #}
32
28
  )
33
29
  end
34
-
35
30
  end
36
31
  class Mock
37
- def create_instance(service_name, cloudStorageContainer, cloudStorageUser, cloudStoragePassword, dbaName, dbaPassword, dbServiceName, shape, version, vmPublicKey, options={})
32
+ def create_instance(config, options)
38
33
  response = Excon::Response.new
39
34
 
35
+ ip = '192.168.1.1'
40
36
  data = {
41
- 'service_name' => service_name,
42
- 'db_service_name' => dbServiceName,
43
- 'shape' => shape,
44
- 'version' => version,
45
- 'status' => 'In Progress'
46
- }.merge(options.select {|key, value| ["description"].include?(key) })
47
-
48
- self.data[:instances][service_name] = data
49
- self.data[:created_at][service_name] = Time.now
37
+ 'status' => 'In Progress',
38
+ 'compute_site_name' => 'EM002_Z11',
39
+ 'content_url' => "http://#{ip}",
40
+ 'created_by' => @username,
41
+ 'creation_job_id' => Random.rand(100000),
42
+ 'creation_time'=> Time.now.strftime('%Y-%b-%dT%H:%M:%S'),
43
+ 'db_info' => "#{options[:dbServiceName]}:1521/#{options[:pdbName] || 'PDB1'}.#{@identity_domain}.oraclecloud.internal",
44
+ 'deletion_job_id' => 0,
45
+ 'domainMode'=>'DEVELOPMENT',
46
+ 'fmw_control_url'=> "https://#{ip}:#{options[:adminPort] || 7002}/em",
47
+ 'last_modified_time'=> Time.now.strftime('%Y-%b-%dT%H:%M:%S'),
48
+ 'num_ip_reservations'=> 2, # Can't rely on this number in mocking mode
49
+ 'num_nodes'=>options[:managedServerCount],
50
+ 'otd_provisioned'=>options[:provisionOTD] || 'no',
51
+ 'psm_plugin_version'=>"16.3.5-532",
52
+ 'secure_content_url' => "https://#{ip}",
53
+ 'service_type'=>'jaas',
54
+ 'service_uri'=>"#{@region_url}/paas/service/dbcs/api/v1.1/instances/#{@identity_domain}/#{config[:serviceName]}",
55
+ 'wls_admin_url'=> "https://#{ip}:#{options[:adminPort] || 7002}/console",
56
+ 'wls_deployment_channel_port' => options[:deploymentChannelPort] || 9001,
57
+ 'wlsVersion'=>'12.2.1.0.160419'
58
+ }
59
+ .merge(config.select {|key, value| [:serviceName, :description, :level, :subscriptionType].include?(key) })
60
+ .merge(options.select {|key, value| [:clusterName, :dbServiceName, :edition, :shape, :version].include?(key) }).collect{|k,v| [k.to_s, v]}.to_h
61
+
62
+ if data['clusterName'].nil? then data['clusterName'] = data['serviceName'][0,8] + "_cluster" end
63
+ if data['domainName'].nil? then data['domainName'] = data['serviceName'][0,8] + "_domain" end
64
+ self.data[:instances][config[:serviceName]] = data
65
+ self.data[:created_at][config[:serviceName]] = Time.now
66
+
67
+ server = {
68
+ "clusterName": data['clusterName'] || data['serviceName'][0,8] + "_cluster",
69
+ "name": "#{data['serviceName'][0,8]}_server_1",
70
+ "shape": data['shape'],
71
+ "nodeType": "WLS",
72
+ "isAdmin": true,
73
+ "hostname": ip,
74
+ "status": "Ready",
75
+ "storageAllocated": 74752,
76
+ "creationDate": Time.now.strftime('%Y-%b-%dT%H:%M:%S')
77
+ }
78
+ self.data[:servers][data['serviceName']] = [server]
79
+
50
80
  response.status = 202
51
81
  response
52
82
  end
@@ -12,7 +12,19 @@ module Fog
12
12
  end
13
13
  end
14
14
 
15
-
15
+ class Mock
16
+ def list_servers(db_name)
17
+ response = Excon::Response.new
18
+
19
+ servers = self.data[:servers][db_name]
20
+
21
+ response.body = {
22
+ 'servers' => servers
23
+ }
24
+
25
+ response
26
+ end
27
+ end
16
28
  end
17
29
  end
18
30
  end
@@ -1,5 +1,5 @@
1
1
  module Fog
2
2
  module OracleCloud
3
- VERSION = "0.1.3"
3
+ VERSION = "0.1.4"
4
4
  end
5
5
  end
@@ -7,10 +7,14 @@ Shindo.tests('Fog::Database[oraclecloud] | database requests', 'database') do
7
7
  :service_name => 'TestDB',
8
8
  :description => 'A new database',
9
9
  :edition => 'SE',
10
- :vmPublicKey => 'ssh-rsa AAAAB3NzaC1yc2EAAAABJQAAAQEAkNNQ4ri2oUW46mBO/4CHMGCOALciumwGvFEMDLGNnlDbUSqU4IRrqgj+znLClfb29Oer0devdarM6DilsZVgZ2YbI5ZD5vICR/O9J0c28dArwbtFeIjcV2TCWyj5xKEXF1r+OrJMexHQa0fW1URGrU8QODpJNC/9eCVGcEXddL31xTZYpjoVOCVx66kNa6lSHEVV3T4zaCby9Oe5QI4gZe1+xyxHPNEW5wogwS3dlKSyL2CfBP0aUKOmJ5Nrl8+y0GqJQXdGjZ9FIknmwWueRW/6qPQvZocjOZ8YiPZgAP0RNy6lL+u8mnAazj/mrEdmB5QUzpDAllIr5Tn/xaddZQ==',
10
+ :ssh_key => 'ssh-rsa AAAAB3NzaC1yc2EAAAABJQAAAQEAkNNQ4ri2oUW46mBO/4CHMGCOALciumwGvFEMDLGNnlDbUSqU4IRrqgj+znLClfb29Oer0devdarM6DilsZVgZ2YbI5ZD5vICR/O9J0c28dArwbtFeIjcV2TCWyj5xKEXF1r+OrJMexHQa0fW1URGrU8QODpJNC/9eCVGcEXddL31xTZYpjoVOCVx66kNa6lSHEVV3T4zaCby9Oe5QI4gZe1+xyxHPNEW5wogwS3dlKSyL2CfBP0aUKOmJ5Nrl8+y0GqJQXdGjZ9FIknmwWueRW/6qPQvZocjOZ8YiPZgAP0RNy6lL+u8mnAazj/mrEdmB5QUzpDAllIr5Tn/xaddZQ==',
11
11
  :shape => 'oc3',
12
- :version => '12.1.0.2'
12
+ :version => '12.1.0.2',
13
+ :backup_destination => 'NONE',
14
+ :admin_password => 'password123',
15
+ :usable_storage => '15'
13
16
  )
17
+
14
18
  test "can create a database" do
15
19
  db.is_a? Fog::OracleCloud::Database::Instance
16
20
  end
@@ -72,6 +76,10 @@ Shindo.tests('Fog::Database[oraclecloud] | database requests', 'database') do
72
76
  servers.size >= 1
73
77
  servers.first.status.is_a? String
74
78
  end
79
+
80
+ test "has special attributes" do
81
+ instance.failover_database == 'no'
82
+ end
75
83
  end
76
84
 
77
85
  tests("#database-backups-create", "create") do
@@ -2,19 +2,16 @@ require 'pp'
2
2
 
3
3
  Shindo.tests('Fog::Java[oraclecloud] | java requests', 'java') do
4
4
 
5
- tests("#database-create", "create") do
5
+ tests("#java-create", "create") do
6
6
  instance = Fog::OracleCloud[:java].instances.create(
7
7
  :service_name => 'TestWLS',
8
8
  :description => 'A new weblogic instance',
9
- :cloud_storage_container => 'todo',
10
- :cloud_storage_user => 'admin',
11
- :cloud_storage_password => 'password',
12
- :dbaName => 'SYS',
13
- :dbaPassword => 'password',
14
- :dbServiceName => 'TestDB',
9
+ :dba_name => 'SYS',
10
+ :dba_password => 'password',
11
+ :db_service_name => 'TestDB',
15
12
  :shape => 'oc3',
16
13
  :version => '12.2.1',
17
- :vmPublicKey => 'ssh-rsa AAAAB3NzaC1yc2EAAAABJQAAAQEAkNNQ4ri2oUW46mBO/4CHMGCOALciumwGvFEMDLGNnlinstanceUSqU4IRrqgj+znLClfb29Oer0devdarM6DilsZVgZ2YbI5ZD5vICR/O9J0c28dArwbtFeIjcV2TCWyj5xKEXF1r+OrJMexHQa0fW1URGrU8QODpJNC/9eCVGcEXddL31xTZYpjoVOCVx66kNa6lSHEVV3T4zaCby9Oe5QI4gZe1+xyxHPNEW5wogwS3dlKSyL2CfBP0aUKOmJ5Nrl8+y0GqJQXdGjZ9FIknmwWueRW/6qPQvZocjOZ8YiPZgAP0RNy6lL+u8mnAazj/mrEdmB5QUzpDAllIr5Tn/xaddZQ==',
14
+ :ssh_key => 'ssh-rsa AAAAB3NzaC1yc2EAAAABJQAAAQEAkNNQ4ri2oUW46mBO/4CHMGCOALciumwGvFEMDLGNnlinstanceUSqU4IRrqgj+znLClfb29Oer0devdarM6DilsZVgZ2YbI5ZD5vICR/O9J0c28dArwbtFeIjcV2TCWyj5xKEXF1r+OrJMexHQa0fW1URGrU8QODpJNC/9eCVGcEXddL31xTZYpjoVOCVx66kNa6lSHEVV3T4zaCby9Oe5QI4gZe1+xyxHPNEW5wogwS3dlKSyL2CfBP0aUKOmJ5Nrl8+y0GqJQXdGjZ9FIknmwWueRW/6qPQvZocjOZ8YiPZgAP0RNy6lL+u8mnAazj/mrEdmB5QUzpDAllIr5Tn/xaddZQ==',
18
15
  )
19
16
  test "can create a java instance" do
20
17
  instance.is_a? Fog::OracleCloud::Java::Instance
@@ -48,6 +45,13 @@ Shindo.tests('Fog::Java[oraclecloud] | java requests', 'java') do
48
45
  test "should return an instance" do
49
46
  instance.service_name.is_a? String
50
47
  end
48
+
49
+ servers = instance.servers
50
+ test "should have compute nodes" do
51
+ servers.is_a? Array
52
+ servers.size >= 1
53
+ servers.first.status.is_a? String
54
+ end
51
55
  end
52
56
 
53
57
  tests("#java-delete", "create") do
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.3
4
+ version: 0.1.4
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 00:00:00.000000000 Z
11
+ date: 2016-10-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -160,6 +160,8 @@ files:
160
160
  - lib/fog/oraclecloud/models/database/servers.rb
161
161
  - lib/fog/oraclecloud/models/database/snapshot.rb
162
162
  - lib/fog/oraclecloud/models/database/snapshots.rb
163
+ - lib/fog/oraclecloud/models/java/database.rb
164
+ - lib/fog/oraclecloud/models/java/databases.rb
163
165
  - lib/fog/oraclecloud/models/java/instance.rb
164
166
  - lib/fog/oraclecloud/models/java/instances.rb
165
167
  - lib/fog/oraclecloud/models/java/server.rb