Skip to content

Commit 004ac3c

Browse files
jshum2479Johnny
authored andcommitted
Add validation for rcudbinfo parameters
1 parent 72bb9bc commit 004ac3c

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
@@ -342,16 +342,8 @@ def validateRCUArgsAndModel(model_context, model):
342342
if model_constants.RCU_DB_INFO in domain_info:
343343
rcu_db_info = domain_info[model_constants.RCU_DB_INFO]
344344
has_tns_admin = atp_helper.has_tns_admin(rcu_db_info)
345-
346-
# has_tns_admin = model_constants.DRIVER_PARAMS_NET_TNS_ADMIN in domain_info[
347-
# model_constants.RCU_DB_INFO]
348-
# has_regular_db = model_constants.RCU_DB_CONN in domain_info[model_constants.RCU_DB_INFO]
349-
350345
has_regular_db = atp_helper.is_regular_db(rcu_db_info)
351-
352-
# if model_constants.ATP_TNS_ENTRY in domain_info[model_constants.RCU_DB_INFO]:
353-
if atp_helper.has_atpdbinfo(rcu_db_info):
354-
has_atpdbinfo = 1
346+
has_atpdbinfo = atp_helper.has_atpdbinfo(rcu_db_info)
355347

356348
if model_context.get_archive_file_name() and not has_regular_db:
357349
# 1. If it does not have the oracle.net.tns_admin specified, then extract to domain/atpwallet
@@ -442,8 +434,13 @@ def main(args):
442434

443435
if has_atp:
444436
atp_helper.fix_jsp_config(model, model_context)
437+
except CreateException, ex:
438+
__logger.severe('WLSDPLY-12409', _program_name, ex.getLocalizedMessage(), error=ex,
439+
class_name=_class_name, method_name=_method_name)
440+
__clean_up_temp_files()
441+
tool_exit.end(model_context, CommandLineArgUtil.PROG_ERROR_EXIT_CODE)
445442

446-
except (IOException | CreateException), ex:
443+
except IOException, ex:
447444
__logger.severe('WLSDPLY-12409', _program_name, ex.getLocalizedMessage(), error=ex,
448445
class_name=_class_name, method_name=_method_name)
449446
__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
@@ -182,6 +186,26 @@ def _create_mbean(self, type_name, model_nodes, base_location, log_created=False
182186
self.topology_helper.qualify_nm_properties(type_name, model_nodes, base_location, self.model_context,
183187
self.attribute_setter)
184188

189+
def __validate_rcudbinfo_entries(self, rcu_dbinfo_properties, keys):
190+
_method_name = '_validate_rcudbinfo_entries'
191+
error = 0
192+
last_error = None
193+
for key in keys:
194+
if key in rcu_dbinfo_properties:
195+
if rcu_dbinfo_properties[key] is None:
196+
error = 1
197+
else:
198+
error = 1
199+
if error:
200+
last_error = key
201+
break
202+
203+
if error:
204+
ex = exception_helper.create_create_exception('WLSDPLY-12413', last_error, str(keys))
205+
self.logger.throwing(ex, class_name=self.__class_name, method_name=_method_name)
206+
raise ex
207+
208+
185209
def __run_rcu(self):
186210
"""
187211
The method that runs RCU to drop and then create the schemas.
@@ -211,26 +235,47 @@ def __run_rcu(self):
211235
if RCU_DB_INFO in self.model.get_model_domain_info():
212236
rcu_properties_map = self.model.get_model_domain_info()[RCU_DB_INFO]
213237

214-
if ATP_TNS_ENTRY in rcu_properties_map:
238+
if atp_helper.has_atpdbinfo(rcu_properties_map):
239+
240+
# Need to validate they are non null
241+
215242
rcu_schema_pass = rcudbinfo_helper.get_rcu_schema_password(rcu_properties_map)
216243
rcu_sys_pass = rcudbinfo_helper.get_admin_password(rcu_properties_map)
217-
runner = RCURunner(domain_type, oracle_home, java_home, rcu_schemas, rcu_properties_map)
244+
245+
# Set it if it needs it
246+
# The java RCURunner use it to construct the argument
247+
# If we don't set it to non null then RCURunner will NPE
248+
249+
rcu_properties_map[ATP_ADMIN_USER] = rcudbinfo_helper.get_atp_admin_user(rcu_properties_map)
250+
rcu_properties_map[ATP_TEMPORARY_TABLESPACE] = rcudbinfo_helper.get_atp_temporary_tablespace(rcu_properties_map)
251+
rcu_properties_map[ATP_DEFAULT_TABLESPACE] = rcudbinfo_helper.get_atp_default_tablespace(rcu_properties_map)
252+
253+
self.__validate_rcudbinfo_entries(rcu_properties_map, [RCU_ADMIN_PASSWORD,
254+
RCU_ADMIN_PASSWORD,
255+
ATP_TNS_ENTRY, RCU_PREFIX,
256+
DRIVER_PARAMS_TRUSTSTOREPWD_PROPERTY,
257+
DRIVER_PARAMS_KEYSTOREPWD_PROPERTY])
258+
259+
runner = RCURunner(domain_type, oracle_home, java_home, rcu_schemas, rcu_properties_map,
260+
rcudbinfo_helper.get_rcu_variables(rcu_properties_map))
218261
runner.runRcu(rcu_sys_pass, rcu_schema_pass)
219262
else:
220263
rcu_db = rcudbinfo_helper.get_rcu_regular_db_conn(rcu_properties_map)
221264
rcu_prefix = rcudbinfo_helper.get_rcu_prefix(rcu_properties_map)
222265
rcu_sys_pass = rcudbinfo_helper.get_admin_password(rcu_properties_map)
223266
rcu_schema_pass = rcudbinfo_helper.get_rcu_schema_password(rcu_properties_map)
224-
225-
runner = RCURunner(domain_type, oracle_home, java_home, rcu_db, rcu_prefix, rcu_schemas)
267+
self.__validate_rcudbinfo_entries(rcu_properties_map, [RCU_PREFIX, RCU_SCHEMA_PASSWORD,
268+
RCU_ADMIN_PASSWORD, RCU_DB_CONN])
269+
runner = RCURunner(domain_type, oracle_home, java_home, rcu_db, rcu_prefix, rcu_schemas,
270+
rcudbinfo_helper.get_rcu_variables(rcu_properties_map))
226271
runner.runRcu(rcu_sys_pass, rcu_schema_pass)
227272
else:
228273
rcu_db = self.model_context.get_rcu_database()
229274
rcu_prefix = self.model_context.get_rcu_prefix()
230275
rcu_sys_pass = self.model_context.get_rcu_sys_pass()
231276
rcu_schema_pass = self.model_context.get_rcu_schema_pass()
232277

233-
runner = RCURunner(domain_type, oracle_home, java_home, rcu_db, rcu_prefix, rcu_schemas)
278+
runner = RCURunner(domain_type, oracle_home, java_home, rcu_db, rcu_prefix, rcu_schemas, None)
234279
runner.runRcu(rcu_sys_pass, rcu_schema_pass)
235280

236281
self.logger.exiting(class_name=self.__class_name, method_name=_method_name)
@@ -726,7 +771,7 @@ def __configure_fmw_infra_database(self):
726771
rcu_properties_map = domain_info[RCU_DB_INFO]
727772
# HANDLE ATP case
728773

729-
if ATP_TNS_ENTRY in rcu_properties_map:
774+
if atp_helper.has_atpdbinfo(rcu_properties_map):
730775
has_atp = 1
731776
# parse the tnsnames.ora file and retrieve the connection string
732777
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
@@ -1055,6 +1055,7 @@ WLSDPLY-12411=The model file specified ATP database info without oracle.net.tns_
10551055
not have wallet included
10561056
WLSDPLY-12412=The model file specified ATP database info without oracle.net.tns_admin directory and there is no \
10571057
archive specified
1058+
WLSDPLY-12413=The model file specified RCUDbInfo section but key {0} is None or missing. Required keys are {1}
10581059

10591060
###############################################################################
10601061
# YAML/JSON messages (18000 - 18999) #

0 commit comments

Comments
 (0)