Skip to content

Opsscli #440

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 4 commits into from
Sep 12, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 27 additions & 1 deletion core/src/main/python/create.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@
CommandLineArgUtil.VARIABLE_FILE_SWITCH,
CommandLineArgUtil.USE_ENCRYPTION_SWITCH,
CommandLineArgUtil.PASSPHRASE_SWITCH,
CommandLineArgUtil.OPSS_WALLET_SWITCH,
CommandLineArgUtil.OPSS_WALLET_PASSPHRASE
]


Expand All @@ -103,7 +105,8 @@ def __process_args(args):

__process_rcu_args(optional_arg_map, domain_type, domain_typedef)
__process_encryption_args(optional_arg_map)

__process_opss_args(optional_arg_map)

combined_arg_map = optional_arg_map.copy()
combined_arg_map.update(required_arg_map)
model_context = ModelContext(_program_name, combined_arg_map)
Expand Down Expand Up @@ -264,6 +267,29 @@ def __process_encryption_args(optional_arg_map):
return


def __process_opss_args(optional_arg_map):
"""
Determine if the user is using opss wallet and if so, get the passphrase.
:param optional_arg_map: the optional arguments map
:raises CLAException: if getting the passphrase from the user fails
"""
_method_name = '__process_opss_args'

if CommandLineArgUtil.OPSS_WALLET_SWITCH in optional_arg_map and \
CommandLineArgUtil.OPSS_WALLET_PASSPHRASE not in optional_arg_map:
try:
passphrase = getcreds.getpass('WLSDPLY-20027')
except IOException, ioe:
ex = exception_helper.create_cla_exception('WLSDPLY-20028', ioe.getLocalizedMessage(),
error=ioe)
ex.setExitCode(CommandLineArgUtil.ARG_VALIDATION_ERROR_EXIT_CODE)
__logger.throwing(ex, class_name=_class_name, method_name=_method_name)
raise ex
optional_arg_map[CommandLineArgUtil.OPSS_WALLET_PASSPHRASE] = String(passphrase)
return



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

Expand Down
26 changes: 15 additions & 11 deletions core/src/main/python/wlsdeploy/tool/create/domain_creator.py
Original file line number Diff line number Diff line change
Expand Up @@ -1164,16 +1164,20 @@ def __configure_opss_secrets(self):
return

self.logger.entering(class_name=self.__class_name, method_name=_method_name)
extract_path = None
domain_info = self._domain_info
if domain_info is not None:
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)
self.wlst_helper.setSharedSecretStoreWithPassword(extract_path, opss_secret_password)
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)
self.wlst_helper.setSharedSecretStoreWithPassword(extract_path, opss_secret_password)
else:
opss_secret_password = self.model_context.get_opss_wallet_passphrase()
opss_wallet = self.model_context.get_opss_wallet()
if opss_wallet is not None and opss_secret_password is not None:
self.wlst_helper.setSharedSecretStoreWithPassword(opss_wallet, opss_secret_password)

self.logger.exiting(class_name=self.__class_name, method_name=_method_name)
return extract_path
return
53 changes: 53 additions & 0 deletions core/src/main/python/wlsdeploy/util/cla_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ class CommandLineArgUtil(object):
ADMIN_PASS_SWITCH = '-admin_pass'
ARCHIVE_FILE_SWITCH = '-archive_file'
MODEL_FILE_SWITCH = '-model_file'
OPSS_WALLET_SWITCH = '-opss_wallet'
OPSS_WALLET_PASSPHRASE = '-opss_wallet_passphrase'
PREVIOUS_MODEL_FILE_SWITCH = '-prev_model_file'
VARIABLE_FILE_SWITCH = '-variable_file'
PRINT_USAGE_SWITCH = '-print_usage'
Expand Down Expand Up @@ -233,6 +235,24 @@ def process_args(self, args, for_domain_create=False):
ex = self._get_out_of_args_exception(key)
self._logger.throwing(ex, class_name=self._class_name, method_name=method_name)
raise ex
elif self.is_opss_passphrase_key(key):
idx += 1
if idx < args_len:
self._validate_opss_passphrase_arg(args[idx])
self._add_arg(key, args[idx])
else:
ex = self._get_out_of_args_exception(key)
self._logger.throwing(ex, class_name=self._class_name, method_name=method_name)
raise ex
elif self.is_opss_wallet_key(key):
idx += 1
if idx < args_len:
full_path = self._validate_opss_wallet_arg(args[idx])
self._add_arg(key, full_path, True)
else:
ex = self._get_out_of_args_exception(key)
self._logger.throwing(ex, class_name=self._class_name, method_name=method_name)
raise ex
elif self.is_model_file_key(key):
idx += 1
if idx < args_len:
Expand Down Expand Up @@ -657,6 +677,39 @@ def _validate_archive_file_arg(self, value):
raise ex
return archive.getAbsolutePath()

