Skip to content
7 changes: 4 additions & 3 deletions core/src/main/python/deploy.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,11 +117,12 @@ def __deploy_online(model, model_context, aliases):
admin_url = model_context.get_admin_url()
admin_user = model_context.get_admin_user()
admin_pwd = model_context.get_admin_password()
timeout = model_context.get_model_config().get_connect_timeout()

__logger.info("WLSDPLY-09005", admin_url, method_name=_method_name, class_name=_class_name)
__logger.info("WLSDPLY-09005", admin_url, timeout, method_name=_method_name, class_name=_class_name)

try:
__wlst_helper.connect(admin_user, admin_pwd, admin_url)
__wlst_helper.connect(admin_user, admin_pwd, admin_url, timeout)
deployer_utils.ensure_no_uncommitted_changes_or_edit_sessions(model_context.is_discard_current_edit())
__wlst_helper.edit()
__wlst_helper.start_edit()
Expand Down Expand Up @@ -156,7 +157,7 @@ def __deploy_online(model, model_context, aliases):
exit_code = CommandLineArgUtil.PROG_ROLLBACK_IF_RESTART_EXIT_CODE
else:
__wlst_helper.save()
__wlst_helper.activate()
__wlst_helper.activate(model_context.get_model_config().get_activate_timeout())
if restart_required:
exit_code = CommandLineArgUtil.PROG_RESTART_REQUIRED
except BundleAwareException, ex:
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/python/discover.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ def __connect_to_domain(model_context, helper):
if __wlst_mode == WlstModes.ONLINE:
try:
helper.connect(model_context.get_admin_user(), model_context.get_admin_password(),
model_context.get_admin_url())
model_context.get_admin_url(), model_context.get_model_config().get_connect_timeout())
except PyWLSTException, wlst_ex:
ex = exception_helper.create_discover_exception('WLSDPLY-06001', model_context.get_admin_url(),
model_context.get_admin_user(),
Expand Down
7 changes: 4 additions & 3 deletions core/src/main/python/update.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,11 +121,12 @@ def __update_online(model, model_context, aliases):
admin_url = model_context.get_admin_url()
admin_user = model_context.get_admin_user()
admin_pwd = model_context.get_admin_password()
timeout = model_context.get_model_config().get_connect_timeout()

__logger.info("WLSDPLY-09005", admin_url, method_name=_method_name, class_name=_class_name)
__logger.info("WLSDPLY-09005", admin_url, timeout, method_name=_method_name, class_name=_class_name)

try:
__wlst_helper.connect(admin_user, admin_pwd, admin_url)
__wlst_helper.connect(admin_user, admin_pwd, admin_url, timeout)
deployer_utils.ensure_no_uncommitted_changes_or_edit_sessions(model_context.is_discard_current_edit())
__wlst_helper.edit()
__wlst_helper.start_edit()
Expand Down Expand Up @@ -193,7 +194,7 @@ def __check_update_require_domain_restart(model_context):
exit_code = CommandLineArgUtil.PROG_ROLLBACK_IF_RESTART_EXIT_CODE
else:
__wlst_helper.save()
__wlst_helper.activate()
__wlst_helper.activate(model_context.get_model_config().get_activate_timeout())
if restart_required:
exit_code = CommandLineArgUtil.PROG_RESTART_REQUIRED
except BundleAwareException, ex:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -273,15 +273,15 @@ def __online_deploy_apps_and_libs(self, base_location):

# shared library updated, app referenced must be stopped, redeployed, and started so stop the app first
for app in stop_app_list:
self.__stop_app(app)
self.__stop_app(app, timeout=self.model_context.get_model_config().get_stop_app_timeout())
# add the referenced app to the redeploy list
redeploy_app_list.append(app)
# add the referenced app to the start list
deployed_app_list.append(app)

# app is updated, it must be stopped and undeployed first
for app in stop_and_undeploy_app_list:
self.__stop_app(app)
self.__stop_app(app, timeout=self.model_context.get_model_config().get_stop_app_timeout())
self.__undeploy_app(app)

# targets were deleted from an app, so undeploy for those specific targets
Expand Down Expand Up @@ -872,11 +872,12 @@ def __start_app(self, application_name, partition_name=None):
_method_name = '__start_app'

self.logger.info('WLSDPLY-09313', application_name, class_name=self._class_name, method_name=_method_name)
self.wlst_helper.start_application(application_name, partition=partition_name)
self.wlst_helper.start_application(application_name, partition=partition_name,
timeout=self.model_context.get_model_config().get_start_app_timeout())
return

def __undeploy_app(self, application_name, library_module='false', partition_name=None,
resource_group_template=None, timeout=None, targets=None):
resource_group_template=None, targets=None):
_method_name = '__undeploy_app'

