-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: stop using device name for interface sync
Use the device ID / UUID which is a better identifier for us to use to find the device to sync the interfaces for. This saves us a trip to the Nautobot DB as well. In Nautobot the device name does not have to be unique so this avoids possible issues there. Added tests of the parser to make sure we get the correct data. Added types so we can have better tests in the future. Cleaned up the duplicate hostname usage in the workflow as well.
- Loading branch information
Showing
9 changed files
with
90 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
python/understack-workflows/tests/test_sync_nautobot_interfaces.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import uuid | ||
|
||
import pytest | ||
|
||
from understack_workflows.main.sync_nautobot_interfaces import argument_parser | ||
|
||
|
||
@pytest.fixture | ||
def device_id() -> uuid.UUID: | ||
return uuid.uuid4() | ||
|
||
|
||
def test_parse_device_name(): | ||
parser = argument_parser(__name__) | ||
with pytest.raises(SystemExit): | ||
parser.parse_args(["--device-id", "FOO"]) | ||
|
||
|
||
def test_parse_device_id(device_id): | ||
parser = argument_parser(__name__) | ||
args = parser.parse_args(["--device-id", str(device_id)]) | ||
|
||
assert args.device_id == device_id |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters