VOL-622: Enforce datapath id (DPID) to be set as a mac address of
the OLT when a logical device is creating.
Change-Id: Ief3a8b0277dfb786fcb8d30d5a6ce6113034433f
diff --git a/common/utils/id_generation.py b/common/utils/id_generation.py
index bb2e144..e0fea1c 100644
--- a/common/utils/id_generation.py
+++ b/common/utils/id_generation.py
@@ -36,16 +36,19 @@
"""
Creates a logical device id and an OpenFlow datapath id that is unique
across the Voltha cluster.
- The returned ids represents a 64 bits integer where the lower 48 bits is
- the switch id and the upper 16 bits is the core id.
+ The returned logical device id represents a 64 bits integer where the
+ lower 48 bits is the switch id and the upper 16 bits is the core id. For
+ the datapath id the core id is set to '0000' as it is not used for voltha
+ core routing
:param core_id: string
:param switch_id:int
:return: cluster logical device id and OpenFlow datapath id
"""
switch_id = format(switch_id, '012x')
core_in_hex=format(int(core_id, 16), '04x')
- id = '{}{}'.format(core_in_hex[-4:], switch_id[-12:])
- return id, int(id, 16)
+ ld_id = '{}{}'.format(core_in_hex[-4:], switch_id[-12:])
+ dpid_id = '{}{}'.format('0000', switch_id[-12:])
+ return ld_id, int(dpid_id, 16)
def is_broadcast_core_id(id):
assert id and len(id) == 16