Skip to content

Commit

Permalink
Merge pull request #298 from rackerlabs/PUC-503
Browse files Browse the repository at this point in the history
chore: rename obm to bmc across the repo
  • Loading branch information
cardoe authored Sep 19, 2024
2 parents d3dc3af + 123f53d commit 66fba24
Show file tree
Hide file tree
Showing 27 changed files with 162 additions and 162 deletions.
16 changes: 8 additions & 8 deletions .github/workflows/build-container-images.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ on:
pull_request:
paths:
- "containers/argo_utils/**"
- "containers/obm-utils/**"
- "containers/bmc-utils/**"
- "containers/python311_alpine/**"
- "containers/python312_alpine/**"
push:
branches:
- main
paths:
- "containers/argo_utils/**"
- "containers/obm-utils/**"
- "containers/bmc-utils/**"
- "containers/python311_alpine/**"
- "containers/python312_alpine/**"

Expand All @@ -23,7 +23,7 @@ env:
VERSION_PYTHON311: 0.0.1
VERSION_PYTHON312: 0.0.1
VERSION_ARGO_UTILS: 0.0.1
VERSION_OBM_UTILS: 0.0.1
VERSION_BMC_UTILS: 0.0.1
VERSION_PYTHON_NAUTOBOT: 0.0.1

jobs:
Expand Down Expand Up @@ -78,13 +78,13 @@ jobs:
labels: |
org.opencontainers.image.version=${{ env.VERSION_ARGO_UTILS }}
- name: Build and deploy OBM Utils image
- name: Build and deploy BMC Utils image
uses: docker/build-push-action@5cd11c3a4ced054e52742c5fd54dca954e0edd85 # v6
with:
context: containers/obm-utils/
file: containers/obm-utils/Dockerfile.obm_utils
context: containers/bmc-utils/
file: containers/bmc-utils/Dockerfile.bmc_utils
# push for all main branch commits
push: ${{ github.event_name != 'pull_request' }}
tags: ghcr.io/${{ github.repository }}/argo-obm-utils-python3.11.8:latest,ghcr.io/${{ github.repository }}/argo-obm-utils-python3.11.8:${{ env.VERSION_OBM_UTILS }}
tags: ghcr.io/${{ github.repository }}/argo-bmc-utils-python3.11.8:latest,ghcr.io/${{ github.repository }}/argo-bmc-utils-python3.11.8:${{ env.VERSION_BMC_UTILS }}
labels: |
org.opencontainers.image.version=${{ env.VERSION_OBM_UTILS }}
org.opencontainers.image.version=${{ env.VERSION_BMC_UTILS }}
4 changes: 2 additions & 2 deletions containers/argo_utils/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ Currently Understack is not including any sort of secret store, outside of what
- Credentials will be mounted from a Kubernetes Secret.
- How those credential Secrets are created is up to you.

`workflowtemplates/get-obm-creds.yaml` and the placeholder secret provided in `deps/` are strictly that, placeholder. They have been provided to allow the workflows to execute,
however they will likely fail until a proper get-obm-creds Workflow is created.
`workflowtemplates/get-bmc-creds.yaml` and the placeholder secret provided in `deps/` are strictly that, placeholder. They have been provided to allow the workflows to execute,
however they will likely fail until a proper get-bmc-creds Workflow is created.

