Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Netbox api call /dcim/devices/ virtual chassis does not have "member_count" #9329

Closed
PaulWestphal opened this issue May 10, 2022 · 7 comments

Comments

@PaulWestphal
Copy link

NetBox version

v3.2.2

Python version

3.8

Steps to Reproduce

  1. Create any number of devices and a virtual chassis.
  2. Add the devices to the virtual chassis.
  3. Send a GET HTTP request to http://netbox-address-here/api/dcim/devices/

Expected Behavior

According to the documentation, the "virtual_chassis" of each of the created devices should have a field "member_count".

Observed Behavior

There is no "member_count".

@PaulWestphal PaulWestphal added the type: bug A confirmed report of unexpected behavior in the application label May 10, 2022
@DanSheps
Copy link
Member

You need to query the virtual chassis, not the device.

@DanSheps
Copy link
Member

Thank you for opening a bug report. It seems that the described functionality is intended behavior. If you meant to open a feature request instead, please close this issue and open a new one using the feature request template. Otherwise, please revise your post above to elaborate on why you believe the observed behavior is flawed.

@DanSheps DanSheps closed this as not planned Won't fix, can't repro, duplicate, stale May 10, 2022
@DanSheps DanSheps removed the type: bug A confirmed report of unexpected behavior in the application label May 10, 2022
@PaulWestphal
Copy link
Author

PaulWestphal commented May 10, 2022

The example value from /dcim/devices/ has the member_count in it. You can check the documentation yourself.

{

  "count": 0,

  "next": "string",

  "previous": "string",

  "results": [

    {

      "id": 0,

      "url": "string",

      "display": "string",

      "name": "string",

      "device_type": {

        "id": 0,

        "url": "string",

        "display": "string",

        "manufacturer": {

          "id": 0,

          "url": "string",

          "display": "string",

          "name": "string",

          "slug": "string",

          "devicetype_count": 0

       [...]

      "virtual_chassis": {

        "id": 0,

        "url": "string",

        "display": "string",

        "name": "string",

        "master": {

          "id": 0,

          "url": "string",

          "display": "string",

          "name": "string"

        },

        "member_count": 0  <-----------

      },

      "vc_position": 0,

      "vc_priority": 0,

      "comments": "string",

      "local_context_data": "string",

     [...]

      },

      "created": "2022-05-10T14:42:55.190Z",

      "last_updated": "2022-05-10T14:42:55.190Z"

    }

  ]

}

@DanSheps
Copy link
Member

You are correct, it is on the serializer.

I am currently looking into this as it may be related to the field not being annotated when the query resolves.

@DanSheps DanSheps reopened this May 10, 2022
@DanSheps DanSheps added type: bug A confirmed report of unexpected behavior in the application status: under review Further discussion is needed to determine this issue's scope and/or implementation labels May 10, 2022
@jeremystretch
Copy link
Member

This isn't a bug. The member_count field is omitted from the serializer because that data is not available when querying the devices list. (Annotating it would require unduly expensive queries.) It is intended for use and present when retrieving virtual chassis directly in either full or brief mode:

GET /api/dcim/virtual-chassis/?brief=True

{
    "count": 4,
    "next": null,
    "previous": null,
    "results": [
        {
            "id": 1,
            "url": "http://netbox:8000/api/dcim/virtual-chassis/1/",
            "display": "r105-torsw",
            "name": "r105-torsw",
            "master": {
                "id": 98,
                "url": "http://netbox:8000/api/dcim/devices/98/",
                "display": "r105-torsw:1 (98)",
                "name": null
            },
            "member_count": 2
        },
...

@jeremystretch jeremystretch closed this as not planned Won't fix, can't repro, duplicate, stale May 11, 2022
@jeremystretch jeremystretch removed type: bug A confirmed report of unexpected behavior in the application status: under review Further discussion is needed to determine this issue's scope and/or implementation labels May 11, 2022
@PaulWestphal
Copy link
Author

In that case, the API documentation of /dcim/devices/ should be changed. Because it still states that there should be a member_count field.

@PaulWestphal
Copy link
Author

Should I create another Issue for the wrong API documentation?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants