Skip to content

Jira wdt 368 multiple archives #461

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Oct 18, 2019
Merged
59 changes: 38 additions & 21 deletions core/src/main/python/create.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@

from wlsdeploy.aliases.aliases import Aliases
from wlsdeploy.aliases import model_constants
from wlsdeploy.aliases.model_constants import DEFAULT_WLS_DOMAIN_NAME
from wlsdeploy.aliases.model_constants import DOMAIN_NAME
from wlsdeploy.aliases.model_constants import TOPOLOGY
from wlsdeploy.aliases.wlst_modes import WlstModes
from wlsdeploy.exception import exception_helper
from wlsdeploy.exception.expection_types import ExceptionType
Expand All @@ -37,6 +40,7 @@
from wlsdeploy.tool.create.domain_typedef import CREATE_DOMAIN
from wlsdeploy.tool.util import filter_helper
from wlsdeploy.tool.util.alias_helper import AliasHelper
from wlsdeploy.tool.util.archive_helper import ArchiveHelper
from wlsdeploy.tool.validate.validator import Validator
from wlsdeploy.util import cla_helper
from wlsdeploy.util import getcreds
Expand Down Expand Up @@ -289,7 +293,6 @@ def __process_opss_args(optional_arg_map):
return



def validate_model(model_dictionary, model_context, aliases):
_method_name = 'validate_model'

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


def validateRCUArgsAndModel(model_context, model, alias_helper):
def validate_rcu_args_and_model(model_context, model, archive_helper, alias_helper):
_method_name = 'validate_rcu_args_and_model'

has_atpdbinfo = 0
domain_info = model[model_constants.DOMAIN_INFO]
if domain_info is not None:
Expand All @@ -321,26 +326,20 @@ def validateRCUArgsAndModel(model_context, model, alias_helper):
has_regular_db = rcu_db_info.is_regular_db()
has_atpdbinfo = rcu_db_info.has_atpdbinfo()

if model_context.get_archive_file_name() and not has_regular_db:
if archive_helper and not has_regular_db:
System.setProperty('oracle.jdbc.fanEnabled', 'false')

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

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


def _get_domain_path(model_context, model):
"""
Returns the domain home path.
:param model_context: the model context
:param model: the model
:return: the domain path
"""
domain_parent = model_context.get_domain_parent_dir()
if domain_parent is None:
return model_context.get_domain_home()
elif TOPOLOGY in model and DOMAIN_NAME in model[TOPOLOGY]:
return domain_parent + os.sep + model[TOPOLOGY][DOMAIN_NAME]
else:
return domain_parent + os.sep + DEFAULT_WLS_DOMAIN_NAME


def main(args):
"""
The entry point for the create domain tool.
Expand Down Expand Up @@ -419,18 +434,20 @@ def main(args):
if filter_helper.apply_filters(model, "create"):
# if any filters were applied, re-validate the model
validate_model(model, model_context, aliases)

try:
archive_helper = None
archive_file_name = model_context.get_archive_file_name()
if archive_file_name:
domain_path = _get_domain_path(model_context, model)
archive_helper = ArchiveHelper(archive_file_name, domain_path, __logger, ExceptionType.CREATE)

has_atp = validate_rcu_args_and_model(model_context, model, archive_helper, alias_helper)

has_atp = validateRCUArgsAndModel(model_context, model, alias_helper)
# check if there is an atpwallet and extract in the domain dir
# it is to support non JRF domain but user wants to use ATP database
archive_file_name = model_context.get_archive_file_name()
if not has_atp and archive_file_name and os.path.exists(archive_file_name):
archive_file = WLSDeployArchive(archive_file_name)
if archive_file:
atp_wallet_zipentry = archive_file.getATPWallet()
if atp_wallet_zipentry:
atp_helper.extract_walletzip(model, model_context, archive_file, atp_wallet_zipentry)
if not has_atp and archive_helper:
archive_helper.extract_atp_wallet()

creator = DomainCreator(model, model_context, aliases)
creator.create()
Expand Down
25 changes: 2 additions & 23 deletions core/src/main/python/deploy.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,27 +119,6 @@ def __verify_required_args_present(required_arg_map):
return


def __validate_archive_file_arg(required_arg_map):
"""
Verify that the archive file exists.
:param required_arg_map: the required arguments map
:return: the archive file name
:raises CLAException: if the archive file is not valid
"""
_method_name = '__validate_archive_file_arg'

archive_file_name = required_arg_map[CommandLineArgUtil.ARCHIVE_FILE_SWITCH]
try:
FileUtils.validateExistingFile(archive_file_name)
except IllegalArgumentException, iae:
ex = exception_helper.create_cla_exception('WLSDPLY-20014', _program_name, archive_file_name,
iae.getLocalizedMessage(), error=iae)
ex.setExitCode(CommandLineArgUtil.ARG_VALIDATION_ERROR_EXIT_CODE)
__logger.throwing(ex, class_name=_class_name, method_name=_method_name)
raise ex
return archive_file_name


def __process_model_args(optional_arg_map):
"""
Determine if the model file was passed separately or requires extraction from the archive.
Expand Down Expand Up @@ -221,10 +200,10 @@ def __deploy(model, model_context, aliases):
ret_code = __deploy_online(model, model_context, aliases)
else:
ret_code = __deploy_offline(model, model_context, aliases)
return ret_code =
return ret_code


