Skip to content

Commit

Permalink
nautobot: remove connected_to_network custom field
Browse files Browse the repository at this point in the history
Closes PUC-431
  • Loading branch information
skrobul committed Sep 10, 2024
1 parent 0022519 commit 214fe00
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@
"natural_slug": "1327198-gp2s-3-understack-iad3_core-5836965_spine1-1_iad3_iad_company_global_0ccd",
"custom_fields": {
"core_number": 1327198,
"connected_to_network": "provisioning",
"ironic_provision_state": ""
},
"secrets_group": null,
Expand Down Expand Up @@ -231,7 +230,6 @@
"natural_slug": "1327198-gp2s-3-understack-iad3_core-5836965_spine1-1_iad3_iad_company_global_0ccd",
"custom_fields": {
"core_number": 1327198,
"connected_to_network": "provisioning",
"ironic_provision_state": ""
},
"secrets_group": null,
Expand Down Expand Up @@ -391,7 +389,6 @@
"natural_slug": "1327198-gp2s-3-understack-iad3_core-5836965_spine1-1_iad3_iad_company_global_0ccd",
"custom_fields": {
"core_number": 1327198,
"connected_to_network": "provisioning",
"ironic_provision_state": ""
},
"secrets_group": null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,8 @@

logger = setup_logger(__name__)

network_name_status = {
"tenant": "Active",
"provisioning": "Provisioning Interface"
}
network_name_status = {"tenant": "Active", "provisioning": "Provisioning Interface"}


def update_nautobot(args) -> UUID:
device_id = args.device_id
Expand All @@ -29,7 +27,9 @@ def update_nautobot(args) -> UUID:

nautobot = Nautobot(nb_url, nb_token, logger=logger)
logger.info(f"Updating Nautobot {device_id=!s} {interface_mac=!s} {network_name=}")
interface = nautobot.update_switch_interface_status(device_id, interface_mac, new_status)
interface = nautobot.update_switch_interface_status(
device_id, interface_mac, new_status
)
logger.info(f"Updated Nautobot {device_id=!s} {interface_mac=!s} {network_name=}")

switch_id = interface.device.id
Expand All @@ -45,7 +45,9 @@ def call_undersync(args, switch_id: UUID):
undersync = Undersync(undersync_token)

try:
return undersync.sync_devices([switch_id], dry_run=args.dry_run, force=args.force)
return undersync.sync_devices(
[str(switch_id)], dry_run=args.dry_run, force=args.force
)
except Exception as error:
logger.error(error)
sys.exit(2)
Expand Down Expand Up @@ -81,11 +83,11 @@ def argument_parser():


def main():
"""Updates connected_to_network and triggers Undersync.
"""Updates Interface status in Nautobot triggers Undersync.
Updates Nautobot Device's 'connected_to_network' field and follows with
request to Undersync service, requesting sync for all of the
uplink_switches that the device is connected to.
Updates Nautobot Interfaces's status field and follows with request to
Undersync service, requesting sync for all of the uplink_switches that the
device is connected to.
"""
args = argument_parser().parse_args()

Expand Down

0 comments on commit 214fe00

Please sign in to comment.