Skip to content

Commit cc711c3

Browse files
rakillenddsharpe
authored andcommitted
Jira wdt 368 multiple archives (#461)
* JIRA WDT-368 - Fixed typo, removed unused method * JIRA WDT-372 - Fixed typo in method call * JIRA WDT-372 - Removed unused method * JIRA WDT-372 - Enable use of multiple archive files * JIRA WDT-368 - Update usage for archive_file * JIRA WDT-368 - Correction to use OPSS wallet * JIRA WDT-368 - Corrected method name for logging * JIRA WDT-368 - Added multiple archive info to usage in scripts
1 parent 484ee09 commit cc711c3

File tree

17 files changed

+340
-224
lines changed

17 files changed

+340
-224
lines changed

core/src/main/python/create.py

Lines changed: 38 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@
2727

2828
from wlsdeploy.aliases.aliases import Aliases
2929
from wlsdeploy.aliases import model_constants
30+
from wlsdeploy.aliases.model_constants import DEFAULT_WLS_DOMAIN_NAME
31+
from wlsdeploy.aliases.model_constants import DOMAIN_NAME
32+
from wlsdeploy.aliases.model_constants import TOPOLOGY
3033
from wlsdeploy.aliases.wlst_modes import WlstModes
3134
from wlsdeploy.exception import exception_helper
3235
from wlsdeploy.exception.expection_types import ExceptionType
@@ -37,6 +40,7 @@
3740
from wlsdeploy.tool.create.domain_typedef import CREATE_DOMAIN
3841
from wlsdeploy.tool.util import filter_helper
3942
from wlsdeploy.tool.util.alias_helper import AliasHelper
43+
from wlsdeploy.tool.util.archive_helper import ArchiveHelper
4044
from wlsdeploy.tool.validate.validator import Validator
4145
from wlsdeploy.util import cla_helper
4246
from wlsdeploy.util import getcreds
@@ -289,7 +293,6 @@ def __process_opss_args(optional_arg_map):
289293
return
290294

291295

292-
293296
def validate_model(model_dictionary, model_context, aliases):
294297
_method_name = 'validate_model'
295298

@@ -311,7 +314,9 @@ def validate_model(model_dictionary, model_context, aliases):
311314
tool_exit.end(model_context, CommandLineArgUtil.PROG_ERROR_EXIT_CODE)
312315

313316

314-
def validateRCUArgsAndModel(model_context, model, alias_helper):
317+
def validate_rcu_args_and_model(model_context, model, archive_helper, alias_helper):
318+
_method_name = 'validate_rcu_args_and_model'
319+
315320
has_atpdbinfo = 0
316321
domain_info = model[model_constants.DOMAIN_INFO]
317322
if domain_info is not None:
@@ -321,26 +326,20 @@ def validateRCUArgsAndModel(model_context, model, alias_helper):
321326
has_regular_db = rcu_db_info.is_regular_db()
322327
has_atpdbinfo = rcu_db_info.has_atpdbinfo()
323328

324-
if model_context.get_archive_file_name() and not has_regular_db:
329+
if archive_helper and not has_regular_db:
325330
System.setProperty('oracle.jdbc.fanEnabled', 'false')
326331

327332
# 1. If it does not have the oracle.net.tns_admin specified, then extract to domain/atpwallet
328333
# 2. If it is plain old regular oracle db, do nothing
329334
# 3. If it deos not have tns_admin in the model, then the wallet must be in the archive
330335
if not has_tns_admin:
331-
# extract the wallet first
332-
archive_file = WLSDeployArchive(model_context.get_archive_file_name())
333-
atp_wallet_zipentry = None
334-
if archive_file:
335-
atp_wallet_zipentry = archive_file.getATPWallet()
336-
if atp_wallet_zipentry and model[model_constants.TOPOLOGY]['Name']:
337-
extract_path = atp_helper.extract_walletzip(model, model_context, archive_file, atp_wallet_zipentry)
336+
wallet_path = archive_helper.extract_atp_wallet()
337+
if wallet_path:
338338
# update the model to add the tns_admin
339339
model[model_constants.DOMAIN_INFO][model_constants.RCU_DB_INFO][
340-
model_constants.DRIVER_PARAMS_NET_TNS_ADMIN] = extract_path
340+
model_constants.DRIVER_PARAMS_NET_TNS_ADMIN] = wallet_path
341341
else:
342-
__logger.severe('WLSDPLY-12411', error=None,
343-
class_name=_class_name, method_name="validateRCUArgsAndModel")
342+
__logger.severe('WLSDPLY-12411', error=None, class_name=_class_name, method_name=_method_name)
344343
cla_helper.clean_up_temp_files()
345344
tool_exit.end(model_context, CommandLineArgUtil.PROG_ERROR_EXIT_CODE)
346345

