Skip to content

Commit cd7baa4

Browse files
Add rcu config files to the rcuDbInfo and runRcu (#688)
1 parent 9a7e3f3 commit cd7baa4

File tree

8 files changed

+98
-27
lines changed

8 files changed

+98
-27
lines changed

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

Lines changed: 37 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,10 @@
1919
import oracle.weblogic.deploy.util.ScriptRunnerException;
2020
import oracle.weblogic.deploy.util.StringUtils;
2121

22+
import org.python.core.Py;
2223
import org.python.core.PyDictionary;
24+
import org.python.core.PyList;
25+
import org.python.core.PyObject;
2326
import org.python.core.PyString;
2427

2528

@@ -80,6 +83,7 @@ public class RCURunner {
8083
private String atpDefaultTablespace = null;
8184
private String atpTemporaryTablespace = null;
8285
private String rcuVariables = null;
86+
private Map<String, String> extraArgs = new HashMap<>();
8387

8488
/**
8589
* The constructor.
@@ -90,21 +94,20 @@ public class RCURunner {
9094
* @param rcuDb the RCU database connect string
9195
* @param rcuPrefix the RCU prefix to use
9296
* @param rcuSchemas the list of RCU schemas to create (this list should not include STB)
97+
* @param rcuVariables a comma separated list of key=value variables
98+
* @param extraArgs Additional dictionary of arguments to add on the command line
9399
* @throws CreateException if a parameter validation error occurs
94100
*/
95101
public RCURunner(String domainType, String oracleHome, String javaHome, String rcuDb, String rcuPrefix,
96-
List<String> rcuSchemas, String rcuVariables) throws CreateException {
102+
List<String> rcuSchemas, String rcuVariables, PyDictionary extraArgs) throws CreateException {
97103

98104
this.oracleHome = validateExistingDirectory(oracleHome, "ORACLE_HOME");
99105
this.javaHome = validateExistingDirectory(javaHome, "JAVA_HOME");
100106
this.rcuDb = validateNonEmptyString(rcuDb, "rcu_db");
101107
this.rcuPrefix = validateNonEmptyString(rcuPrefix, "rcu_prefix");
102108
this.rcuSchemas = validateNonEmptyListOfStrings(rcuSchemas, "rcu_schema_list");
103109
this.rcuVariables = rcuVariables;
104-
// if (this.rcuSchemas.contains(SERVICE_TABLE_COMPONENT)) {
105-
// LOGGER.warning("WLSDPLY-12000", CLASS, domainType, SERVICE_TABLE_COMPONENT);
106-
// this.rcuSchemas.remove(SERVICE_TABLE_COMPONENT);
107-
// }
110+
createExtraArgs(extraArgs);
108111
}
109112

110113
/**
@@ -113,10 +116,14 @@ public RCURunner(String domainType, String oracleHome, String javaHome, String r
113116
* @param domainType the domain type
114117
* @param oracleHome the ORACLE_HOME location
115118
* @param javaHome the JAVA_HOME location
119+
* @param rcuSchemas the list of RCU schemas to create (this list should not include STB)
120+
* @param rcuProperties dictionary of ATP specific arguments
121+
* @param rcuVariables a comma separated list of key=value variables
122+
* @param extraArgs Additional dictionary of arguments to add on the command line
116123
* @throws CreateException if a parameter validation error occurs
117124
*/
118125
public RCURunner(String domainType, String oracleHome, String javaHome, List<String> rcuSchemas,
119-
PyDictionary rcuProperties, String rcuVariables)
126+
PyDictionary rcuProperties, String rcuVariables, PyDictionary extraArgs)
120127
throws CreateException {
121128

122129

@@ -153,14 +160,9 @@ public RCURunner(String domainType, String oracleHome, String javaHome, List<Str
153160
this.atpDefaultTablespace = rcuProperties.get(new PyString("atp.default.tablespace")).toString();
154161
this.atpTemporaryTablespace = rcuProperties.get(new PyString("atp.temp.tablespace")).toString();
155162
this.rcuVariables = rcuVariables;
156-
157-
// if (!this.rcuSchemas.contains(SERVICE_TABLE_COMPONENT)) {
158-
// LOGGER.warning("WLSDPLY-12000", CLASS, domainType, SERVICE_TABLE_COMPONENT);
159-
// this.rcuSchemas.add(SERVICE_TABLE_COMPONENT);
160-
// }
163+
createExtraArgs(extraArgs);
161164
}
162165

163-
164166
/**
165167
* Run RCU to drop and recreate the RCU schemas.
166168
*
@@ -275,10 +277,11 @@ private String[] getRcuDropArgs() {
275277
dropArgs.add(COMPONENT_SWITCH);
276278
dropArgs.add(rcuSchema);
277279
}
278-
// Add STB to the drop list since it is never specified in the create list...
279-
// dropArgs.add(COMPONENT_SWITCH);
280-
// dropArgs.add(SERVICE_TABLE_COMPONENT);
281-
280+
// extra arguments are for both create and drop. If add one only for create, need extra logic here
281+
for (Map.Entry<String, String> entry : extraArgs.entrySet()) {
282+
dropArgs.add("-" + entry.getKey());
283+
dropArgs.add(entry.getValue());
284+
}
282285
dropArgs.add(READ_STDIN_SWITCH);
283286

284287
String[] result = new String[dropArgs.size()];
@@ -323,6 +326,10 @@ private String[] getRcuCreateArgs() {
323326
createArgs.add(this.atpTemporaryTablespace);
324327
}
325328
}
329+
for (Map.Entry<String, String> entry : extraArgs.entrySet()) {
330+
createArgs.add("-" + entry.getKey());
331+
createArgs.add(entry.getValue());
332+
}
326333
if (rcuVariables != null) {
327334
createArgs.add(RCU_VARIABLES_SWITCH);
328335
createArgs.add(this.rcuVariables);
@@ -483,8 +490,22 @@ private static void validateExistingExecutableFile(File executable, String execu
483490
LOGGER.exiting(CLASS, METHOD);
484491
}
485492

493+
private void createExtraArgs(PyDictionary extraArgs) {
494+
if (extraArgs != null) {
495+
PyList keys = extraArgs.keys();
496+
for (int idx = 0; idx<keys.size(); idx++) {
497+
Object key = keys.get(idx);
498+
if (key instanceof String) {
499+
String value = extraArgs.get(new PyString((String)key)).toString();
500+
this.extraArgs.put((String)key, value);
501+
}
502+
}
503+
}
504+
}
505+
486506
/**
487507
* RCU Operation Type enum.
488508
*/
489509
private enum RcuOpType { DROP, CREATE}
490510
}
511+

core/src/main/python/create.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ def validate_rcu_args_and_model(model_context, model, archive_helper, alias_help
237237
domain_info = model[model_constants.DOMAIN_INFO]
238238
if domain_info is not None:
239239
if model_constants.RCU_DB_INFO in domain_info:
240-
rcu_db_info = RcuDbInfo(alias_helper, domain_info[model_constants.RCU_DB_INFO])
240+
rcu_db_info = RcuDbInfo(model_context, alias_helper, domain_info[model_constants.RCU_DB_INFO])
241241
has_tns_admin = rcu_db_info.has_tns_admin()
242242
has_regular_db = rcu_db_info.is_regular_db()
243243
has_atpdbinfo = rcu_db_info.has_atpdbinfo()
@@ -340,7 +340,7 @@ def main(args):
340340

341341
if has_atp:
342342
rcu_properties_map = model_dictionary[model_constants.DOMAIN_INFO][model_constants.RCU_DB_INFO]
343-
rcu_db_info = RcuDbInfo(alias_helper, rcu_properties_map)
343+
rcu_db_info = RcuDbInfo(model_context, alias_helper, rcu_properties_map)
344344
atp_helper.fix_jps_config(rcu_db_info, model_context)
345345

346346
except WLSDeployArchiveIOException, ex:

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@
3030
RCU_ADMIN_PASSWORD = 'rcu_admin_password'
3131
RCU_DB_USER = 'rcu_db_user'
3232
RCU_DB_CONN = 'rcu_db_conn_string'
33+
RCU_COMP_INFO = 'compInfoXMLLocation'
34+
RCU_STG_INFO = 'storageXMLLocation'
3335
RCU_VARIABLES = 'rcu_variables'
3436
USE_ATP = 'useATP'
3537
ATP_TNS_ENTRY = 'tns.alias'

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

Lines changed: 37 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import weblogic.security.internal.SerializedSystemIni as SerializedSystemIni
77
import weblogic.security.internal.encryption.ClearOrEncryptedService as ClearOrEncryptedService
88
from java.io import FileOutputStream
9+
from java.lang import IllegalArgumentException
910
from java.util import Properties
1011
from oracle.weblogic.deploy.create import RCURunner
1112
from oracle.weblogic.deploy.util import WLSDeployArchive, FileUtils
@@ -51,10 +52,12 @@
5152
from wlsdeploy.aliases.model_constants import PASSWORD_ENCRYPTED
5253
from wlsdeploy.aliases.model_constants import PRODUCTION_MODE_ENABLED
5354
from wlsdeploy.aliases.model_constants import RCU_ADMIN_PASSWORD
55+
from wlsdeploy.aliases.model_constants import RCU_COMP_INFO
5456
from wlsdeploy.aliases.model_constants import RCU_DB_CONN
5557
from wlsdeploy.aliases.model_constants import RCU_DB_INFO
5658
from wlsdeploy.aliases.model_constants import RCU_PREFIX
5759
from wlsdeploy.aliases.model_constants import RCU_SCHEMA_PASSWORD
60+
from wlsdeploy.aliases.model_constants import RCU_STG_INFO
5861
from wlsdeploy.aliases.model_constants import RESOURCE_GROUP
5962
from wlsdeploy.aliases.model_constants import RESOURCE_GROUP_TEMPLATE
6063
from wlsdeploy.aliases.model_constants import SECURITY
@@ -222,6 +225,26 @@ def __validate_rcudbinfo_entries(self, rcu_dbinfo_properties, keys):
222225
self.logger.throwing(ex, class_name=self.__class_name, method_name=_method_name)
223226
raise ex
224227

228+
def __extract_rcu_xml_file(self, xml_type, path):
229+
_method_name = '__extract_rcu_xml_files'
230+
self.logger.entering(path, class_name=self.__class_name, method_name=_method_name)
231+
result = None
232+
if path is not None:
233+
resolved_path = self.model_context.replace_token_string(path)
234+
if self.archive_helper is not None and self.archive_helper.contains_file(resolved_path):
235+
resolved_path = self.archive_helper.extract_file(resolved_path)
236+
try:
237+
resolved_file = FileUtils.validateFileName(resolved_path)
238+
result = resolved_file.getPath()
239+
except IllegalArgumentException, iae:
240+
ex = exception_helper.create_create_exception('WLSDPLY-12258', xml_type, path,
241+
iae.getLocalizedMessage(), error=iae)
242+
self.logger.throwing(ex, class_name=self._class_name, method_name=_method_name)
243+
raise ex
244+
245+
self.logger.exiting(class_name=self.__class_name, method_name=_method_name, result=result)
246+
return result
247+
225248
def __run_rcu(self):
226249
"""
227250
The method that runs RCU to drop and then create the schemas.
@@ -251,7 +274,15 @@ def __run_rcu(self):
251274
if RCU_DB_INFO in self.model.get_model_domain_info():
252275

253276
rcu_properties_map = self.model.get_model_domain_info()[RCU_DB_INFO]
254-
rcu_db_info = RcuDbInfo(self.alias_helper, rcu_properties_map)
277+
rcu_db_info = RcuDbInfo(self.model_context, self.alias_helper, rcu_properties_map)
278+
rcu_extra_args = dict()
279+
280+
rcu_comp_info = self.__extract_rcu_xml_file(RCU_COMP_INFO, rcu_db_info.get_comp_info_location())
281+
if rcu_comp_info is not None:
282+
rcu_extra_args[RCU_COMP_INFO] = rcu_comp_info
283+
rcu_stg_info = self.__extract_rcu_xml_file(RCU_STG_INFO, rcu_db_info.get_storage_location())
284+
if rcu_stg_info is not None:
285+
rcu_extra_args[RCU_STG_INFO] = rcu_stg_info
255286

256287
if rcu_db_info.has_atpdbinfo():
257288

@@ -280,7 +311,7 @@ def __run_rcu(self):
280311
DRIVER_PARAMS_KEYSTOREPWD_PROPERTY])
281312

282313
runner = RCURunner(domain_type, oracle_home, java_home, rcu_schemas, rcu_runner_map,
283-
rcu_db_info.get_rcu_variables())
314+
rcu_db_info.get_rcu_variables(), rcu_extra_args)
284315
runner.runRcu(rcu_sys_pass, rcu_schema_pass)
285316
else:
286317
# Has RCUDbInfo in the model but non ATP case
@@ -292,7 +323,7 @@ def __run_rcu(self):
292323
self.__validate_rcudbinfo_entries(rcu_properties_map, [RCU_PREFIX, RCU_SCHEMA_PASSWORD,
293324
RCU_ADMIN_PASSWORD, RCU_DB_CONN])
294325
runner = RCURunner(domain_type, oracle_home, java_home, rcu_db, rcu_prefix, rcu_schemas,
295-
rcu_db_info.get_rcu_variables())
326+
rcu_db_info.get_rcu_variables(), rcu_extra_args)
296327
runner.setRCUAdminUser(rcu_db_user)
297328
runner.runRcu(rcu_sys_pass, rcu_schema_pass)
298329
else:
@@ -880,7 +911,7 @@ def __configure_fmw_infra_database(self):
880911
domain_info = self.model.get_model_domain_info()
881912

882913
if RCU_DB_INFO in domain_info:
883-
rcu_db_info = RcuDbInfo(self.alias_helper, domain_info[RCU_DB_INFO])
914+
rcu_db_info = RcuDbInfo(self.model_context, self.alias_helper, domain_info[RCU_DB_INFO])
884915

885916
# HANDLE ATP case
886917

@@ -896,7 +927,7 @@ def __configure_fmw_infra_database(self):
896927
keystore_pwd = rcu_db_info.get_keystore_password()
897928
truststore_pwd = rcu_db_info.get_truststore_password()
898929

899-
# Need to set for the connection proeprty for each datasource
930+
# Need to set for the connection property for each datasource
900931

901932
fmw_database = self.wls_helper.get_jdbc_url_from_rcu_connect_string(rcu_database)
902933

@@ -963,7 +994,7 @@ def __configure_fmw_infra_database(self):
963994

964995
if not has_atp:
965996
if RCU_DB_INFO in domain_info:
966-
rcu_db_info = RcuDbInfo(self.alias_helper, domain_info[RCU_DB_INFO])
997+
rcu_db_info = RcuDbInfo(self.model_context, self.alias_helper, domain_info[RCU_DB_INFO])
967998
rcu_prefix = rcu_db_info.get_rcu_prefix()
968999
rcu_database = rcu_db_info.get_rcu_regular_db_conn()
9691000
rcu_schema_pwd = rcu_db_info.get_rcu_schema_password()

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

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,15 @@
1111
from wlsdeploy.aliases.model_constants import DRIVER_PARAMS_NET_TNS_ADMIN
1212
from wlsdeploy.aliases.model_constants import DRIVER_PARAMS_TRUSTSTOREPWD_PROPERTY
1313
from wlsdeploy.aliases.model_constants import RCU_ADMIN_PASSWORD
14+
from wlsdeploy.aliases.model_constants import RCU_COMP_INFO
1415
from wlsdeploy.aliases.model_constants import RCU_DB_CONN
16+
from wlsdeploy.aliases.model_constants import RCU_DB_USER
1517
from wlsdeploy.aliases.model_constants import RCU_PREFIX
1618
from wlsdeploy.aliases.model_constants import RCU_SCHEMA_PASSWORD
17-
from wlsdeploy.aliases.model_constants import RCU_DB_USER
19+
from wlsdeploy.aliases.model_constants import RCU_STG_INFO
1820
from wlsdeploy.aliases.model_constants import RCU_VARIABLES
1921
from wlsdeploy.aliases.model_constants import USE_ATP
22+
from wlsdeploy.util.model_context import ModelContext
2023

2124

2225
class RcuDbInfo(object):
@@ -26,7 +29,8 @@ class RcuDbInfo(object):
2629
Returns default values for some unspecified fields.
2730
"""
2831

29-
def __init__(self, alias_helper, rcu_properties_map):
32+
def __init__(self, model_context, alias_helper, rcu_properties_map):
33+
self.model_context = model_context
3034
self.alias_helper = alias_helper
3135
self.rcu_properties_map = rcu_properties_map
3236

@@ -82,6 +86,16 @@ def get_rcu_db_user(self):
8286
else:
8387
return 'SYS'
8488

89+
def get_comp_info_location(self):
90+
if RCU_COMP_INFO in self.rcu_properties_map:
91+
return self.model_context.replace_token_string(self.rcu_properties_map[RCU_COMP_INFO])
92+
return None
93+
94+
def get_storage_location(self):
95+
if RCU_STG_INFO in self.rcu_properties_map:
96+
return self.model_context.replace_token_string(self.rcu_properties_map[RCU_STG_INFO])
97+
return None
98+
8599
def get_rcu_variables(self):
86100
if RCU_VARIABLES in self.rcu_properties_map:
87101
return self.rcu_properties_map[RCU_VARIABLES]

core/src/main/python/wlsdeploy/tool/util/rcu_helper.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def update_rcu_password(self):
3535

3636
domain_info = self.model.get_model_domain_info()
3737
if RCU_DB_INFO in domain_info:
38-
rcu_db_info = RcuDbInfo(self.alias_helper, domain_info[RCU_DB_INFO])
38+
rcu_db_info = RcuDbInfo(self.model_context, self.alias_helper, domain_info[RCU_DB_INFO])
3939
rcu_schema_pass = rcu_db_info.get_rcu_schema_password()
4040
rcu_prefix = rcu_db_info.get_rcu_prefix()
4141

core/src/main/resources/oracle/weblogic/deploy/aliases/category_modules/RCUDbInfo.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
"atp.admin.user": [ {"version": "[10,)", "wlst_mode": "both", "wlst_name": "atp.admin.user", "wlst_path": "WP001", "value": {"default": "None" }, "wlst_type": "string" } ],
88
"atp.default.tablespace": [ {"version": "[10,)", "wlst_mode": "both", "wlst_name": "atp.default.tablespace", "wlst_path": "WP001", "value": {"default": "None" }, "wlst_type": "string" } ],
99
"atp.temp.tablespace": [ {"version": "[10,)", "wlst_mode": "both", "wlst_name": "atp.temp.tablespace", "wlst_path": "WP001", "value": {"default": "None" }, "wlst_type": "string" } ],
10+
"compInfoXMLLocation": [ {"version": "[10,)", "wlst_mode": "both", "wlst_name": "compInfoXMLLocation", "wlst_path": "WP001", "value": {"default": "None" }, "wlst_type": "string", "uses_path_tokens": "true"} ],
1011
"javax.net.ssl.keyStorePassword": [ {"version": "[10,)", "wlst_mode": "both", "wlst_name": "javax.net.ssl.keyStorePassword", "wlst_path": "WP001", "value": {"default": "None" }, "wlst_type": "password" } ],
1112
"javax.net.ssl.trustStorePassword": [ {"version": "[10,)", "wlst_mode": "both", "wlst_name": "javax.net.ssl.trustStorePassword", "wlst_path": "WP001", "value": {"default": "None" }, "wlst_type": "password" } ],
1213
"oracle.net.tns_admin": [ {"version": "[10,)", "wlst_mode": "both", "wlst_name": "oracle.net.tns_admin", "wlst_path": "WP001", "value": {"default": "None" }, "wlst_type": "string" } ],
@@ -16,6 +17,7 @@
1617
"rcu_db_user": [ {"version": "[10,)", "wlst_mode": "both", "wlst_name": "rcu_db_user", "wlst_path": "WP001", "value": {"default": "None" }, "wlst_type": "string" } ],
1718
"rcu_schema_password": [ {"version": "[10,)", "wlst_mode": "both", "wlst_name": "rcu_schema_password", "wlst_path": "WP001", "value": {"default": "None" }, "wlst_type": "password" } ],
1819
"rcu_variables": [ {"version": "[10,)", "wlst_mode": "both", "wlst_name": "rcu_variables", "wlst_path": "WP001", "value": {"default": "None" }, "wlst_type": "string" } ],
20+
"storageXMLLocation": [ {"version": "[10,)", "wlst_mode": "both", "wlst_name": "storageXMLLocation", "wlst_path": "WP001", "value": {"default": "None" }, "wlst_type": "string", "uses_path_tokens": "true"} ],
1921
"tns.alias": [ {"version": "[10,)", "wlst_mode": "both", "wlst_name": "tns.alias", "wlst_path": "WP001", "value": {"default": "None" }, "wlst_type": "string" } ],
2022
"useATP": [ {"version": "[10,)", "wlst_mode": "both", "wlst_name": "useATP", "wlst_path": "WP001", "value": {"default": "None" }, "wlst_type": "boolean" } ]
2123
},

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
@@ -1240,6 +1240,7 @@ WLSDPLY-12256=Attempting to target dynamic cluster {0} to multiple server groups
12401240
WebLogic Server prior to 12.2.1.4 do not support targeting more than one server group to a dynamic cluster.
12411241
WLSDPLY-12257=No server group found for dynamic cluster {0}. Versions of WebLogic Server prior to 12.2.1.4 \
12421242
do not support targeting more than one server group to a dynamic cluster. Server group not defined in domain typedef
1243+
WLSDPLY-12258=RCU {0} file {1} is invalid : {2}
12431244

12441245
# domain_typedef.py
12451246
WLSDPLY-12300={0} got the domain type {1} but the domain type definition file {2} was not valid: {3}

0 commit comments

Comments
 (0)