def get_opss_passphrase_key(self):
return self.OPSS_WALLET_PASSPHRASE

def is_opss_passphrase_key(self, key):

return self.OPSS_WALLET_PASSPHRASE == key

def _validate_opss_passphrase_arg(self, value):
method_name = '_validate_opss_passphrase_arg'
if value is None or len(value) == 0:
ex = exception_helper.create_cla_exception('WLSDPLY-01615')
ex.setExitCode(self.ARG_VALIDATION_ERROR_EXIT_CODE)
self._logger.throwing(ex, class_name=self._class_name, method_name=method_name)
raise ex
return

def get_opss_wallet_key(self):
return self.OPSS_WALLET_SWITCH

def is_opss_wallet_key(self, key):
return self.OPSS_WALLET_SWITCH == key

def _validate_opss_wallet_arg(self, value):
method_name = '_validate_opss_wallet_arg'
try:
opss_wallet = JFileUtils.validateDirectoryName(value)
except JIllegalArgumentException, iae:
ex = exception_helper.create_cla_exception('WLSDPLY-01616', value, iae.getLocalizedMessage(), error=iae)
ex.setExitCode(self.ARG_VALIDATION_ERROR_EXIT_CODE)
self._logger.throwing(ex, class_name=self._class_name, method_name=method_name)
raise ex
return opss_wallet.getAbsolutePath()

def get_model_file_key(self):
return self.MODEL_FILE_SWITCH

Expand Down
23 changes: 23 additions & 0 deletions core/src/main/python/wlsdeploy/util/model_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ def __init__(self, program_name, arg_map):
self._recursive = False
self._attributes_only = False
self._folders_only = False
self._opss_wallet_passphrase = None
self._opss_wallet = None

if CommandLineArgUtil.ORACLE_HOME_SWITCH in arg_map:
self._oracle_home = arg_map[CommandLineArgUtil.ORACLE_HOME_SWITCH]
Expand Down Expand Up @@ -145,6 +147,12 @@ def __init__(self, program_name, arg_map):
if CommandLineArgUtil.ARCHIVE_FILE in arg_map:
self._archive_file = arg_map[CommandLineArgUtil.ARCHIVE_FILE]

if CommandLineArgUtil.OPSS_WALLET_PASSPHRASE in arg_map:
self._opss_wallet_passphrase = arg_map[CommandLineArgUtil.OPSS_WALLET_PASSPHRASE]

if CommandLineArgUtil.OPSS_WALLET_SWITCH in arg_map:
self._opss_wallet = arg_map[CommandLineArgUtil.OPSS_WALLET_SWITCH]

if CommandLineArgUtil.TARGET_VERSION_SWITCH in arg_map:
self._wl_version = arg_map[CommandLineArgUtil.TARGET_VERSION_SWITCH]

Expand Down Expand Up @@ -265,6 +273,21 @@ def get_archive_file_name(self):
"""
return self._archive_file_name

def get_opss_wallet(self):
"""
Get the opss wallet.
:return: the opss wallet
"""
return self._opss_wallet

def get_opss_wallet_passphrase(self):
"""
Get the wallet passphrase.
:return: the wallet passphrase
"""
return self._opss_wallet_passphrase


def get_archive_file(self):
"""
Get the archive file.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1444,6 +1444,8 @@ WLSDPLY-20023={0} unable to add model file {1} to archive as {2}: {3}
WLSDPLY-20024={0} failed to persist the model to the archive file {1}: {2}
WLSDPLY-20025=For {0}, specify the {1} or {2} argument, but not both
WLSDPLY-20026={0} failed to find a model file in archive {1}, and {2} argument not specified
WLSDPLY-20027=Enter the OPSS wallet passphrase
WLSDPLY-20028=Failed to read the OPSS wallet passphrase input from the user: {0}

# Common messages used for tool exit and clean-up
WLSDPLY-21000={0} Messages:
Expand Down