Skip to content

Issue #147 - Correct exception type in catch statements; perform undo… #153

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
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
20 changes: 8 additions & 12 deletions core/src/main/python/deploy.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
from oracle.weblogic.deploy.exception import BundleAwareException
from oracle.weblogic.deploy.util import CLAException
from oracle.weblogic.deploy.util import FileUtils
from oracle.weblogic.deploy.util import PyWLSTException
from oracle.weblogic.deploy.util import TranslateException
from oracle.weblogic.deploy.util import VariableException
from oracle.weblogic.deploy.util import WebLogicDeployToolingVersion
Expand Down Expand Up @@ -283,10 +282,7 @@ def __deploy_online(model, model_context, aliases):
deployer_utils.ensure_no_uncommitted_changes_or_edit_sessions()
__wlst_helper.edit()
__wlst_helper.start_edit()
except PyWLSTException, pwe:
ex = exception_helper.create_deploy_exception('WLSDPLY-09006', _program_name, admin_url,
pwe.getLocalizedMessage(), error=pwe)
__logger.throwing(ex, class_name=_class_name, method_name=_method_name)
except BundleAwareException, ex:
raise ex

__logger.info("WLSDPLY-09007", admin_url, method_name=_method_name, class_name=_class_name)
Expand All @@ -300,20 +296,18 @@ def __deploy_online(model, model_context, aliases):
try:
__wlst_helper.save()
__wlst_helper.activate()
except PyWLSTException, pwe:
ex = exception_helper.create_deploy_exception('WLSDPLY-09008', pwe.getLocalizedMessage(), error=pwe)
__logger.throwing(ex, class_name=_class_name, method_name=_method_name)
except BundleAwareException, ex:
__release_edit_session_and_disconnect()
raise ex

model_deployer.deploy_applications(model, model_context, aliases, wlst_mode=__wlst_mode)