## Example
```bash
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ RUN --mount=type=cache,target=/root/.cache/.pip pip install --no-cache-dir -r /a

FROM ${BASE} as prod

Check warning on line 14 in containers/bmc-utils/Dockerfile.bmc_utils

View workflow job for this annotation

GitHub Actions / build-ghcr-registry

The 'as' keyword should match the case of the 'from' keyword

FromAsCasing: 'as' and 'FROM' keywords' casing do not match More info: https://docs.docker.com/go/dockerfile/rule/from-as-casing/

LABEL org.opencontainers.image.title="Python 3.11 image with OBM utils"
LABEL org.opencontainers.image.base.name="ghcr.io/rackerlabs/understack/argo-obm-utils-python3.11.8"
LABEL org.opencontainers.image.title="Python 3.11 image with BMC utils"
LABEL org.opencontainers.image.base.name="ghcr.io/rackerlabs/understack/argo-bmc-utils-python3.11.8"
LABEL org.opencontainers.image.source=https://github.com/rackerlabs/understack

ENV PATH="/opt/venv/bin:$PATH"
Expand Down
24 changes: 12 additions & 12 deletions containers/obm-utils/README.md → containers/bmc-utils/README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
# Overview

The WorkflowTemplates provided in this directory were created to provide common lifecycle and maintenance functions on OBM controllers.
The WorkflowTemplates provided in this directory were created to provide common lifecycle and maintenance functions on BMC controllers.

## Caveats

- TODO: the obm-sync-creds workflow logic should probably be broken to include an obm-update-password workflow, which then likely has more utility.
- TODO: the bmc-sync-creds workflow logic should probably be broken to include a bmc-update-password workflow, which then likely has more utility.

## Example
```bash
argo -n argo-events submit --from workflowtemplate/obm-sync-creds --parameter device_id=1de4f169-9848-4d8e-921b-65338c1e00ca
argo -n argo-events submit --from workflowtemplate/bmc-sync-creds --parameter device_id=1de4f169-9848-4d8e-921b-65338c1e00ca

Name: obm-sync-creds-wrn2c
Name: bmc-sync-creds-wrn2c
Namespace: argo-events
ServiceAccount: unset
Status: Pending
Expand All @@ -22,7 +22,7 @@ Parameters:

```bash
argo -n argo-events get @latest
Name: obm-sync-creds-wrn2c
Name: bmc-sync-creds-wrn2c
Namespace: argo-events
ServiceAccount: workflow
Status: Running
Expand All @@ -37,14 +37,14 @@ Parameters:
device_id: 1de4f169-9848-4d8e-921b-65338c1e00ca

STEP TEMPLATE PODNAME DURATION MESSAGE
obm-sync-creds-wrn2c main
├─✔ get-obm-creds get-obm-creds/main
│ └─✔ get-obm-creds get-obm-creds-ext/main
│ └─✔ get-obm-creds-ext get-creds-ext/main
bmc-sync-creds-wrn2c main
├─✔ get-bmc-creds get-bmc-creds/main
│ └─✔ get-bmc-creds get-bmc-creds-ext/main
│ └─✔ get-bmc-creds-ext get-creds-ext/main
│ ├─✔ get-ext-num get-ext-num/main
│ └─✔ get-creds-ext get-creds-ext obm-sync-creds-wrn2c-get-creds-ext-2059517959 5s
├─✔ get-obm-ip get-obm-ip/main
│ └─✔ get-creds-ext get-creds-ext bmc-sync-creds-wrn2c-get-creds-ext-2059517959 5s
├─✔ get-bmc-ip get-bmc-ip/main
│ └───✔ nautobot-query nautobot-api/main
│ └───✔ send-request http
└─◷ obm-sync-creds obm-sync-creds obm-sync-creds-wrn2c-obm-sync-creds-2727609696 28s
└─◷ bmc-sync-creds bmc-sync-creds bmc-sync-creds-wrn2c-bmc-sync-creds-2727609696 28s
```
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,17 @@


if __name__ == "__main__":
parser = argparse.ArgumentParser(prog=os.path.basename(__file__), description="Update OBM firmware")
parser.add_argument("--host", required=True, help="The address of the OBM interface")
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["OBM_USERNAME"]
password = os.environ["OBM_PASSWORD"]
username = os.environ["BMC_USERNAME"]
password = os.environ["BMC_PASSWORD"]

logger.info("Fetching OBM update service ...")
logger.info("Fetching BMC update service ...")

authn = sushy.auth.SessionOrBasicAuth(username, password)
c = sushy.Sushy(f"https://{host}/redfish/v1/", verify=False, auth=authn)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ def verify_auth(host: str, username: str = "root", password: str = "") -> bool:
return False


