[ 3050 ] Fixing cut and paste error in voltha.proto.
This commit is an amendment to the previous commit with the
following changes:
1) Simplify the gRPC API to replace the activate_olt and re_enable apis
with only one enable api. Note the adapter interface remains
unchanged to keep the flexibility of operations between different
device adapters.
2) Small changes following the initial code review
This commit consits of the following updates:
1) Support for the following config changes:
1a) Reboot of an OLT/ONU
1b) Deletion of an OLT/ONU
1c) Disabling of an OLT/ONU
1d) Re-enabling of an OLT/ONU
2) Corresponding APIs are added to the voltha.proto file
3) The adapter interface has been augmented with the above
APIs
4) The ponsim_olt and ponsim_onu adapters have been updated to
implement the above APIs
TODOs:
1) Existing flows on the ponsim devices have not been updated
to reflect the above changes.
2) ponsim needs to be augmented to support the above APIs
3) integration tests
The above will be addressed in a separate commit
Change-Id: Ia7af7d773517df269cdc2b0c629d5ef8f1fb6e3a
diff --git a/voltha/core/global_handler.py b/voltha/core/global_handler.py
index 326f407..7d52d29 100644
--- a/voltha/core/global_handler.py
+++ b/voltha/core/global_handler.py
@@ -264,13 +264,87 @@
context)
@twisted_async
- def ActivateDevice(self, request, context):
+ def EnableDevice(self, request, context):
log.info('grpc-request', request=request)
- # TODO dispatching to local instead of passing it to leader
+
+ try:
+ instance_id = self.dispatcher.instance_id_by_device_id(
+ request.id
+ )
+ except KeyError:
+ context.set_details(
+ 'Device \'{}\' not found'.format(request.id))
+ context.set_code(StatusCode.NOT_FOUND)
+ return Device()
+
return self.dispatcher.dispatch(
- self.instance_id,
+ instance_id,
VolthaLocalServiceStub,
- 'ActivateDevice',
+ 'EnableDevice',
+ request,
+ context)
+
+
+ @twisted_async
+ def DisableDevice(self, request, context):
+ log.info('grpc-request', request=request)
+
+ try:
+ instance_id = self.dispatcher.instance_id_by_device_id(
+ request.id
+ )
+ except KeyError:
+ context.set_details(
+ 'Device \'{}\' not found'.format(request.id))
+ context.set_code(StatusCode.NOT_FOUND)
+ return Device()
+
+ return self.dispatcher.dispatch(
+ instance_id,
+ VolthaLocalServiceStub,
+ 'DisableDevice',
+ request,
+ context)
+
+ @twisted_async
+ def RebootDevice(self, request, context):
+ log.info('grpc-request', request=request)
+
+ try:
+ instance_id = self.dispatcher.instance_id_by_device_id(
+ request.id
+ )
+ except KeyError:
+ context.set_details(
+ 'Device \'{}\' not found'.format(request.id))
+ context.set_code(StatusCode.NOT_FOUND)
+ return Device()
+
+ return self.dispatcher.dispatch(
+ instance_id,
+ VolthaLocalServiceStub,
+ 'RebootDevice',
+ request,
+ context)
+
+ @twisted_async
+ def DeleteDevice(self, request, context):
+ log.info('grpc-request', request=request)
+
+ try:
+ instance_id = self.dispatcher.instance_id_by_device_id(
+ request.id
+ )
+ except KeyError:
+ context.set_details(
+ 'Device \'{}\' not found'.format(request.id))
+ context.set_code(StatusCode.NOT_FOUND)
+ return Device()
+
+ return self.dispatcher.dispatch(
+ instance_id,
+ VolthaLocalServiceStub,
+ 'DeleteDevice',
request,
context)