blob: b8b491fee1e6437f48065bd9a1cc5adac1a089cf [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"
20
21 "voltha-go-controller/internal/pkg/of"
22 "github.com/opencord/voltha-lib-go/v7/pkg/db/kvstore"
23)
24
25var dbObj DBIntf
26
27// DBIntf defines db related methods
28type DBIntf interface {
29 Get(key string) (string, error)
30 Put(fullKeyPath string, value string) error
31 Del(path string) error
32 List(key string) (map[string]*kvstore.KVPair, error)
33 DeleteAll(path string) error
34 DeleteAllUnderHashKey(hashKeyPrefix string) error
35 GetOlt(deviceID string) (string, error)
36 PutOlt(deviceID string, value string) error
37 DelOlt(deviceID string) error
38 GetFlow(deviceID string, flowID uint64) (string, error)
39 GetFlows(deviceID string) (map[string]*kvstore.KVPair, error)
40 PutFlow(deviceID string, flowID uint64, value string) error
41 DelFlow(deviceID string, flowID uint64) error
42 PutGroup(deviceID string, groupID uint32, value string) error
43 GetGroup(deviceID string, groupID uint32) (string, error)
44 GetGroups(deviceID string) (map[string]*kvstore.KVPair, error)
45 DelGroup(deviceID string, groupID uint32) error
46 DelAllGroup(string) error
47 DelAllPorts(deviceID string) error
48 DelPort(deviceID string, portID uint32) error
49 PutPort(deviceID string, portID uint32, value string) error
50 GetPort(deviceID string, portID uint32) (string, error)
51 GetPorts(deviceID string) (map[string]*kvstore.KVPair, error)
52 PutDeviceMeter(deviceID string, meterID uint32, value string) error
53 GetDeviceMeter(deviceID string, meterID uint32) (string, error)
54 GetDeviceMeters(deviceID string) (map[string]*kvstore.KVPair, error)
55 DelDeviceMeter(deviceID string, meterID uint32) error
56 GetService(name string) (string, error)
57 GetServices() (map[string]*kvstore.KVPair, error)
58 PutService(name string, value string) error
59 DelService(name string) error
60 GetVnets() (map[string]*kvstore.KVPair, error)
61 GetVnet(name string) (string, error)
62 PutVnet(name string, value string) error
63 DelVnet(name string) error
64 GetVpvs() (map[string]*kvstore.KVPair, error)
65 GetVpv(port string, SVlan uint16, CVlan uint16, UniVlan uint16) (string, error)
66 PutVpv(port string, SVlan uint16, CVlan uint16, UniVlan uint16, value string) error
67 DelVpv(port string, SVlan uint16, CVlan uint16, UniVlan uint16) error
68 GetMvlans() (map[string]*kvstore.KVPair, error)
69 GetMvlan(mvlan uint16) (string, error)
70 PutMvlan(mvlan uint16, value string) error
71 DelMvlan(mvlan uint16) error
72 DelIGMPCfg() error
73 GetHealth() (string, error)
74 PutHealth(value string) error
75 DelHealth() error
76 GetMeters() (map[string]*kvstore.KVPair, error)
77 GetMeter(name string) (string, error)
78 PutMeter(name string, value string) error
79 DelMeter(name string) error
80 DelAllMeter(device string) error
81 GetIgmpGroups() (map[string]*kvstore.KVPair, error)
82 GetIgmpGroup(id string) (string, error)
83 PutIgmpGroup(id string, value string) error
84 DelIgmpGroup(id string) error
85 GetAllIgmpDevices() (map[string]*kvstore.KVPair, error)
86 GetPrevIgmpDevices(mvlan of.VlanType, gid string) (map[string]*kvstore.KVPair, error)
87 GetIgmpDevices(mvlan of.VlanType, gid string, gip net.IP) (map[string]*kvstore.KVPair, error)
88 GetIgmpDevice(mvlan of.VlanType, gid string, gip net.IP, device string) (string, error)
89 PutIgmpDevice(mvlan of.VlanType, gid string, gip net.IP, device string, value string) error
90 DelIgmpDevice(mvlan of.VlanType, gid string, gip net.IP, device string) error
91 GetAllIgmpChannels() (map[string]*kvstore.KVPair, error)
92 GetPrevIgmpChannels(gname string, device string) (map[string]*kvstore.KVPair, error)
93 GetIgmpChannels(mvlan of.VlanType, gname string, device string) (map[string]*kvstore.KVPair, error)
94 GetIgmpChannel(mvlan of.VlanType, gName string, device string, gip net.IP) (string, error)
95 PutIgmpChannel(mvlan of.VlanType, gName string, device string, gip net.IP, value string) error
96 DelIgmpChannel(mvlan of.VlanType, gName string, device string, gip net.IP) error
97 GetAllIgmpRcvrs() (map[string]*kvstore.KVPair, error)
98 GetPrevIgmpRcvrs(gip net.IP, device string) (map[string]*kvstore.KVPair, error)
99 GetIgmpRcvrs(mvlan of.VlanType, gip net.IP, device string) (map[string]*kvstore.KVPair, error)
100 GetIgmpRcvr(mvlan of.VlanType, gip net.IP, device string, rcvr string) (string, error)
101 PutIgmpRcvr(mvlan of.VlanType, gip net.IP, device string, rcvr string, value string) error
102 DelIgmpRcvr(mvlan of.VlanType, gip net.IP, device string, rcvr string) error
103 DelAllIgmpRcvr(mvlan of.VlanType, gip net.IP, device string) error
104 DelAllRoutesForDevice(device string) error
105 DelNbDevicePort(device string, ponPortID uint32)
106 GetAllNbPorts(deviceID string) (map[string]*kvstore.KVPair, error)
107 GetMigrationInfo() (string, error)
108 PutMigrationInfo(value string) error
109 DelMigrationInfo() error
110 GetAllPonCounters(device string) (map[string]*kvstore.KVPair, error)
111 GetPonCounter(device string, ponID string) (string, error)
112 PutPonCounter(device string, ponID string, value string) error
113 DelPonCounter(device string, ponID string) error
114 GetAllPonChannelCounters(device string, ponID string) (map[string]*kvstore.KVPair, error)
115 GetPonChannelCounter(device string, ponID string, channel string) (string, error)
116 PutNbDevicePort(device string, ponPortID uint32, value string)
117 PutPonChannelCounter(device string, ponID string, channel string, value string) error
118 DelPonChannelCounter(device string, ponID string, channel string) error
119 DelAllPONCounters(device string) error
120 DelPONCounters(device string, ponID string)
121 GetAllServiceChannelCounters(serviceName string) (map[string]*kvstore.KVPair, error)
122 GetServiceChannelCounter(serviceName string, channel string) (string, error)
123 PutServiceChannelCounter(serviceName string, channel string, value string) error
124 DelServiceChannelCounter(serviceName string, channel string) error
125 DelAllServiceChannelCounter(serviceName string) error
126 PutOltIgmpCounters(device string, value string) error
127 GetOltIgmpCounter(device string) (string, error)
128 PutFlowHash(deviceID string, value string) error
129 GetFlowHash(deviceID string) (string, error)
130 OltExists(deviceID string) bool
131 GetIgmpProfiles() (map[string]*kvstore.KVPair, error)
132 GetIgmpProfile(name string) (string, error)
133 PutIgmpProfile(name string, value string) error
134 DelIgmpProfile(name string) error
135 GetMcastConfigs() (map[string]*kvstore.KVPair, error)
136 GetMcastConfig(name string) (string, error)
137 PutMcastConfig(name string, value string) error
138 DelMcastConfig(name string) error
139 PutPortAlarmProfile(portAlarmProfileID string, value string)
140 GetPortAlarmProfile(portAlarmProfileID string) (map[string]*kvstore.KVPair, error)
141 DelPortAlarmProfile(portAlarmProfileID string)
142 PutPortAlarmData(deviceID string, portID uint32, value string)
143 GetPortAlarmData(deviceID string, portID uint32) (string, error)
144 DelPortAlarmData(deviceID string, portID uint32)
145 GetAllPortAlarmData(deviceID string) (map[string]*kvstore.KVPair, error)
146 PutSubAlarmData(deviceID string, portName string, value string)
147 GetSubAlarmData(deviceID string, portName string) (string, error)
148 DelSubAlarmData(deviceID string, portName string)
149 GetAllSubAlarmData(deviceID string) (map[string]*kvstore.KVPair, error)
150 PutMigrateServicesReq(deviceID string, vlan string, value string) error
151 GetMigrateServicesReq(deviceID string, vlan string) (string, error)
152 GetAllMigrateServicesReq(deviceID string) (map[string]*kvstore.KVPair, error)
153 DelMigrateServicesReq(deviceID string, vlan string) error
154 DelAllMigrateServicesReq(deviceID string) error
155}
156
157//GetDatabase - returns databse operation based on configuration
158func GetDatabase() DBIntf {
159 return dbObj
160}
161
162//SetDatabase - sets the DB object based on the type
163func SetDatabase(df DBIntf) {
164 dbObj = df
165}