diff --git a/Makefile b/Makefile index bb526115..c32a69ab 100644 --- a/Makefile +++ b/Makefile @@ -26,14 +26,14 @@ $(ACTIVATE): requirements-docs.txt @$(PIP) install -U -r requirements-docs.txt @touch $(ACTIVATE) -docs/workflows: $(ACTIVATE) +docs/workflows/argo-events.md: $(ACTIVATE) @mkdir -p docs/workflows @$(PYTHON) scripts/argo-workflows-to-mkdocs.py workflows docs/workflows .PHONY: docs -docs: $(ACTIVATE) docs/workflows ## Builds the documentation +docs: $(ACTIVATE) docs/workflows/argo-events.md ## Builds the documentation $(MKDOCS) build --strict .PHONY: docs-local -docs-local: $(ACTIVATE) docs/workflows ## Build and locally host the documentation +docs-local: $(ACTIVATE) docs/workflows/argo-events.md ## Build and locally host the documentation $(MKDOCS) serve --strict diff --git a/containers/bmc-utils/code/bmc_firmware_update.py b/containers/bmc-utils/code/bmc_firmware_update.py deleted file mode 100644 index 583d31da..00000000 --- a/containers/bmc-utils/code/bmc_firmware_update.py +++ /dev/null @@ -1,76 +0,0 @@ -import os -import requests -import sushy -import json -from urllib import parse as urlparse -import urllib3 -import argparse -import logging - -urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning) - -logger = logging.getLogger(__name__) -handler = logging.StreamHandler() -formatter = logging.Formatter("%(asctime)s - %(name)s - %(levelname)s - %(message)s") -handler.setFormatter(formatter) -logger.addHandler(handler) -logger.setLevel(logging.DEBUG) - - -if __name__ == "__main__": - parser = argparse.ArgumentParser( - prog=os.path.basename(__file__), description="Update BMC firmware" - ) - parser.add_argument( - "--host", required=True, help="The address of the BMC interface" - ) - parser.add_argument("--firmware-url", required=True, help="URL of firmware") - - args = parser.parse_args() - host = args.host - firmware_url = args.firmware_url - username = os.environ["BMC_USERNAME"] - password = os.environ["BMC_PASSWORD"] - - logger.info("Fetching BMC update service ...") - - authn = sushy.auth.SessionOrBasicAuth(username, password) - c = sushy.Sushy(f"https://{host}/redfish/v1/", verify=False, auth=authn) - updsvc = c.get_update_service() - - filename = firmware_url.split("/")[-1] - - headers = { - "Cookie": f"sessionKey={c._conn._auth._session_key}", - "Content-Type": "multipart/form-data", - } - - update_data = { - "UpdateRepository": True, - "UpdateTarget": True, - "ETag": "atag", - "Section": 0, - } - - upd_url = urlparse.urljoin(c._conn._url, updsvc.http_push_uri) - - logger.info(f"Fetching firmware from {firmware_url}") - logger.info(f"Uploading firmware to {upd_url}") - - task = None - try: - with requests.get(firmware_url, stream=True) as r: - r.raise_for_status() - multipart = [ - ("sessionKey", c._conn._auth._session_key), - ("parameters", json.dumps(update_data)), - ("file", (filename, r.raw, "application/octet-stream")), - ] - rsp = c._conn._session.post( - upd_url, files=multipart, verify=False, headers=headers - ) - logger.info(rsp.json()) - except Exception as e: - logger.error(e) - - logger.info("Firmware update complete.") diff --git a/docs/component-argo-workflows.md b/docs/component-argo-workflows.md index 9f52b039..b98d25f7 100644 --- a/docs/component-argo-workflows.md +++ b/docs/component-argo-workflows.md @@ -12,7 +12,6 @@ set of WorkflowTemplates below. | get-bmc-creds | Get the credentials for the target Device | device_id | secret | * | | get-bmc-ip | Get BMC IP address for target Device | device_id | ip | | | nautobot-api | HTTP Template Workflow to query the Nautobot API | method,nautobot_url,uri | result | | -| bmc-firmware-update | Update BMC firmware on target Device | device_id | | | | bmc-sync-creds | Sync's a devices BMC password with what we have on record | device_id | | | \* WorkflowTemplate which requires a manual / custom implementation. diff --git a/workflows/argo-events/docs/README.md b/workflows/argo-events/docs/README.md deleted file mode 120000 index bb92d163..00000000 --- a/workflows/argo-events/docs/README.md +++ /dev/null @@ -1 +0,0 @@ -../../../docs/component-understack-workflows.md \ No newline at end of file diff --git a/workflows/argo-events/kustomization.yaml b/workflows/argo-events/kustomization.yaml index 48b6b5c5..d19d5f2a 100644 --- a/workflows/argo-events/kustomization.yaml +++ b/workflows/argo-events/kustomization.yaml @@ -35,5 +35,4 @@ resources: - workflowtemplates/idrac-enable-network-boot.yaml - workflowtemplates/bmc-sync-creds.yaml - workflowtemplates/sync-srv-redfish-intfs-to-nb.yaml - - workflowtemplates/bmc-firmware-update.yaml - workflowtemplates/sync-bmc-creds.yaml diff --git a/workflows/argo-events/workflowtemplates/bmc-firmware-update.yaml b/workflows/argo-events/workflowtemplates/bmc-firmware-update.yaml deleted file mode 100644 index 3d3195ec..00000000 --- a/workflows/argo-events/workflowtemplates/bmc-firmware-update.yaml +++ /dev/null @@ -1,69 +0,0 @@ -apiVersion: argoproj.io/v1alpha1 -kind: WorkflowTemplate -metadata: - name: bmc-firmware-update - namespace: argo-events - annotations: - workflows.argoproj.io/title: Update BMC firmware on target Device - workflows.argoproj.io/description: | - Defined in `workflows/argo-events/workflowtemplates/bmc-firmware-update.yaml` -spec: - serviceAccountName: workflow - entrypoint: main - arguments: - parameters: - - name: device_id - - name: firmware-url - templates: - - name: main - dag: - tasks: - - name: get-bmc-ip - templateRef: - name: get-bmc-ip - template: main - arguments: - parameters: - - name: device_id - value: "{{workflow.parameters.device_id}}" - - name: get-bmc-creds - templateRef: - name: get-bmc-creds - template: main - arguments: - parameters: - - name: device_id - value: "{{workflow.parameters.device_id}}" - - name: update-firmware - dependencies: [get-bmc-ip, get-bmc-creds] - template: bmc-firmware-update - arguments: - parameters: - - name: ip - value: "{{tasks.get-bmc-ip.outputs.parameters.ip}}" - - name: creds - value: "{{tasks.get-bmc-creds.outputs.parameters.secret}}" - - name: firmware_url - value: "{{workflow.parameters.firmware-url}}" - - - name: bmc-firmware-update - inputs: - parameters: - - name: ip - - name: creds - - name: firmware_url - container: - image: ghcr.io/rackerlabs/understack/argo-bmc-utils-python3.11.8:latest - command: [python] - args: ["/app/bmc_firmware_update.py", "--host", "{{inputs.parameters.ip}}", "--firmware-url", "{{inputs.parameters.firmware_url}}"] - env: - - name: BMC_USERNAME - valueFrom: - secretKeyRef: - name: "{{inputs.parameters.creds}}" - key: username - - name: BMC_PASSWORD - valueFrom: - secretKeyRef: - name: "{{inputs.parameters.creds}}" - key: password