Closed jmcgill298 closed 6 years ago
I incremented __version__
.
I used hconfig-remediation-ansible
to test the patch with python v2 and v3, noting differences:
(env) jamess-mbp:example jtdub$ md5 router1-remediation*.conf
MD5 (router1-remediation-post-patch-py2.conf) = 6081233c0dcfddd877c76a0fe7655649
MD5 (router1-remediation-post-patch-py3.conf) = 6081233c0dcfddd877c76a0fe7655649
MD5 (router1-remediation-pre-patch-py2.conf) = a90f0cc073927746947548b5564f8b56
MD5 (router1-remediation-pre-patch-py3.conf) = 6081233c0dcfddd877c76a0fe7655649
MD5 (router1-remediation-with-exclude-tags-post-patch-py2.conf) = 180b41f9c2f0a7113762f523794cdc7a
MD5 (router1-remediation-with-exclude-tags-post-patch-py3.conf) = 180b41f9c2f0a7113762f523794cdc7a
MD5 (router1-remediation-with-exclude-tags-pre-patch-py2.conf) = 4bf3c7486bc3c4bc85e5648cb6517d2c
MD5 (router1-remediation-with-exclude-tags-pre-patch-py3.conf) = 180b41f9c2f0a7113762f523794cdc7a
MD5 (router1-remediation-with-include-tags-post-patch-py2.conf) = 75cfa0df9b7167bc2d30218cc9a78a43
MD5 (router1-remediation-with-include-tags-post-patch-py3.conf) = 75cfa0df9b7167bc2d30218cc9a78a43
MD5 (router1-remediation-with-include-tags-pre-patch-py2.conf) = d4648409931fe52b2594d41e653b1ae7
MD5 (router1-remediation-with-include-tags-pre-patch-py3.conf) = 75cfa0df9b7167bc2d30218cc9a78a43
In all instances, the pre-patched python v2
run has a different checksum than all runs. Post patch, all checksums are the same. Nice catch.
Python2 does not accurately recognize compiled configs being present in running config.
I identified the issue in the truth test in
HConfigChild._config_to_get_to_right()
.None
is returnedNone
and not all truth tests__bool__()
magic method, which replaces Python2's__nonzero__()
method.__nonzero__()
magic method which returns__bool__()
HConfigChild
objects evaluate toTrue
HConfigChild._config_to_get_to_right()
doesn't include a config line that is present in both running and compiled configs, and that a config line in compiled, but absent in running, is added.