networktocode/network-importer

virtual interfaces and flexible-vlan-tagging do not import as "tagged" from Juniper Routers

craigcpj opened this issue · 1 comments

Environment

  • Python version: 3.10.6
  • Network Importer version: 3.1.0

We have an interface - xe-0/1/1 with flexible-vlan-tagging and a logical unit 420 on a router.

'network-importer check' produces no errors and finds the logical interface:
2023-02-22 13:22:02,539 - network-importer - DEBUG - Network | Import for EDGE::xe-0/1/1.420

When we run network-importer apply we get the following:

network-importer - WARNING - Unable to create interface xe-0/1/1.420 on EDGE01-ZZZ in Nautobot ({"tagged_vlans":["Mode must be set to tagged when specifying tagged_vlans"]})

Steps to Reproduce

  1. Create an interface with flexible-vlan-tagging and without setting interface-mode trunk/access
  2. run network-importer

On our Switches - we have interface-mode's set to trunk and the interface and logical units were added no problem.
On our Routers - we have flexible-vlan-tagging on the interface which I expected would be added to Nautobot as Mode "tagged" just like on the switches

network-importer - WARNING - Unable to create interface xe-0/1/1.420 on EDGE01-ZZZ in Nautobot ({"tagged_vlans":["Mode must be set to tagged when specifying tagged_vlans"]})

After adding in some additional checks in : adapters/nautobot_api/models.py:

2023-02-22 13:23:41,696 - network-importer - WARNING - NB_PARAMS: {'device': 'device_hash', 'name': 'xe-0/1/1.420', 'type': 'virtual', 'description': 'Description Here'}

2023-02-22 13:23:41,696 - network-importer - WARNING - ATTRS: {'description': 'Description here', 'mode': 'L3_SUB_VLAN', 'switchport_mode': 'NONE', 'is_virtual': True, 'is_lag': False, 'is_lag_member': None, 'parent': None, 'allowed_vlans': ['zzz__420'], 'access_vlan': None}

adding the following to adapters/nautobot_api/models.py at line 126 allows me to work around the issue - but I'm not sure it's the best place to handle this:

    elif ("switchport_mode" in attrs and attrs["switchport_mode"] == "NONE") and attrs["mode"] == "L3_SUB_VLAN":
        LOGGER.warning("NB_PARAMS: %s", nb_params)
        LOGGER.warning("ATTRS: %s", attrs)
        nb_params["mode"] = "tagged"

#311 may be related.