Skip to content

Commit 8b073f9

Browse files
committed
Add validation for rcudbinfo parameters
1 parent caac7df commit 8b073f9

File tree

7 files changed

+132
-28
lines changed

7 files changed

+132
-28
lines changed

core/src/main/java/oracle/weblogic/deploy/create/RCURunner.java

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import org.python.core.PyDictionary;
2323
import org.python.core.PyString;
2424

25+
2526
/**
2627
* This class does all the work to drop and recreate the RCU schemas besed on the domain type definition.
2728
*/
@@ -49,6 +50,7 @@ public class RCURunner {
4950
private static final String COMPONENT_SWITCH = "-component";
5051
private static final String TABLESPACE_SWITCH = "-tablespace";
5152
private static final String TEMPTABLESPACE_SWITCH = "-tempTablespace";
53+
private static final String RCU_VARIABLES_SWITCH = "-variables";
5254
private static final String READ_STDIN_SWITCH = "-f";
5355
private static final String USE_SSL_SWITCH = "-useSSL";
5456
private static final String SERVER_DN_SWITCH = "-serverDN";
@@ -72,6 +74,10 @@ public class RCURunner {
7274
private List<String> rcuSchemas;
7375
private boolean ATP_DB = false;
7476
private String atpSSlArgs = null;
77+
private String atpAdminUser = null;
78+
private String atpDefaultTablespace = null;
79+
private String atpTemporaryTablespace = null;
80+
private String rcuVariables = null;
7581

7682
/**
7783
* The constructor.
@@ -85,29 +91,30 @@ public class RCURunner {
8591
* @throws CreateException if a parameter validation error occurs
8692
*/
8793
public RCURunner(String domainType, String oracleHome, String javaHome, String rcuDb, String rcuPrefix,
88-
List<String> rcuSchemas) throws CreateException {
94+
List<String> rcuSchemas, String rcuVariables) throws CreateException {
8995

9096
this.oracleHome = validateExistingDirectory(oracleHome, "ORACLE_HOME");
9197
this.javaHome = validateExistingDirectory(javaHome, "JAVA_HOME");
9298
this.rcuDb = validateNonEmptyString(rcuDb, "rcu_db");
9399
this.rcuPrefix = validateNonEmptyString(rcuPrefix, "rcu_prefix");
94100
this.rcuSchemas = validateNonEmptyListOfStrings(rcuSchemas, "rcu_schema_list");
101+
this.rcuVariables = rcuVariables;
95102
if (this.rcuSchemas.contains(SERVICE_TABLE_COMPONENT)) {
96103
LOGGER.warning("WLSDPLY-12000", CLASS, domainType, SERVICE_TABLE_COMPONENT);
97104
this.rcuSchemas.remove(SERVICE_TABLE_COMPONENT);
98105
}
99106
}
100107

101108
/**
102-
* The constructor.
109+
* The constructor - used only by ATP database
103110
*
104111
* @param domainType the domain type
105112
* @param oracleHome the ORACLE_HOME location
106113
* @param javaHome the JAVA_HOME location
107114
* @throws CreateException if a parameter validation error occurs
108115
*/
109116
public RCURunner(String domainType, String oracleHome, String javaHome, List<String> rcuSchemas,
110-
PyDictionary rcuProperties)
117+
PyDictionary rcuProperties, String rcuVariables)
111118
throws CreateException {
112119

113120

@@ -140,6 +147,11 @@ public RCURunner(String domainType, String oracleHome, String javaHome, List<Str
140147
this.rcuDb = "jdbc:oracle:thin:@" + rcuProperties.get(new PyString("tns.entry")).toString();
141148
this.rcuPrefix = rcuProperties.get(new PyString("rcu_prefix")).toString();
142149
this.rcuSchemas = validateNonEmptyListOfStrings(rcuSchemas, "rcu_schema_list");
150+
this.atpAdminUser = rcuProperties.get(new PyString("atp.admin.user")).toString();
151+
this.atpDefaultTablespace = rcuProperties.get(new PyString("atp.default.tablespace")).toString();
152+
this.atpTemporaryTablespace = rcuProperties.get(new PyString("atp.temp.tablespace")).toString();
153+
this.rcuVariables = rcuVariables;
154+
143155
if (!this.rcuSchemas.contains(SERVICE_TABLE_COMPONENT)) {
144156
LOGGER.warning("WLSDPLY-12000", CLASS, domainType, SERVICE_TABLE_COMPONENT);
145157
this.rcuSchemas.add(SERVICE_TABLE_COMPONENT);
@@ -240,7 +252,7 @@ private String[] getRcuDropArgs() {
240252

241253
if (ATP_DB) {
242254
dropArgs.add(DB_USER_SWITCH);
243-
dropArgs.add("admin");
255+
dropArgs.add(this.atpAdminUser);
244256
dropArgs.add(USE_SSL_SWITCH);
245257
dropArgs.add("true");
246258
dropArgs.add(SERVER_DN_SWITCH);
@@ -281,7 +293,7 @@ private String[] getRcuCreateArgs() {
281293
createArgs.add(rcuDb);
282294
if (ATP_DB) {
283295
createArgs.add(DB_USER_SWITCH);
284-
createArgs.add("admin");
296+
createArgs.add(this.atpAdminUser);
285297
createArgs.add(USE_SSL_SWITCH);
286298
createArgs.add("true");
287299
createArgs.add(SERVER_DN_SWITCH);
@@ -302,11 +314,15 @@ private String[] getRcuCreateArgs() {
302314
createArgs.add(rcuSchema);
303315
if (ATP_DB) {
304316
createArgs.add(TABLESPACE_SWITCH);
305-
createArgs.add("DATA");
317+
createArgs.add(this.atpDefaultTablespace);
306318
createArgs.add(TEMPTABLESPACE_SWITCH);
307-
createArgs.add("TEMP");
319+
createArgs.add(this.atpTemporaryTablespace);
308320
}
309321
}
322+
if (rcuVariables != null) {
323+
createArgs.add(RCU_VARIABLES_SWITCH);
324+
createArgs.add(this.rcuVariables);
325+
}
310326
createArgs.add(READ_STDIN_SWITCH);
311327

312328
String[] result = new String[createArgs.size()];

core/src/main/python/create.py

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -336,16 +336,8 @@ def validateRCUArgsAndModel(model_context, model):
336336
if model_constants.RCU_DB_INFO in domain_info:
337337
rcu_db_info = domain_info[model_constants.RCU_DB_INFO]
338338
has_tns_admin = atp_helper.has_tns_admin(rcu_db_info)
339-
340-
# has_tns_admin = model_constants.DRIVER_PARAMS_NET_TNS_ADMIN in domain_info[
341-
# model_constants.RCU_DB_INFO]
342-
# has_regular_db = model_constants.RCU_DB_CONN in domain_info[model_constants.RCU_DB_INFO]
343-
344339
has_regular_db = atp_helper.is_regular_db(rcu_db_info)
345-
346-
# if model_constants.ATP_TNS_ENTRY in domain_info[model_constants.RCU_DB_INFO]:
347-
if atp_helper.has_atpdbinfo(rcu_db_info):
348-
has_atpdbinfo = 1
340+
has_atpdbinfo = atp_helper.has_atpdbinfo(rcu_db_info)
349341

350342
if model_context.get_archive_file_name() and not has_regular_db:
351343
# 1. If it does not have the oracle.net.tns_admin specified, then extract to domain/atpwallet
@@ -436,8 +428,13 @@ def main(args):
436428

437429
if has_atp:
438430
atp_helper.fix_jsp_config(model, model_context)
431+
except CreateException, ex:
432+
__logger.severe('WLSDPLY-12409', _program_name, ex.getLocalizedMessage(), error=ex,
433+
class_name=_class_name, method_name=_method_name)
434+
__clean_up_temp_files()
435+
tool_exit.end(model_context, CommandLineArgUtil.PROG_ERROR_EXIT_CODE)
439436

440-
except (IOException | CreateException), ex:
437+
except IOException, ex:
441438
__logger.severe('WLSDPLY-12409', _program_name, ex.getLocalizedMessage(), error=ex,
442439
class_name=_class_name, method_name=_method_name)
443440
__clean_up_temp_files()

core/src/main/python/wlsdeploy/aliases/model_constants.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,12 @@
2222
RCU_SCHEMA_PASSWORD= 'rcu_schema_password'
2323
RCU_ADMIN_PASSWORD = 'rcu_admin_password'
2424
RCU_DB_CONN = 'rcu_db_conn_string'
25+
RCU_VARIABLES = 'rcu_variables'
26+
USE_ATP = 'useATP'
2527
ATP_TNS_ENTRY = 'tns.entry'
26-
28+
ATP_DEFAULT_TABLESPACE = 'atp.default.tablespace'
29+
ATP_TEMPORARY_TABLESPACE = 'atp.temp.tablespace'
30+
ATP_ADMIN_USER = 'atp.admin.user'
2731
AUDITOR = 'Auditor'
2832
AUTHENTICATION_PROVIDER = 'AuthenticationProvider'
2933
AUTHORIZER = 'Authorizer'

core/src/main/python/wlsdeploy/tool/create/atp_helper.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,11 +164,24 @@ def has_tns_admin(rcu_db_info):
164164

165165

166166
def has_atpdbinfo(rcu_db_info):
167-
return model_constants.ATP_TNS_ENTRY in rcu_db_info
167+
is_atp = 0
168+
if model_constants.USE_ATP in rcu_db_info:
169+
print
170+
if rcu_db_info[model_constants.USE_ATP] == 'true' or rcu_db_info[model_constants.USE_ATP] == 1:
171+
is_atp = 1
172+
return is_atp
173+
# return model_constants.USE_ATP in rcu_db_info
174+
# return model_constants.ATP_TNS_ENTRY in rcu_db_info
168175

169176

170177
def is_regular_db(rcu_db_info):
171-
return model_constants.RCU_DB_CONN in rcu_db_info
178+
is_regular = 0
179+
if model_constants.USE_ATP in rcu_db_info:
180+
if rcu_db_info[model_constants.USE_ATP] is 'false' or rcu_db_info[model_constants.USE_ATP] is 0:
181+
is_regular = 1
182+
if model_constants.RCU_DB_CONN in rcu_db_info:
183+
is_regular = 1
184+
return is_regular
172185

173186

174187
def extract_walletzip(model, model_context, archive_file, atp_path):

core/src/main/python/wlsdeploy/tool/create/domain_creator.py

Lines changed: 51 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@
1010
from wlsdeploy.aliases.model_constants import ADMIN_SERVER_NAME
1111
from wlsdeploy.aliases.model_constants import ADMIN_USERNAME
1212
from wlsdeploy.aliases.model_constants import APP_DIR
13+
from wlsdeploy.aliases.model_constants import ATP_ADMIN_USER
1314
from wlsdeploy.aliases.model_constants import ATP_TNS_ENTRY
15+
from wlsdeploy.aliases.model_constants import ATP_DEFAULT_TABLESPACE
16+
from wlsdeploy.aliases.model_constants import ATP_TEMPORARY_TABLESPACE
1417
from wlsdeploy.aliases.model_constants import CLUSTER
1518
from wlsdeploy.aliases.model_constants import DEFAULT_ADMIN_SERVER_NAME
1619
from wlsdeploy.aliases.model_constants import DEFAULT_WLS_DOMAIN_NAME
@@ -43,6 +46,7 @@
4346
from wlsdeploy.aliases.model_constants import RCU_DB_INFO
4447
from wlsdeploy.aliases.model_constants import RCU_PREFIX
4548
from wlsdeploy.aliases.model_constants import RCU_SCHEMA_PASSWORD
49+
from wlsdeploy.aliases.model_constants import RCU_ADMIN_PASSWORD
4650
from wlsdeploy.aliases.model_constants import RESOURCE_GROUP
4751
from wlsdeploy.aliases.model_constants import RESOURCE_GROUP_TEMPLATE
4852
from wlsdeploy.aliases.model_constants import SECURITY
@@ -190,6 +194,26 @@ def _create_mbean(self, type_name, model_nodes, base_location, log_created=False
190194
self.topology_helper.qualify_nm_properties(type_name, model_nodes, base_location, self.model_context,
191195
self.attribute_setter)
192196

197+
def __validate_rcudbinfo_entries(self, rcu_dbinfo_properties, keys):
198+
_method_name = '_validate_rcudbinfo_entries'
199+
error = 0
200+
last_error = None
201+
for key in keys:
202+
if key in rcu_dbinfo_properties:
203+
if rcu_dbinfo_properties[key] is None:
204+
error = 1
205+
else:
206+
error = 1
207+
if error:
208+
last_error = key
209+
break
210+
211+
if error:
212+
ex = exception_helper.create_create_exception('WLSDPLY-12413', last_error, str(keys))
213+
self.logger.throwing(ex, class_name=self.__class_name, method_name=_method_name)
214+
raise ex
215+
216+
193217
def __run_rcu(self):
194218
"""
195219
The method that runs RCU to drop and then create the schemas.
@@ -219,26 +243,47 @@ def __run_rcu(self):
219243
if RCU_DB_INFO in self.model.get_model_domain_info():
220244
rcu_properties_map = self.model.get_model_domain_info()[RCU_DB_INFO]
221245

222-
if ATP_TNS_ENTRY in rcu_properties_map:
246+
if atp_helper.has_atpdbinfo(rcu_properties_map):
247+
248+
# Need to validate they are non null
249+
223250
rcu_schema_pass = rcudbinfo_helper.get_rcu_schema_password(rcu_properties_map)
224251
rcu_sys_pass = rcudbinfo_helper.get_admin_password(rcu_properties_map)
225-
runner = RCURunner(domain_type, oracle_home, java_home, rcu_schemas, rcu_properties_map)
252+
253+
# Set it if it needs it
254+
# The java RCURunner use it to construct the argument
255+
# If we don't set it to non null then RCURunner will NPE
256+
257+
rcu_properties_map[ATP_ADMIN_USER] = rcudbinfo_helper.get_atp_admin_user(rcu_properties_map)
258+
rcu_properties_map[ATP_TEMPORARY_TABLESPACE] = rcudbinfo_helper.get_atp_temporary_tablespace(rcu_properties_map)
259+
rcu_properties_map[ATP_DEFAULT_TABLESPACE] = rcudbinfo_helper.get_atp_default_tablespace(rcu_properties_map)
260+
261+
self.__validate_rcudbinfo_entries(rcu_properties_map, [RCU_ADMIN_PASSWORD,
262+
RCU_ADMIN_PASSWORD,
263+
ATP_TNS_ENTRY, RCU_PREFIX,
264+
DRIVER_PARAMS_TRUSTSTOREPWD_PROPERTY,
265+
DRIVER_PARAMS_KEYSTOREPWD_PROPERTY])
266+
267+
runner = RCURunner(domain_type, oracle_home, java_home, rcu_schemas, rcu_properties_map,
268+
rcudbinfo_helper.get_rcu_variables(rcu_properties_map))
226269
runner.runRcu(rcu_sys_pass, rcu_schema_pass)
227270
else:
228271
rcu_db = rcudbinfo_helper.get_rcu_regular_db_conn(rcu_properties_map)
229272
rcu_prefix = rcudbinfo_helper.get_rcu_prefix(rcu_properties_map)
230273
rcu_sys_pass = rcudbinfo_helper.get_admin_password(rcu_properties_map)
231274
rcu_schema_pass = rcudbinfo_helper.get_rcu_schema_password(rcu_properties_map)
232-
233-
runner = RCURunner(domain_type, oracle_home, java_home, rcu_db, rcu_prefix, rcu_schemas)
275+
self.__validate_rcudbinfo_entries(rcu_properties_map, [RCU_PREFIX, RCU_SCHEMA_PASSWORD,
276+
RCU_ADMIN_PASSWORD, RCU_DB_CONN])
277+
runner = RCURunner(domain_type, oracle_home, java_home, rcu_db, rcu_prefix, rcu_schemas,
278+
rcudbinfo_helper.get_rcu_variables(rcu_properties_map))
234279
runner.runRcu(rcu_sys_pass, rcu_schema_pass)
235280
else:
236281
rcu_db = self.model_context.get_rcu_database()
237282
rcu_prefix = self.model_context.get_rcu_prefix()
238283
rcu_sys_pass = self.model_context.get_rcu_sys_pass()
239284
rcu_schema_pass = self.model_context.get_rcu_schema_pass()
240285

241-
runner = RCURunner(domain_type, oracle_home, java_home, rcu_db, rcu_prefix, rcu_schemas)
286+
runner = RCURunner(domain_type, oracle_home, java_home, rcu_db, rcu_prefix, rcu_schemas, None)
242287
runner.runRcu(rcu_sys_pass, rcu_schema_pass)
243288

244289
self.logger.exiting(class_name=self.__class_name, method_name=_method_name)
@@ -732,7 +777,7 @@ def __configure_fmw_infra_database(self):
732777
rcu_properties_map = domain_info[RCU_DB_INFO]
733778
# HANDLE ATP case
734779

735-
if ATP_TNS_ENTRY in rcu_properties_map:
780+
if atp_helper.has_atpdbinfo(rcu_properties_map):
736781
has_atp = 1
737782
# parse the tnsnames.ora file and retrieve the connection string
738783
tns_admin = rcu_properties_map[DRIVER_PARAMS_NET_TNS_ADMIN]

core/src/main/python/wlsdeploy/tool/create/rcudbinfo_helper.py

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88

99
def get_atp_tns_admin(rcu_properties_map):
10-
return rcu_properties_map[model_constants.DRIVER_PARAMS_NET_TNSADMIN]
10+
return rcu_properties_map[model_constants.DRIVER_PARAMS_NET_TNS_ADMIN]
1111

1212

1313
def get_atp_entry(rcu_properties_map):
@@ -35,4 +35,32 @@ def get_admin_password(rcu_properties_map):
3535

3636

3737
def get_rcu_regular_db_conn(rcu_properties_map):
38-
return rcu_properties_map[model_constants.RCU_DB_CONN]
38+
return rcu_properties_map[model_constants.RCU_DB_CONN]
39+
40+
41+
def get_atp_default_tablespace(rcu_properties_map):
42+
if model_constants.ATP_DEFAULT_TABLESPACE in rcu_properties_map:
43+
return rcu_properties_map[model_constants.ATP_DEFAULT_TABLESPACE]
44+
else:
45+
return 'DATA'
46+
47+
48+
def get_atp_temporary_tablespace(rcu_properties_map):
49+
if model_constants.ATP_TEMPORARY_TABLESPACE in rcu_properties_map:
50+
return rcu_properties_map[model_constants.ATP_TEMPORARY_TABLESPACE]
51+
else:
52+
return 'TEMP'
53+
54+
55+
def get_atp_admin_user(rcu_properties_map):
56+
if model_constants.ATP_ADMIN_USER in rcu_properties_map:
57+
return rcu_properties_map[model_constants.ATP_ADMIN_USER]
58+
else:
59+
return 'admin'
60+
61+
62+
def get_rcu_variables(rcu_properties_map):
63+
if model_constants.RCU_VARIABLES in rcu_properties_map:
64+
return rcu_properties_map[model_constants.RCU_VARIABLES]
65+
else:
66+
return None

core/src/main/resources/oracle/weblogic/deploy/messages/wlsdeploy_rb.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1015,6 +1015,7 @@ WLSDPLY-12411=The model file specified ATP database info without oracle.net.tns_
10151015
not have wallet included
10161016
WLSDPLY-12412=The model file specified ATP database info without oracle.net.tns_admin directory and there is no \
10171017
archive specified
1018+
WLSDPLY-12413=The model file specified RCUDbInfo section but key {0} is None or missing. Required keys are {1}
10181019

10191020
###############################################################################
10201021
# YAML/JSON messages (18000 - 18999) #

0 commit comments

Comments
 (0)