Skip to content

Commit

Permalink
NAS-133788 / 25.10 / Turn off tagging when null is passed to `ipmi.la…
Browse files Browse the repository at this point in the history
…n.update.vlan` (#15484)

* handle when null is passed to vlan

* do not return disabled vlan id on query
  • Loading branch information
creatorcary authored Jan 29, 2025
1 parent 1c67b30 commit 98ba0b5
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions src/middlewared/middlewared/plugins/ipmi_/lan.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from functools import cache

from middlewared.schema import accepts, Bool, Dict, Int, IPAddr, List, Password, Ref, returns, Str
from middlewared.service import private, CallError, filterable_returns, CRUDService, ValidationError, ValidationErrors
from middlewared.service import private, CallError, CRUDService, ValidationError, ValidationErrors
from middlewared.utils import filter_list
from middlewared.validators import Netmask, PasswordComplexity, Range

Expand Down Expand Up @@ -38,7 +38,10 @@ def apply_config(channel, data):
rc |= run(base_cmd + ['netmask', data['netmask']], **options).returncode
rc |= run(base_cmd + ['defgw', 'ipaddr', data['gateway']], **options).returncode

rc |= run(base_cmd + ['vlan', 'id', f'{data.get("vlan", "off")}'], **options).returncode
vlan = data.get("vlan")
if vlan is None:
vlan = "off"
rc |= run(base_cmd + ['vlan', 'id', str(vlan)], **options).returncode

rc |= run(base_cmd + ['access', 'on'], **options).returncode
rc |= run(base_cmd + ['auth', 'USER', 'MD2,MD5'], **options).returncode
Expand Down Expand Up @@ -79,7 +82,7 @@ class IPMILanService(CRUDService):
Str('default_gateway_mac_address'),
Str('backup_gateway_ip_address'),
Str('backup_gateway_mac_address'),
Int('vlan_id'),
Int('vlan_id', null=True),
Bool('vlan_id_enable'),
Int('vlan_priority'),
)
Expand Down Expand Up @@ -120,9 +123,9 @@ def query_impl(self):
continue

data = {'channel': channel, 'id': channel}
for i in filter(lambda x: x.startswith('\t') and not x.startswith('\t#'), stdout):
for line in filter(lambda x: x.startswith('\t') and not x.startswith('\t#'), stdout):
try:
name, value = i.strip().split()
name, value = line.strip().split()
name, value = name.lower(), value.lower()
if value in ('no', 'yes'):
value = True if value == 'yes' else False
Expand All @@ -133,6 +136,9 @@ def query_impl(self):
except ValueError:
break

if data['vlan_id_enable'] is False:
data['vlan_id'] = None

result.append(data)

return result
Expand Down Expand Up @@ -195,7 +201,7 @@ def do_update(self, id_, data):
`gateway` is an IPv4 address used by `ipaddress` to reach outside the local subnet.
`password` is a password to be assigned to channel number `id`
`dhcp` is a boolean. If False, `ipaddress`, `netmask` and `gateway` must be set.
`vlan` is an integer representing the vlan tag number.
`vlan` is an integer representing the vlan tag number. Passing null will disable vlan tagging.
`apply_remote` is a boolean. If True and this is an HA licensed system, will apply
the configuration to the remote controller.
"""
Expand Down

0 comments on commit 98ba0b5

Please sign in to comment.