-
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.
extract nautobot-update-cf workflow into understack_workflows
- Loading branch information
Showing
9 changed files
with
47 additions
and
168 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
Empty file.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
2 changes: 0 additions & 2 deletions
2
argo-workflows/nautobot-update-cf/containers/requirements.txt
This file was deleted.
Oops, something went wrong.
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
43 changes: 43 additions & 0 deletions
43
python/understack-workflows/understack_workflows/main/nautobot_update_cf.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,43 @@ | ||
import argparse | ||
|
||
from sushy.main import os | ||
|
||
from understack_workflows.helpers import arg_parser | ||
from understack_workflows.helpers import credential | ||
from understack_workflows.helpers import setup_logger | ||
from understack_workflows.nautobot import Nautobot | ||
|
||
|
||
def argument_parser(): | ||
parser = argparse.ArgumentParser( | ||
prog=os.path.basename(__file__), | ||
description="Ironic to Nautobot provisioning state sync", | ||
) | ||
parser.add_argument("--device_uuid", required=True, help="Nautobot device UUID") | ||
parser.add_argument("--field-name", required=True) | ||
parser.add_argument("--field-value", required=True) | ||
parser.add_argument("--nautobot_url", required=False) | ||
parser.add_argument("--nautobot_token", required=False) | ||
|
||
return parser | ||
|
||
|
||
logger = setup_logger(__name__) | ||
|
||
|
||
def main(): | ||
args = argument_parser().parse_args() | ||
|
||
default_nb_url = "http://nautobot-default.nautobot.svc.cluster.local" | ||
device_uuid = args.device_uuid | ||
field_name = args.field_name | ||
field_value = args.field_value | ||
nb_url = args.nautobot_url or default_nb_url | ||
nb_token = args.nautobot_token or credential("nb-token", "token") | ||
|
||
nautobot = Nautobot(nb_url, nb_token, logger=logger) | ||
nautobot.update_cf(device_uuid, field_name, field_value) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |