blob: 58f75492cfa3320a71f0330c7023a8b575cf7a00 [file] [log] [blame]
Prince Pereirac1c21d62021-04-22 08:38:15 +00001/*
2 * Copyright 2020-present Open Networking Foundation
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17// Package sbi holds interfaces for adapter operations
18package sbi
19
20import (
21 "context"
22
23 dmi "github.com/opencord/device-management-interface/go/dmi"
24 dev "github.com/opencord/opendevice-manager/pkg/models/device"
25 hw "github.com/opencord/opendevice-manager/pkg/models/hwcomponents"
26 grpc "github.com/opencord/opendevice-manager/pkg/sbi/grpc"
27)
28
29// GetHwMgmtSvcClient returns the adapter
30func GetHwMgmtSvcClient(devRec *dev.DeviceRecord) Adapter {
31 switch devRec.Make {
32 case "ROLT":
33 return grpc.NewClient(devRec.Uri)
34 }
35 return grpc.NewClient(devRec.Uri)
36}
37
38// Adapter interface contains all methods for rpc calls
39type Adapter interface {
40 Connect(ctx context.Context) error
41 Disconnect(ctx context.Context) error
42 AdapterHwMgmtSvc
43}
44
45// AdapterHwMgmtSvc refers to the interface used for defining RPCs for HW management Service
46type AdapterHwMgmtSvc interface {
47 StartManagingDevice(context.Context, *dev.DeviceRecord, *dmi.ModifiableComponent, dmi.NativeHWManagementService_StartManagingDeviceServer) (error, bool)
48 StopManagingDevice(context.Context, *dev.DeviceRecord, *dmi.StopManagingDeviceRequest) (*dmi.StopManagingDeviceResponse, error)
49 GetPhysicalInventory(context.Context, *dev.DeviceRecord, *dmi.PhysicalInventoryRequest, dmi.NativeHWManagementService_GetPhysicalInventoryServer) error
50 SetHWComponentInfo(context.Context, string, *hw.HwCompRecord, *dmi.HWComponentInfoSetRequest) (*dmi.HWComponentInfoSetResponse, error)
51 GetHWComponentInfo(context.Context, string, *hw.HwCompRecord, *dmi.HWComponentInfoGetRequest, dmi.NativeHWManagementService_GetHWComponentInfoServer) error
52 SetLoggingEndpoint(context.Context, *dev.DeviceRecord, *dmi.SetLoggingEndpointRequest) (*dmi.SetRemoteEndpointResponse, error)
53 GetLoggingEndpoint(context.Context, *dev.DeviceRecord, *dmi.HardwareID) (*dmi.GetLoggingEndpointResponse, error)
54 GetLoggableEntities(context.Context, *dev.DeviceRecord, *dmi.GetLoggableEntitiesRequest) (*dmi.GetLogLevelResponse, error)
55 SetLogLevel(context.Context, *dev.DeviceRecord, *dmi.SetLogLevelRequest) (*dmi.SetLogLevelResponse, error)
56 GetLogLevel(context.Context, *dev.DeviceRecord, *dmi.GetLogLevelRequest) (*dmi.GetLogLevelResponse, error)
57}