-
Notifications
You must be signed in to change notification settings - Fork 124
Issue #974 Interface Enable State Idempotency #987
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -68,7 +68,7 @@ def __init__(self, lines=None, module=None): | |
| "setval": "shutdown", | ||
| "result": { | ||
| '{{ name }}': { | ||
| 'enabled': "{{ False if shutdown is defined and negate is not defined else True }}", | ||
| 'enabled': "{{ True if negate is defined and shutdown is defined else False if shutdown is defined else None }}", | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Dont assume at this point that the absence of This change means we only set enabled True|False if it is explicit in the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Perhaps the logic that resolves facts should handle the system default shutdown logic such that the facts are complete. But that's not the previous convention. |
||
| }, | ||
| }, | ||
| }, | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -451,16 +451,13 @@ def test_3(self): | |
| ) | ||
| merged = [ | ||
| "interface Ethernet1/1", | ||
| "no shutdown", | ||
| "no switchport", | ||
| "interface Ethernet1/2", | ||
| "shutdown", | ||
| "interface loopback1", | ||
| "shutdown", | ||
| "interface loopback2", | ||
| "no shutdown", | ||
| "interface loopback3", | ||
| "no shutdown", | ||
| "interface port-channel3", | ||
| "no shutdown", | ||
| "interface loopback4", | ||
|
|
@@ -474,6 +471,11 @@ def test_3(self): | |
| self.assertEqual(sorted(result["commands"]), sorted(merged)) | ||
|
|
||
| # Test with an older image version which has different defaults | ||
| self.exec_get_defaults.return_value = { | ||
| "default_mode": "layer2", | ||
| "L2_enabled": False, | ||
| } | ||
|
|
||
| merged_legacy = [ | ||
| "interface Ethernet1/1", | ||
| "no shutdown", | ||
|
|
@@ -484,22 +486,24 @@ def test_3(self): | |
| "shutdown", | ||
| "interface loopback2", | ||
| "no shutdown", | ||
| "interface loopback3", | ||
| "no shutdown", | ||
| "interface port-channel3", | ||
| "no shutdown", | ||
| "interface loopback4", | ||
| "no shutdown", | ||
| "interface port-channel4", | ||
| "no shutdown", | ||
| ] | ||
| result = self.execute_module(changed=True, device="legacy") | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This actually appears to be ineffective. The parent class does not process the "device" arg at all from what I can see. Or load any fixtures one way or another |
||
| result = self.execute_module(changed=True) | ||
| self.assertEqual(sorted(result["commands"]), sorted(merged_legacy)) | ||
|
|
||
| deleted = [ | ||
| "interface Ethernet1/2", | ||
| "switchport", | ||
| "shutdown", | ||
| "interface loopback1", | ||
| "shutdown", | ||
| "interface loopback3", | ||
| "shutdown", | ||
| ] | ||
| playbook["state"] = "deleted" | ||
| set_module_args(playbook) | ||
|
|
@@ -516,8 +520,6 @@ def test_3(self): | |
| "shutdown", | ||
| "interface loopback2", | ||
| "no shutdown", | ||
| "interface loopback3", | ||
| "no shutdown", | ||
| "interface port-channel3", | ||
| "no shutdown", | ||
| "interface loopback4", | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moves the resolution of the state to after the interface mode, so that we can feed the final
have_modeinto the enabled state resolution.