def __deploy_online(model, model_context, aliases):
def __deploy_online(model, model_context, aliases):
"""
Online deployment orchestration
:param model: the model
Expand Down
22 changes: 0 additions & 22 deletions core/src/main/python/update.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import sys

from java.io import IOException, PrintStream
from java.lang import IllegalArgumentException
from java.lang import String, System

from oracle.weblogic.deploy.deploy import DeployException
Expand Down Expand Up @@ -128,27 +127,6 @@ def __verify_required_args_present(required_arg_map):
return


def __validate_archive_file_arg(required_arg_map):
"""
Verify that the archive file exists.
:param required_arg_map: the required arguments map
:return: the archive file name
:raises CLAException: if the archive file is not valid
"""
_method_name = '__validate_archive_file_arg'

archive_file_name = required_arg_map[CommandLineArgUtil.ARCHIVE_FILE_SWITCH]
try:
FileUtils.validateExistingFile(archive_file_name)
except IllegalArgumentException, iae:
ex = exception_helper.create_cla_exception('WLSDPLY-20014', _program_name, archive_file_name,
iae.getLocalizedMessage(), error=iae)
ex.setExitCode(CommandLineArgUtil.ARG_VALIDATION_ERROR_EXIT_CODE)
__logger.throwing(ex, class_name=_class_name, method_name=_method_name)
raise ex
return archive_file_name


def __process_model_args(optional_arg_map):
"""
Determine if the model file was passed separately or requires extraction from the archive.
Expand Down
20 changes: 0 additions & 20 deletions core/src/main/python/wlsdeploy/tool/create/atp_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,7 @@


"""

import os
import re
from java.io import File
from oracle.weblogic.deploy.util import FileUtils
from wlsdeploy.aliases import model_constants
from xml.dom.minidom import parse


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

return connect_string


def extract_walletzip(model, model_context, archive_file, atp_zipentry):
domain_parent = model_context.get_domain_parent_dir()
if domain_parent is None:
domain_path = model_context.get_domain_home()
else:
domain_path = domain_parent + os.sep + model[model_constants.TOPOLOGY][
'Name']
extract_path = domain_path + os.sep + 'atpwallet'
extract_dir = File(extract_path)
extract_dir.mkdirs()
FileUtils.extractZipFileContent(archive_file, atp_zipentry, extract_path)
return extract_path
# update the model to add the tns_admin
2 changes: 1 addition & 1 deletion core/src/main/python/wlsdeploy/tool/create/creator.py
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ def _extract_archive_files(self, location, model_name, model_value):
self.files_to_extract_from_archive.append(model_path)
else:
path = self.alias_helper.get_model_folder_path(location)
archive_file_name = self.model_context.get_archive_file_name
archive_file_name = self.model_context.get_archive_file_name()
ex = exception_helper.create_create_exception('WLSDPLY-12121', model_name, path,
model_path, archive_file_name)
self.logger.throwing(ex, class_name=self.__class_name, method_name=_method_name)
Expand Down
7 changes: 2 additions & 5 deletions core/src/main/python/wlsdeploy/tool/create/domain_creator.py
Original file line number Diff line number Diff line change
Expand Up @@ -1172,11 +1172,8 @@ def __configure_opss_secrets(self):
domain_info = self._domain_info
if OPSS_SECRETS in domain_info:
opss_secret_password = domain_info[OPSS_SECRETS]
if self.model_context.get_archive_file_name() and opss_secret_password:
archive_file = WLSDeployArchive(self.model_context.get_archive_file_name())
extract_path = self._domain_home + os.sep + 'opsswallet'
zip_entry = archive_file.getOPSSWallet();
FileUtils.extractZipFileContent(archive_file, zip_entry, extract_path)
if self.archive_helper and opss_secret_password:
extract_path = self.archive_helper.extract_opss_wallet()
self.wlst_helper.setSharedSecretStoreWithPassword(extract_path, opss_secret_password)
else:
opss_secret_password = self.model_context.get_opss_wallet_passphrase()
Expand Down
Loading