Skip to content

Comments in STDOUT for attributes whose values have changed #699

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 1 commit into from
Aug 7, 2020
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
56 changes: 34 additions & 22 deletions core/src/main/python/compare_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import oracle.weblogic.deploy.util.TranslateException as TranslateException
from oracle.weblogic.deploy.util import CLAException
from oracle.weblogic.deploy.util import FileUtils
from oracle.weblogic.deploy.util import PyOrderedDict
from oracle.weblogic.deploy.util import VariableException
from oracle.weblogic.deploy.compare import CompareException
from oracle.weblogic.deploy.exception import ExceptionHelper
Expand Down Expand Up @@ -86,7 +87,7 @@ def __process_args(args):
class ModelDiffer:

def __init__(self, current_dict, past_dict):
self.final_changed_model=dict()
self.final_changed_model = PyOrderedDict()
self.current_dict = current_dict
self.past_dict = past_dict
self.set_current = sets.Set()
Expand Down Expand Up @@ -182,7 +183,7 @@ def is_dict(self,key):
:param key: key of the dictionary
:return: true if it is a dictionary otherwise false
"""
if self.current_dict.has_key(key) and isinstance(self.current_dict[key],dict):
if self.current_dict.has_key(key) and isinstance(self.current_dict[key], PyOrderedDict):
return 1
else:
return 0
Expand Down Expand Up @@ -274,7 +275,7 @@ def _is_alias_folder(self, path):

return found

def _add_results(self, ar_changes, is_delete=False):
def _add_results(self, ar_changes, is_delete=False, is_change=False):
"""
Update the differences in the final model dictionary with the changes
:param ar_changes: Array of changes in delimited format
Expand All @@ -290,40 +291,47 @@ def _add_results(self, ar_changes, is_delete=False):
if not found_in_allowable_delete:
compare_msgs.add(('WLSDPLY-05701',item))
continue

splitted=item.split(PATH_TOKEN,1)
n=len(splitted)
result=dict()
walked=[]
splitted = item.split(PATH_TOKEN,1)
n = len(splitted)
result = PyOrderedDict()
walked = []

while n > 1:
tmp=dict()
tmp[splitted[0]]=dict()
tmp = PyOrderedDict()
tmp[splitted[0]] = PyOrderedDict()
if len(result) > 0:
# traverse to the leaf
leaf=result
leaf = result
for k in walked:
leaf = leaf[k]
leaf[splitted[0]]=dict()
leaf[splitted[0]] = PyOrderedDict()
walked.append(splitted[0])
else:
result=tmp
result = tmp
walked.append(splitted[0])
splitted=splitted[1].split(PATH_TOKEN,1)
n=len(splitted)
splitted = splitted[1].split(PATH_TOKEN,1)
n = len(splitted)
#
# result is the dictionary format
#
leaf=result
value_tree=self.current_dict
if is_change:
value_tree = self.past_dict
else:
value_tree = self.current_dict
for k in walked:
leaf = leaf[k]
value_tree=value_tree[k]
value_tree = value_tree[k]
#
# walk the current dictionary and set the value
#
if value_tree:
leaf[splitted[0]] = value_tree[splitted[0]]
if is_change:
leaf['# - ' + splitted[0]] = value_tree[splitted[0]]
else:
if value_tree[splitted[0]] is not None and not isinstance(value_tree[splitted[0]], PyOrderedDict):
self._add_results(ar_changes, is_delete, is_change=True)
leaf[splitted[0]] = value_tree[splitted[0]]
else:
leaf[splitted[0]] = None

Expand All @@ -348,12 +356,12 @@ def _add_results(self, ar_changes, is_delete=False):
del pointer_dict[parent_key][app_key]
# Special handling for deleting all resources in high level
if split_delete_length == 2 and app_key != 'WebAppContainer':
pointer_dict[parent_key][app_key] = dict()
pointer_dict[parent_key][app_key] = PyOrderedDict()
old_keys = self.past_dict[parent_key][app_key].keys()
for old_key in old_keys:
pointer_dict[parent_key][app_key]['!' + old_key] = dict()
pointer_dict[parent_key][app_key]['!' + old_key] = PyOrderedDict()
else:
pointer_dict[parent_key]['!' + app_key] = dict()
pointer_dict[parent_key]['!' + app_key] = PyOrderedDict()

def merge_dictionaries(self, dictionary, new_dictionary):
"""
Expand All @@ -367,7 +375,7 @@ def merge_dictionaries(self, dictionary, new_dictionary):
dictionary[key] = new_value
else:
value = dictionary[key]
if isinstance(value, dict) and isinstance(new_value, dict):
if isinstance(value, PyOrderedDict) and isinstance(new_value, PyOrderedDict):
self.merge_dictionaries(value, new_value)
else:
dictionary[key] = new_value
Expand Down Expand Up @@ -542,6 +550,7 @@ def get_compare_msgs(self):
"""
return compare_msgs


def debug(format_string, *arguments):
"""
Generic debug code.
Expand All @@ -553,6 +562,7 @@ def debug(format_string, *arguments):
else:
_logger.finest(format_string, arguments)


def main():
"""
The main entry point for the discoverDomain tool.
Expand Down Expand Up @@ -657,6 +667,7 @@ def main():
_logger.severe('WLSDPLY-05704', eeString)
System.exit(2)


def format_message(key, *args):
"""
Get message using the bundle.
Expand All @@ -666,6 +677,7 @@ def format_message(key, *args):
"""
return ExceptionHelper.getMessage(key, list(args))


if __name__ == "__main__":
main()

Expand Down
3 changes: 3 additions & 0 deletions core/src/main/python/wlsdeploy/yaml/yaml_translator.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,9 @@ def _quotify_string(self, text):
:param text: the input string
:return: the quoted string, or the original string if no quoting was required
"""
if text.startswith('#'):
# this is a comment so don't quote
return text
if bool(re.search(self._requires_quotes_chars_regex, text)):
result = '\'' + _quote_embedded_quotes(text) + '\''
elif len(text) == 0:
Expand Down