Skip to content

Incorrect DeviceRole matching when parent is present #128

@anshulkamath

Description

@anshulkamath

Diode NetBox Plugin version

v1.3.0

NetBox version

v4.3.2

Diode version

v1.6.2

Diode SDK type

diode-sdk-python

Diode SDK version

v1.3.0

Steps to reproduce

import os
from netboxlabs.diode.sdk import DiodeClient
from netboxlabs.diode.sdk.ingester import (
    DeviceRole,
    DeviceType,
    Device,
    Entity,
)


if __name__ == "__main__":
    with DiodeClient(
        target=os.getenv("DIODE_UPSTREAM"),
        app_name="test-app",
        app_version="0.0.1",
    ) as client:
        GPUType = DeviceType(
            manufacturer="Nvidia",
            model="GPU Server",
            slug="gpu-server",
        )

        GPUServerEnclosure = DeviceRole(
            name="GPU Server Enclosure",
            slug="gpu-server-enclosure",
        )

        GPUTray = DeviceRole(
            name="GPU Server Tray",
            slug="gpu-server-tray",
            parent=GPUServerEnclosure,  # there seems to be a matching bug
        )

        entities = [
            Entity(
                device=Device(
                    name="Server",
                    device_type=GPUType,
                    site="Site ABC",
                    role=GPUServerEnclosure,
                )
            ),
            Entity(
                device=Device(
                    name="Tray 1",
                    device_type=GPUType,
                    site="Site ABC",
                    role=GPUTray,
                )
            ),
            Entity(
                device=Device(
                    name="Tray 2",
                    device_type=GPUType,
                    site="Site ABC",
                    role=GPUTray,
                )
            ),
        ]

        response = client.ingest(entities=entities)
        if response.errors:
            print(f"Errors: {response.errors}")

Expected behavior

Only one GPUServerEnclosure and GPUTray should be created in device roles. It seems that we're violating the matching rules defined here (namely, we don't seem to be falling back on the builtin checks properly)

Observed behavior

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingstatus: needs triageThis issue is awaiting triage by a maintainer

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions