Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions aos/blueprint.py
Original file line number Diff line number Diff line change
Expand Up @@ -2191,3 +2191,50 @@ def add_virtual_network_batch(self, bp_id: str, payload: str):
vn_path = f"/api/blueprints/{bp_id}/virtual-networks-batch"

return self.rest.json_resp_post(uri=vn_path, data=payload)

def get_fabric_addressing_policy(self, bp_id):
"""
Return fabric-addressing-policy in a given blueprint.

Parameters
----------
bp_id
(str) - ID of AOS Blueprint

Returns
----------
(obj) json object
"""
path = f'/api/blueprints/{bp_id}/fabric-addressing-policy'
return self.rest.json_resp_get(path)

def update_fabric_addressing_policy(
self,
bp_id,
ipv6_enabled=None,
esi_mac_msb=None
):
"""
Sets a fabric addressing policy for a given blueprint.

Parameters
----------
bp_id
(str) - ID of AOS Blueprint
(bool) - (optional) enable or disable support for IPv6 virtual networks
(int) - (optional) Most Significant Byte (MSB) value used for
ESI MAC addresses
Returns
-------
"""

data = {}

if ipv6_enabled:
data['ipv6_enabled'] = ipv6_enabled

if esi_mac_msb:
data['esi_mac_msb'] = esi_mac_msb

url = f'/api/blueprints/{bp_id}/fabric-addressing-policy'
return self.rest.patch(url, data=data)
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

NAME = "apstra-api-python"

VERSION = '0.1.20'
VERSION = '0.1.21'


REQUIRES = (["requests==2.24.0"],)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"ipv6_enabled": false, "esi_mac_msb": 2}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"ipv6_enabled": false, "esi_mac_msb": 2}
67 changes: 67 additions & 0 deletions tests/test_blueprint.py
Original file line number Diff line number Diff line change
Expand Up @@ -1554,3 +1554,70 @@ def test_get_routing_policies(
"static_routes": False,
"l3edge_server_links": True,
}


def test_get_fabric_addressing_policy(
aos_logged_in, aos_session, expected_auth_headers, aos_api_version
):
bp_id = 'test-bp-1'
aos_session.add_response(
'GET',
f"http://aos:80/api/blueprints/{bp_id}/fabric-addressing-policy",
status=200,
resp=read_fixture(
f'aos/{aos_api_version}/blueprints/' f'get_fabric_addressing_policy.json'
),
)

resp = aos_logged_in.blueprint.get_fabric_addressing_policy(bp_id=bp_id)
assert not resp['ipv6_enabled']
assert resp['esi_mac_msb'] % 2 == 0


def test_update_fabric_addressing_policy(
aos_logged_in, aos_session, expected_auth_headers, aos_api_version
):
bp_id = 'test-bp-1'
url = f"http://aos:80/api/blueprints/{bp_id}/fabric-addressing-policy"
aos_session.add_response(
'PATCH',
url,
status=200,
)

aos_logged_in.blueprint.update_fabric_addressing_policy(
bp_id=bp_id,
ipv6_enabled=True
)
aos_session.request.assert_called_with(
"PATCH",
url,
json={"ipv6_enabled": True},
params=None,
headers=expected_auth_headers,
)

aos_logged_in.blueprint.update_fabric_addressing_policy(
bp_id=bp_id,
esi_mac_msb=4
)
aos_session.request.assert_called_with(
"PATCH",
url,
json={"esi_mac_msb": 4},
params=None,
headers=expected_auth_headers,
)

aos_logged_in.blueprint.update_fabric_addressing_policy(
bp_id=bp_id,
ipv6_enabled=True,
esi_mac_msb=4
)
aos_session.request.assert_called_with(
"PATCH",
url,
json={"ipv6_enabled": True, "esi_mac_msb": 4},
params=None,
headers=expected_auth_headers,
)