blob: 5de5761b527fca27199faf3484cff112d048cabf [file] [log] [blame]
Naveen Sampath04696f72022-06-13 15:19:14 +05301/*
2* Copyright 2022-present Open Networking Foundation
3* Licensed under the Apache License, Version 2.0 (the "License");
4* you may not use this file except in compliance with the License.
5* You may obtain a copy of the License at
6*
7* http://www.apache.org/licenses/LICENSE-2.0
8*
9* Unless required by applicable law or agreed to in writing, software
10* distributed under the License is distributed on an "AS IS" BASIS,
11* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12* See the License for the specific language governing permissions and
13* limitations under the License.
14*/
15
16package database
17
18import (
19 "net"
Tinoj Joseph07cc5372022-07-18 22:53:51 +053020 "context"
Naveen Sampath04696f72022-06-13 15:19:14 +053021
22 "voltha-go-controller/internal/pkg/of"
23 "github.com/opencord/voltha-lib-go/v7/pkg/db/kvstore"
24)
25
26var dbObj DBIntf
27
28// DBIntf defines db related methods
29type DBIntf interface {
Tinoj Joseph07cc5372022-07-18 22:53:51 +053030 Get(ctx context.Context, key string) (string, error)
31 Put(ctx context.Context, fullKeyPath string, value string) error
32 Del(ctx context.Context, path string) error
33 List(ctx context.Context, key string) (map[string]*kvstore.KVPair, error)
34 DeleteAll(ctx context.Context, path string) error
35 DeleteAllUnderHashKey(ctx context.Context, hashKeyPrefix string) error
36 GetOlt(ctx context.Context, deviceID string) (string, error)
37 PutOlt(ctx context.Context, deviceID string, value string) error
38 DelOlt(ctx context.Context, deviceID string) error
39 GetFlow(ctx context.Context, deviceID string, flowID uint64) (string, error)
40 GetFlows(ctx context.Context, deviceID string) (map[string]*kvstore.KVPair, error)
41 PutFlow(ctx context.Context, deviceID string, flowID uint64, value string) error
42 DelFlow(ctx context.Context, deviceID string, flowID uint64) error
43 PutGroup(ctx context.Context, deviceID string, groupID uint32, value string) error
44 GetGroup(ctx context.Context, deviceID string, groupID uint32) (string, error)
45 GetGroups(ctx context.Context, deviceID string) (map[string]*kvstore.KVPair, error)
46 DelGroup(ctx context.Context, deviceID string, groupID uint32) error
47 DelAllGroup(ctx context.Context, deviceID string) error
48 DelAllPorts(ctx context.Context, deviceID string) error
49 DelPort(ctx context.Context, deviceID string, portID uint32) error
50 PutPort(ctx context.Context, deviceID string, portID uint32, value string) error
51 GetPort(ctx context.Context, deviceID string, portID uint32) (string, error)
52 GetPorts(ctx context.Context, deviceID string) (map[string]*kvstore.KVPair, error)
53 PutDeviceMeter(ctx context.Context, deviceID string, meterID uint32, value string) error
54 GetDeviceMeter(ctx context.Context, deviceID string, meterID uint32) (string, error)
55 GetDeviceMeters(ctx context.Context, deviceID string) (map[string]*kvstore.KVPair, error)
56 DelDeviceMeter(ctx context.Context, deviceID string, meterID uint32) error
57 GetService(ctx context.Context, name string) (string, error)
58 GetServices(ctx context.Context) (map[string]*kvstore.KVPair, error)
59 PutService(ctx context.Context, name string, value string) error
60 DelService(ctx context.Context, name string) error
61 GetVnets(ctx context.Context) (map[string]*kvstore.KVPair, error)
62 GetVnet(ctx context.Context, name string) (string, error)
63 PutVnet(ctx context.Context, name string, value string) error
64 DelVnet(ctx context.Context, name string) error
65 GetVpvs(ctx context.Context) (map[string]*kvstore.KVPair, error)
66 GetVpv(ctx context.Context, port string, SVlan uint16, CVlan uint16, UniVlan uint16) (string, error)
67 PutVpv(ctx context.Context, port string, SVlan uint16, CVlan uint16, UniVlan uint16, value string) error
68 DelVpv(ctx context.Context, port string, SVlan uint16, CVlan uint16, UniVlan uint16) error
69 GetMvlans(ctx context.Context) (map[string]*kvstore.KVPair, error)
70 GetMvlan(ctx context.Context, mvlan uint16) (string, error)
71 PutMvlan(ctx context.Context, mvlan uint16, value string) error
72 DelMvlan(ctx context.Context, mvlan uint16) error
73 DelIGMPCfg(ctx context.Context) error
74 GetHealth(ctx context.Context) (string, error)
75 PutHealth(ctx context.Context, value string) error
76 DelHealth(ctx context.Context) error
77 GetMeters(ctx context.Context) (map[string]*kvstore.KVPair, error)
78 GetMeter(ctx context.Context, name string) (string, error)
79 PutMeter(ctx context.Context, name string, value string) error
80 DelMeter(ctx context.Context, name string) error
81 DelAllMeter(ctx context.Context, device string) error
82 GetIgmpGroups(ctx context.Context) (map[string]*kvstore.KVPair, error)
83 GetIgmpGroup(ctx context.Context, id string) (string, error)
84 PutIgmpGroup(ctx context.Context, id string, value string) error
85 DelIgmpGroup(ctx context.Context, id string) error
86 GetAllIgmpDevices(ctx context.Context) (map[string]*kvstore.KVPair, error)
87 GetPrevIgmpDevices(ctx context.Context, mvlan of.VlanType, gid string) (map[string]*kvstore.KVPair, error)
88 GetIgmpDevices(ctx context.Context, mvlan of.VlanType, gid string, gip net.IP) (map[string]*kvstore.KVPair, error)
89 GetIgmpDevice(ctx context.Context, mvlan of.VlanType, gid string, gip net.IP, device string) (string, error)
90 PutIgmpDevice(ctx context.Context, mvlan of.VlanType, gid string, gip net.IP, device string, value string) error
91 DelIgmpDevice(ctx context.Context, mvlan of.VlanType, gid string, gip net.IP, device string) error
92 GetAllIgmpChannels(ctx context.Context) (map[string]*kvstore.KVPair, error)
93 GetPrevIgmpChannels(ctx context.Context, gname string, device string) (map[string]*kvstore.KVPair, error)
94 GetIgmpChannels(ctx context.Context, mvlan of.VlanType, gname string, device string) (map[string]*kvstore.KVPair, error)
95 GetIgmpChannel(ctx context.Context, mvlan of.VlanType, gName string, device string, gip net.IP) (string, error)
96 PutIgmpChannel(ctx context.Context, mvlan of.VlanType, gName string, device string, gip net.IP, value string) error
97 DelIgmpChannel(ctx context.Context, mvlan of.VlanType, gName string, device string, gip net.IP) error
98 GetAllIgmpRcvrs(ctx context.Context) (map[string]*kvstore.KVPair, error)
99 GetPrevIgmpRcvrs(ctx context.Context, gip net.IP, device string) (map[string]*kvstore.KVPair, error)
100 GetIgmpRcvrs(ctx context.Context, mvlan of.VlanType, gip net.IP, device string) (map[string]*kvstore.KVPair, error)
101 GetIgmpRcvr(ctx context.Context, mvlan of.VlanType, gip net.IP, device string, rcvr string) (string, error)
102 PutIgmpRcvr(ctx context.Context, mvlan of.VlanType, gip net.IP, device string, rcvr string, value string) error
103 DelIgmpRcvr(ctx context.Context, mvlan of.VlanType, gip net.IP, device string, rcvr string) error
104 DelAllIgmpRcvr(ctx context.Context, mvlan of.VlanType, gip net.IP, device string) error
105 DelAllRoutesForDevice(ctx context.Context, device string) error
106 DelNbDevicePort(ctx context.Context, device string, ponPortID uint32)
107 GetAllNbPorts(ctx context.Context, deviceID string) (map[string]*kvstore.KVPair, error)
108 GetMigrationInfo(ctx context.Context) (string, error)
109 PutMigrationInfo(ctx context.Context, value string) error
110 DelMigrationInfo(ctx context.Context) error
111 GetAllPonCounters(ctx context.Context, device string) (map[string]*kvstore.KVPair, error)
112 GetPonCounter(ctx context.Context, device string, ponID string) (string, error)
113 PutPonCounter(ctx context.Context, device string, ponID string, value string) error
114 DelPonCounter(ctx context.Context, device string, ponID string) error
115 GetAllPonChannelCounters(ctx context.Context, device string, ponID string) (map[string]*kvstore.KVPair, error)
116 GetPonChannelCounter(ctx context.Context, device string, ponID string, channel string) (string, error)
117 PutNbDevicePort(ctx context.Context, device string, ponPortID uint32, value string)
118 PutPonChannelCounter(ctx context.Context, device string, ponID string, channel string, value string) error
119 DelPonChannelCounter(ctx context.Context, device string, ponID string, channel string) error
120 DelAllPONCounters(ctx context.Context, device string) error
121 DelPONCounters(ctx context.Context, device string, ponID string)
122 GetAllServiceChannelCounters(ctx context.Context, serviceName string) (map[string]*kvstore.KVPair, error)
123 GetServiceChannelCounter(ctx context.Context, serviceName string, channel string) (string, error)
124 PutServiceChannelCounter(ctx context.Context, serviceName string, channel string, value string) error
125 DelServiceChannelCounter(ctx context.Context, serviceName string, channel string) error
126 DelAllServiceChannelCounter(ctx context.Context, serviceName string) error
127 PutOltIgmpCounters(ctx context.Context, device string, value string) error
128 GetOltIgmpCounter(ctx context.Context, device string) (string, error)
129 PutFlowHash(ctx context.Context, deviceID string, value string) error
130 GetFlowHash(ctx context.Context, deviceID string) (string, error)
131 OltExists(ctx context.Context, deviceID string) bool
132 GetIgmpProfiles(ctx context.Context) (map[string]*kvstore.KVPair, error)
133 GetIgmpProfile(ctx context.Context, name string) (string, error)
134 PutIgmpProfile(ctx context.Context, name string, value string) error
135 DelIgmpProfile(ctx context.Context, name string) error
136 GetMcastConfigs(ctx context.Context) (map[string]*kvstore.KVPair, error)
137 GetMcastConfig(ctx context.Context, name string) (string, error)
138 PutMcastConfig(ctx context.Context, name string, value string) error
139 DelMcastConfig(ctx context.Context, name string) error
140 PutPortAlarmProfile(ctx context.Context, portAlarmProfileID string, value string)
141 GetPortAlarmProfile(ctx context.Context, portAlarmProfileID string) (map[string]*kvstore.KVPair, error)
142 DelPortAlarmProfile(ctx context.Context, portAlarmProfileID string)
143 PutPortAlarmData(ctx context.Context, deviceID string, portID uint32, value string)
144 GetPortAlarmData(ctx context.Context, deviceID string, portID uint32) (string, error)
145 DelPortAlarmData(ctx context.Context, deviceID string, portID uint32)
146 GetAllPortAlarmData(ctx context.Context, deviceID string) (map[string]*kvstore.KVPair, error)
147 PutSubAlarmData(ctx context.Context, deviceID string, portName string, value string)
148 GetSubAlarmData(ctx context.Context, deviceID string, portName string) (string, error)
149 DelSubAlarmData(ctx context.Context, deviceID string, portName string)
150 GetAllSubAlarmData(ctx context.Context, deviceID string) (map[string]*kvstore.KVPair, error)
151 PutMigrateServicesReq(ctx context.Context, deviceID string, vlan string, value string) error
152 GetMigrateServicesReq(ctx context.Context, deviceID string, vlan string) (string, error)
153 GetAllMigrateServicesReq(ctx context.Context, deviceID string) (map[string]*kvstore.KVPair, error)
154 DelMigrateServicesReq(ctx context.Context, deviceID string, vlan string) error
155 DelAllMigrateServicesReq(ctx context.Context, deviceID string) error
Tinoj Joseph4ead4e02023-01-30 03:12:44 +0530156 PutOltFlowService(ctx context.Context, value string) error
157 GetOltFlowService(ctx context.Context) (string, error)
Naveen Sampath04696f72022-06-13 15:19:14 +0530158}
159
160//GetDatabase - returns databse operation based on configuration
161func GetDatabase() DBIntf {
162 return dbObj
163}
164
165//SetDatabase - sets the DB object based on the type
166func SetDatabase(df DBIntf) {
167 dbObj = df
168}