VOL-2463 : Enable and disable pon/NNI port
changes in request_handler.go and iAdapter.go interface to accept request from core and process in voltha-openolt-adapter.
Change-Id: I9e4eb5da0a13d12997e95be3aadb0bd856792135
diff --git a/VERSION b/VERSION
index eca690e..818bd47 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-3.0.5
+3.0.6
diff --git a/pkg/adapters/common/request_handler.go b/pkg/adapters/common/request_handler.go
index 414116b..78b8eb5 100644
--- a/pkg/adapters/common/request_handler.go
+++ b/pkg/adapters/common/request_handler.go
@@ -613,3 +613,48 @@
func (rhp *RequestHandlerProxy) Revert_image_update(args []*ic.Argument) (*voltha.ImageDownload, error) {
return &voltha.ImageDownload{}, nil
}
+
+func (rhp *RequestHandlerProxy) Enable_port(args []*ic.Argument) error {
+ logger.Debugw("enable_port", log.Fields{"args": args})
+ deviceId, port, err := rhp.getEnableDisableParams(args)
+ if err != nil {
+ logger.Warnw("enable_port", log.Fields{"args": args, "deviceId": deviceId, "port": port})
+ return err
+ }
+ return rhp.adapter.Enable_port(deviceId, port)
+}
+
+func (rhp *RequestHandlerProxy) Disable_port(args []*ic.Argument) error {
+ logger.Debugw("disable_port", log.Fields{"args": args})
+ deviceId, port, err := rhp.getEnableDisableParams(args)
+ if err != nil {
+ logger.Warnw("disable_port", log.Fields{"args": args, "deviceId": deviceId, "port": port})
+ return err
+ }
+ return rhp.adapter.Disable_port(deviceId, port)
+}
+
+func (rhp *RequestHandlerProxy) getEnableDisableParams(args []*ic.Argument) (string, *voltha.Port, error) {
+ logger.Debugw("getEnableDisableParams", log.Fields{"args": args})
+ if len(args) < 3 {
+ logger.Warn("invalid-number-of-args", log.Fields{"args": args})
+ return "", nil, errors.New("invalid-number-of-args")
+ }
+ deviceId := &ic.StrType{}
+ port := &voltha.Port{}
+ for _, arg := range args {
+ switch arg.Key {
+ case "deviceId":
+ if err := ptypes.UnmarshalAny(arg.Value, deviceId); err != nil {
+ logger.Warnw("cannot-unmarshal-device", log.Fields{"error": err})
+ return "", nil, err
+ }
+ case "port":
+ if err := ptypes.UnmarshalAny(arg.Value, port); err != nil {
+ logger.Warnw("cannot-unmarshal-port", log.Fields{"error": err})
+ return "", nil, err
+ }
+ }
+ }
+ return deviceId.Val, port, nil
+}
diff --git a/pkg/adapters/iAdapter.go b/pkg/adapters/iAdapter.go
index 3b86ac5..c0e44be 100644
--- a/pkg/adapters/iAdapter.go
+++ b/pkg/adapters/iAdapter.go
@@ -49,4 +49,6 @@
Cancel_image_download(device *voltha.Device, request *voltha.ImageDownload) (*voltha.ImageDownload, error)
Activate_image_update(device *voltha.Device, request *voltha.ImageDownload) (*voltha.ImageDownload, error)
Revert_image_update(device *voltha.Device, request *voltha.ImageDownload) (*voltha.ImageDownload, error)
+ Enable_port(deviceId string, port *voltha.Port) error
+ Disable_port(deviceId string, port *voltha.Port) error
}