From cb1123bcbae70c5d3fa374db86f6a2f2d5851cbf Mon Sep 17 00:00:00 2001 From: "a.letaillanter" Date: Mon, 17 Feb 2025 16:11:18 +0100 Subject: [PATCH] [ZTP] allow MAC identifier in ZTP dynamic URLs --- src/usr/lib/python3/dist-packages/ztp/ZTPObjects.py | 2 ++ tests/test_Identifier.py | 9 +++++++++ 2 files changed, 11 insertions(+) diff --git a/src/usr/lib/python3/dist-packages/ztp/ZTPObjects.py b/src/usr/lib/python3/dist-packages/ztp/ZTPObjects.py index 5b2b7e9..c40a969 100644 --- a/src/usr/lib/python3/dist-packages/ztp/ZTPObjects.py +++ b/src/usr/lib/python3/dist-packages/ztp/ZTPObjects.py @@ -51,6 +51,8 @@ def getIdentifier(self): return sysEeprom.get_serial_number() elif identifier_data == "product-name": return sysEeprom.get_product_name() + elif identifier_data == "mac": + return sysEeprom.get_mac_addr() elif identifier_data == "sonic-version": return get_sonic_version() else: diff --git a/tests/test_Identifier.py b/tests/test_Identifier.py index 474abd4..6dd72f8 100644 --- a/tests/test_Identifier.py +++ b/tests/test_Identifier.py @@ -95,6 +95,15 @@ def test_product_name(self): v = id.getIdentifier() assert(v == sysEeprom.get_product_name()) + def test_mac(self): + '''! + Test when we call the constructor function using the MAC + ''' + + id = Identifier('mac') + v = id.getIdentifier() + assert(v == sysEeprom.get_mac_addr()) + def test_other(self): '''! Test when we call the constructor function using the product name