Skip to content

Commit

Permalink
extract nautobot-update-cf workflow into understack_workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
skrobul committed Aug 6, 2024
1 parent 4632dc9 commit 1e3e239
Show file tree
Hide file tree
Showing 9 changed files with 47 additions and 168 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,13 @@ metadata:
name: synchronize-provision-state-to-nautobot
kind: WorkflowTemplate
spec:
arguments:
parameters:
- name: device_uuid
value: "{}"
- name: provision_state
value: "{}"
serviceAccountName: workflow
templates:
- name: synchronize-state
container:
image: ghcr.io/rackerlabs/understack/nautobot-update-cf:latest
image: ghcr.io/rackerlabs/understack/ironic-nautobot-client:latest
command:
- python
- /app/main.py
- nautobot-update-cf
args:
- --device_uuid
- "{{workflow.parameters.device_uuid}}"
Expand Down
Empty file.
43 changes: 0 additions & 43 deletions argo-workflows/nautobot-update-cf/code/helpers.py

This file was deleted.

25 changes: 0 additions & 25 deletions argo-workflows/nautobot-update-cf/code/main.py

This file was deleted.

59 changes: 0 additions & 59 deletions argo-workflows/nautobot-update-cf/code/nautobot.py

This file was deleted.

30 changes: 0 additions & 30 deletions argo-workflows/nautobot-update-cf/containers/Dockerfile

This file was deleted.

2 changes: 0 additions & 2 deletions argo-workflows/nautobot-update-cf/containers/requirements.txt

This file was deleted.

1 change: 1 addition & 0 deletions python/understack-workflows/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ synchronize-server = "understack_workflows.main.synchronize_server:main"
sync-nautobot-interfaces = "understack_workflows.main.sync_nautobot_interfaces:main"
undersync-switch = "understack_workflows.main.undersync_switch:main"
undersync-device = "understack_workflows.main.undersync_device:main"
nautobot-update-cf = "understack_workflows.main.nautobot_update_cf:main"

[tool.setuptools.packages.find]
# avoid packaging up our tests
Expand Down
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()

0 comments on commit 1e3e239

Please sign in to comment.