Skip to content

Commit

Permalink
Merge pull request #171 from SUNET/feature.access_aggregate_id
Browse files Browse the repository at this point in the history
Access aggregate ID config option
  • Loading branch information
indy-independence authored May 31, 2021
2 parents c906d0a + c25a777 commit 02c3e2c
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 4 deletions.
11 changes: 7 additions & 4 deletions docs/apiref/interfaces.rst
Original file line number Diff line number Diff line change
Expand Up @@ -140,11 +140,14 @@ You can check what VLAN names exist on a specific switch by using the /settings
API call and specifying the hostname and then look for the vlan_name field
under a specific vxlan.

Data can also optionally contain a key called "description" to set a
description for the interface, this should be a string 0-64 characters.
Data can also contain any of these optional keys:

Data can also optionally contain a key called "enabled" to set the
administrative state of the interface. Defaults to enabled: true if not set.
- description: Description for the interface, this should be a string 0-64 characters.
- enabled: Set the administrative state of the interface. Defaults to true if not set.
- aggregate_id: Identifier for configuring LACP etc. Integer value.
Special value -1 means configure MLAG and use ID based on indexnum.

Setting an optional value to JSON null will remove it from the database.

To disable a port:

Expand Down
10 changes: 10 additions & 0 deletions src/cnaas_nms/api/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,16 @@ def put(self, hostname):
errors.append(
"Enabled must be a bool, true or false, got: {}".
format(if_dict['data']['enabled']))
if 'aggregate_id' in if_dict['data']:
if type(if_dict['data']['aggregate_id']) == int:
intfdata['aggregate_id'] = if_dict['data']['aggregate_id']
elif if_dict['data']['aggregate_id'] is None:
if 'aggregate_id' in intfdata:
del intfdata['aggregate_id']
else:
errors.append(
"Aggregate ID must be an integer: {}".
format(if_dict['data']['aggregate_id']))

if intfdata != intfdata_original:
intf.data = intfdata
Expand Down
16 changes: 16 additions & 0 deletions test/integrationtests.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,22 @@ def test_03_interfaces(self):
)
self.assertEqual(r.status_code, 200, "Failed to update interface")

r = requests.put(
f'{URL}/api/v1.0/device/eosaccess/interfaces',
headers=AUTH_HEADER,
json={"interfaces": {"Ethernet1": {"data": {"aggregate_id": -1}}}},
verify=TLS_VERIFY
)
self.assertEqual(r.status_code, 200, "Failed to update interface")

r = requests.put(
f'{URL}/api/v1.0/device/eosaccess/interfaces',
headers=AUTH_HEADER,
json={"interfaces": {"Ethernet1": {"data": {"aggregate_id": None}}}},
verify=TLS_VERIFY
)
self.assertEqual(r.status_code, 200, "Failed to update interface")

def test_04_syncto_access(self):
r = requests.post(
f'{URL}/api/v1.0/device_syncto',
Expand Down

0 comments on commit 02c3e2c

Please sign in to comment.