Skip to content

Commit 46b1edc

Browse files
authored
#565 RCU alternate user (#653)
* support different db user
1 parent 67178da commit 46b1edc

File tree

13 files changed

+71
-4
lines changed

13 files changed

+71
-4
lines changed

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

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ public class RCURunner {
7676
private boolean ATP_DB = false;
7777
private String atpSSlArgs = null;
7878
private String atpAdminUser = null;
79+
private String rcuAdminUser = DB_USER;
7980
private String atpDefaultTablespace = null;
8081
private String atpTemporaryTablespace = null;
8182
private String rcuVariables = null;
@@ -263,7 +264,7 @@ private String[] getRcuDropArgs() {
263264

264265
} else {
265266
dropArgs.add(DB_USER_SWITCH);
266-
dropArgs.add(DB_USER);
267+
dropArgs.add(getRCUAdminUser());
267268
dropArgs.add(DB_ROLE_SWITCH);
268269
dropArgs.add(DB_ROLE);
269270
}
@@ -305,7 +306,7 @@ private String[] getRcuCreateArgs() {
305306
createArgs.add(atpSSlArgs);
306307
} else {
307308
createArgs.add(DB_USER_SWITCH);
308-
createArgs.add(DB_USER);
309+
createArgs.add(getRCUAdminUser());
309310
createArgs.add(DB_ROLE_SWITCH);
310311
createArgs.add(DB_ROLE);
311312
}
@@ -362,6 +363,14 @@ private int getExtraRcuSchemaPasswordCount(RcuOpType rcuOpType) {
362363
return result;
363364
}
364365

366+
public void setRCUAdminUser(String rcuDBUser) {
367+
rcuAdminUser = rcuDBUser;
368+
}
369+
370+
public String getRCUAdminUser() {
371+
return rcuAdminUser;
372+
}
373+
365374
private static boolean isSchemaNotExistError(ScriptRunner runner) {
366375
List<String> stdoutBuffer = runner.getStdoutBuffer();
367376
boolean schemaDoesNotExist = false;

core/src/main/python/create.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@
6969
CommandLineArgUtil.RUN_RCU_SWITCH,
7070
CommandLineArgUtil.RCU_SYS_PASS_SWITCH,
7171
CommandLineArgUtil.RCU_DB_SWITCH,
72+
CommandLineArgUtil.RCU_DB_USER_SWITCH,
7273
CommandLineArgUtil.RCU_PREFIX_SWITCH,
7374
CommandLineArgUtil.RCU_SCHEMA_PASS_SWITCH,
7475
CommandLineArgUtil.VARIABLE_FILE_SWITCH,

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
RCU_PREFIX = 'rcu_prefix'
2929
RCU_SCHEMA_PASSWORD = 'rcu_schema_password'
3030
RCU_ADMIN_PASSWORD = 'rcu_admin_password'
31+
RCU_DB_USER = 'rcu_db_user'
3132
RCU_DB_CONN = 'rcu_db_conn_string'
3233
RCU_VARIABLES = 'rcu_variables'
3334
USE_ATP = 'useATP'

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,22 +283,28 @@ def __run_rcu(self):
283283
rcu_db_info.get_rcu_variables())
284284
runner.runRcu(rcu_sys_pass, rcu_schema_pass)
285285
else:
286+
# Has RCUDbInfo in the model but non ATP case
286287
rcu_db = rcu_db_info.get_rcu_regular_db_conn()
287288
rcu_prefix = rcu_db_info.get_rcu_prefix()
288289
rcu_sys_pass = rcu_db_info.get_admin_password()
289290
rcu_schema_pass = rcu_db_info.get_rcu_schema_password()
291+
rcu_db_user = rcu_db_info.get_rcu_db_user()
290292
self.__validate_rcudbinfo_entries(rcu_properties_map, [RCU_PREFIX, RCU_SCHEMA_PASSWORD,
291293
RCU_ADMIN_PASSWORD, RCU_DB_CONN])
292294
runner = RCURunner(domain_type, oracle_home, java_home, rcu_db, rcu_prefix, rcu_schemas,
293295
rcu_db_info.get_rcu_variables())
296+
runner.setRCUAdminUser(rcu_db_user)
294297
runner.runRcu(rcu_sys_pass, rcu_schema_pass)
295298
else:
299+
# No RCUDbInfo in the model. CLI case
296300
rcu_db = self.model_context.get_rcu_database()
297301
rcu_prefix = self.model_context.get_rcu_prefix()
298302
rcu_sys_pass = self.model_context.get_rcu_sys_pass()
299303
rcu_schema_pass = self.model_context.get_rcu_schema_pass()
304+
rcu_db_user = self.model_context.get_rcu_db_user()
300305

301306
runner = RCURunner(domain_type, oracle_home, java_home, rcu_db, rcu_prefix, rcu_schemas, None)
307+
runner.setRCUAdminUser(rcu_db_user)
302308
runner.runRcu(rcu_sys_pass, rcu_schema_pass)
303309

304310
self.logger.exiting(class_name=self.__class_name, method_name=_method_name)

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
from wlsdeploy.aliases.model_constants import RCU_DB_CONN
1515
from wlsdeploy.aliases.model_constants import RCU_PREFIX
1616
from wlsdeploy.aliases.model_constants import RCU_SCHEMA_PASSWORD
17+
from wlsdeploy.aliases.model_constants import RCU_DB_USER
1718
from wlsdeploy.aliases.model_constants import RCU_VARIABLES
1819
from wlsdeploy.aliases.model_constants import USE_ATP
1920

@@ -75,6 +76,12 @@ def get_atp_admin_user(self):
7576
else:
7677
return 'admin'
7778

79+
def get_rcu_db_user(self):
80+
if RCU_DB_USER in self.rcu_properties_map:
81+
return self.rcu_properties_map[RCU_DB_USER]
82+
else:
83+
return 'SYS'
84+
7885
def get_rcu_variables(self):
7986
if RCU_VARIABLES in self.rcu_properties_map:
8087
return self.rcu_properties_map[RCU_VARIABLES]

core/src/main/python/wlsdeploy/util/cla_utils.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ class CommandLineArgUtil(object):
4949
PREVIOUS_MODEL_FILE_SWITCH = '-prev_model_file'
5050
VARIABLE_FILE_SWITCH = '-variable_file'
5151
RCU_DB_SWITCH = '-rcu_db'
52+
RCU_DB_USER_SWITCH = '-rcu_db_user'
5253
RCU_PREFIX_SWITCH = '-rcu_prefix'
5354
# phony arg used as a key to store the password
5455
RCU_SYS_PASS_SWITCH = '-rcu_sys_pass'
@@ -247,6 +248,10 @@ def process_args(self, args, tool_type=TOOL_TYPE_DEFAULT, trailing_arg_count=0):
247248
value, idx = self._get_arg_value(args, idx)
248249
self._validate_rcu_database_arg(value)
249250
self._add_arg(key, value)
251+
elif self.is_rcu_dbuser_key(key):
252+
value, idx = self._get_arg_value(args, idx)
253+
self._validate_rcu_dbuser_arg(value)
254+
self._add_arg(key, value)
250255
elif self.is_rcu_prefix_key(key):
251256
value, idx = self._get_arg_value(args, idx)
252257
self._validate_rcu_prefix_arg(value)
@@ -803,6 +808,21 @@ def _validate_rcu_database_arg(self, value):
803808
raise ex
804809
return
805810

811+
def get_rcu_dbuser_key(self):
812+
return self.RCU_DB_USER_SWITCH
813+
814+
def is_rcu_dbuser_key(self, key):
815+
return self.RCU_DB_USER_SWITCH == key
816+
817+
def _validate_rcu_dbuser_arg(self, value):
818+
method_name = '_validate_rcu_dbuser_arg'
819+
if value is None or len(value) == 0:
820+
ex = exception_helper.create_cla_exception('WLSDPLY-01622')
821+
ex.setExitCode(self.ARG_VALIDATION_ERROR_EXIT_CODE)
822+
self._logger.throwing(ex, class_name=self._class_name, method_name=method_name)
823+
raise ex
824+
return
825+
806826
def get_rcu_prefix_key(self):
807827
return self.RCU_PREFIX_SWITCH
808828

core/src/main/python/wlsdeploy/util/model_context.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ def __init__(self, program_name, arg_map):
8383
self._variable_injector_file = None
8484
self._variable_keywords_file = None
8585
self._variable_properties_file = None
86+
self._rcu_db_user = 'SYS'
8687

8788
self._trailing_args = []
8889

@@ -148,6 +149,9 @@ def __init__(self, program_name, arg_map):
148149
if CommandLineArgUtil.RCU_SYS_PASS_SWITCH in arg_map:
149150
self._rcu_sys_pass = arg_map[CommandLineArgUtil.RCU_SYS_PASS_SWITCH]
150151

152+
if CommandLineArgUtil.RCU_DB_USER_SWITCH in arg_map:
153+
self._rcu_db_user = arg_map[CommandLineArgUtil.RCU_DB_USER_SWITCH]
154+
151155
if CommandLineArgUtil.RCU_SCHEMA_PASS_SWITCH in arg_map:
152156
self._rcu_schema_pass = arg_map[CommandLineArgUtil.RCU_SCHEMA_PASS_SWITCH]
153157

@@ -452,6 +456,13 @@ def get_rcu_prefix(self):
452456
"""
453457
return self._rcu_prefix
454458

459+
def get_rcu_db_user(self):
460+
"""
461+
Get the RCU DB user.
462+
:return: the RCU dbUser
463+
"""
464+
return self._rcu_db_user
465+
455466
def get_rcu_sys_pass(self):
456467
"""
457468
Get the RCU database SYS user password.

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
"rcu_admin_password": [ {"version": "[10,)", "wlst_mode": "both", "wlst_name": "rcu_admin_password", "wlst_path": "WP001", "value": {"default": "None" }, "wlst_type": "password" } ],
1414
"rcu_db_conn_string": [ {"version": "[10,)", "wlst_mode": "both", "wlst_name": "rcu_db_conn_string", "wlst_path": "WP001", "value": {"default": "None" }, "wlst_type": "string" } ],
1515
"rcu_prefix": [ {"version": "[10,)", "wlst_mode": "both", "wlst_name": "rcu_prefix", "wlst_path": "WP001", "value": {"default": "None" }, "wlst_type": "string" } ],
16+
"rcu_db_user": [ {"version": "[10,)", "wlst_mode": "both", "wlst_name": "rcu_db_user", "wlst_path": "WP001", "value": {"default": "None" }, "wlst_type": "string" } ],
1617
"rcu_schema_password": [ {"version": "[10,)", "wlst_mode": "both", "wlst_name": "rcu_schema_password", "wlst_path": "WP001", "value": {"default": "None" }, "wlst_type": "password" } ],
1718
"rcu_variables": [ {"version": "[10,)", "wlst_mode": "both", "wlst_name": "rcu_variables", "wlst_path": "WP001", "value": {"default": "None" }, "wlst_type": "string" } ],
1819
"tns.alias": [ {"version": "[10,)", "wlst_mode": "both", "wlst_name": "tns.alias", "wlst_path": "WP001", "value": {"default": "None" }, "wlst_type": "string" } ],

installer/src/main/bin/createDomain.cmd

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ ECHO [-variable_file ^<variable_file^>]
8282
ECHO [-wlst_path ^<wlst_path^>]
8383
ECHO [-rcu_db ^<rcu_database^>
8484
ECHO -rcu_prefix ^<rcu_prefix^>
85+
ECHO -rcu_db_user ^<rcu_db_user^>
8586
ECHO ]
8687
ECHO.
8788
ECHO where:
@@ -128,6 +129,9 @@ ECHO.
128129
ECHO rcu_prefix - the RCU prefix to use (if the domain type requires
129130
ECHO RCU).
130131
ECHO.
132+
ECHO rcu_db_user - the RCU dbUser to use (if the domain type requires
133+
ECHO RCU. Default SYS if not specified). This user must have SYSDBA privilege
134+
ECHO.
131135
ECHO The -use_encryption switch tells the program that one or more of the
132136
ECHO passwords in the model or variables files are encrypted. The program will
133137
ECHO prompt for the decryption passphrase to use to decrypt the passwords.

installer/src/main/bin/createDomain.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ usage() {
4343
echo " [-wlst_path <wlst_path>]"
4444
echo " [-rcu_db <rcu_database>"
4545
echo " -rcu_prefix <rcu_prefix>"
46+
echo " -rcu_db_user <rcu dbUser>"
4647
echo " ]"
4748
echo ""
4849
echo " where:"
@@ -89,6 +90,9 @@ usage() {
8990
echo " rcu_prefix - the RCU prefix to use (if the domain type requires"
9091
echo " RCU)."
9192
echo ""
93+
echo " rcu_db_user - the RCU dbUser to use (if the domain type requires"
94+
echo " RCU. Default SYS if not specified). This user must have SYSDBA privilege"
95+
echo ""
9296
echo " The -use_encryption switch tells the program that one or more of the"
9397
echo " passwords in the model or variables files are encrypted. The program will"
9498
echo " prompt for the decryption passphrase to use to decrypt the passwords."

0 commit comments

Comments
 (0)