US2853 make object name shorter for switch pnics 43/39143/1
authoryayogev <yaronyogev@gmail.com>
Fri, 11 Aug 2017 15:16:08 +0000 (18:16 +0300)
committeryayogev <yaronyogev@gmail.com>
Fri, 11 Aug 2017 15:16:08 +0000 (18:16 +0300)
Change-Id: Iadc5df69fcdbfa46c29bb94709f67bb95592efcb
Signed-off-by: yayogev <yaronyogev@gmail.com>
app/discover/fetchers/aci/aci_fetch_leaf_to_spine_pnics.py
app/discover/fetchers/aci/aci_fetch_switch_pnic.py

index 992df77..d400007 100644 (file)
@@ -126,6 +126,7 @@ class AciFetchLeafToSpinePnics(AciAccess):
 
             downlink_pnic_json = {
                 "id": db_downlink_pnic_id,
+                "object_name": downlink_pnic_id,
                 "type": "switch_pnic",
                 "role": "downlink",
                 "connected_to": db_uplink_pnic_id,
@@ -137,6 +138,7 @@ class AciFetchLeafToSpinePnics(AciAccess):
 
             uplink_pnic_json = {
                 "id": db_uplink_pnic_id,
+                "object_name": uplink_pnic_id,
                 "type": "switch_pnic",
                 "role": "uplink",
                 "connected_to": db_downlink_pnic_id,
index cd82d7e..bb87b7b 100644 (file)
@@ -11,7 +11,7 @@ import re
 
 from discover.fetchers.aci.aci_access import AciAccess, aci_config_required
 from utils.inventory_mgr import InventoryMgr
-from utils.util import encode_aci_dn, get_object_path_part
+from utils.util import decode_aci_dn, encode_aci_dn, get_object_path_part
 
 
 # Fetches and adds to database:
@@ -91,11 +91,11 @@ class AciFetchSwitchPnic(AciAccess):
                                            environment=environment)
 
         # Prepare pnic json for results list
-        db_pnic_id = "-".join((db_leaf_id,
-                               encode_aci_dn(leaf_pnic["ifId"]),
-                               mac_address))
+        if_id = decode_aci_dn(leaf_pnic["ifId"])
+        db_pnic_id = "-".join([db_leaf_id, if_id, mac_address])
         pnic_json = {
             "id": db_pnic_id,
+            "object_name": if_id,
             "type": "switch_pnic",
             "role": "hostlink",
             "parent_id": db_leaf_id,