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

tagged port set untagged vlan fails #36

Open
johanreinalda opened this issue Oct 3, 2024 · 4 comments
Open

tagged port set untagged vlan fails #36

johanreinalda opened this issue Oct 3, 2024 · 4 comments

Comments

@johanreinalda
Copy link

johanreinalda commented Oct 3, 2024

Trying to set a new untagged vlan on a tagged port:

Hardware: CX6300, running 10.13.xxxx

Base config:

show runn int 1/1/10
interface 1/1/10
  no shutdown
  no routing
  vlan trunk native 888
  vlan trunk allowed all
exit

After using following code fragment below, port has all vlans removed, except for untagged:

show runn int 1/1/10
interface 1/1/10
  no shutdown
  no routing
  vlan trunk native 999
  vlan trunk allowed 999
exit

Here is the code fragment:

session = Session(ip_address=device_ip, api=API_VERSION)
session.open(username=username, password=password)

iface = Interface(session=session, name=interface_name)
# materialize the attributes:
iface.get()
print(f"Get() vlan_trunks: {pprint.pformat(iface.vlan_trunks)}")

# materialize the attributes:
iface.get(selector="writable", depth=4)
print(f"Get(selector) vlan_trunks: {pprint.pformat(iface.vlan_trunks)}")


iface.set_native_vlan(vlan=int(new_vlan_id), tagged=False)

session.close()

This appears to be because the "iface.vlan_trunks" never gets set (materialized?), and therefor the iface.set_native_vlan() behaves by adding only the new vlan (see interface.py)

Program output:

Get() vlan_trunks: []
Get(selector) vlan_trunks: []

I have tried this with various selector types ("configuration", "writable"), but it makes no difference...
So, how do I get an Interface() object properly materialized to be able to make this change ?

In reference, this is to support the AOS-CX driver in

https://github.com/openl2m/openl2m/blob/development/openl2m/switches/connect/aruba_aoscx/connector.py

@johanreinalda
Copy link
Author

Further testing:

when this is the config:

trunk vlan allowed 888,999

Then I get the following for iface.vlan_trunks:

Get() vlan_trunks: [<pyaoscx.vlan.Vlan object at 0x7fcb5b79b150>, <pyaoscx.vlan.Vlan object at 0x7fcb5b799290>]

I.e. is appears that 'trunk vlan allowed all' produces an empty set, where specific allowed vlans is OK...

Is this expected behaviour? and if so, should interface.py be adjusted to account for that ?

@alagoutte
Copy link

Hi johan,

Yes after a quick look, there is no check when using all vlan (vlan_trunks is empty array) -> https://github.com/aruba/pyaoscx/blob/master/pyaoscx/interface.py#L1568 -> need to modified this @alvinc13

Do you have try to use configure_l2_interface ? ansible module is this

@johanreinalda
Copy link
Author

I've worked around this.

My applications reads all interfaces from Interfaces().get_facts(). This is then cached as needed. Note that get_facts() expands the vlans allowed, and returns 'vlan_trunks' not as [], but as a dict() with each allowed vlan as key.

So when I change an interface with .get() I am now looping through those allowed vlans and adding, similar to below:

trunk_vlans = []
for vlan in allowed_vlans:
v = Vlan(vlan.id)
trunk_vlans.append(v)

iface.vlan_trunks = vlan_trunks
iface.set_native_vlan()

This works.

I still think you do need to fix the set_native_vlan() code in the interface.py module, similar to what is in configure_l2_interface()

@alagoutte
Copy link

Yes, need to be fixed !

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

No branches or pull requests

2 participants