[VOL-1158] Initial commit of grpc voltha service handler. Also
add license to all files.
Change-Id: I923a53504c74939c1db8177df6197694f2c2b3cd
diff --git a/common/core/northbound/grpc/default_api_handler.go b/common/core/northbound/grpc/default_api_handler.go
new file mode 100644
index 0000000..8fa31d9
--- /dev/null
+++ b/common/core/northbound/grpc/default_api_handler.go
@@ -0,0 +1,259 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+
+ * 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.
+ */
+package grpc
+
+import (
+ "context"
+ "errors"
+ "github.com/golang/protobuf/ptypes/empty"
+ "github.com/opencord/voltha-go/common/log"
+ "github.com/opencord/voltha-go/protos/common"
+ "github.com/opencord/voltha-go/protos/openflow_13"
+ "github.com/opencord/voltha-go/protos/voltha"
+)
+
+type DefaultAPIHandler struct {
+}
+
+func NewDefaultAPIHandler() *DefaultAPIHandler {
+ handler := &DefaultAPIHandler{}
+ return handler
+}
+
+func (handler *DefaultAPIHandler) UpdateLogLevel(ctx context.Context, logging *voltha.Logging) (*empty.Empty, error) {
+ log.Debugw("UpdateLogLevel-request", log.Fields{"newloglevel": logging.Level, "intval": int(logging.Level)})
+ return nil, errors.New("UnImplemented")
+}
+
+func (handler *DefaultAPIHandler) GetVoltha(ctx context.Context, empty *empty.Empty) (*voltha.Voltha, error) {
+ log.Debug("GetVoltha-request")
+ return nil, errors.New("UnImplemented")
+}
+
+func (handler *DefaultAPIHandler) ListCoreInstances(ctx context.Context, empty *empty.Empty) (*voltha.CoreInstances, error) {
+ log.Debug("ListCoreInstances-request")
+ return nil, errors.New("UnImplemented")
+}
+
+func (handler *DefaultAPIHandler) GetCoreInstance(ctx context.Context, id *voltha.ID) (*voltha.CoreInstance, error) {
+ log.Debugw("GetCoreInstance-request", log.Fields{"id": *id})
+ return nil, errors.New("UnImplemented")
+}
+
+func (handler *DefaultAPIHandler) ListAdapters(ctx context.Context, empty *empty.Empty) (*voltha.Adapters, error) {
+ log.Debug("ListAdapters-request")
+ return nil, errors.New("UnImplemented")
+}
+
+func (handler *DefaultAPIHandler) ListLogicalDevices(ctx context.Context, empty *empty.Empty) (*voltha.LogicalDevices, error) {
+ log.Debug("ListLogicalDevices-request")
+ return nil, errors.New("UnImplemented")
+}
+
+func (handler *DefaultAPIHandler) GetLogicalDevice(ctx context.Context, id *voltha.ID) (*voltha.LogicalDevice, error) {
+ log.Debugw("GetLogicalDevice-request", log.Fields{"id": *id})
+ return nil, errors.New("UnImplemented")
+}
+
+func (handler *DefaultAPIHandler) ListLogicalDevicePorts(ctx context.Context, id *voltha.ID) (*voltha.LogicalPorts, error) {
+ log.Debugw("ListLogicalDevicePorts-request", log.Fields{"id": *id})
+ return nil, errors.New("UnImplemented")
+}
+
+func (handler *DefaultAPIHandler) GetLogicalDevicePort(ctx context.Context, id *voltha.LogicalPortId) (*voltha.LogicalPort, error) {
+ log.Debugw("GetLogicalDevicePort-request", log.Fields{"id": *id})
+ return nil, errors.New("UnImplemented")
+}
+
+func (handler *DefaultAPIHandler) EnableLogicalDevicePort(ctx context.Context, id *voltha.LogicalPortId) (*empty.Empty, error) {
+ log.Debugw("EnableLogicalDevicePort-request", log.Fields{"id": *id})
+ return nil, errors.New("UnImplemented")
+}
+
+func (handler *DefaultAPIHandler) DisableLogicalDevicePort(ctx context.Context, id *voltha.LogicalPortId) (*empty.Empty, error) {
+ log.Debugw("DisableLogicalDevicePort-request", log.Fields{"id": *id})
+ return nil, errors.New("UnImplemented")
+}
+
+func (handler *DefaultAPIHandler) ListLogicalDeviceFlows(ctx context.Context, id *voltha.ID) (*openflow_13.Flows, error) {
+ log.Debugw("ListLogicalDeviceFlows-request", log.Fields{"id": *id})
+ return nil, errors.New("UnImplemented")
+}
+
+func (handler *DefaultAPIHandler) UpdateLogicalDeviceFlowTable(ctx context.Context, flow *openflow_13.FlowTableUpdate) (*empty.Empty, error) {
+ log.Debugw("UpdateLogicalDeviceFlowTable-request", log.Fields{"flow": *flow})
+ return nil, errors.New("UnImplemented")
+}
+
+func (handler *DefaultAPIHandler) UpdateLogicalDeviceFlowGroupTable(ctx context.Context, flow *openflow_13.FlowGroupTableUpdate) (*empty.Empty, error) {
+ log.Debugw("UpdateLogicalDeviceFlowGroupTable-request", log.Fields{"flow": *flow})
+ return nil, errors.New("UnImplemented")
+}
+
+func (handler *DefaultAPIHandler) ListLogicalDeviceFlowGroups(ctx context.Context, id *voltha.ID) (*openflow_13.FlowGroups, error) {
+ log.Debugw("ListLogicalDeviceFlowGroups-request", log.Fields{"id": *id})
+ return nil, errors.New("UnImplemented")
+}
+
+func (handler *DefaultAPIHandler) ListDevices(ctx context.Context, empty *empty.Empty) (*voltha.Devices, error) {
+ log.Debug("ListDevices-request")
+ return nil, errors.New("UnImplemented")
+}
+
+func (handler *DefaultAPIHandler) GetDevice(ctx context.Context, id *voltha.ID) (*voltha.Device, error) {
+ log.Debugw("GetDevice-request", log.Fields{"id": id})
+ return nil, errors.New("UnImplemented")
+}
+
+func (handler *DefaultAPIHandler) CreateDevice(ctx context.Context, device *voltha.Device) (*voltha.Device, error) {
+ log.Debugw("CreateDevice-request", log.Fields{"device": *device})
+ return nil, errors.New("UnImplemented")
+}
+
+func (handler *DefaultAPIHandler) EnableDevice(ctx context.Context, id *voltha.ID) (*empty.Empty, error) {
+ log.Debugw("EnableDevice-request", log.Fields{"id": *id})
+ return nil, errors.New("UnImplemented")
+}
+
+func (handler *DefaultAPIHandler) DisableDevice(ctx context.Context, id *voltha.ID) (*empty.Empty, error) {
+ log.Debugw("DisableDevice-request", log.Fields{"id": *id})
+ return nil, errors.New("UnImplemented")
+}
+
+func (handler *DefaultAPIHandler) RebootDevice(ctx context.Context, id *voltha.ID) (*empty.Empty, error) {
+ log.Debugw("RebootDevice-request", log.Fields{"id": *id})
+ return nil, errors.New("UnImplemented")
+}
+
+func (handler *DefaultAPIHandler) DeleteDevice(ctx context.Context, id *voltha.ID) (*empty.Empty, error) {
+ log.Debugw("DeleteDevice-request", log.Fields{"id": *id})
+ return nil, errors.New("UnImplemented")
+}
+
+func (handler *DefaultAPIHandler) DownloadImage(ctx context.Context, img *voltha.ImageDownload) (*common.OperationResp, error) {
+ log.Debugw("DownloadImage-request", log.Fields{"img": *img})
+ return nil, errors.New("UnImplemented")
+}
+
+func (handler *DefaultAPIHandler) GetImageDownloadStatus(ctx context.Context, img *voltha.ImageDownload) (*voltha.ImageDownload, error) {
+ log.Debugw("GetImageDownloadStatus-request", log.Fields{"img": *img})
+ return nil, errors.New("UnImplemented")
+}
+
+func (handler *DefaultAPIHandler) GetImageDownload(ctx context.Context, img *voltha.ImageDownload) (*voltha.ImageDownload, error) {
+ log.Debugw("getdevice-request", log.Fields{"img": *img})
+ return nil, errors.New("UnImplemented")
+}
+
+func (handler *DefaultAPIHandler) ListImageDownloads(ctx context.Context, id *voltha.ID) (*voltha.ImageDownloads, error) {
+ log.Debugw("ListImageDownloads-request", log.Fields{"id": *id})
+ return nil, errors.New("UnImplemented")
+}
+
+func (handler *DefaultAPIHandler) CancelImageDownload(ctx context.Context, img *voltha.ImageDownload) (*common.OperationResp, error) {
+ log.Debugw("CancelImageDownload-request", log.Fields{"img": *img})
+ return nil, errors.New("UnImplemented")
+}
+
+func (handler *DefaultAPIHandler) ActivateImageUpdate(ctx context.Context, img *voltha.ImageDownload) (*common.OperationResp, error) {
+ log.Debugw("ActivateImageUpdate-request", log.Fields{"img": *img})
+ return nil, errors.New("UnImplemented")
+}
+
+func (handler *DefaultAPIHandler) RevertImageUpdate(ctx context.Context, img *voltha.ImageDownload) (*common.OperationResp, error) {
+ log.Debugw("RevertImageUpdate-request", log.Fields{"img": *img})
+ return nil, errors.New("UnImplemented")
+}
+
+func (handler *DefaultAPIHandler) ListDevicePorts(ctx context.Context, id *voltha.ID) (*voltha.Ports, error) {
+ log.Debugw("ListDevicePorts-request", log.Fields{"id": *id})
+ return nil, errors.New("UnImplemented")
+}
+
+func (handler *DefaultAPIHandler) ListDevicePmConfigs(ctx context.Context, id *voltha.ID) (*voltha.PmConfigs, error) {
+ log.Debugw("ListDevicePmConfigs-request", log.Fields{"id": *id})
+ return nil, errors.New("UnImplemented")
+}
+
+func (handler *DefaultAPIHandler) UpdateDevicePmConfigs(ctx context.Context, configs *voltha.PmConfigs) (*empty.Empty, error) {
+ log.Debugw("UpdateDevicePmConfigs-request", log.Fields{"configs": *configs})
+ return nil, errors.New("UnImplemented")
+}
+
+func (handler *DefaultAPIHandler) ListDeviceFlows(ctx context.Context, id *voltha.ID) (*openflow_13.Flows, error) {
+ log.Debugw("ListDeviceFlows-request", log.Fields{"id": *id})
+ return nil, errors.New("UnImplemented")
+}
+
+func (handler *DefaultAPIHandler) ListDeviceFlowGroups(ctx context.Context, id *voltha.ID) (*openflow_13.FlowGroups, error) {
+ log.Debugw("ListDeviceFlowGroups-request", log.Fields{"id": *id})
+ return nil, errors.New("UnImplemented")
+}
+
+func (handler *DefaultAPIHandler) ListDeviceTypes(ctx context.Context, empty *empty.Empty) (*voltha.DeviceTypes, error) {
+ log.Debug("ListDeviceTypes-request")
+ return nil, errors.New("UnImplemented")
+}
+
+func (handler *DefaultAPIHandler) GetDeviceType(ctx context.Context, id *voltha.ID) (*voltha.DeviceType, error) {
+ log.Debugw("GetDeviceType-request", log.Fields{"id": *id})
+ return nil, errors.New("UnImplemented")
+}
+
+func (handler *DefaultAPIHandler) ListDeviceGroups(ctx context.Context, empty *empty.Empty) (*voltha.DeviceGroups, error) {
+ log.Debug("ListDeviceGroups-request")
+ return nil, errors.New("UnImplemented")
+}
+
+func (handler *DefaultAPIHandler) GetDeviceGroup(ctx context.Context, id *voltha.ID) (*voltha.DeviceGroup, error) {
+ log.Debugw("GetDeviceGroup-request", log.Fields{"id": *id})
+ return nil, errors.New("UnImplemented")
+}
+
+func (handler *DefaultAPIHandler) CreateAlarmFilter(ctx context.Context, filter *voltha.AlarmFilter) (*voltha.AlarmFilter, error) {
+ log.Debugw("CreateAlarmFilter-request", log.Fields{"filter": *filter})
+ return nil, errors.New("UnImplemented")
+}
+
+func (handler *DefaultAPIHandler) GetAlarmFilter(ctx context.Context, id *voltha.ID) (*voltha.AlarmFilter, error) {
+ log.Debugw("GetAlarmFilter-request", log.Fields{"id": id})
+ return nil, errors.New("UnImplemented")
+}
+
+func (handler *DefaultAPIHandler) UpdateAlarmFilter(ctx context.Context, filter *voltha.AlarmFilter) (*voltha.AlarmFilter, error) {
+ log.Debugw("UpdateAlarmFilter-request", log.Fields{"filter": *filter})
+ return nil, errors.New("UnImplemented")
+}
+
+func (handler *DefaultAPIHandler) DeleteAlarmFilter(ctx context.Context, id *voltha.ID) (*empty.Empty, error) {
+ log.Debugw("DeleteAlarmFilter-request", log.Fields{"id": *id})
+ return nil, errors.New("UnImplemented")
+}
+
+func (handler *DefaultAPIHandler) ListAlarmFilters(ctx context.Context, empty *empty.Empty) (*voltha.AlarmFilters, error) {
+ log.Debug("ListAlarmFilters-request")
+ return nil, errors.New("UnImplemented")
+}
+
+func (handler *DefaultAPIHandler) GetImages(ctx context.Context, id *voltha.ID) (*voltha.Images, error) {
+ log.Debugw("GetImages-request", log.Fields{"id": id})
+ return nil, errors.New("UnImplemented")
+}
+
+func (handler *DefaultAPIHandler) SelfTest(ctx context.Context, id *voltha.ID) (*voltha.SelfTestResponse, error) {
+ log.Debugw("SelfTest-request", log.Fields{"id": id})
+ return nil, errors.New("UnImplemented")
+}
diff --git a/common/grpc/security.go b/common/grpc/security.go
index e198cb8..930d2c8 100644
--- a/common/grpc/security.go
+++ b/common/grpc/security.go
@@ -1,7 +1,22 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+
+ * 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.
+ */
package grpc
type GrpcSecurity struct {
KeyFile string
CertFile string
CaFile string
-}
\ No newline at end of file
+}
diff --git a/common/grpc/server.go b/common/grpc/server.go
index c3f8c3f..0441fcf 100644
--- a/common/grpc/server.go
+++ b/common/grpc/server.go
@@ -1,12 +1,27 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+
+ * 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.
+ */
package grpc
import (
- "net"
"context"
+ "github.com/opencord/voltha-go/common/log"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials"
+ "net"
"strconv"
- "github.com/opencord/voltha-go/common/log"
"strings"
)
@@ -36,9 +51,7 @@
4. Start the server
s.server.Start(ctx)
- */
-
-
+*/
type GrpcServer struct {
gs *grpc.Server
diff --git a/common/log/log.go b/common/log/log.go
index 93b2072..38a051d 100644
--- a/common/log/log.go
+++ b/common/log/log.go
@@ -1,3 +1,18 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+
+ * 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.
+ */
package log
import (
diff --git a/compose/rw_core.yml b/compose/rw_core.yml
index bd8ea9f..a11f4a9 100644
--- a/compose/rw_core.yml
+++ b/compose/rw_core.yml
@@ -7,7 +7,11 @@
- -kv_store_type=etcd
- -kv_store_host=${DOCKER_HOST_IP}
- -kv_store_port=2379
+ - -grpc_host=${DOCKER_HOST_IP}
+ - -grpc_port=50057
- -banner=true
+ ports:
+ - "50057:50057"
volumes:
- "/var/run/docker.sock:/tmp/docker.sock"
networks:
diff --git a/db/kvstore/client.go b/db/kvstore/client.go
index 8463747..8b1c914 100644
--- a/db/kvstore/client.go
+++ b/db/kvstore/client.go
@@ -1,3 +1,18 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+
+ * 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.
+ */
package kvstore
const (
diff --git a/db/kvstore/consulclient.go b/db/kvstore/consulclient.go
index 911da58..e4f6baf 100644
--- a/db/kvstore/consulclient.go
+++ b/db/kvstore/consulclient.go
@@ -1,3 +1,18 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+
+ * 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.
+ */
package kvstore
import (
diff --git a/db/kvstore/etcdclient.go b/db/kvstore/etcdclient.go
index becc86b..a6a1433 100644
--- a/db/kvstore/etcdclient.go
+++ b/db/kvstore/etcdclient.go
@@ -1,3 +1,18 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+
+ * 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.
+ */
package kvstore
import (
diff --git a/db/kvstore/kvutils.go b/db/kvstore/kvutils.go
index 318482f..cf9a95c 100644
--- a/db/kvstore/kvutils.go
+++ b/db/kvstore/kvutils.go
@@ -1,3 +1,18 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+
+ * 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.
+ */
package kvstore
import (
diff --git a/db/kvstore/kvutils_test.go b/db/kvstore/kvutils_test.go
index 2f3818d..86c4369 100644
--- a/db/kvstore/kvutils_test.go
+++ b/db/kvstore/kvutils_test.go
@@ -1,3 +1,18 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+
+ * 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.
+ */
package kvstore
import (
diff --git a/db/model/backend.go b/db/model/backend.go
index c327fc3..396e233 100644
--- a/db/model/backend.go
+++ b/db/model/backend.go
@@ -1,3 +1,18 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+
+ * 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.
+ */
package model
import (
diff --git a/db/model/backend_test.go b/db/model/backend_test.go
index f51351c..eaa6523 100644
--- a/db/model/backend_test.go
+++ b/db/model/backend_test.go
@@ -1,3 +1,18 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+
+ * 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.
+ */
package model
import (
@@ -11,8 +26,8 @@
CONSUL_KV = "consul"
INVALID_KV = "invalid"
- etcd_host = "10.104.149.247"
- etcd_port = 2379
+ etcd_host = "10.104.149.247"
+ etcd_port = 2379
/*
To debug locally with the remote ETCD container
diff --git a/db/model/branch.go b/db/model/branch.go
index 8a37157..44fe230 100644
--- a/db/model/branch.go
+++ b/db/model/branch.go
@@ -1,3 +1,18 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+
+ * 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.
+ */
package model
// TODO: implement weak references or something equivalent
diff --git a/db/model/branch_test.go b/db/model/branch_test.go
index 4016b70..719bd82 100644
--- a/db/model/branch_test.go
+++ b/db/model/branch_test.go
@@ -1,3 +1,18 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+
+ * 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.
+ */
package model
import (
diff --git a/db/model/callback_type.go b/db/model/callback_type.go
index 42ff608..8f55688 100644
--- a/db/model/callback_type.go
+++ b/db/model/callback_type.go
@@ -1,3 +1,18 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+
+ * 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.
+ */
package model
type CallbackType uint8
diff --git a/db/model/child_type.go b/db/model/child_type.go
index 73f79a3..0020e7d 100644
--- a/db/model/child_type.go
+++ b/db/model/child_type.go
@@ -1,3 +1,18 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+
+ * 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.
+ */
package model
import (
diff --git a/db/model/child_type_test.go b/db/model/child_type_test.go
index 6996a6d..f60462c 100644
--- a/db/model/child_type_test.go
+++ b/db/model/child_type_test.go
@@ -1,3 +1,18 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+
+ * 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.
+ */
package model
import (
diff --git a/db/model/data_revision.go b/db/model/data_revision.go
index deceb87..7918c14 100644
--- a/db/model/data_revision.go
+++ b/db/model/data_revision.go
@@ -1,3 +1,18 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+
+ * 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.
+ */
package model
import (
diff --git a/db/model/event_bus.go b/db/model/event_bus.go
index a833d58..6d95a4d 100644
--- a/db/model/event_bus.go
+++ b/db/model/event_bus.go
@@ -1,3 +1,18 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+
+ * 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.
+ */
package model
import (
diff --git a/db/model/event_bus_client.go b/db/model/event_bus_client.go
index 262b7cc..6d3ce2d 100644
--- a/db/model/event_bus_client.go
+++ b/db/model/event_bus_client.go
@@ -1,3 +1,18 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+
+ * 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.
+ */
package model
import (
diff --git a/db/model/node.go b/db/model/node.go
index 936a79a..eacbec7 100644
--- a/db/model/node.go
+++ b/db/model/node.go
@@ -1,3 +1,18 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+
+ * 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.
+ */
package model
import (
diff --git a/db/model/node_test.go b/db/model/node_test.go
index 3fa05c9..cc17981 100644
--- a/db/model/node_test.go
+++ b/db/model/node_test.go
@@ -1,3 +1,18 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+
+ * 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.
+ */
package model
import (
diff --git a/db/model/persisted_revision.go b/db/model/persisted_revision.go
index f390e0b..81d3563 100644
--- a/db/model/persisted_revision.go
+++ b/db/model/persisted_revision.go
@@ -1,3 +1,18 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+
+ * 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.
+ */
package model
import (
diff --git a/db/model/proxy.go b/db/model/proxy.go
index 41255e5..82ab113 100644
--- a/db/model/proxy.go
+++ b/db/model/proxy.go
@@ -1,3 +1,18 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+
+ * 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.
+ */
package model
import (
diff --git a/db/model/revision.go b/db/model/revision.go
index 06a04ae..07c3388 100644
--- a/db/model/revision.go
+++ b/db/model/revision.go
@@ -1,3 +1,18 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+
+ * 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.
+ */
package model
import (
diff --git a/db/model/revision_test.go b/db/model/revision_test.go
index 9d3ebc5..e7da6a5 100644
--- a/db/model/revision_test.go
+++ b/db/model/revision_test.go
@@ -1,3 +1,18 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+
+ * 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.
+ */
package model
import (
diff --git a/db/model/root.go b/db/model/root.go
index 722fc94..27a6746 100644
--- a/db/model/root.go
+++ b/db/model/root.go
@@ -1,3 +1,18 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+
+ * 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.
+ */
package model
import (
diff --git a/db/model/root_test.go b/db/model/root_test.go
index f9aeb67..de58800 100644
--- a/db/model/root_test.go
+++ b/db/model/root_test.go
@@ -1,3 +1,18 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+
+ * 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.
+ */
package model
import (
diff --git a/db/model/transaction.go b/db/model/transaction.go
index b7288ab..b2afe83 100644
--- a/db/model/transaction.go
+++ b/db/model/transaction.go
@@ -1,3 +1,18 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+
+ * 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.
+ */
package model
import "fmt"
diff --git a/db/model/utils.go b/db/model/utils.go
index d8079f9..497b3f6 100644
--- a/db/model/utils.go
+++ b/db/model/utils.go
@@ -1,3 +1,18 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+
+ * 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.
+ */
package model
import (
diff --git a/docker/Dockerfile.rw_core b/docker/Dockerfile.rw_core
index 2431fa9..0c6b79c 100644
--- a/docker/Dockerfile.rw_core
+++ b/docker/Dockerfile.rw_core
@@ -10,6 +10,8 @@
RUN ["mkdir", "-p", "/src", "src/protos"]
RUN ["mkdir", "-p", "$GOPATH/src", "$GOPATH/pkg", "$GOPATH/bin"]
RUN ["mkdir", "-p", "$GOPATH/src/github.com/opencord/voltha/protos/go"]
+#RUN ["mkdir", "-p", "$GOPATH/src/github.com/opencord/voltha-go"]
+
# Copy files
ADD rw_core $GOPATH/src/github.com/opencord/voltha-go/rw_core
@@ -30,7 +32,7 @@
RUN sh /src/protos/build_protos.sh /src/protos
# Build rw_core
-RUN cd $GOPATH/src/github.com/opencord/voltha-go/rw_core && go get -d ./... && go build -o /src/rw_core
+RUN cd $GOPATH/src/github.com/opencord/voltha-go/rw_core && go get -d ./... && rm -rf $GOPATH/src/github.com/coreos/etcd/vendor/golang.org/x/net/trace && go build -o /src/rw_core
# -------------
# Image creation stage
diff --git a/kafka/kafka_inter_container_library.go b/kafka/kafka_inter_container_library.go
index 9db57a0..00086e3 100644
--- a/kafka/kafka_inter_container_library.go
+++ b/kafka/kafka_inter_container_library.go
@@ -1,3 +1,18 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+
+ * 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.
+ */
package kafka
import (
diff --git a/kafka/kafka_inter_container_library_test.go b/kafka/kafka_inter_container_library_test.go
index 0fca49a..6a3bb37 100644
--- a/kafka/kafka_inter_container_library_test.go
+++ b/kafka/kafka_inter_container_library_test.go
@@ -1,3 +1,18 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+
+ * 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.
+ */
package kafka
import (
@@ -5,7 +20,6 @@
"testing"
)
-
func TestDefaultKafkaProxy(t *testing.T) {
actualResult, error := NewKafkaMessagingProxy()
assert.Equal(t, error, nil)
@@ -71,4 +85,3 @@
assert.Equal(t, actualResult.TargetInterface, m)
assert.Equal(t, actualResult.DefaultTopic.Name, "Adapter")
}
-
diff --git a/kafka/messaging_interface.go b/kafka/messaging_interface.go
index 3511dc7..20784b5 100644
--- a/kafka/messaging_interface.go
+++ b/kafka/messaging_interface.go
@@ -1,3 +1,18 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+
+ * 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.
+ */
package kafka
import (
diff --git a/protos/common.proto b/protos/common.proto
index 4f9ea1e..aca0a36 100644
--- a/protos/common.proto
+++ b/protos/common.proto
@@ -11,6 +11,10 @@
string id = 1;
}
+enum TestModeKeys {
+ api_test=0;
+}
+
message LogLevel {
option (yang_child_rule) = MOVE_TO_PARENT_LEVEL;
@@ -21,6 +25,7 @@
WARNING = 2;
ERROR = 3;
CRITICAL = 4;
+ FATAL = 5;
}
}
diff --git a/protos/voltha.proto b/protos/voltha.proto
index a107bd2..562ed60 100644
--- a/protos/voltha.proto
+++ b/protos/voltha.proto
@@ -70,8 +70,12 @@
repeated AlarmFilter filters = 1;
}
+message Logging {
+ LogLevel.LogLevel level = 1;
+}
+
// Top-level (root) node for a Voltha Instance
-message VolthaInstance {
+message CoreInstance {
option (yang_message_rule) = CREATE_BOTH_GROUPING_AND_CONTAINER;
string instance_id = 1 [(access) = READ_ONLY];
@@ -82,24 +86,16 @@
HealthStatus health = 10 [(child_node) = {}];
- repeated Adapter adapters = 11 [(child_node) = {key: "id" }];
-
repeated LogicalDevice logical_devices = 12 [(child_node) = {key: "id"}];
repeated Device devices = 13 [(child_node) = {key: "id"}];
- repeated DeviceType device_types = 14 [(child_node) = {key: "id"}];
-
repeated DeviceGroup device_groups = 15 [(child_node) = {key: "id"}];
repeated AlarmFilter alarm_filters = 16 [(child_node) = {key: "id"}];
-
- repeated
- omci.MibDeviceData omci_mibs = 28
- [(child_node) = {key: "device_id"}];
}
-message VolthaInstances {
+message CoreInstances {
option (yang_message_rule) = CREATE_BOTH_GROUPING_AND_CONTAINER;
repeated string items = 1;
}
@@ -112,7 +108,7 @@
LogLevel.LogLevel log_level = 2;
- repeated VolthaInstance instances = 3 [(child_node) = {key: "instance_id"}];
+ repeated CoreInstance core_instances = 3 [(child_node) = {key: "instance_id"}];
repeated Adapter adapters = 11 [(child_node) = {key: "id"}];
@@ -122,6 +118,8 @@
repeated DeviceGroup device_groups = 15 [(child_node) = {key: "id"}];
+ repeated AlarmFilter alarm_filters = 16 [(child_node) = {key: "id"}];
+
repeated
omci.MibDeviceData omci_mib_database = 28
[(child_node) = {key: "device_id"}];
@@ -154,6 +152,13 @@
*/
service VolthaService {
+ // Get more information on a given physical device
+ rpc UpdateLogLevel(Logging) returns(google.protobuf.Empty) {
+ option (google.api.http) = {
+ get: "/api/v1/devices/{id}"
+ };
+ }
+
// Get high level information on the Voltha cluster
rpc GetVoltha(google.protobuf.Empty) returns(Voltha) {
option (google.api.http) = {
@@ -161,8 +166,8 @@
};
}
- // List all Voltha cluster instances
- rpc ListVolthaInstances(google.protobuf.Empty) returns(VolthaInstances) {
+ // List all Voltha cluster core instances
+ rpc ListCoreInstances(google.protobuf.Empty) returns(CoreInstances) {
option (google.api.http) = {
get: "/api/v1/instances"
};
@@ -171,7 +176,7 @@
}
// Get details on a Voltha cluster instance
- rpc GetVolthaInstance(ID) returns(VolthaInstance) {
+ rpc GetCoreInstance(ID) returns(CoreInstance) {
option (google.api.http) = {
get: "/api/v1/instances/{id}"
};
diff --git a/rw_core/config/config.go b/rw_core/config/config.go
index 8b2c165..32b7abb 100644
--- a/rw_core/config/config.go
+++ b/rw_core/config/config.go
@@ -1,3 +1,18 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+
+ * 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.
+ */
package config
import (
@@ -15,7 +30,7 @@
EtcdStoreName = "etcd"
default_InstanceID = "rwcore001"
default_GrpcPort = 50057
- default_GrpcHost = "10.100.198.240"
+ default_GrpcHost = "127.0.0.1"
default_KafkaAdapterHost = "10.100.198.240"
default_KafkaAdapterPort = 9092
default_KafkaClusterHost = "10.100.198.240"
diff --git a/rw_core/core/requestHandlerProxy.go b/rw_core/core/requestHandlerProxy.go
index 4bfafa5..1582906 100644
--- a/rw_core/core/requestHandlerProxy.go
+++ b/rw_core/core/requestHandlerProxy.go
@@ -1,18 +1,33 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+
+ * 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.
+ */
package core
import (
+ "errors"
+ "github.com/golang/protobuf/ptypes"
"github.com/opencord/voltha-go/common/log"
ca "github.com/opencord/voltha-go/protos/core_adapter"
"github.com/opencord/voltha-go/protos/voltha"
- "github.com/golang/protobuf/ptypes"
- "errors"
)
type RequestHandlerProxy struct {
TestMode bool
}
-func (rhp *RequestHandlerProxy) GetDevice(args []*ca.Argument)(error, *voltha.Device) {
+func (rhp *RequestHandlerProxy) GetDevice(args []*ca.Argument) (error, *voltha.Device) {
if len(args) != 1 {
log.Warn("invalid-number-of-args", log.Fields{"args": args})
err := errors.New("invalid-number-of-args")
@@ -32,8 +47,7 @@
return nil, nil
}
-
-func (rhp *RequestHandlerProxy) GetChildDevice(args []*ca.Argument)(error, *voltha.Device) {
+func (rhp *RequestHandlerProxy) GetChildDevice(args []*ca.Argument) (error, *voltha.Device) {
if len(args) < 1 {
log.Warn("invalid-number-of-args", log.Fields{"args": args})
err := errors.New("invalid-number-of-args")
@@ -53,7 +67,7 @@
return nil, nil
}
-func (rhp *RequestHandlerProxy) GetPorts(args []*ca.Argument)(error, *voltha.Ports) {
+func (rhp *RequestHandlerProxy) GetPorts(args []*ca.Argument) (error, *voltha.Ports) {
if len(args) != 2 {
log.Warn("invalid-number-of-args", log.Fields{"args": args})
err := errors.New("invalid-number-of-args")
@@ -75,7 +89,7 @@
log.Debugw("GetPorts", log.Fields{"deviceID": pID.Val, "portype": pt.Val})
if rhp.TestMode { // Execute only for test cases
- aPort := &voltha.Port{Label:"test_port"}
+ aPort := &voltha.Port{Label: "test_port"}
allPorts := &voltha.Ports{}
allPorts.Items = append(allPorts.Items, aPort)
return nil, allPorts
@@ -84,7 +98,7 @@
}
-func (rhp *RequestHandlerProxy) GetChildDevices(args []*ca.Argument)(error, *voltha.Device) {
+func (rhp *RequestHandlerProxy) GetChildDevices(args []*ca.Argument) (error, *voltha.Device) {
if len(args) != 1 {
log.Warn("invalid-number-of-args", log.Fields{"args": args})
err := errors.New("invalid-number-of-args")
@@ -107,7 +121,7 @@
// ChildDeviceDetected is invoked when a child device is detected. The following
// parameters are expected:
// {parent_device_id, parent_port_no, child_device_type, proxy_address, admin_state, **kw)
-func (rhp *RequestHandlerProxy) ChildDeviceDetected(args []*ca.Argument) (error) {
+func (rhp *RequestHandlerProxy) ChildDeviceDetected(args []*ca.Argument) error {
if len(args) < 5 {
log.Warn("invalid-number-of-args", log.Fields{"args": args})
err := errors.New("invalid-number-of-args")
@@ -142,13 +156,11 @@
// Need to decode the other params - in this case the key will represent the proto type
// TODO decompose the other parameteres for matching criteria and process
- log.Debugw("ChildDeviceDetected", log.Fields{"deviceId": pID.Val, "portNo":portNo.Val,
- "deviceType": dt.Val, "proxyAddress": pAddr, "adminState": adminState})
+ log.Debugw("ChildDeviceDetected", log.Fields{"deviceId": pID.Val, "portNo": portNo.Val,
+ "deviceType": dt.Val, "proxyAddress": pAddr, "adminState": adminState})
if rhp.TestMode { // Execute only for test cases
return nil
}
return nil
}
-
-
diff --git a/rw_core/main.go b/rw_core/main.go
index a0928c5..f495aeb 100644
--- a/rw_core/main.go
+++ b/rw_core/main.go
@@ -1,14 +1,33 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+
+ * 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.
+ */
package main
import (
"context"
"errors"
"fmt"
+ grpcserver "github.com/opencord/voltha-go/common/grpc"
"github.com/opencord/voltha-go/common/log"
"github.com/opencord/voltha-go/db/kvstore"
"github.com/opencord/voltha-go/kafka"
ca "github.com/opencord/voltha-go/protos/core_adapter"
+ "github.com/opencord/voltha-go/protos/voltha"
"github.com/opencord/voltha-go/rw_core/config"
+ grpcapi "github.com/opencord/voltha-go/rw_core/nbi/grpc"
+ "google.golang.org/grpc"
"os"
"os/signal"
"strconv"
@@ -22,6 +41,7 @@
halted bool
exitChannel chan int
kmp *kafka.KafkaMessagingProxy
+ grpcServer *grpcserver.GrpcServer
//For test
receiverChannels []<-chan *ca.InterContainerMessage
}
@@ -69,10 +89,32 @@
}
}
+func (core *rwCore) startGRPCService(context.Context) {
+ // create an insecure gserver server
+ core.grpcServer = grpcserver.NewGrpcServer(core.config.GrpcHost, core.config.GrpcPort, nil, false)
+ log.Info("server created")
+ //
+ // Create a function to register the core GRPC service with the GRPC server
+ f := func(gs *grpc.Server) {
+ voltha.RegisterVolthaServiceServer(
+ gs,
+ grpcapi.NewAPIHandler(),
+ )
+ }
+
+ core.grpcServer.AddService(f)
+ log.Info("service add")
+
+ // Start the server
+ core.grpcServer.Start(context.Background())
+ log.Info("server started")
+}
+
func (core *rwCore) start(ctx context.Context) {
log.Info("Starting RW Core components")
// Setup GRPC Server
+ go core.startGRPCService(ctx)
// Setup KV Client
diff --git a/rw_core/nbi/grpc/api_handler.go b/rw_core/nbi/grpc/api_handler.go
new file mode 100644
index 0000000..e4ebf0c
--- /dev/null
+++ b/rw_core/nbi/grpc/api_handler.go
@@ -0,0 +1,215 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+
+ * 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.
+ */
+package grpc
+
+import (
+ "context"
+ "errors"
+ "github.com/golang/protobuf/ptypes/empty"
+ da "github.com/opencord/voltha-go/common/core/northbound/grpc"
+ "github.com/opencord/voltha-go/common/log"
+ "github.com/opencord/voltha-go/protos/common"
+ "github.com/opencord/voltha-go/protos/openflow_13"
+ "github.com/opencord/voltha-go/protos/voltha"
+ "google.golang.org/grpc/metadata"
+)
+
+type APIHandler struct {
+ da.DefaultAPIHandler
+}
+
+func NewAPIHandler() *APIHandler {
+ handler := &APIHandler{}
+ return handler
+}
+func isTestMode(ctx context.Context) bool {
+ md, _ := metadata.FromIncomingContext(ctx)
+ _, exist := md[common.TestModeKeys_api_test.String()]
+ return exist
+}
+
+func (handler *APIHandler) UpdateLogLevel(ctx context.Context, logging *voltha.Logging) (*empty.Empty, error) {
+ log.Debugw("UpdateLogLevel-request", log.Fields{"newloglevel": logging.Level, "intval": int(logging.Level)})
+ if isTestMode(ctx) {
+ out := new(empty.Empty)
+ log.SetLoglevel(int(logging.Level))
+ return out, nil
+ }
+ return nil, errors.New("Unimplemented")
+
+}
+
+func (handler *APIHandler) EnableLogicalDevicePort(ctx context.Context, id *voltha.LogicalPortId) (*empty.Empty, error) {
+ log.Debugw("EnableLogicalDevicePort-request", log.Fields{"id": id, "test": common.TestModeKeys_api_test.String()})
+ if isTestMode(ctx) {
+ out := new(empty.Empty)
+ return out, nil
+ }
+ return nil, errors.New("Unimplemented")
+}
+
+func (handler *APIHandler) DisableLogicalDevicePort(ctx context.Context, id *voltha.LogicalPortId) (*empty.Empty, error) {
+ log.Debugw("DisableLogicalDevicePort-request", log.Fields{"id": id, "test": common.TestModeKeys_api_test.String()})
+ if isTestMode(ctx) {
+ out := new(empty.Empty)
+ return out, nil
+ }
+ return nil, errors.New("Unimplemented")
+}
+
+func (handler *APIHandler) UpdateLogicalDeviceFlowTable(ctx context.Context, flow *openflow_13.FlowTableUpdate) (*empty.Empty, error) {
+ log.Debugw("UpdateLogicalDeviceFlowTable-request", log.Fields{"flow": flow, "test": common.TestModeKeys_api_test.String()})
+ if isTestMode(ctx) {
+ out := new(empty.Empty)
+ return out, nil
+ }
+ return nil, errors.New("Unimplemented")
+}
+
+func (handler *APIHandler) UpdateLogicalDeviceFlowGroupTable(ctx context.Context, flow *openflow_13.FlowGroupTableUpdate) (*empty.Empty, error) {
+ log.Debugw("UpdateLogicalDeviceFlowGroupTable-request", log.Fields{"flow": flow, "test": common.TestModeKeys_api_test.String()})
+ if isTestMode(ctx) {
+ out := new(empty.Empty)
+ return out, nil
+ }
+ return nil, errors.New("Unimplemented")
+}
+
+func (handler *APIHandler) CreateDevice(ctx context.Context, device *voltha.Device) (*voltha.Device, error) {
+ log.Debugw("createdevice-request", log.Fields{"device": *device})
+ if isTestMode(ctx) {
+ return &voltha.Device{Id: device.Id}, nil
+ }
+ return nil, errors.New("Unimplemented")
+}
+
+func (handler *APIHandler) EnableDevice(ctx context.Context, id *voltha.ID) (*empty.Empty, error) {
+ log.Debugw("enabledevice-request", log.Fields{"id": id})
+ if isTestMode(ctx) {
+ out := new(empty.Empty)
+ return out, nil
+ }
+ return nil, errors.New("Unimplemented")
+}
+
+func (handler *APIHandler) DisableDevice(ctx context.Context, id *voltha.ID) (*empty.Empty, error) {
+ log.Debugw("disabledevice-request", log.Fields{"id": id})
+ if isTestMode(ctx) {
+ out := new(empty.Empty)
+ return out, nil
+ }
+ return nil, errors.New("Unimplemented")
+}
+
+func (handler *APIHandler) RebootDevice(ctx context.Context, id *voltha.ID) (*empty.Empty, error) {
+ log.Debugw("disabledevice-request", log.Fields{"id": id})
+ if isTestMode(ctx) {
+ out := new(empty.Empty)
+ return out, nil
+ }
+ return nil, errors.New("Unimplemented")
+}
+
+func (handler *APIHandler) DeleteDevice(ctx context.Context, id *voltha.ID) (*empty.Empty, error) {
+ log.Debugw("deletedevice-request", log.Fields{"id": id})
+ if isTestMode(ctx) {
+ out := new(empty.Empty)
+ return out, nil
+ }
+ return nil, errors.New("Unimplemented")
+}
+
+func (handler *APIHandler) DownloadImage(ctx context.Context, img *voltha.ImageDownload) (*common.OperationResp, error) {
+ log.Debugw("DownloadImage-request", log.Fields{"img": *img})
+ if isTestMode(ctx) {
+ resp := &common.OperationResp{Code: common.OperationResp_OPERATION_SUCCESS}
+ return resp, nil
+ }
+
+ return nil, errors.New("UnImplemented")
+}
+
+func (handler *APIHandler) CancelImageDownload(ctx context.Context, img *voltha.ImageDownload) (*common.OperationResp, error) {
+ log.Debugw("CancelImageDownload-request", log.Fields{"img": *img})
+ if isTestMode(ctx) {
+ resp := &common.OperationResp{Code: common.OperationResp_OPERATION_SUCCESS}
+ return resp, nil
+ }
+ return nil, errors.New("UnImplemented")
+}
+
+func (handler *APIHandler) ActivateImageUpdate(ctx context.Context, img *voltha.ImageDownload) (*common.OperationResp, error) {
+ log.Debugw("ActivateImageUpdate-request", log.Fields{"img": *img})
+ if isTestMode(ctx) {
+ resp := &common.OperationResp{Code: common.OperationResp_OPERATION_SUCCESS}
+ return resp, nil
+ }
+ return nil, errors.New("UnImplemented")
+}
+
+func (handler *APIHandler) RevertImageUpdate(ctx context.Context, img *voltha.ImageDownload) (*common.OperationResp, error) {
+ log.Debugw("RevertImageUpdate-request", log.Fields{"img": *img})
+ if isTestMode(ctx) {
+ resp := &common.OperationResp{Code: common.OperationResp_OPERATION_SUCCESS}
+ return resp, nil
+ }
+ return nil, errors.New("UnImplemented")
+}
+
+func (handler *APIHandler) UpdateDevicePmConfigs(ctx context.Context, configs *voltha.PmConfigs) (*empty.Empty, error) {
+ log.Debugw("UpdateDevicePmConfigs-request", log.Fields{"configs": *configs})
+ if isTestMode(ctx) {
+ out := new(empty.Empty)
+ return out, nil
+ }
+ return nil, errors.New("UnImplemented")
+}
+
+func (handler *APIHandler) CreateAlarmFilter(ctx context.Context, filter *voltha.AlarmFilter) (*voltha.AlarmFilter, error) {
+ log.Debugw("CreateAlarmFilter-request", log.Fields{"filter": *filter})
+ if isTestMode(ctx) {
+ f := &voltha.AlarmFilter{Id: filter.Id}
+ return f, nil
+ }
+ return nil, errors.New("UnImplemented")
+}
+
+func (handler *APIHandler) UpdateAlarmFilter(ctx context.Context, filter *voltha.AlarmFilter) (*voltha.AlarmFilter, error) {
+ log.Debugw("UpdateAlarmFilter-request", log.Fields{"filter": *filter})
+ if isTestMode(ctx) {
+ f := &voltha.AlarmFilter{Id: filter.Id}
+ return f, nil
+ }
+ return nil, errors.New("UnImplemented")
+}
+
+func (handler *APIHandler) DeleteAlarmFilter(ctx context.Context, id *voltha.ID) (*empty.Empty, error) {
+ log.Debugw("DeleteAlarmFilter-request", log.Fields{"id": *id})
+ if isTestMode(ctx) {
+ out := new(empty.Empty)
+ return out, nil
+ }
+ return nil, errors.New("UnImplemented")
+}
+
+func (handler *APIHandler) SelfTest(ctx context.Context, id *voltha.ID) (*voltha.SelfTestResponse, error) {
+ log.Debugw("SelfTest-request", log.Fields{"id": id})
+ if isTestMode(ctx) {
+ resp := &voltha.SelfTestResponse{Result: voltha.SelfTestResponse_SUCCESS}
+ return resp, nil
+ }
+ return nil, errors.New("UnImplemented")
+}
diff --git a/rw_core/nbi/grpc/api_handler_client_test.go b/rw_core/nbi/grpc/api_handler_client_test.go
new file mode 100644
index 0000000..e2f3188
--- /dev/null
+++ b/rw_core/nbi/grpc/api_handler_client_test.go
@@ -0,0 +1,267 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+
+ * 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.
+ */
+package grpc
+
+import (
+ "context"
+ "github.com/golang/protobuf/ptypes/empty"
+ "github.com/opencord/voltha-go/common/log"
+ "github.com/opencord/voltha-go/protos/common"
+ "github.com/opencord/voltha-go/protos/openflow_13"
+ "github.com/opencord/voltha-go/protos/voltha"
+ "github.com/stretchr/testify/assert"
+ "google.golang.org/grpc"
+ "google.golang.org/grpc/metadata"
+ "google.golang.org/grpc/status"
+ "os"
+ "testing"
+)
+
+var conn *grpc.ClientConn
+var stub voltha.VolthaServiceClient
+var testMode string
+
+func setup() {
+ var err error
+ if _, err = log.SetLogger(log.JSON, 3, log.Fields{"instanceId": "testing"}); err != nil {
+ log.With(log.Fields{"error": err}).Fatal("Cannot setup logging")
+ }
+ conn, err = grpc.Dial("localhost:50057", grpc.WithInsecure())
+ if err != nil {
+ log.Fatalf("did not connect: %s", err)
+ }
+
+ stub = voltha.NewVolthaServiceClient(conn)
+ testMode = common.TestModeKeys_api_test.String()
+}
+
+func TestGetDevice(t *testing.T) {
+ var id common.ID
+ id.Id = "anyid"
+ ctx := metadata.NewOutgoingContext(context.Background(), metadata.Pairs(testMode, "true"))
+ response, err := stub.GetDevice(ctx, &id)
+ assert.Nil(t, response)
+ st, _ := status.FromError(err)
+ assert.Equal(t, "UnImplemented", st.Message())
+
+}
+
+func TestUpdateLogLevelError(t *testing.T) {
+ ctx := metadata.NewOutgoingContext(context.Background(), metadata.Pairs(testMode, "true"))
+ level := voltha.Logging{Level: common.LogLevel_ERROR}
+ response, err := stub.UpdateLogLevel(ctx, &level)
+ log.Infow("response", log.Fields{"res": response, "error": err})
+ assert.Equal(t, &empty.Empty{}, response)
+ assert.Nil(t, err)
+}
+
+func TestGetVoltha(t *testing.T) {
+ ctx := metadata.NewOutgoingContext(context.Background(), metadata.Pairs(testMode, "true"))
+ response, err := stub.GetVoltha(ctx, &empty.Empty{})
+ assert.Nil(t, response)
+ st, _ := status.FromError(err)
+ assert.Equal(t, "UnImplemented", st.Message())
+}
+
+func TestUpdateLogLevelDebug(t *testing.T) {
+ ctx := metadata.NewOutgoingContext(context.Background(), metadata.Pairs(testMode, "true"))
+ level := voltha.Logging{Level: common.LogLevel_DEBUG}
+ response, err := stub.UpdateLogLevel(ctx, &level)
+ log.Infow("response", log.Fields{"res": response, "error": err})
+ assert.Equal(t, &empty.Empty{}, response)
+ assert.Nil(t, err)
+}
+
+
+func TestGetCoreInstance(t *testing.T) {
+ id := &voltha.ID{Id: "getCoreInstance"}
+ ctx := metadata.NewOutgoingContext(context.Background(), metadata.Pairs(testMode, "true"))
+ response, err := stub.GetCoreInstance(ctx, id)
+ assert.Nil(t, response)
+ st, _ := status.FromError(err)
+ assert.Equal(t, "UnImplemented", st.Message())
+}
+
+func TestGetLogicalDevice(t *testing.T) {
+ id := &voltha.ID{Id: "getLogicalDevice"}
+ ctx := metadata.NewOutgoingContext(context.Background(), metadata.Pairs(testMode, "true"))
+ response, err := stub.GetLogicalDevice(ctx, id)
+ assert.Nil(t, response)
+ st, _ := status.FromError(err)
+ assert.Equal(t, "UnImplemented", st.Message())
+}
+
+func TestGetLogicalDevicePort(t *testing.T) {
+ id := &voltha.LogicalPortId{Id: "GetLogicalDevicePort"}
+ ctx := metadata.NewOutgoingContext(context.Background(), metadata.Pairs(testMode, "true"))
+ response, err := stub.GetLogicalDevicePort(ctx, id)
+ assert.Nil(t, response)
+ st, _ := status.FromError(err)
+ assert.Equal(t, "UnImplemented", st.Message())
+}
+
+func TestListLogicalDevicePorts(t *testing.T) {
+ id := &voltha.ID{Id: "listLogicalDevicePorts"}
+ ctx := metadata.NewOutgoingContext(context.Background(), metadata.Pairs(testMode, "true"))
+ response, err := stub.ListLogicalDevicePorts(ctx, id)
+ assert.Nil(t, response)
+ st, _ := status.FromError(err)
+ assert.Equal(t, "UnImplemented", st.Message())
+}
+
+func TestListLogicalDeviceFlows(t *testing.T) {
+ id := &voltha.ID{Id: "ListLogicalDeviceFlows"}
+ ctx := metadata.NewOutgoingContext(context.Background(), metadata.Pairs(testMode, "true"))
+ response, err := stub.ListLogicalDeviceFlows(ctx, id)
+ assert.Nil(t, response)
+ st, _ := status.FromError(err)
+ assert.Equal(t, "UnImplemented", st.Message())
+}
+
+func TestListLogicalDeviceFlowGroups(t *testing.T) {
+ id := &voltha.ID{Id: "ListLogicalDeviceFlowGroups"}
+ ctx := metadata.NewOutgoingContext(context.Background(), metadata.Pairs(testMode, "true"))
+ response, err := stub.ListLogicalDeviceFlowGroups(ctx, id)
+ assert.Nil(t, response)
+ st, _ := status.FromError(err)
+ assert.Equal(t, "UnImplemented", st.Message())
+}
+
+func TestListDevices(t *testing.T) {
+ ctx := metadata.NewOutgoingContext(context.Background(), metadata.Pairs(testMode, "true"))
+ response, err := stub.ListDevices(ctx, &empty.Empty{})
+ assert.Nil(t, response)
+ st, _ := status.FromError(err)
+ assert.Equal(t, "UnImplemented", st.Message())
+}
+
+func TestListAdapters(t *testing.T) {
+ ctx := metadata.NewOutgoingContext(context.Background(), metadata.Pairs(testMode, "true"))
+ response, err := stub.ListAdapters(ctx, &empty.Empty{})
+ assert.Nil(t, response)
+ st, _ := status.FromError(err)
+ assert.Equal(t, "UnImplemented", st.Message())
+}
+
+func TestListLogicalDevices(t *testing.T) {
+ ctx := metadata.NewOutgoingContext(context.Background(), metadata.Pairs(testMode, "true"))
+ response, err := stub.ListLogicalDevices(ctx, &empty.Empty{})
+ assert.Nil(t, response)
+ st, _ := status.FromError(err)
+ assert.Equal(t, "UnImplemented", st.Message())
+}
+
+func TestListCoreInstances(t *testing.T) {
+ ctx := metadata.NewOutgoingContext(context.Background(), metadata.Pairs(testMode, "true"))
+ response, err := stub.ListCoreInstances(ctx, &empty.Empty{})
+ assert.Nil(t, response)
+ st, _ := status.FromError(err)
+ assert.Equal(t, "UnImplemented", st.Message())
+}
+
+func TestCreateDevice(t *testing.T) {
+ ctx := metadata.NewOutgoingContext(context.Background(), metadata.Pairs(testMode, "true"))
+ device := &voltha.Device{Id: "newdevice"}
+ response, err := stub.CreateDevice(ctx, device)
+ log.Infow("response", log.Fields{"res": response, "error": err})
+ assert.Equal(t, &voltha.Device{Id: "newdevice"}, response)
+ assert.Nil(t, err)
+}
+
+func TestEnableDevice(t *testing.T) {
+ ctx := metadata.NewOutgoingContext(context.Background(), metadata.Pairs(testMode, "true"))
+ id := &voltha.ID{Id: "enabledevice"}
+ response, err := stub.EnableDevice(ctx, id)
+ log.Infow("response", log.Fields{"res": response, "error": err})
+ assert.Equal(t, &empty.Empty{}, response)
+ assert.Nil(t, err)
+}
+
+func TestDisableDevice(t *testing.T) {
+ ctx := metadata.NewOutgoingContext(context.Background(), metadata.Pairs(testMode, "true"))
+ id := &voltha.ID{Id: "DisableDevice"}
+ response, err := stub.DisableDevice(ctx, id)
+ log.Infow("response", log.Fields{"res": response, "error": err})
+ assert.Equal(t, &empty.Empty{}, response)
+ assert.Nil(t, err)
+}
+
+func TestRebootDevice(t *testing.T) {
+ ctx := metadata.NewOutgoingContext(context.Background(), metadata.Pairs(testMode, "true"))
+ id := &voltha.ID{Id: "RebootDevice"}
+ response, err := stub.RebootDevice(ctx, id)
+ log.Infow("response", log.Fields{"res": response, "error": err})
+ assert.Equal(t, &empty.Empty{}, response)
+ assert.Nil(t, err)
+}
+
+func TestDeleteDevice(t *testing.T) {
+ ctx := metadata.NewOutgoingContext(context.Background(), metadata.Pairs(testMode, "true"))
+ id := &voltha.ID{Id: "DeleteDevice"}
+ response, err := stub.DeleteDevice(ctx, id)
+ log.Infow("response", log.Fields{"res": response, "error": err})
+ assert.Equal(t, &empty.Empty{}, response)
+ assert.Nil(t, err)
+}
+
+func TestEnableLogicalDevicePort(t *testing.T) {
+ ctx := metadata.NewOutgoingContext(context.Background(), metadata.Pairs(testMode, "true"))
+ id := &voltha.LogicalPortId{Id: "EnableLogicalDevicePort"}
+ response, err := stub.EnableLogicalDevicePort(ctx, id)
+ log.Infow("response", log.Fields{"res": response, "error": err})
+ assert.Equal(t, &empty.Empty{}, response)
+ assert.Nil(t, err)
+}
+
+func TestDisableLogicalDevicePort(t *testing.T) {
+ ctx := metadata.NewOutgoingContext(context.Background(), metadata.Pairs(testMode, "true"))
+ id := &voltha.LogicalPortId{Id: "DisableLogicalDevicePort"}
+ response, err := stub.DisableLogicalDevicePort(ctx, id)
+ log.Infow("response", log.Fields{"res": response, "error": err})
+ assert.Equal(t, &empty.Empty{}, response)
+ assert.Nil(t, err)
+}
+
+func TestUpdateLogicalDeviceFlowGroupTable(t *testing.T) {
+ ctx := metadata.NewOutgoingContext(context.Background(), metadata.Pairs(testMode, "true"))
+ flow := &openflow_13.FlowGroupTableUpdate{Id: "UpdateLogicalDeviceFlowGroupTable"}
+ response, err := stub.UpdateLogicalDeviceFlowGroupTable(ctx, flow)
+ log.Infow("response", log.Fields{"res": response, "error": err})
+ assert.Equal(t, &empty.Empty{}, response)
+ assert.Nil(t, err)
+}
+
+func TestGetImageDownloadStatus(t *testing.T) {
+ ctx := metadata.NewOutgoingContext(context.Background(), metadata.Pairs(testMode, "true"))
+ img := &voltha.ImageDownload{Id: "GetImageDownloadStatus"}
+ response, err := stub.GetImageDownloadStatus(ctx, img)
+ assert.Nil(t, response)
+ st, _ := status.FromError(err)
+ assert.Equal(t, "UnImplemented", st.Message())
+}
+
+// TODO: complete the remaining tests
+
+func shutdown() {
+ conn.Close()
+}
+
+func TestMain(m *testing.M) {
+ setup()
+ code := m.Run()
+ shutdown()
+ os.Exit(code)
+}
diff --git a/tests/kafka/kafka_inter_container_messaging_test.go b/tests/kafka/kafka_inter_container_messaging_test.go
index 5553d14..a1865c7 100644
--- a/tests/kafka/kafka_inter_container_messaging_test.go
+++ b/tests/kafka/kafka_inter_container_messaging_test.go
@@ -1,3 +1,18 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+
+ * 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.
+ */
package kafka
import (