@@ -355,6 +354,22 @@ def validateRCUArgsAndModel(model_context, model, alias_helper):
355354
return has_atpdbinfo
356355

357356

357+
def _get_domain_path(model_context, model):
358+
"""
359+
Returns the domain home path.
360+
:param model_context: the model context
361+
:param model: the model
362+
:return: the domain path
363+
"""
364+
domain_parent = model_context.get_domain_parent_dir()
365+
if domain_parent is None:
366+
return model_context.get_domain_home()
367+
elif TOPOLOGY in model and DOMAIN_NAME in model[TOPOLOGY]:
368+
return domain_parent + os.sep + model[TOPOLOGY][DOMAIN_NAME]
369+
else:
370+
return domain_parent + os.sep + DEFAULT_WLS_DOMAIN_NAME
371+
372+
358373
def main(args):
359374
"""
360375
The entry point for the create domain tool.
@@ -419,18 +434,20 @@ def main(args):
419434
if filter_helper.apply_filters(model, "create"):
420435
# if any filters were applied, re-validate the model
421436
validate_model(model, model_context, aliases)
437+
422438
try:
439+
archive_helper = None
440+
archive_file_name = model_context.get_archive_file_name()
441+
if archive_file_name:
442+
domain_path = _get_domain_path(model_context, model)
443+
archive_helper = ArchiveHelper(archive_file_name, domain_path, __logger, ExceptionType.CREATE)
444+
445+
has_atp = validate_rcu_args_and_model(model_context, model, archive_helper, alias_helper)
423446

424-
has_atp = validateRCUArgsAndModel(model_context, model, alias_helper)
425447
# check if there is an atpwallet and extract in the domain dir
426448
# it is to support non JRF domain but user wants to use ATP database
427-
archive_file_name = model_context.get_archive_file_name()
428-
if not has_atp and archive_file_name and os.path.exists(archive_file_name):
429-
archive_file = WLSDeployArchive(archive_file_name)
430-
if archive_file:
431-
atp_wallet_zipentry = archive_file.getATPWallet()
432-
if atp_wallet_zipentry:
433-
atp_helper.extract_walletzip(model, model_context, archive_file, atp_wallet_zipentry)
449+
if not has_atp and archive_helper:
450+
archive_helper.extract_atp_wallet()
434451

435452
creator = DomainCreator(model, model_context, aliases)
436453
creator.create()

core/src/main/python/deploy.py

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -119,27 +119,6 @@ def __verify_required_args_present(required_arg_map):
119119
return
120120

121121

122-
def __validate_archive_file_arg(required_arg_map):
123-
"""
124-
Verify that the archive file exists.
125-
:param required_arg_map: the required arguments map
126-
:return: the archive file name
127-
:raises CLAException: if the archive file is not valid
128-
"""
129-
_method_name = '__validate_archive_file_arg'
130-
131-
archive_file_name = required_arg_map[CommandLineArgUtil.ARCHIVE_FILE_SWITCH]
132-
try:
133-
FileUtils.validateExistingFile(archive_file_name)
134-
except IllegalArgumentException, iae:
135-
ex = exception_helper.create_cla_exception('WLSDPLY-20014', _program_name, archive_file_name,
136-
iae.getLocalizedMessage(), error=iae)
137-
ex.setExitCode(CommandLineArgUtil.ARG_VALIDATION_ERROR_EXIT_CODE)
138-
__logger.throwing(ex, class_name=_class_name, method_name=_method_name)
139-
raise ex
140-
return archive_file_name
141-
142-
143122
def __process_model_args(optional_arg_map):
144123
"""
145124
Determine if the model file was passed separately or requires extraction from the archive.
@@ -221,10 +200,10 @@ def __deploy(model, model_context, aliases):
221200
ret_code = __deploy_online(model, model_context, aliases)
222201
else:
223202
ret_code = __deploy_offline(model, model_context, aliases)
224-
return ret_code =
203+
return ret_code
225204

226205