type_name = APPLICATION
Expand All @@ -891,15 +892,17 @@ def __undeploy_app(self, application_name, library_module='false', partition_nam
method_name=_method_name)

self.wlst_helper.undeploy_application(application_name, libraryModule=library_module, partition=partition_name,
resourceGroupTemplate=resource_group_template, timeout=timeout,
resourceGroupTemplate=resource_group_template,
timeout=self.model_context.get_model_config().get_undeploy_timeout(),
targets=targets)
return

def __redeploy_app(self, application_name):
_method_name = '__redeploy_app'

self.logger.info('WLSDPLY-09315', application_name, class_name=self._class_name, method_name=_method_name)
self.wlst_helper.redeploy_application(application_name)
self.wlst_helper.redeploy_application(application_name,
timeout=self.model_context.get_model_config().get_redeploy_timeout())
return

def __deploy_model_libraries(self, model_libs, lib_location):
Expand Down Expand Up @@ -1026,6 +1029,7 @@ def __deploy_app_online(self, application_name, source_path, targets, plan=None,
if options is not None:
for key, value in options.iteritems():
kwargs[key] = value
kwargs['timeout'] = self.model_context.get_model_config().get_deploy_timeout()

self.logger.fine('WLSDPLY-09320', application_name, kwargs,
class_name=self._class_name, method_name=_method_name)
Expand Down
3 changes: 2 additions & 1 deletion core/src/main/python/wlsdeploy/tool/util/target_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,8 @@ def target_server_groups(self, server_assigns):
server_name = self.wlst_helper.get_quoted_name_for_wlst(server)
self.logger.info('WLSDPLY-12224', str(server_groups), server_name,
class_name=self.__class_name, method_name=_method_name)
self.wlst_helper.set_server_groups(server_name, server_groups)
self.wlst_helper.set_server_groups(server_name, server_groups,
self.model_context.get_model_config().get_set_server_grps_timeout())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

get_set_server_grps_timeout no method, s/b get_server_grps_timeout() ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ty. Done


self.logger.exiting(class_name=self.__class_name, method_name=_method_name)

Expand Down
21 changes: 12 additions & 9 deletions core/src/main/python/wlsdeploy/tool/util/wlst_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -369,19 +369,20 @@ def modify_bootstrap_credentials(self, jps_configfile, username, password):
raise pwe
self.__logger.exiting(class_name=self.__class_name, method_name=_method_name)

def set_server_groups(self, server, server_groups):
def set_server_groups(self, server, server_groups, timeout):
"""
Targets the list of server groups to the managed server.

:param server: the name of the managed server
:param server_groups: the list of template-defined server groups to target to the server
:param timeout: the timeout for the setServerGroups command
:raises: Exception for the specified tool type: if a WLST error occurs
"""
_method_name = 'set_server_groups'
self.__logger.entering(server_groups, server, class_name=self.__class_name, method_name=_method_name)
self.__logger.entering(server_groups, server, timeout, class_name=self.__class_name, method_name=_method_name)

try:
self.__load_global('setServerGroups')(server, server_groups)
self.__load_global('setServerGroups')(server, server_groups, timeout)
except (self.__load_global('WLSTException'), offlineWLSTException), e:
pwe = exception_helper.create_exception(self.__exception_type, 'WLSDPLY-00023', server_groups, server,
_format_exception(e), error=e)
Expand Down Expand Up @@ -763,19 +764,20 @@ def close_domain(self):
raise pwe
self.__logger.exiting(class_name=self.__class_name, method_name=_method_name)

def connect(self, username, password, url):
def connect(self, username, password, url, timeout):
"""
Connect WLST to a WebLogic Server instance at the provided url with the provided credentials.
:param username: WebLogic user name
:param password: WebLogic password
:param url: WebLogic Server URL
:param timeout: Connect timeout
:raises: Exception for the specified tool type: if a WLST error occurs
"""
_method_name = 'connect'
self.__logger.entering(username, url, class_name=self.__class_name, method_name=_method_name)
self.__logger.entering(username, url, timeout, class_name=self.__class_name, method_name=_method_name)

try:
self.__load_global('connect')(username=username, password=password, url=url)
self.__load_global('connect')(username=username, password=password, url=url, timeout=timeout)
except self.__load_global('WLSTException'), e:
pwe = exception_helper.create_exception(self.__exception_type, 'WLSDPLY-00047', username, url,
self.__get_exception_mode(e), _format_exception(e), error=e)
Expand Down Expand Up @@ -886,15 +888,16 @@ def save(self):
raise pwe
self.__logger.exiting(class_name=self.__class_name, method_name=_method_name)

def activate(self):
def activate(self, timeout):
"""
Activate changes saved during the current edit session but not yet deployed.
:param timeout: Timeout for the activate command
:raises: Exception for the specified tool type: if a WLST error occurs
"""
_method_name = 'activate'
self.__logger.entering(class_name=self.__class_name, method_name=_method_name)
self.__logger.entering(timeout, class_name=self.__class_name, method_name=_method_name)
try:
self.__load_global('activate')()
self.__load_global('activate')(timeout)
except self.__load_global('WLSTException'), e:
pwe = exception_helper.create_exception(self.__exception_type, 'WLSDPLY-00053',
_format_exception(e), error=e)
Expand Down
3 changes: 3 additions & 0 deletions core/src/main/python/wlsdeploy/util/cla_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,14 @@
from wlsdeploy.util import getcreds
from wlsdeploy.util import model_helper
from wlsdeploy.util import model_translator, path_utils
from wlsdeploy.util import path_utils

from wlsdeploy.util import tool_exit
from wlsdeploy.util import variables
from wlsdeploy.util.cla_utils import CommandLineArgUtil
from wlsdeploy.util.model_translator import FileToPython


__logger = PlatformLogger('wlsdeploy.util')
_class_name = 'cla_helper'

Expand Down
3 changes: 2 additions & 1 deletion core/src/main/python/wlsdeploy/util/cla_utils.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
Copyright (c) 2017, 2020, Oracle Corporation and/or its affiliates. All rights reserved.
Copyright (c) 2017, 2020, Oracle Corporation and/or its affiliates.
Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.

Module that handles command-line argument parsing and common validation.
Expand Down Expand Up @@ -88,6 +88,7 @@ class CommandLineArgUtil(object):

TARGET_SWITCH = '-target'


# arguments that are true if specified, false if not
BOOLEAN_SWITCHES = [
ATTRIBUTES_ONLY_SWITCH,
Expand Down
125 changes: 125 additions & 0 deletions core/src/main/python/wlsdeploy/util/model_config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
"""
Copyright (c) 2020, Oracle Corporation and/or its affiliates.
Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
"""

from java.io import IOException
from java.lang import Long

from wlsdeploy.logging.platform_logger import PlatformLogger
from wlsdeploy.util import path_utils
from wlsdeploy.util import string_utils

TOOL_PROPERTIES_FILE_NAME = 'tool.properties'

_logger = PlatformLogger('wlsdeploy.config')
_class_name = 'ModelConfig'

# Tool Properties for configuration and default values if properties not loaded

# WLST TIMEOUT PROPERTIES
CONNECT_TIMEOUT_PROP = 'connect.timeout'
CONNECT_TIMEOUT_DEFAULT = '120000'
ACTIVATE_TIMEOUT_PROP = 'activate.timeout'
ACTIVATE_TIMEOUT_DEFAULT = '180000'
DEPLOY_TIMEOUT_PROP = 'deploy.timeout'
DEPLOY_TIMEOUT_DEFAULT = '180000'
REDEPLOY_TIMEOUT_PROP = 'redeploy.timeout'
REDEPLOY_TIMEOUT_DEFAULT = '180000'
UNDEPLOY_TIMEOUT_PROP = 'undeploy.timeout'
UNDEPLOY_TIMEOUT_DEFAULT = '180000'
START_APP_TIMEOUT_PROP = 'start.application.timeout'
START_APP_TIMEOUT_DEFAULT = '180000'
STOP_APP_TIMEOUT_PROP = 'stop.application.timeout'
STOP_APP_TIMEOUT_DEFAULT = '180000'
SET_SERVER_GRPS_TIMEOUT_PROP = 'set.server.groups.timeout'
SET_SERVER_GRPS_TIMEOUT_DEFAULT = '30000'


class ModelConfiguration(object):
"""
This class encapsulates the tool properties used in configuring and tuning
"""

def __init__(self):
"""
Load the properties from the tools.properties file and save the resulting dictionary
:return:
"""
self.__config_dict = _load_properties_file()

def get_connect_timeout(self):
"""
Return the connect timeout from tool properties.
:return: connect timeout
"""
return self._get_from_dict(CONNECT_TIMEOUT_PROP, CONNECT_TIMEOUT_DEFAULT)

def get_activate_timeout(self):
"""
Return the activate timeout from tool properties.
:return: activate timeout
"""
return self._get_from_dict_as_long(ACTIVATE_TIMEOUT_PROP, ACTIVATE_TIMEOUT_DEFAULT)

def get_deploy_timeout(self):
"""
Return the deploy timeout from tool properties.
:return: deploy timeout
"""
return self._get_from_dict_as_long(DEPLOY_TIMEOUT_PROP, DEPLOY_TIMEOUT_DEFAULT)

def get_redeploy_timeout(self):
"""
Return the redeploy timeout from tool properties
:return: redeploy timeout
"""
return self._get_from_dict_as_long(REDEPLOY_TIMEOUT_PROP, REDEPLOY_TIMEOUT_DEFAULT)

def get_undeploy_timeout(self):
"""
Return undeploy timeout from tool properties.
:return: undeploy timeout
"""
return self._get_from_dict_as_long(UNDEPLOY_TIMEOUT_PROP, UNDEPLOY_TIMEOUT_DEFAULT)

def get_stop_app_timeout(self):
"""
Return stop application timeout from tool properties.
:return: stop application timeout
"""
return self._get_from_dict_as_long(STOP_APP_TIMEOUT_PROP, STOP_APP_TIMEOUT_DEFAULT)

def get_start_app_timeout(self):
"""
Return start application timeout from tool properties.
:return: start application timeout
"""
return self._get_from_dict_as_long(START_APP_TIMEOUT_PROP, START_APP_TIMEOUT_DEFAULT)

def _get_from_dict(self, name, default_value=None):
result = default_value
if name in self.__config_dict:
result = self.__config_dict[name]
return result

def _get_from_dict_as_long(self, name, default_value=None):
return Long(self._get_from_dict(name, default_value)).longValue()


def _load_properties_file():
"""
Load the properties from the WLSDEPLOY properties file into dictionary
:return: tool config properties in dict format
"""
_method_name = 'load_properties_file'
_logger.entering(class_name=_class_name, method_name=_method_name)
wlsdeploy_path = path_utils.find_config_path(TOOL_PROPERTIES_FILE_NAME)
result = None
try:
result = string_utils.load_properties(wlsdeploy_path)
except IOException, ioe:
_logger.warning('WLSDPLY-01651', wlsdeploy_path, ioe.getMessage(),
class_name=_class_name, method_name=_method_name)
_logger.exiting(class_name=_class_name, method_name=_method_name)
return result
16 changes: 14 additions & 2 deletions core/src/main/python/wlsdeploy/util/model_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from wlsdeploy.util.cla_utils import CommandLineArgUtil
from wlsdeploy.util import path_utils
from wlsdeploy.util import string_utils
from wlsdeploy.util.model_config import ModelConfiguration
from wlsdeploy.util.target_configuration import TargetConfiguration
from wlsdeploy.util.weblogic_helper import WebLogicHelper

Expand Down Expand Up @@ -88,6 +89,7 @@ def __init__(self, program_name, arg_map):
self._variable_properties_file = None
self._rcu_db_user = 'SYS'
self._discard_current_edit = False
self._model_config = None

self._trailing_args = []

Expand Down Expand Up @@ -270,9 +272,9 @@ def __copy__(self):
if self._variable_file_name is not None:
arg_map[CommandLineArgUtil.VARIABLE_FILE_SWITCH] = self._variable_file_name
if self._run_rcu is not None:
arg_map[CommandLineArgUtil.RUN_RCU_SWITCH]= self._run_rcu
arg_map[CommandLineArgUtil.RUN_RCU_SWITCH] = self._run_rcu
if self._discard_current_edit is not None:
arg_map[CommandLineArgUtil.DISCARD_CURRENT_EDIT_SWITCH]= self._discard_current_edit
arg_map[CommandLineArgUtil.DISCARD_CURRENT_EDIT_SWITCH] = self._discard_current_edit
if self._rcu_database is not None:
arg_map[CommandLineArgUtil.RCU_DB_SWITCH] = self._rcu_database
if self._rcu_prefix is not None:
Expand Down Expand Up @@ -325,6 +327,16 @@ def __copy__(self):
arg_map[CommandLineArgUtil.VARIABLE_PROPERTIES_FILE_SWITCH] = self._variable_properties_file
return ModelContext(self._program_name, arg_map)

def get_model_config(self):
"""
Return the encapsulated tool properties configuration instance.
This will load the ModelConfiguration from the tool properties on the first request
:return: model configuration instance
"""
if self._model_config is None:
self._model_config = ModelConfiguration()
return self._model_config

def get_program_name(self):
"""
Get the program name of the program that is executing.
Expand Down
Loading