VOL-627: Asfvolt16 OLT adapter should specify the mac_address of OLT
during the creation of logical_device
Change-Id: I8c929a8573129431c2075a317e89c6135e645846
diff --git a/voltha/adapters/asfvolt16_olt/asfvolt16_device_handler.py b/voltha/adapters/asfvolt16_olt/asfvolt16_device_handler.py
index 6b40a5f..c31bcfa 100644
--- a/voltha/adapters/asfvolt16_olt/asfvolt16_device_handler.py
+++ b/voltha/adapters/asfvolt16_olt/asfvolt16_device_handler.py
@@ -351,8 +351,7 @@
self.add_port(port_no=ASFVOLT_NNI_PORT,
port_type=Port.ETHERNET_NNI,
label='NNI facing Ethernet port')
- self.logical_device_id = \
- self.add_logical_device(device_id=device.id)
+ self.add_logical_device(device_id=device.id)
self.add_logical_port(port_no=ASFVOLT_NNI_PORT,
port_type=Port.ETHERNET_NNI,
device_id=device.id,
@@ -755,8 +754,24 @@
break
self.adapter_agent.delete_port(self.device_id, port)
+ @inlineCallbacks
def add_logical_device(self, device_id):
self.log.info('adding-logical-device', device_id=device_id)
+ # Initialze default values for dpid and serial_num
+ dpid = None
+ serial_num = self.host_and_port
+
+ try:
+ asfvolt_system_info = \
+ yield self.bal.get_asfvolt_system_info(device_id)
+ if asfvolt_system_info is not None:
+ if asfvolt_system_info.mac_address is not None:
+ dpid = asfvolt_system_info.mac_address
+ if asfvolt_system_info.serial_num is not None:
+ serial_num = asfvolt_system_info.serial_num
+ except Exception as e:
+ self.log.error('using-default-values', exc=str(e))
+
ld = LogicalDevice(
# not setting id and datapth_id will let the adapter
# agent pick id
@@ -765,7 +780,7 @@
hw_desc='n/a',
sw_desc='logical device for Edgecore ASFvOLT16 OLT',
#serial_num=uuid4().hex,
- serial_num=self.host_and_port,
+ serial_num=serial_num,
dp_desc='n/a'
),
switch_features=ofp_switch_features(
@@ -780,8 +795,8 @@
),
root_device_id=device_id
)
- ld_initialized = self.adapter_agent.create_logical_device(ld)
- return ld_initialized.id
+ ld_initialized = self.adapter_agent.create_logical_device(ld, dpid=dpid)
+ self.logical_device_id = ld_initialized.id
def add_logical_port(self, port_no, port_type,
device_id, logical_device_id):
diff --git a/voltha/adapters/asfvolt16_olt/bal.py b/voltha/adapters/asfvolt16_olt/bal.py
index 9237ee4..e0cab9f 100644
--- a/voltha/adapters/asfvolt16_olt/bal.py
+++ b/voltha/adapters/asfvolt16_olt/bal.py
@@ -16,7 +16,7 @@
from twisted.internet.defer import inlineCallbacks, returnValue
from voltha.adapters.asfvolt16_olt.protos import bal_pb2, \
- bal_model_types_pb2, bal_model_ids_pb2, bal_indications_pb2
+ bal_model_types_pb2, bal_model_ids_pb2, bal_indications_pb2, asfvolt_pb2
from voltha.adapters.asfvolt16_olt.grpc_client import GrpcClient
from voltha.adapters.asfvolt16_olt.asfvolt16_ind_handler \
import Asfvolt16IndHandler
@@ -50,6 +50,7 @@
self.grpc_client.connect(host_and_port)
self.stub = bal_pb2.BalStub(self.grpc_client.channel)
self.ind_stub = bal_indications_pb2.BalGetIndStub(self.grpc_client.channel)
+ self.asfvolt_stub = asfvolt_pb2.AsfvoltStub(self.grpc_client.channel)
self.olt.running = True
# Right now Bi-Directional GRPC support is not there in grpc-c.
@@ -505,6 +506,21 @@
except Exception as e:
self.log.info('OLT-HeartBeat-failed', exc=str(e))
+ @inlineCallbacks
+ def get_asfvolt_system_info(self, device_id):
+ self.log.info('get-asfvolt-system-info')
+ try:
+ obj = bal_pb2.BalDefault()
+ obj.device_id = device_id
+ asfvolt_system_info = \
+ yield self.asfvolt_stub.AsfvoltGetSystemInfo(obj, timeout=GRPC_TIMEOUT)
+ self.log.debug('asf-volt-system-info',
+ asfvolt_system_info=asfvolt_system_info)
+ returnValue(asfvolt_system_info)
+ except Exception as e:
+ self.log.error('get-asfvolt-system-info-failed', exc=str(e))
+ returnValue(None)
+
def get_indication_info(self, device_id):
while self.olt.running:
try:
diff --git a/voltha/adapters/asfvolt16_olt/protos/asfvolt.proto b/voltha/adapters/asfvolt16_olt/protos/asfvolt.proto
new file mode 100644
index 0000000..71869b6
--- /dev/null
+++ b/voltha/adapters/asfvolt16_olt/protos/asfvolt.proto
@@ -0,0 +1,41 @@
+//
+// Copyright 2017 the original author or authors.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+syntax = "proto3";
+
+import "bal.proto";
+
+message AsfSystemInfo {
+ string product_name = 1;
+ string part_num = 2;
+ string serial_num = 3;
+ string mac_address = 4;
+ string mac_range = 5;
+ string manufacturer = 6;
+ string manufacture_date = 7;
+ string vendor = 8;
+ string platform_name = 9;
+ string label_revision = 10;
+ string country_code = 11;
+ string diag_version = 12;
+ string onie_version = 13;
+}
+
+service Asfvolt {
+ /* The grpc-c doesn't accept empty parameters in the RPC request.
+ Hence filling in some default message in the RPC request */
+ rpc AsfvoltGetSystemInfo(BalDefault) returns(AsfSystemInfo) {};
+}