227-
def __deploy_online(model, model_context, aliases):
206+
def __deploy_online(model, model_context, aliases):
228207
"""
229208
Online deployment orchestration
230209
:param model: the model

core/src/main/python/update.py

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
import sys
99

1010
from java.io import IOException, PrintStream
11-
from java.lang import IllegalArgumentException
1211
from java.lang import String, System
1312

1413
from oracle.weblogic.deploy.deploy import DeployException
@@ -128,27 +127,6 @@ def __verify_required_args_present(required_arg_map):
128127
return
129128

130129

131-
def __validate_archive_file_arg(required_arg_map):
132-
"""
133-
Verify that the archive file exists.
134-
:param required_arg_map: the required arguments map
135-
:return: the archive file name
136-
:raises CLAException: if the archive file is not valid
137-
"""
138-
_method_name = '__validate_archive_file_arg'
139-
140-
archive_file_name = required_arg_map[CommandLineArgUtil.ARCHIVE_FILE_SWITCH]
141-
try:
142-
FileUtils.validateExistingFile(archive_file_name)
143-
except IllegalArgumentException, iae:
144-
ex = exception_helper.create_cla_exception('WLSDPLY-20014', _program_name, archive_file_name,
145-
iae.getLocalizedMessage(), error=iae)
146-
ex.setExitCode(CommandLineArgUtil.ARG_VALIDATION_ERROR_EXIT_CODE)
147-
__logger.throwing(ex, class_name=_class_name, method_name=_method_name)
148-
raise ex
149-
return archive_file_name
150-
151-
152130
def __process_model_args(optional_arg_map):
153131
"""
154132
Determine if the model file was passed separately or requires extraction from the archive.

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

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,7 @@
44
55
66
"""
7-
8-
import os
97
import re
10-
from java.io import File
11-
from oracle.weblogic.deploy.util import FileUtils
12-
from wlsdeploy.aliases import model_constants
138
from xml.dom.minidom import parse
149

1510

@@ -117,18 +112,3 @@ def format_connect_string(connect_string):
117112
connect_string = "%s%s%s%s" % (part1, part2, part3, part4)
118113

119114
return connect_string
120-
121-
122-
def extract_walletzip(model, model_context, archive_file, atp_zipentry):
123-
domain_parent = model_context.get_domain_parent_dir()
124-
if domain_parent is None:
125-
domain_path = model_context.get_domain_home()
126-
else:
127-
domain_path = domain_parent + os.sep + model[model_constants.TOPOLOGY][
128-
'Name']
129-
extract_path = domain_path + os.sep + 'atpwallet'
130-
extract_dir = File(extract_path)
131-
extract_dir.mkdirs()
132-
FileUtils.extractZipFileContent(archive_file, atp_zipentry, extract_path)
133-
return extract_path
134-
# update the model to add the tns_admin

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ def _extract_archive_files(self, location, model_name, model_value):
366366
self.files_to_extract_from_archive.append(model_path)
367367
else:
368368
path = self.alias_helper.get_model_folder_path(location)
369-
archive_file_name = self.model_context.get_archive_file_name
369+
archive_file_name = self.model_context.get_archive_file_name()
370370
ex = exception_helper.create_create_exception('WLSDPLY-12121', model_name, path,
371371
model_path, archive_file_name)
372372
self.logger.throwing(ex, class_name=self.__class_name, method_name=_method_name)

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

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1172,11 +1172,8 @@ def __configure_opss_secrets(self):
11721172
domain_info = self._domain_info
11731173
if OPSS_SECRETS in domain_info:
11741174
opss_secret_password = domain_info[OPSS_SECRETS]
1175-
if self.model_context.get_archive_file_name() and opss_secret_password:
1176-
archive_file = WLSDeployArchive(self.model_context.get_archive_file_name())
1177-
extract_path = self._domain_home + os.sep + 'opsswallet'
1178-
zip_entry = archive_file.getOPSSWallet();
1179-
FileUtils.extractZipFileContent(archive_file, zip_entry, extract_path)
1175+
if self.archive_helper and opss_secret_password:
1176+
extract_path = self.archive_helper.extract_opss_wallet()
11801177
self.wlst_helper.setSharedSecretStoreWithPassword(extract_path, opss_secret_password)
11811178
else:
11821179
opss_secret_password = self.model_context.get_opss_wallet_passphrase()

0 commit comments

Comments
 (0)