def get_obm_accounts(host: str, username: str, password: str) -> List[Dict]:
"""A vendor agnostic approach to crawling the API for OBM accounts"""
def get_bmc_accounts(host: str, username: str, password: str) -> List[Dict]:
"""A vendor agnostic approach to crawling the API for BMC accounts"""
try:
# get account service
r = redfish_request(host, "/redfish/v1", username, password)
Expand All @@ -67,10 +67,10 @@ def get_obm_accounts(host: str, username: str, password: str) -> List[Dict]:
raise


def set_obm_creds(host: str, username: str, password: str, expected_username: str, expected_password: str) -> bool:
def set_bmc_creds(host: str, username: str, password: str, expected_username: str, expected_password: str) -> bool:
"""Find the account associated with the username in question"""
try:
accounts = get_obm_accounts(host, username, password)
accounts = get_bmc_accounts(host, username, password)

matched_account = None
for account in accounts:
Expand All @@ -83,7 +83,7 @@ def set_obm_creds(host: str, username: str, password: str, expected_username: st
break

if not matched_account:
raise Exception(f"Unable to find OBM account for {expected_username}")
raise Exception(f"Unable to find BMC account for {expected_username}")

account_uri = matched_account["@odata.id"]

Expand All @@ -97,39 +97,39 @@ def set_obm_creds(host: str, username: str, password: str, expected_username: st

if __name__ == "__main__":
parser = argparse.ArgumentParser(
prog=os.path.basename(__file__), description="Attempts to find the correct OBM credentials for a device"
prog=os.path.basename(__file__), description="Attempts to find the correct BMC credentials for a device"
)
parser.add_argument("--host", required=True, help="the address of the obm interface for the device")
parser.add_argument("--host", required=True, help="the address of the bmc interface for the device")

args = parser.parse_args()
host = args.host
expected_username = os.environ["OBM_USERNAME"]
expected_password = os.environ["OBM_PASSWORD"]
expected_username = os.environ["BMC_USERNAME"]
expected_password = os.environ["BMC_PASSWORD"]

legacy_passwords = json.loads(os.getenv("OBM_LEGACY_PASSWORDS", "[]"))
legacy_passwords = json.loads(os.getenv("BMC_LEGACY_PASSWORDS", "[]"))
if not legacy_passwords:
logger.info("env variable OBM_LEGACY_PASSWORDS was not set.")
logger.info("env variable BMC_LEGACY_PASSWORDS was not set.")
sys.exit(1)

logger.info("Ensuring OBM credentials are synced correctly ...")
logger.info("Ensuring BMC credentials are synced correctly ...")

if verify_auth(host, expected_username, expected_password):
logger.info("OBM credentials are in sync.")
logger.info("BMC credentials are in sync.")
sys.exit(0)
else:
logger.info("OBM credentials are NOT in sync. Trying known legacy/vendor credentials ...")
logger.info("BMC credentials are NOT in sync. Trying known legacy/vendor credentials ...")

# iDRAC defaults to blocking an IP address after 3 bad login attempts within 60 second. Since we have the
# initial attempt above, we will sleep 35 seconds between any additional attempts.
delay = 60
username = os.getenv("OBM_LEGACY_USER", "root")
username = os.getenv("BMC_LEGACY_USER", "root")
for password in legacy_passwords:
logger.info(f"Delaying for {delay} seconds to prevent failed auth lockouts ...")
time.sleep(delay)
if verify_auth(host, username, password):
if set_obm_creds(host, username, password, expected_username, expected_password):
logger.info("OBM password has been synced.")
if set_bmc_creds(host, username, password, expected_username, expected_password):
logger.info("BMC password has been synced.")
sys.exit(0)

logger.info("Unable to sync the OBM password.")
logger.info("Unable to sync the BMC password.")
sys.exit(1)
File renamed without changes.
12 changes: 6 additions & 6 deletions docs/component-argo-workflows.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@ set of WorkflowTemplates below.
| WorkflowTemplate | Description | Input | Output | |
|---------------------- |-----------------------------------------------------------|-------------------------|------------|---|
| get-device-nautobot | Return Device Information from Nautobot | device_id | device | |
| get-obm-creds | Get the credentials for the target Device | device_id | secret | * |
| get-obm-ip | Get OBM IP address for target Device | device_id | ip | |
| 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 | |
| obm-firmware-update | Update OBM firmware on target Device | device_id | | |
| obm-sync-creds | Sync's a devices OBM password with what we have on record | device_id | | |
| 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.

As Understack develops, there may be underlying / dependant services which are not included, and require some of the
included WorkflowTemplates to be manually implemented to work in your environment. For example, the get-obm-creds
included WorkflowTemplates to be manually implemented to work in your environment. For example, the get-bmc-creds
WorkflowTemplate will need to be written to communicate with whatever service you're using to store your device
credentials.

Expand Down Expand Up @@ -53,7 +53,7 @@ the Pod's uid can be passed via the `KUBERNETES_POD_UID` environment variable. T
completion of the Workflow `.spec.podGC.strategy` can be set to `OnWorkflowCompletion`.

An example WorkflowTemplate demonstrating argo-python usage can be found
[here](https://github.com/rackerlabs/understack/blob/main/workflows/argo-events/workflowtemplates/get-obm-creds.yaml).
[here](https://github.com/rackerlabs/understack/blob/main/workflows/argo-events/workflowtemplates/get-bmc-creds.yaml).

### Argo CLI

Expand Down
2 changes: 1 addition & 1 deletion python/understack-workflows/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ requests-mock = "^1.12.1"
[tool.poetry.scripts]
sync-keystone = "understack_workflows.main.sync_keystone:main"
sync-interfaces = "understack_workflows.main.sync_interfaces:main"
sync-obm-creds = "understack_workflows.main.sync_obm_creds:main"
sync-bmc-creds = "understack_workflows.main.sync_bmc_creds:main"
sync-server = "understack_workflows.main.sync_server:main"
sync-provision-state = "understack_workflows.main.sync_provision_state:main"
sync-nautobot-interfaces = "understack_workflows.main.sync_nautobot_interfaces:main"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ def main():
)
sys.exit(0)

# Update OBM credentials
expected_username = credential("obm", "username")
expected_password = credential("obm", "password")
# Update BMC credentials
expected_username = credential("bmc", "username")
expected_password = credential("bmc", "password")

updates = [
f"driver_info/redfish_username={expected_username}",
Expand Down
4 changes: 2 additions & 2 deletions python/understack-workflows/understack_workflows/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def check_manufacturer(cls, manufacturer: str) -> None:
)

@classmethod
def obm_is_ilo4(cls, chassis_data: SushyChassis) -> bool:
def bmc_is_ilo4(cls, chassis_data: SushyChassis) -> bool:
return (
chassis_data.redfish_version == "1.0.0"
and chassis_data.manufacturer == "HPE"
Expand All @@ -126,7 +126,7 @@ def from_redfish(cls, oob_obj: Sushy) -> Chassis:

cls.check_manufacturer(chassis_data.manufacturer)

if cls.obm_is_ilo4(chassis_data):
if cls.bmc_is_ilo4(chassis_data):
return cls.from_hp_json(oob_obj, chassis_data.name)

chassis = cls(chassis_data.name, [], [])
Expand Down
2 changes: 1 addition & 1 deletion workflows/argo-events/docs/sync-nb-server-to-ironic.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ We initially wanted to listen on the `dcim.Device` record creation events, but
it is more efficient to listen for the updates on the `dcim.Interface` and
perform additional checks to see:

- if the updated Interface is an OBM interface
- if the updated Interface is an BMC interface
- if the updated Interface's device is a Server (currently we determine this by an interface name, since the Network devices don't have DRAC/iLo cards)

## Caveats
Expand Down
6 changes: 3 additions & 3 deletions workflows/argo-events/docs/sync-srv-redfish-intfs-to-nb.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# Overview

The workflow templates in this folder are designed to create device interfaces in Nautobot based on Redfish information retrieved from devices using OBM credentials.
The workflow templates in this folder are designed to create device interfaces in Nautobot based on Redfish information retrieved from devices using BMC credentials.

The process begins when a sensor detects updates to Nautobot OBM interfaces, prompting the get-obm-creds action to fetch the necessary OBM credentials. This step is crucial as it serves as a prerequisite for the other workflows in this folder. You can find examples of such dependencies in the `deps` folder.
The process begins when a sensor detects updates to Nautobot BMC interfaces, prompting the get-bmc-creds action to fetch the necessary BMC credentials. This step is crucial as it serves as a prerequisite for the other workflows in this folder. You can find examples of such dependencies in the `deps` folder.

Following this, the sensor initiates the `sync-interfaces-to-nautobot` workflow. This workflow obtains Redfish information from a server and uses it to create new device interfaces in Nautobot.

It is also worth noting that embedded/integrated interfaces are omitted for the purposes of the Undercloud project.

## Servers/OBMs supported
## Servers/BMCs supported
The code utilizes the Sushy library to obtain Redfish information. However, to accommodate older versions of Redfish, several workarounds have been implemented within the code.

It was successfully tested on:
Expand Down
16 changes: 8 additions & 8 deletions workflows/argo-events/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ namespace: argo-events

resources:
- secrets/openstack-svc-acct.yaml
- secrets/obm-creds.yaml
- secrets/placeholder-obm-creds.yaml
- secrets/bmc-creds.yaml
- secrets/placeholder-bmc-creds.yaml
- secrets/operate-workflow-sa.token.yaml
- secrets/nautobot-token.yaml
- secrets/placeholder-obm-legacy-passwords.yaml
- secrets/placeholder-bmc-legacy-passwords.yaml
- sensors/ironic-node-update.yaml
- sensors/debug-sensor.yaml
- sensors/nb-oob-interface-update.yaml
Expand All @@ -21,17 +21,17 @@ resources:
- workflowtemplates/get-device-nautobot.yaml
- workflowtemplates/sync-interfaces-to-nautobot.yaml
- workflowtemplates/sync-nb-server-to-ironic.yaml
- workflowtemplates/get-obm-ip.yaml
- workflowtemplates/get-bmc-ip.yaml
- workflowtemplates/sync-provision-state-to-nautobot.yaml
- workflowtemplates/node-events.yaml
- workflowtemplates/sync-interfaces-to-ironic.yaml
- workflowtemplates/undersync-device.yaml
- workflowtemplates/sync-server-to-ironic.yaml
- workflowtemplates/undersync-switch.yaml
- workflowtemplates/keystone-event-project.yaml
- workflowtemplates/get-obm-creds.yaml
- workflowtemplates/get-bmc-creds.yaml
- workflowtemplates/idrac-enable-network-boot.yaml
- workflowtemplates/obm-sync-creds.yaml
- workflowtemplates/bmc-sync-creds.yaml
- workflowtemplates/sync-srv-redfish-intfs-to-nb.yaml
- workflowtemplates/obm-firmware-update.yaml
- workflowtemplates/sync-obm-creds.yaml
- workflowtemplates/bmc-firmware-update.yaml
- workflowtemplates/sync-bmc-creds.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ data:
password: Y2FsdmluY2FsdmluCg==
kind: Secret
metadata:
name: obm-creds
name: bmc-creds
namespace: argo-events
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# The credentials here are the Dell OBM default of root:calvin
# The credentials here are the Dell BMC default of root:calvin
apiVersion: v1
data:
username: cm9vdA==
password: Y2FsdmluY2Fsdmlu
kind: Secret
metadata:
creationTimestamp: null
name: placeholder-obm-creds
name: placeholder-bmc-creds
namespace: argo-events
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# This is a placeholder Secret, used by the bmc-sync-creds.yaml WorkflowTemplate, containing the default Dell BMC password of: '["calvin"]'
apiVersion: v1
data:
passwords: WyJjYWx2aW4iXQ==
kind: Secret
metadata:
creationTimestamp: null
name: placeholder-bmc-legacy-passwords
namespace: argo-events
Loading

0 comments on commit 66fba24

Please sign in to comment.