Skip to content

Commit 1b3d8e3

Browse files
committed
add support to generalize taking db connect info from model
1 parent d3dbf8b commit 1b3d8e3

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
@@ -278,15 +277,15 @@ def __process_rcu_args(optional_arg_map, domain_type, domain_typedef):
278277
ex.setExitCode(CommandLineArgUtil.USAGE_ERROR_EXIT_CODE)
279278
__logger.throwing(ex, class_name=_class_name, method_name=_method_name)
280279
raise ex
281-
elif CommandLineArgUtil.ATP_PROPERTIES_FILE_SWITCH in optional_arg_map:
282-
pass
283-
else:
284-
ex = exception_helper.create_cla_exception('WLSDPLY-12408', domain_type, rcu_schema_count,
285-
CommandLineArgUtil.RCU_DB_SWITCH,
286-
CommandLineArgUtil.RCU_PREFIX_SWITCH)
287-
ex.setExitCode(CommandLineArgUtil.USAGE_ERROR_EXIT_CODE)
288-
__logger.throwing(ex, class_name=_class_name, method_name=_method_name)
289-
raise ex
280+
# elif CommandLineArgUtil.ATP_PROPERTIES_FILE_SWITCH in optional_arg_map:
281+
# pass
282+
# else:
283+
# ex = exception_helper.create_cla_exception('WLSDPLY-12408', domain_type, rcu_schema_count,
284+
# CommandLineArgUtil.RCU_DB_SWITCH,
285+
# CommandLineArgUtil.RCU_PREFIX_SWITCH)
286+
# ex.setExitCode(CommandLineArgUtil.USAGE_ERROR_EXIT_CODE)
287+
# __logger.throwing(ex, class_name=_class_name, method_name=_method_name)
288+
# raise ex
290289
return
291290

292291

@@ -414,6 +413,51 @@ def unzip_atp_wallet(wallet_file, location):
414413
fis.close()
415414

416415

416+
def validateRCUArgsAndModel(model_context, model):
417+
has_atp = 0
418+
if model_constants.RCU_DB_INFO in model[model_constants.DOMAIN_INFO]:
419+
# extract the wallet first
420+
has_atp = 1
421+
has_tns_admin = model_constants.DRIVER_PARAMS_NET_TNS_ADMIN in model[model_constants.DOMAIN_INFO][
422+
model_constants.RCU_DB_INFO]
423+
if model_context.get_archive_file_name():
424+
# if it does not have the oracle.net.tns_admin specified, then extract to
425+
if not has_tns_admin:
426+
archive_file = WLSDeployArchive(model_context.get_archive_file_name())
427+
atp_path = archive_file.getATPWallet()
428+
if atp_path and model[model_constants.TOPOLOGY]['Name']:
429+
domain_path = model_context.get_domain_parent_dir() + os.sep + model[model_constants.TOPOLOGY][
430+
'Name']
431+
extract_path = domain_path + os.sep + 'atpwallet'
432+
extract_dir = File(extract_path)
433+
extract_dir.mkdirs()
434+
wallet_zip = archive_file.extractFile(atp_path, File(domain_path))
435+
unzip_atp_wallet(wallet_zip, extract_path)
436+
os.remove(wallet_zip)
437+
# update the model to add the tns_admin
438+
model[model_constants.DOMAIN_INFO][model_constants.RCU_DB_INFO][
439+
model_constants.DRIVER_PARAMS_NET_TNS_ADMIN] = extract_path
440+
else:
441+
__logger.severe('WLSDPLY-12411', error=None,
442+
class_name=_class_name, method_name="validateRCUArgsAndModel")
443+
__clean_up_temp_files()
444+
tool_exit.end(model_context, CommandLineArgUtil.PROG_ERROR_EXIT_CODE)
445+
elif not has_tns_admin:
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+
451+
if not has_atp and model_context.get_domain_type() not in ['WLS', 'RestrictedJRF']:
452+
if not model_context.get_rcu_database() or not model_context.get_rcu_prefix():
453+
__logger.severe('WLSDPLY-12408', model_context.get_domain_type(), CommandLineArgUtil.RCU_DB_SWITCH,
454+
CommandLineArgUtil.RCU_PREFIX_SWITCH)
455+
__clean_up_temp_files()
456+
tool_exit.end(model_context, CommandLineArgUtil.PROG_ERROR_EXIT_CODE)
457+
458+
return has_atp
459+
460+
417461
def main(args):
418462
"""
419463
The entry point for the create domain tool.
@@ -442,10 +486,8 @@ def main(args):
442486
model_file = model_context.get_model_file()
443487
try:
444488
model = FileToPython(model_file, True).parse()
445-
if model_context.get_atp_properties_file():
446-
os.environ['oracle.net.fanEnabled'] = 'false'
447-
unzip_atp_wallet(model_context.get_atp_properties_file(), model[model_constants.DOMAIN_INFO][
448-
model_constants.ATP_DB_INFO][model_constants.DRIVER_PARAMS_NET_TNS_ADMIN])
489+
# if model_context.get_archive_file():
490+
# os.environ['oracle.net.fanEnabled'] = 'false'
449491
except TranslateException, te:
450492
__logger.severe('WLSDPLY-20009', _program_name, model_file, te.getLocalizedMessage(), error=te,
451493
class_name=_class_name, method_name=_method_name)
@@ -471,17 +513,19 @@ def main(args):
471513
validate_model(model, model_context, aliases)
472514

473515
try:
516+
517+
has_atp = validateRCUArgsAndModel(model_context, model)
474518
creator = DomainCreator(model, model_context, aliases)
475519
creator.create()
476520

477-
if model_context.get_atp_properties_file():
521+
if has_atp:
478522
#print model[model_constants.DOMAIN_INFO][model_constants.ATP_DB_INFO]
479-
tns_admin = model[model_constants.DOMAIN_INFO][model_constants.ATP_DB_INFO][
523+
tns_admin = model[model_constants.DOMAIN_INFO][model_constants.RCU_DB_INFO][
480524
model_constants.DRIVER_PARAMS_NET_TNS_ADMIN]
481-
keystore_password = model[model_constants.DOMAIN_INFO][model_constants.ATP_DB_INFO][
525+
keystore_password = model[model_constants.DOMAIN_INFO][model_constants.RCU_DB_INFO][
482526
model_constants.DRIVER_PARAMS_KEYSTOREPWD_PROPERTY]
483527

484-
truststore_password = model[model_constants.DOMAIN_INFO][model_constants.ATP_DB_INFO][
528+
truststore_password = model[model_constants.DOMAIN_INFO][model_constants.RCU_DB_INFO][
485529
model_constants.DRIVER_PARAMS_TRUSTSTOREPWD_PROPERTY]
486530

487531
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)