Skip to content

[Feature]: Add support to assign interface to module in the device #1395

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

Open
alexandrud opened this issue Mar 13, 2025 · 0 comments
Open

[Feature]: Add support to assign interface to module in the device #1395

alexandrud opened this issue Mar 13, 2025 · 0 comments

Comments

@alexandrud
Copy link

NetBox version

v4.1.7

Feature type

Change to existing Module

Proposed functionality

Add support to netbox_device_interface to assign it to a netbox_module on a device.

For example on NetApp storage appliances you have 2 controllers for redundancy. You would map them out as netbox modules inside the main storage enclosure. Both controllers have the same interfaces (a0a, a0b). So you cannot map out correctly all interfaces without the modules. Additionaly, each module has it's own management IP.

Request:

Add a field "module" to the netbox_device_interface module so you can assign the interface accordingly.

---
- name: Get network interfaces
  delegate_to: localhost
  netapp.ontap.na_ontap_info:
    hostname: "{{ hostname }}"
    username: "{{ username }}"
    password: "{{ password }}"
    vserver: "{{ vserver | default(omit) }}"
    validate_certs: "{{ validate_certs | default('true') }}"
    use_rest: always
    https: true
    gather_subset:
      - cluster_identity_info
      - cluster_node_info
      - cluster_peer_info
      - ontap_system_version
      - net_interface_info
      - net_port_info
  register: ontap_facts

- name: Ontap - Print data
  when: print_data == true
  debug:
    msg: "{{ ontap_facts.ontap_info }}"
  
- name: Ontap - Create interfaces
  delegate_to: localhost
  with_items: "{{  ontap_facts.ontap_info.net_port_info | dict2items }}"
  when: item.value.port_type != "vlan"
  netbox.netbox.netbox_device_interface:
    netbox_url: "{{ netbox_url }}"
    netbox_token: "{{ netbox_token }}"
    data:
      device: "{{ netbox_device_name }}"
      module: "{{ item.value.node }}"
      name: "{{ item.value.port }}"
      description: "{{ item.value.description | default('') }}"
      type: "{{ '10gbase-x-sfpp' }}" # this needs to be improved
      mac_address: "{{ item.value.mac_address }}"
      speed: "{{ (item.value.operational_speed | default(0)) | int }}"
      enabled: "{{ item.value.is_administrative_up }}"
      mark_connected: "{{ 'true' if (item.value.link_status | default('')) == 'up' else 'false' }}"
      mtu: "{{ item.value.mtu }}"
    state: present
    validate_certs: "{{ validate_certs | default('true') }}"

The netbox object would look like this:

{
    "id": 4313,
    "url": "https://netbox/api/dcim/interfaces/4313/",
    "display_url": "https://netbox/dcim/interfaces/4313/",
    "display": "test",
    "device": {
        "id": 228,
        "url": "https://netbox/api/dcim/devices/228/",
        "display": "stonas (02DI20)",
        "name": "stonas",
        "description": "[TF] CCAB main storage"
    },
    "vdcs": [],
    "module": {
        "id": 1,
        "url": "https://netbox/api/dcim/modules/1/",
        "display": "stonas-10: FAS2720 Node (1)",
        "device": {
            "id": 228,
            "url": "https://netbox/api/dcim/devices/228/",
            "display": "stonas (02DI20)",
            "name": "stonas",
            "description": "[TF] CCAB main storage"
        },
        "module_bay": {
            "id": 1,
            "url": "https://netbox/api/dcim/module-bays/1/",
            "display_url": "https://netbox/dcim/module-bays/1/",
            "display": "stonas-10",
            "name": "stonas-10"
        }
    },
    "name": "test",
    "label": "",
    "type": {
        "value": "100base-fx",
        "label": "100BASE-FX (10/100ME FIBER)"
    },
    "enabled": true,
    "parent": null,
    "bridge": null,
    "lag": null,
    "mtu": null,
    "mac_address": null,
    "speed": null,
    "duplex": null,
    "wwn": null,
    "mgmt_only": false,
    "description": "",
    "mode": null,
    "rf_role": null,
    "rf_channel": null,
    "poe_mode": null,
    "poe_type": null,
    "rf_channel_frequency": null,
    "rf_channel_width": null,
    "tx_power": null,
    "untagged_vlan": null,
    "tagged_vlans": [],
    "mark_connected": false,
    "cable": null,
    "cable_end": "",
    "wireless_link": null,
    "link_peers": [],
    "link_peers_type": null,
    "wireless_lans": [],
    "vrf": null,
    "l2vpn_termination": null,
    "connected_endpoints": null,
    "connected_endpoints_type": null,
    "connected_endpoints_reachable": null,
    "tags": [],
    "custom_fields": {},
    "created": "2025-03-13T12:43:41.242264Z",
    "last_updated": "2025-03-13T12:43:41.242286Z",
    "count_ipaddresses": 0,
    "count_fhrp_groups": 0,
    "_occupied": false
}

Use case

For devices with multiple controllers like enterprise storages.

External dependencies

N/A

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

No branches or pull requests

1 participant