Skip to content

Commit 7145c03

Browse files
jshum2479Johnny
authored andcommitted
add support to generalize taking db connect info from model
1 parent 3767e46 commit 7145c03

File tree

7 files changed

+205
-119
lines changed

7 files changed

+205
-119
lines changed

core/src/main/java/oracle/weblogic/deploy/util/WLSDeployArchive.java

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,12 @@ public class WLSDeployArchive {
2828

2929
public static final String WLSDPLY_ARCHIVE_BINARY_DIR = "wlsdeploy";
3030

31+
32+
/**
33+
* Top-level archive subdirectory where the atp wallet is stored
34+
*/
35+
public static final String ARCHIVE_ATP_WALLET_PATH = "atpwallet";
36+
3137
/**
3238
* Top-level archive subdirectory where the model is stored and the subdirectory to which it will be extracted.
3339
*/
@@ -39,6 +45,7 @@ public class WLSDeployArchive {
3945
*/
4046
public static final String ARCHIVE_APPS_TARGET_DIR = WLSDPLY_ARCHIVE_BINARY_DIR + "/applications";
4147

48+
4249
/**
4350
* Top-level archive subdirectory where the shared libraries are stored and the subdirectory to
4451
* which they will be extracted.
@@ -129,7 +136,8 @@ public static boolean isPathIntoArchive(String path) {
129136
LOGGER.entering(CLASS, METHOD, path);
130137
boolean result = false;
131138
if (!StringUtils.isEmpty(path)) {
132-
result = path.startsWith(WLSDPLY_ARCHIVE_BINARY_DIR + ZIP_SEP);
139+
result =
140+
path.startsWith(WLSDPLY_ARCHIVE_BINARY_DIR + ZIP_SEP) || path.startsWith(ARCHIVE_ATP_WALLET_PATH + ZIP_SEP);
133141
}
134142
LOGGER.exiting(CLASS, METHOD, result);
135143
return result;
@@ -362,7 +370,6 @@ public String extractFile(String path, File extractToLocation) throws WLSDeployA
362370
public String extractFile(String path, File extractToLocation, boolean stripLeadingPathDirectories)
363371
throws WLSDeployArchiveIOException {
364372
final String METHOD = "extractFile";
365-
366373
LOGGER.entering(CLASS, METHOD, path, extractToLocation, stripLeadingPathDirectories);
367374
validateNonEmptyString(path, "path", METHOD);
368375
validateExistingDirectory(extractToLocation, "extractToLocation", getArchiveFileName(), METHOD);
@@ -504,6 +511,25 @@ public List<String> listApplications() throws WLSDeployArchiveIOException {
504511
return result;
505512
}
506513

514+
/**
515+
* Get the path of the ATP wallet in the archive.
516+
*
517+
* @return path of the ATP wallet
518+
* @throws WLSDeployArchiveIOException if an error occurs reading the archive
519+
*/
520+
public String getATPWallet() throws WLSDeployArchiveIOException {
521+
final String METHOD = "getATPWallet";
522+
523+
LOGGER.entering(CLASS, METHOD);
524+
List<String> result = getZipFile().listZipEntries(ARCHIVE_ATP_WALLET_PATH + ZIP_SEP);
525+
LOGGER.exiting(CLASS, METHOD, result);
526+
if (result.size()>0) {
527+
return result.get(0);
528+
} else {
529+
return null;
530+
}
531+
}
532+
507533
/**
508534
* Extract the specified application from the archive to the domain home directory.
509535
*

core/src/main/python/create.py

Lines changed: 63 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,12 @@
1414
from java.lang import IllegalStateException
1515
from java.lang import String
1616
from java.io import File
17+
from java.nio.file import Files
1718
from java.io import FileInputStream
1819
from java.io import FileOutputStream
1920
from java.util.zip import ZipInputStream
2021
import jarray
2122

22-
23-
2423
from oracle.weblogic.deploy.create import CreateException
2524
from oracle.weblogic.deploy.deploy import DeployException
2625
from oracle.weblogic.deploy.util import CLAException
@@ -283,15 +282,15 @@ def __process_rcu_args(optional_arg_map, domain_type, domain_typedef):
283282
ex.setExitCode(CommandLineArgUtil.USAGE_ERROR_EXIT_CODE)
284283
__logger.throwing(ex, class_name=_class_name, method_name=_method_name)
285284
raise ex
286-
elif CommandLineArgUtil.ATP_PROPERTIES_FILE_SWITCH in optional_arg_map:
287-
pass
288-
else:
289-
ex = exception_helper.create_cla_exception('WLSDPLY-12408', domain_type, rcu_schema_count,
290-
CommandLineArgUtil.RCU_DB_SWITCH,
291-
CommandLineArgUtil.RCU_PREFIX_SWITCH)
292-
ex.setExitCode(CommandLineArgUtil.USAGE_ERROR_EXIT_CODE)
293-
__logger.throwing(ex, class_name=_class_name, method_name=_method_name)
294-
raise ex
285+
# elif CommandLineArgUtil.ATP_PROPERTIES_FILE_SWITCH in optional_arg_map:
286+
# pass
287+
# else:
288+
# ex = exception_helper.create_cla_exception('WLSDPLY-12408', domain_type, rcu_schema_count,
289+
# CommandLineArgUtil.RCU_DB_SWITCH,
290+
# CommandLineArgUtil.RCU_PREFIX_SWITCH)
291+
# ex.setExitCode(CommandLineArgUtil.USAGE_ERROR_EXIT_CODE)
292+
# __logger.throwing(ex, class_name=_class_name, method_name=_method_name)
293+
# raise ex
295294
return
296295

297296

@@ -419,6 +418,51 @@ def unzip_atp_wallet(wallet_file, location):
419418
fis.close()
420419

421420

421+
def validateRCUArgsAndModel(model_context, model):
422+
has_atp = 0
423+
if model_constants.RCU_DB_INFO in model[model_constants.DOMAIN_INFO]:
424+
# extract the wallet first
425+
has_atp = 1
426+
has_tns_admin = model_constants.DRIVER_PARAMS_NET_TNS_ADMIN in model[model_constants.DOMAIN_INFO][
427+
model_constants.RCU_DB_INFO]
428+
if model_context.get_archive_file_name():
429+
# if it does not have the oracle.net.tns_admin specified, then extract to
430+
if not has_tns_admin:
431+
archive_file = WLSDeployArchive(model_context.get_archive_file_name())
432+
atp_path = archive_file.getATPWallet()
433+
if atp_path and model[model_constants.TOPOLOGY]['Name']:
434+
domain_path = model_context.get_domain_parent_dir() + os.sep + model[model_constants.TOPOLOGY][
435+
'Name']
436+
extract_path = domain_path + os.sep + 'atpwallet'
437+
extract_dir = File(extract_path)
438+
extract_dir.mkdirs()
439+
wallet_zip = archive_file.extractFile(atp_path, File(domain_path))
440+
unzip_atp_wallet(wallet_zip, extract_path)
441+
os.remove(wallet_zip)
442+
# update the model to add the tns_admin
443+
model[model_constants.DOMAIN_INFO][model_constants.RCU_DB_INFO][
444+
model_constants.DRIVER_PARAMS_NET_TNS_ADMIN] = extract_path
445+
else:
446+
__logger.severe('WLSDPLY-12411', error=None,
447+
class_name=_class_name, method_name="validateRCUArgsAndModel")
448+
__clean_up_temp_files()
449+
tool_exit.end(model_context, CommandLineArgUtil.PROG_ERROR_EXIT_CODE)
450+
elif not has_tns_admin:
451+
__logger.severe('WLSDPLY-12411', error=None,
452+
class_name=_class_name, method_name="validateRCUArgsAndModel")
453+
__clean_up_temp_files()
454+
tool_exit.end(model_context, CommandLineArgUtil.PROG_ERROR_EXIT_CODE)
455+
456+
if not has_atp and model_context.get_domain_type() not in ['WLS', 'RestrictedJRF']:
457+
if not model_context.get_rcu_database() or not model_context.get_rcu_prefix():
458+
__logger.severe('WLSDPLY-12408', model_context.get_domain_type(), CommandLineArgUtil.RCU_DB_SWITCH,
459+
CommandLineArgUtil.RCU_PREFIX_SWITCH)
460+
__clean_up_temp_files()
461+
tool_exit.end(model_context, CommandLineArgUtil.PROG_ERROR_EXIT_CODE)
462+
463+
return has_atp
464+
465+
422466
def main(args):
423467
"""
424468
The entry point for the create domain tool.
@@ -447,10 +491,8 @@ def main(args):
447491
model_file = model_context.get_model_file()
448492
try:
449493
model = FileToPython(model_file, True).parse()
450-
if model_context.get_atp_properties_file():
451-
os.environ['oracle.net.fanEnabled'] = 'false'
452-
unzip_atp_wallet(model_context.get_atp_properties_file(), model[model_constants.DOMAIN_INFO][
453-
model_constants.ATP_DB_INFO][model_constants.DRIVER_PARAMS_NET_TNS_ADMIN])
494+
# if model_context.get_archive_file():
495+
# os.environ['oracle.net.fanEnabled'] = 'false'
454496
except TranslateException, te:
455497
__logger.severe('WLSDPLY-20009', _program_name, model_file, te.getLocalizedMessage(), error=te,
456498
class_name=_class_name, method_name=_method_name)
@@ -476,17 +518,19 @@ def main(args):
476518
validate_model(model, model_context, aliases)
477519

478520
try:
521+
522+
has_atp = validateRCUArgsAndModel(model_context, model)
479523
creator = DomainCreator(model, model_context, aliases)
480524
creator.create()
481525

482-
if model_context.get_atp_properties_file():
526+
if has_atp:
483527
#print model[model_constants.DOMAIN_INFO][model_constants.ATP_DB_INFO]
484-
tns_admin = model[model_constants.DOMAIN_INFO][model_constants.ATP_DB_INFO][
528+
tns_admin = model[model_constants.DOMAIN_INFO][model_constants.RCU_DB_INFO][
485529
model_constants.DRIVER_PARAMS_NET_TNS_ADMIN]
486-
keystore_password = model[model_constants.DOMAIN_INFO][model_constants.ATP_DB_INFO][
530+
keystore_password = model[model_constants.DOMAIN_INFO][model_constants.RCU_DB_INFO][
487531
model_constants.DRIVER_PARAMS_KEYSTOREPWD_PROPERTY]
488532

489-
truststore_password = model[model_constants.DOMAIN_INFO][model_constants.ATP_DB_INFO][
533+
truststore_password = model[model_constants.DOMAIN_INFO][model_constants.RCU_DB_INFO][
490534
model_constants.DRIVER_PARAMS_TRUSTSTOREPWD_PROPERTY]
491535

492536
jsp_config = model_context.get_domain_home() + '/config/fmwconfig/jps-config.xml'

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ class AliasEntries(object):
179179
# the ServerGroup is not listed in this map, it will be targeted to all managed
180180
# servers in the domain.
181181
'ServerGroupTargetingLimits': 'dict',
182-
'ATPDbInfo' : 'dict'
182+
'RCUDbInfo' : 'dict'
183183
}
184184

185185
__domain_name_token = 'DOMAIN'

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

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,12 @@
1717
APP_DEPLOYMENTS = 'appDeployments'
1818
APP_DIR = 'AppDir'
1919
APPLICATION = 'Application'
20-
ATP_DB_INFO = 'ATPDbInfo'
21-
ATP_RCU_PREFIX='rcu_prefix'
22-
ATP_RCU_SCHEMA_PASSWORD='rcu_schema_password'
23-
ATP_ADMIN_PASSWORD='rcu_admin_password'
24-
ATP_TNS_ENTRY='tns.entry'
20+
RCU_DB_INFO = 'RCUDbInfo'
21+
RCU_PREFIX= 'rcu_prefix'
22+
RCU_SCHEMA_PASSWORD= 'rcu_schema_password'
23+
RCU_ADMIN_PASSWORD = 'rcu_admin_password'
24+
RCU_DB_CONN = 'rcu_db_conn_string'
25+
ATP_TNS_ENTRY = 'tns.entry'
2526

2627
AUDITOR = 'Auditor'
2728
AUTHENTICATION_PROVIDER = 'AuthenticationProvider'

0 commit comments

Comments
 (0)