try:
__wlst_helper.disconnect()
except PyWLSTException, pwe:
except BundleAwareException, ex:
# All the changes are made and active so don't raise an error that causes the program
# to indicate a failure...just log the error since the process is going to exit anyway.
__logger.warning('WLSDPLY-09009', _program_name, pwe.getLocalizedMessage(), error=pwe,
__logger.warning('WLSDPLY-09009', _program_name, ex.getLocalizedMessage(), error=ex,
class_name=_class_name, method_name=_method_name)
return

Expand Down Expand Up @@ -357,6 +351,7 @@ def __release_edit_session_and_disconnect():
"""
_method_name = '__release_edit_session_and_disconnect'
try:
__wlst_helper.undo()
__wlst_helper.stop_edit()
__wlst_helper.disconnect()
except BundleAwareException, ex:
Expand All @@ -374,10 +369,10 @@ def __close_domain_on_error():
_method_name = '__close_domain_on_error'
try:
__wlst_helper.close_domain()
except PyWLSTException, pwe:
except BundleAwareException, ex:
# This method is only used for cleanup after an error so don't mask
# the original problem by throwing yet another exception...
__logger.warning('WLSDPLY-09013', pwe.getLocalizedMessage(), error=pwe,
__logger.warning('WLSDPLY-09013', ex.getLocalizedMessage(), error=ex,
class_name=_class_name, method_name=_method_name)
return

Expand Down Expand Up @@ -478,6 +473,7 @@ def main(args):
__clean_up_temp_files()
return


if __name__ == "main":
WebLogicDeployToolingVersion.logVersionInfo(_program_name)
main(sys.argv)
19 changes: 7 additions & 12 deletions core/src/main/python/update.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
from oracle.weblogic.deploy.exception import BundleAwareException
from oracle.weblogic.deploy.util import CLAException
from oracle.weblogic.deploy.util import FileUtils
from oracle.weblogic.deploy.util import PyWLSTException
from oracle.weblogic.deploy.util import TranslateException
from oracle.weblogic.deploy.util import VariableException
from oracle.weblogic.deploy.util import WebLogicDeployToolingVersion
Expand Down Expand Up @@ -294,10 +293,7 @@ def __update_online(model, model_context, aliases):
deployer_utils.ensure_no_uncommitted_changes_or_edit_sessions()
__wlst_helper.edit()
__wlst_helper.start_edit()
except PyWLSTException, pwe:
ex = exception_helper.create_deploy_exception('WLSDPLY-09006', _program_name, admin_url,
pwe.getLocalizedMessage(), error=pwe)
__logger.throwing(ex, class_name=_class_name, method_name=_method_name)
except BundleAwareException, ex:
raise ex

__logger.info("WLSDPLY-09007", admin_url, method_name=_method_name, class_name=_class_name)
Expand All @@ -314,20 +310,18 @@ def __update_online(model, model_context, aliases):
try:
__wlst_helper.save()
__wlst_helper.activate()
except PyWLSTException, pwe:
ex = exception_helper.create_deploy_exception('WLSDPLY-09008', pwe.getLocalizedMessage(), error=pwe)
__logger.throwing(ex, class_name=_class_name, method_name=_method_name)
except BundleAwareException, ex:
__release_edit_session_and_disconnect()
raise ex

model_deployer.deploy_applications(model, model_context, aliases, wlst_mode=__wlst_mode)

try:
__wlst_helper.disconnect()
except PyWLSTException, pwe:
except BundleAwareException, ex:
# All the changes are made and active so don't raise an error that causes the program
# to indicate a failure...just log the error since the process is going to exit anyway.
__logger.warning('WLSDPLY-09009', _program_name, pwe.getLocalizedMessage(), error=pwe,
__logger.warning('WLSDPLY-09009', _program_name, ex.getLocalizedMessage(), error=ex,
class_name=_class_name, method_name=_method_name)
return

Expand Down Expand Up @@ -374,6 +368,7 @@ def __release_edit_session_and_disconnect():
"""
_method_name = '__release_edit_session_and_disconnect'
try:
__wlst_helper.undo()
__wlst_helper.stop_edit()
__wlst_helper.disconnect()
except BundleAwareException, ex:
Expand All @@ -391,10 +386,10 @@ def __close_domain_on_error():
_method_name = '__close_domain_on_error'
try:
__wlst_helper.close_domain()
except PyWLSTException, pwe:
except BundleAwareException, ex:
# This method is only used for cleanup after an error so don't mask
# the original problem by throwing yet another exception...
__logger.warning('WLSDPLY-09013', pwe.getLocalizedMessage(), error=pwe,
__logger.warning('WLSDPLY-09013', ex.getLocalizedMessage(), error=ex,
class_name=_class_name, method_name=_method_name)
return

Expand Down
16 changes: 16 additions & 0 deletions core/src/main/python/wlsdeploy/tool/util/wlst_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -520,6 +520,22 @@ def stop_edit(self):
raise ex
return

def undo(self):
"""
Revert all unsaved or unactivated edits.
:raises: BundleAwareException of the specified type: if an error occurs
"""
_method_name = 'undo'

try:
wlst_helper.undo()
except PyWLSTException, pwe:
ex = exception_helper.create_exception(self.__exception_type, 'WLSDPLY-19142',
pwe.getLocalizedMessage(), error=pwe)
self.__logger.throwing(ex, class_name=self.__class_name, method_name=_method_name)
raise ex
return

def save(self):
"""
Save the outstanding Weblogic Server configuration changes for the current edit session.
Expand Down
17 changes: 17 additions & 0 deletions core/src/main/python/wlsdeploy/util/wlst_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -692,6 +692,23 @@ def stop_edit():
_logger.exiting(class_name=_class_name, method_name=_method_name)


def undo():
"""
Revert all unsaved or unactivated edits.
:raises: PyWLSTException: if a WLST error occurs
"""
_method_name = 'undo'
_logger.entering(class_name=_class_name, method_name=_method_name)

try:
wlst.undo('true', 'y')
except wlst.WLSTException, e:
pwe = exception_helper.create_pywlst_exception('WLSDPLY-00069', _format_exception(e), error=e)
_logger.throwing(class_name=_class_name, method_name=_method_name, error=pwe)
raise pwe
_logger.exiting(class_name=_class_name, method_name=_method_name)


def save():
"""
Save the outstanding Weblogic Server configuration changes for the current edit session.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ WLSDPLY-00065=Failed to switch to the serverConfig MBean tree: {0}
WLSDPLY-00066=Failed to switch to the domainRuntime MBean tree: {0}
WLSDPLY-00067=Failed to switch to the custom MBean tree: {0}
WLSDPLY-00068=Failed to change directories back to the original location {0}: {1}
WLSDPLY-00069=wlst.undo() failed : {0}

###############################################################################
# Util messages (1000 - 3999) #
Expand Down Expand Up @@ -1098,6 +1099,7 @@ WLSDPLY-19138=Failed to redeploy application {0}:{1}
WLSDPLY-19139=Failed to start application {0}: {1}
WLSDPLY-19140=Failed to stop application {0}: {1}
WLSDPLY-19141=Failed to undeploy application {0}:{1}
WLSDPLY-19142=Failed to undo changes: {0}

# wlsdeploy/tool/util/attribute_setter.py
WLSDPLY-19200=No target found with name {0}
Expand Down