diff --git a/core/src/main/python/deploy.py b/core/src/main/python/deploy.py index 79a2b8cb9..80dd3c00f 100644 --- a/core/src/main/python/deploy.py +++ b/core/src/main/python/deploy.py @@ -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 @@ -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) @@ -300,9 +296,7 @@ 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 @@ -310,10 +304,10 @@ def __deploy_online(model, model_context, aliases): 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 @@ -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: @@ -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 @@ -478,6 +473,7 @@ def main(args): __clean_up_temp_files() return + if __name__ == "main": WebLogicDeployToolingVersion.logVersionInfo(_program_name) main(sys.argv) diff --git a/core/src/main/python/update.py b/core/src/main/python/update.py index 1bf036cae..1b765cb05 100644 --- a/core/src/main/python/update.py +++ b/core/src/main/python/update.py @@ -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 @@ -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) @@ -314,9 +310,7 @@ 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 @@ -324,10 +318,10 @@ def __update_online(model, model_context, aliases): 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 @@ -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: @@ -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 diff --git a/core/src/main/python/wlsdeploy/tool/util/wlst_helper.py b/core/src/main/python/wlsdeploy/tool/util/wlst_helper.py index 28452b344..a2d434089 100644 --- a/core/src/main/python/wlsdeploy/tool/util/wlst_helper.py +++ b/core/src/main/python/wlsdeploy/tool/util/wlst_helper.py @@ -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. diff --git a/core/src/main/python/wlsdeploy/util/wlst_helper.py b/core/src/main/python/wlsdeploy/util/wlst_helper.py index df21ad365..6191f4437 100644 --- a/core/src/main/python/wlsdeploy/util/wlst_helper.py +++ b/core/src/main/python/wlsdeploy/util/wlst_helper.py @@ -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. diff --git a/core/src/main/resources/oracle/weblogic/deploy/messages/wlsdeploy_rb.properties b/core/src/main/resources/oracle/weblogic/deploy/messages/wlsdeploy_rb.properties index 016b5869f..c722260b2 100644 --- a/core/src/main/resources/oracle/weblogic/deploy/messages/wlsdeploy_rb.properties +++ b/core/src/main/resources/oracle/weblogic/deploy/messages/wlsdeploy_rb.properties @@ -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) # @@ -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}