VOL-757: OpenOLT - dpid based on OLT ip address
Change-Id: I67949c8ded5dd0a9d1465f85179f282ebc1b6ae9
diff --git a/voltha/adapters/openolt/openolt_device.py b/voltha/adapters/openolt/openolt_device.py
index 0656b79..2b44547 100644
--- a/voltha/adapters/openolt/openolt_device.py
+++ b/voltha/adapters/openolt/openolt_device.py
@@ -129,11 +129,7 @@
olt_indication = event.kwargs.get('ind', None)
self.log.debug("olt indication", olt_ind=olt_indication)
- if not hasattr(olt_indication, 'mac') or \
- not olt_indication.mac:
- mac = '00:00:00:00:00:' + '{:02x}'.format(self.device_num)
- else:
- mac = olt_indication.mac
+ dpid = '00:00:' + self.ip_hex(self.host_and_port.split(":")[0])
# Create logical OF device
ld = LogicalDevice(
@@ -149,7 +145,7 @@
)
)
)
- ld_initialized = self.adapter_agent.create_logical_device(ld, dpid=mac)
+ ld_initialized = self.adapter_agent.create_logical_device(ld, dpid=dpid)
self.logical_device_id = ld_initialized.id
# Update phys OF device
@@ -490,3 +486,14 @@
self.flow_mgr.add_flow(flow, is_down_stream)
except Exception as e:
self.log.exception('failed-to-install-flow', e=e, flow=flow)
+
+ # There has to be a better way to do this
+ def ip_hex(self, ip):
+ octets = ip.split(".")
+ hex_ip = []
+ for octet in octets:
+ octet_hex = hex(int(octet))
+ octet_hex = octet_hex.split('0x')[1]
+ octet_hex = octet_hex.rjust(2, '0')
+ hex_ip.append(octet_hex)
+ return ":".join(hex_ip)
diff --git a/voltha/adapters/openolt/protos/openolt.proto b/voltha/adapters/openolt/protos/openolt.proto
index 7041800..c9f6d98 100644
--- a/voltha/adapters/openolt/protos/openolt.proto
+++ b/voltha/adapters/openolt/protos/openolt.proto
@@ -63,10 +63,6 @@
message OltIndication {
string oper_state = 1; // up, down
- string mac = 2;
- string serial_number = 3;
- string manufacturer = 4;
- string name = 5;
}
message IntfIndication {