blob: fe885566a326f0c6f795a6566f2927eb21ede9e3 [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// This implementation of database assumes that it is working for
16// Open ONU adapter. Thus, it assumes some base path for all the
17// database operations. For all database operations, the key passed is
18// added to the database base path.
19
20package database
21
22import (
23 "context"
24 "errors"
25 "net"
26 "strconv"
27 "time"
28 "fmt"
29
30 "voltha-go-controller/internal/pkg/of"
31 "github.com/opencord/voltha-lib-go/v7/pkg/db/kvstore"
Tinoj Joseph1d108322022-07-13 10:07:39 +053032 "voltha-go-controller/log"
Naveen Sampath04696f72022-06-13 15:19:14 +053033)
34
35var logger log.CLogger
36var ctx = context.TODO()
37
38// Database structure
39type Database struct {
40 storeType string
41 address string
42 //timeout uint32
43 kvc kvstore.Client
44}
45
46// Initialize the database module. The database module runs as a singleton
47// object and is initialized when the adapter is created.
48func Initialize(storeType string, address string, timeout int) (*Database, error) {
49 var err error
50 var database Database
51 logger.Infow(ctx, "kv-store-type", log.Fields{"store": storeType})
52 database.address = address
53 database.storeType = storeType
54 switch storeType {
55 case "redis":
56 database.kvc, err = kvstore.NewRedisClient(address, time.Duration(timeout), false)
57 return &database, err
58 }
59 return &database, errors.New("unsupported-kv-store")
60}
61
62// Utility function that retrieves value for a key. It is assumed that
63// the information is always a string and the data retrieved is returned
64// as a string
65
66// Put to add value to database
67func (db *Database) Put(fullKeyPath, value string) error {
68 return db.kvc.Put(context.Background(), fullKeyPath, value)
69}
70
71// Get to retrieve value from database
72func (db *Database) Get(key string) (string, error) {
73 kv, err := db.kvc.Get(context.Background(), key)
74 if err != nil {
75 return "", err
76 }
77 if kv != nil {
78 return string(kv.Value.([]byte)), nil
79 }
80 return "", errors.New("Value not found")
81}
82
83// Del to delete value from database
84func (db *Database) Del(fullPath string) error {
85 if err := db.kvc.Delete(context.Background(), fullPath); err != nil {
Tinoj Joseph1d108322022-07-13 10:07:39 +053086 logger.Errorw(ctx, "The path doesn't exist", log.Fields{"key": fullPath, "Error": err})
Naveen Sampath04696f72022-06-13 15:19:14 +053087 return err
88 }
89 return nil
90}
91
92// DeleteAll to delete all value from database
93func (db *Database) DeleteAll(fullPath string) error {
94 if err := db.kvc.DeleteWithPrefix(context.Background(), fullPath); err != nil {
Tinoj Joseph1d108322022-07-13 10:07:39 +053095 logger.Errorw(ctx, "The key doesn't exist", log.Fields{"key": fullPath, "Error": err})
Naveen Sampath04696f72022-06-13 15:19:14 +053096 return err
97 }
98 return nil
99}
100
101// DeleteAllUnderHashKey to delete all values under hash key
102func (db *Database) DeleteAllUnderHashKey(hashKeyPrefix string) error {
103 if err := db.kvc.Delete(context.Background(), hashKeyPrefix); err != nil {
Tinoj Joseph1d108322022-07-13 10:07:39 +0530104 logger.Errorw(ctx, "The key path doesn't exist", log.Fields{"key": hashKeyPrefix, "Error": err})
Naveen Sampath04696f72022-06-13 15:19:14 +0530105 return err
106 }
107 return nil
108}
109
110// List to list the values
111func (db *Database) List(key string) (map[string]*kvstore.KVPair, error) {
112 kv, err := db.kvc.List(context.Background(), key)
113 if err != nil {
114 return nil, err
115 }
116 if kv != nil {
117 return kv, nil
118 }
119 return nil, errors.New("Value not found")
120}
121
122// OLT specific database items
123
124// GetOlt to get olt info
125func (db *Database) GetOlt(deviceID string) (string, error) {
126 key := fmt.Sprintf(GetKeyPath(DevicePath), deviceID)
127 return db.Get(key)
128}
129
130// PutOlt to add olt info
131func (db *Database) PutOlt(deviceID string, value string) error {
132 key := fmt.Sprintf(GetKeyPath(DevicePath), deviceID)
133 return db.kvc.Put(context.Background(), key, value)
134}
135
136// DelOlt to delete olt info
137func (db *Database) DelOlt(deviceID string) error {
138 key := fmt.Sprintf(GetKeyPath(DevicePath), deviceID)
139 if err := db.kvc.Delete(context.Background(), key); err != nil {
Tinoj Joseph1d108322022-07-13 10:07:39 +0530140 logger.Errorw(ctx, "The key doesn't exist", log.Fields{"key": key, "Error": err})
Naveen Sampath04696f72022-06-13 15:19:14 +0530141 return err
142 }
143 return nil
144}
145
146// Flows specific database actions
147
148// PutFlow to add flow
149func (db *Database) PutFlow(deviceID string, flowID uint64, value string) error {
150 key := fmt.Sprintf(GetKeyPath(DeviceFlowPath), deviceID) + strconv.FormatUint(flowID, 10)
151 return db.kvc.Put(context.Background(), key, value)
152}
153
154// GetFlow to get flow
155func (db *Database) GetFlow(deviceID string, flowID uint64) (string, error) {
156 key := fmt.Sprintf(GetKeyPath(DeviceFlowPath), deviceID) + strconv.FormatUint(flowID, 10)
157 return db.Get(key)
158}
159
160// GetFlows to get multiple flows
161func (db *Database) GetFlows(deviceID string) (map[string]*kvstore.KVPair, error) {
162 key := fmt.Sprintf(GetKeyPath(DeviceFlowPath), deviceID)
163 return db.List(key)
164}
165
166// DelFlow to delete flow
167func (db *Database) DelFlow(deviceID string, flowID uint64) error {
168 key := fmt.Sprintf(GetKeyPath(DeviceFlowPath), deviceID) + strconv.FormatUint(flowID, 10)
169 if err := db.kvc.Delete(context.Background(), key); err != nil {
Tinoj Joseph1d108322022-07-13 10:07:39 +0530170 logger.Errorw(ctx, "The key doesn't exist", log.Fields{"key": key, "Error": err})
Naveen Sampath04696f72022-06-13 15:19:14 +0530171 return err
172 }
173 return nil
174}
175
176// Group specific database actions
177
178// PutGroup to add group info
179func (db *Database) PutGroup(deviceID string, groupID uint32, value string) error {
180 key := fmt.Sprintf(GetKeyPath(DeviceGroupPath), deviceID) + strconv.FormatUint(uint64(groupID), 10)
181 return db.kvc.Put(context.Background(), key, value)
182}
183
184// GetGroup to get group info
185func (db *Database) GetGroup(deviceID string, groupID uint32) (string, error) {
186 key := fmt.Sprintf(GetKeyPath(DeviceGroupPath), deviceID) + strconv.FormatUint(uint64(groupID), 10)
187 return db.Get(key)
188}
189
190// GetGroups to get multiple group info
191func (db *Database) GetGroups(deviceID string) (map[string]*kvstore.KVPair, error) {
192 key := fmt.Sprintf(GetKeyPath(DeviceGroupPath), deviceID)
193 logger.Infow(ctx, "key", log.Fields{"Key": key})
194 return db.List(key)
195}
196
197// DelGroup to delete group info
198func (db *Database) DelGroup(deviceID string, groupID uint32) error {
199 key := fmt.Sprintf(GetKeyPath(DeviceGroupPath), deviceID) + strconv.FormatUint(uint64(groupID), 10)
200 if err := db.kvc.Delete(context.Background(), key); err != nil {
Tinoj Joseph1d108322022-07-13 10:07:39 +0530201 logger.Errorw(ctx, "The key doesn't exist", log.Fields{"key": key, "Error": err})
Naveen Sampath04696f72022-06-13 15:19:14 +0530202 return err
203 }
204 return nil
205}
206
207// DelAllGroup to delete all group info
208func (db *Database) DelAllGroup(deviceID string) error {
209 key := fmt.Sprintf(GetKeyPath(DeviceGroupPath), deviceID)
210 if err := db.DeleteAllUnderHashKey(key); err != nil {
Tinoj Joseph1d108322022-07-13 10:07:39 +0530211 logger.Warnw(ctx, "Delete All failed: The key doesn't exist", log.Fields{"key": key, "Error": err})
Naveen Sampath04696f72022-06-13 15:19:14 +0530212 return err
213 }
214 logger.Infow(ctx, "Deleting all the groups for device", log.Fields{"device": deviceID})
215 return nil
216}
217
218// DelAllPorts to delete all ports info
219func (db *Database) DelAllPorts(device string) error {
220 key := fmt.Sprintf(GetKeyPath(DevicePortPath), device)
221 if err := db.DeleteAllUnderHashKey(key); err != nil {
Tinoj Joseph1d108322022-07-13 10:07:39 +0530222 logger.Warnw(ctx, "Delete All failed: The key doesn't exist", log.Fields{"key": key, "Error": err})
Naveen Sampath04696f72022-06-13 15:19:14 +0530223 return err
224 }
225 logger.Infow(ctx, "Deleting all the ports for device", log.Fields{"device": device})
226 return nil
227}
228
229// Ports specific database actions
230
231// PutPort to add port info
232func (db *Database) PutPort(deviceID string, portID uint32, value string) error {
233 key := fmt.Sprintf(GetKeyPath(DevicePortPath), deviceID) + strconv.FormatUint(uint64(portID), 10)
234 return db.kvc.Put(context.Background(), key, value)
235}
236
237// GetPort to get port info
238func (db *Database) GetPort(deviceID string, portID uint32) (string, error) {
239 key := fmt.Sprintf(GetKeyPath(DevicePortPath), deviceID) + strconv.FormatUint(uint64(portID), 10)
240 return db.Get(key)
241}
242
243// GetPorts to get multiple ports info
244func (db *Database) GetPorts(deviceID string) (map[string]*kvstore.KVPair, error) {
245 key := fmt.Sprintf(GetKeyPath(DevicePortPath), deviceID)
246 return db.List(key)
247}
248
249// DelPort to delete port info
250func (db *Database) DelPort(deviceID string, portID uint32) error {
251 key := fmt.Sprintf(GetKeyPath(DevicePortPath), deviceID) + strconv.FormatUint(uint64(portID), 10)
252 if err := db.kvc.Delete(context.Background(), key); err != nil {
Tinoj Joseph1d108322022-07-13 10:07:39 +0530253 logger.Errorw(ctx, "The key doesn't exist", log.Fields{"key": key, "Error": err})
Naveen Sampath04696f72022-06-13 15:19:14 +0530254 return err
255 }
256 return nil
257}
258
259// Device meter specific database actions
260
261// PutDeviceMeter to add device meter info
262func (db *Database) PutDeviceMeter(deviceID string, meterID uint32, value string) error {
263 key := fmt.Sprintf(GetKeyPath(DeviceMeterPath), deviceID) + strconv.FormatUint(uint64(meterID), 10)
264 return db.kvc.Put(context.Background(), key, value)
265}
266
267// GetDeviceMeter to get device meter info
268func (db *Database) GetDeviceMeter(deviceID string, meterID uint32) (string, error) {
269 key := fmt.Sprintf(GetKeyPath(DeviceMeterPath), deviceID) + strconv.FormatUint(uint64(meterID), 10)
270 return db.Get(key)
271}
272
273// GetDeviceMeters to get multiple device meter info
274func (db *Database) GetDeviceMeters(deviceID string) (map[string]*kvstore.KVPair, error) {
275 key := fmt.Sprintf(GetKeyPath(DeviceMeterPath), deviceID)
276 return db.List(key)
277}
278
279// DelDeviceMeter to delete device meter info
280func (db *Database) DelDeviceMeter(deviceID string, meterID uint32) error {
281 key := fmt.Sprintf(GetKeyPath(DeviceMeterPath), deviceID) + strconv.FormatUint(uint64(meterID), 10)
282 if err := db.kvc.Delete(context.Background(), key); err != nil {
Tinoj Joseph1d108322022-07-13 10:07:39 +0530283 logger.Errorw(ctx, "The key doesn't exist", log.Fields{"key": key, "Error": err})
Naveen Sampath04696f72022-06-13 15:19:14 +0530284 return err
285 }
286 return nil
287}
288
289// Service specific database actions
290
291// GetServices to get multiple services info
292func (db *Database) GetServices() (map[string]*kvstore.KVPair, error) {
293 key := GetKeyPath(ServicePath)
294 return db.List(key)
295}
296
297// GetService to get service info
298func (db *Database) GetService(name string) (string, error) {
299 key := GetKeyPath(ServicePath) + name
300 return db.Get(key)
301}
302
303// PutService to add service info
304func (db *Database) PutService(name string, value string) error {
305 key := GetKeyPath(ServicePath) + name
306 return db.kvc.Put(context.Background(), key, value)
307}
308
309// DelService to delete service info
310func (db *Database) DelService(name string) error {
311 key := GetKeyPath(ServicePath) + name
312 if err := db.kvc.Delete(context.Background(), key); err != nil {
Tinoj Joseph1d108322022-07-13 10:07:39 +0530313 logger.Errorw(ctx, "The key doesn't exist", log.Fields{"key": key, "Error": err})
Naveen Sampath04696f72022-06-13 15:19:14 +0530314 return err
315 }
316 return nil
317}
318
319// Virtual networks specific database actions
320
321// GetVnets to get multiple vnets info
322func (db *Database) GetVnets() (map[string]*kvstore.KVPair, error) {
323 key := GetKeyPath(VnetPath)
324 return db.List(key)
325}
326
327// GetVnet to get vnet info
328func (db *Database) GetVnet(name string) (string, error) {
329 key := GetKeyPath(VnetPath) + name
330 return db.Get(key)
331}
332
333// PutVnet to add vnet info
334func (db *Database) PutVnet(name string, value string) error {
335 key := GetKeyPath(VnetPath) + name
336 return db.kvc.Put(context.Background(), key, value)
337}
338
339// DelVnet to delete vnet info
340func (db *Database) DelVnet(name string) error {
341 key := GetKeyPath(VnetPath) + name
342 if err := db.kvc.Delete(context.Background(), key); err != nil {
Tinoj Joseph1d108322022-07-13 10:07:39 +0530343 logger.Errorw(ctx, "The key doesn't exist", log.Fields{"key": key, "Error": err})
Naveen Sampath04696f72022-06-13 15:19:14 +0530344 return err
345 }
346 return nil
347}
348
349// Virtual networks on ports specific database actions
350
351// GetVpvs to get multiple vpvs info
352func (db *Database) GetVpvs() (map[string]*kvstore.KVPair, error) {
353 key := GetKeyPath(VpvPath)
354 return db.List(key)
355}
356
357// GetVpv to get vpv info
358func (db *Database) GetVpv(port string, SVlan uint16, CVlan uint16, UniVlan uint16) (string, error) {
359 name := port + fmt.Sprintf("-%v-%v-%v", SVlan, CVlan, UniVlan)
360 key := GetKeyPath(VpvPath) + name
361 return db.Get(key)
362}
363
364// PutVpv to add vpv info
365func (db *Database) PutVpv(port string, SVlan uint16, CVlan uint16, UniVlan uint16, value string) error {
366 name := port + fmt.Sprintf("-%v-%v-%v", SVlan, CVlan, UniVlan)
367 key := GetKeyPath(VpvPath) + name
368 return db.kvc.Put(context.Background(), key, value)
369}
370
371// DelVpv to delete vpv info
372func (db *Database) DelVpv(port string, SVlan uint16, CVlan uint16, UniVlan uint16) error {
373 name := port + fmt.Sprintf("-%v-%v-%v", SVlan, CVlan, UniVlan)
374 key := GetKeyPath(VpvPath) + name
375 if err := db.kvc.Delete(context.Background(), key); err != nil {
Tinoj Joseph1d108322022-07-13 10:07:39 +0530376 logger.Errorw(ctx, "The key doesn't exist", log.Fields{"key": key, "Error": err})
Naveen Sampath04696f72022-06-13 15:19:14 +0530377 return err
378 }
379 return nil
380}
381
382// Virtual networks on ports specific database actions
383
384// GetMvlans to get multiple mvlans info
385func (db *Database) GetMvlans() (map[string]*kvstore.KVPair, error) {
386 key := GetKeyPath(MvlanPath)
387 return db.List(key)
388}
389
390// GetMvlan to get mvlan info
391func (db *Database) GetMvlan(mvlan uint16) (string, error) {
392 name := strconv.FormatInt(int64(mvlan), 10)
393 key := GetKeyPath(MvlanPath) + name
394 return db.Get(key)
395}
396
397// PutMvlan to add mvlan info
398func (db *Database) PutMvlan(mvlan uint16, value string) error {
399 name := strconv.FormatInt(int64(mvlan), 10)
400 key := GetKeyPath(MvlanPath) + name
401 return db.kvc.Put(context.Background(), key, value)
402}
403
404// DelMvlan to delete mvlan info
405func (db *Database) DelMvlan(mvlan uint16) error {
406 name := strconv.FormatInt(int64(mvlan), 10)
407 key := GetKeyPath(MvlanPath) + name
408 if err := db.kvc.Delete(context.Background(), key); err != nil {
Tinoj Joseph1d108322022-07-13 10:07:39 +0530409 logger.Errorw(ctx, "The key doesn't exist", log.Fields{"key": key, "Error": err})
Naveen Sampath04696f72022-06-13 15:19:14 +0530410 return err
411 }
412 return nil
413}
414
415// database specific actions on IGMP config
416
417// DelIGMPCfg to delete icmp config
418func (db *Database) DelIGMPCfg() error {
419 key := GetKeyPath(IgmpConfPath)
420 if err := db.kvc.Delete(context.Background(), key); err != nil {
Tinoj Joseph1d108322022-07-13 10:07:39 +0530421 logger.Errorw(ctx, "The key doesn't exist", log.Fields{"key": key, "Error": err})
Naveen Sampath04696f72022-06-13 15:19:14 +0530422 return err
423 }
424 return nil
425}
426
427// database specific actions on IGMP Profile
428
429// GetIgmpProfiles to get multiple igmp profile info
430func (db *Database) GetIgmpProfiles() (map[string]*kvstore.KVPair, error) {
431 key := GetKeyPath(IgmpProfPath)
432 return db.List(key)
433}
434
435// GetIgmpProfile to get igmp profile info
436func (db *Database) GetIgmpProfile(name string) (string, error) {
437 key := GetKeyPath(IgmpProfPath) + name
438 return db.Get(key)
439}
440
441// PutIgmpProfile to put igmp profile info
442func (db *Database) PutIgmpProfile(name string, value string) error {
443 key := GetKeyPath(IgmpProfPath) + name
444 return db.kvc.Put(context.Background(), key, value)
445}
446
447// DelIgmpProfile to delete igmp profile
448func (db *Database) DelIgmpProfile(name string) error {
449 key := GetKeyPath(IgmpProfPath) + name
450 if err := db.kvc.Delete(context.Background(), key); err != nil {
Tinoj Joseph1d108322022-07-13 10:07:39 +0530451 logger.Errorw(ctx, "The key doesn't exist", log.Fields{"key": key, "Error": err})
Naveen Sampath04696f72022-06-13 15:19:14 +0530452 return err
453 }
454 return nil
455}
456
457// database specific actions on Mcast config Info
458
459// GetMcastConfigs to get multiple mcast config info
460func (db *Database) GetMcastConfigs() (map[string]*kvstore.KVPair, error) {
461 key := GetKeyPath(McastConfigPath)
462 return db.List(key)
463}
464
465// GetMcastConfig to get igmp profile info
466func (db *Database) GetMcastConfig(name string) (string, error) {
467 key := GetKeyPath(McastConfigPath) + name
468 return db.Get(key)
469}
470
471// PutMcastConfig to put igmp profile info
472func (db *Database) PutMcastConfig(name string, value string) error {
473 key := GetKeyPath(McastConfigPath) + name
474 return db.kvc.Put(context.Background(), key, value)
475}
476
477// DelMcastConfig to delete igmp profile
478func (db *Database) DelMcastConfig(name string) error {
479 key := GetKeyPath(McastConfigPath) + name
480 if err := db.kvc.Delete(context.Background(), key); err != nil {
Tinoj Joseph1d108322022-07-13 10:07:39 +0530481 logger.Errorw(ctx, "The key doesn't exist", log.Fields{"key": key, "Error": err})
Naveen Sampath04696f72022-06-13 15:19:14 +0530482 return err
483 }
484 return nil
485}
486
487// database specific actions on health
488
489// GetHealth to get health info
490func (db *Database) GetHealth() (string, error) {
491 key := GetKeyPath(HealthPath)
492 return db.Get(key)
493}
494
495// PutHealth to add health info
496func (db *Database) PutHealth(value string) error {
497 key := GetKeyPath(HealthPath)
498 return db.kvc.Put(context.Background(), key, value)
499}
500
501// DelHealth to delete health info
502func (db *Database) DelHealth() error {
503 key := GetKeyPath(HealthPath)
504 if err := db.kvc.Delete(context.Background(), key); err != nil {
Tinoj Joseph1d108322022-07-13 10:07:39 +0530505 logger.Errorw(ctx, "The key doesn't exist", log.Fields{"key": key, "Error": err})
Naveen Sampath04696f72022-06-13 15:19:14 +0530506 return err
507 }
508 return nil
509}
510
511// Meters
512
513// GetMeters to get multiple meters info
514func (db *Database) GetMeters() (map[string]*kvstore.KVPair, error) {
515 key := GetKeyPath(MeterPath)
516 return db.List(key)
517}
518
519// GetMeter to get meter info
520func (db *Database) GetMeter(name string) (string, error) {
521 key := GetKeyPath(MeterPath) + name
522 return db.Get(key)
523}
524
525// PutMeter to add meter info
526func (db *Database) PutMeter(name string, value string) error {
527 key := GetKeyPath(MeterPath) + name
528 return db.kvc.Put(context.Background(), key, value)
529}
530
531// DelMeter to delete meter info
532func (db *Database) DelMeter(name string) error {
533 key := GetKeyPath(MeterPath) + name
534 if err := db.kvc.Delete(context.Background(), key); err != nil {
Tinoj Joseph1d108322022-07-13 10:07:39 +0530535 logger.Errorw(ctx, "The key doesn't exist", log.Fields{"key": key, "Error": err})
Naveen Sampath04696f72022-06-13 15:19:14 +0530536 return err
537 }
538 return nil
539}
540
541// DelAllMeter to delete meter info
542func (db *Database) DelAllMeter(device string) error {
543 key := GetKeyPath(DevicePath) + device + "/" + MeterPath
544 if err := db.DeleteAllUnderHashKey(key); err != nil {
Tinoj Joseph1d108322022-07-13 10:07:39 +0530545 logger.Warnw(ctx, "Delete All failed: The key doesn't exist", log.Fields{"key": key, "Error": err})
Naveen Sampath04696f72022-06-13 15:19:14 +0530546 return err
547 }
548 logger.Infow(ctx, "Deleting all the meters for device", log.Fields{"device": device})
549 return nil
550}
551
552// IGMP groups
553
554// GetIgmpGroups to get multiple igmp groups info
555func (db *Database) GetIgmpGroups() (map[string]*kvstore.KVPair, error) {
556 key := GetKeyPath(IgmpGroupPath)
557 return db.List(key)
558}
559
560// GetIgmpGroup to get igmp group info
561func (db *Database) GetIgmpGroup(id string) (string, error) {
562 key := GetKeyPath(IgmpGroupPath) + id
563 return db.Get(key)
564}
565
566// PutIgmpGroup to add igmp group info
567func (db *Database) PutIgmpGroup(id string, value string) error {
568 key := GetKeyPath(IgmpGroupPath) + id
569 return db.kvc.Put(context.Background(), key, value)
570}
571
572// DelIgmpGroup to delete igmp group info
573func (db *Database) DelIgmpGroup(id string) error {
574 key := GetKeyPath(IgmpGroupPath) + id
575 if err := db.kvc.Delete(context.Background(), key); err != nil {
Tinoj Joseph1d108322022-07-13 10:07:39 +0530576 logger.Warnw(ctx, "The key doesn't exist", log.Fields{"key": key, "Error": err})
Naveen Sampath04696f72022-06-13 15:19:14 +0530577 return err
578 }
579 return nil
580}
581
582// IGMP group devices
583
584// GetAllIgmpDevices to get multiple igmp devices info
585func (db *Database) GetAllIgmpDevices() (map[string]*kvstore.KVPair, error) {
586 key := GetKeyPath(IgmpDevicePath)
587 return db.List(key)
588}
589
590// GetPrevIgmpDevices to get previous igmp devices
591func (db *Database) GetPrevIgmpDevices(mvlan of.VlanType, gid string) (map[string]*kvstore.KVPair, error) {
592 key := GetKeyPath(IgmpDevicePath) + mvlan.String() + "/" + gid + "/"
593 return db.List(key)
594}
595
596// GetIgmpDevices to get igmp devices
597func (db *Database) GetIgmpDevices(mvlan of.VlanType, gid string, gip net.IP) (map[string]*kvstore.KVPair, error) {
598 key := GetKeyPath(IgmpDevicePath) + mvlan.String() + "/" + gid + "/" + gip.String() + "/"
599 return db.List(key)
600}
601
602// GetIgmpDevice to get igmp device
603func (db *Database) GetIgmpDevice(mvlan of.VlanType, gid string, gip net.IP, device string) (string, error) {
604 key := GetKeyPath(IgmpDevicePath) + mvlan.String() + "/" + gid + "/" + gip.String() + "/" + device
605 return db.Get(key)
606}
607
608// PutIgmpDevice to add igmp device
609func (db *Database) PutIgmpDevice(mvlan of.VlanType, gid string, gip net.IP, device string, value string) error {
610 key := GetKeyPath(IgmpDevicePath) + mvlan.String() + "/" + gid + "/" + gip.String() + "/" + device
611 return db.kvc.Put(context.Background(), key, value)
612}
613
614// DelIgmpDevice to delete igmp device
615func (db *Database) DelIgmpDevice(mvlan of.VlanType, gid string, gip net.IP, device string) error {
616 key := GetKeyPath(IgmpDevicePath) + mvlan.String() + "/" + gid + "/" + gip.String() + "/" + device
617 if err := db.kvc.Delete(context.Background(), key); err != nil {
Tinoj Joseph1d108322022-07-13 10:07:39 +0530618 logger.Warnw(ctx, "The key doesn't exist", log.Fields{"key": key, "Error": err})
Naveen Sampath04696f72022-06-13 15:19:14 +0530619 return err
620 }
621 return nil
622}
623
624// IGMP group channels
625
626// GetAllIgmpChannels to get all igmp channels
627func (db *Database) GetAllIgmpChannels() (map[string]*kvstore.KVPair, error) {
628 key := GetKeyPath(IgmpChannelPath)
629 return db.List(key)
630}
631
632// GetPrevIgmpChannels to get previous igmp channels
633func (db *Database) GetPrevIgmpChannels(gName, device string) (map[string]*kvstore.KVPair, error) {
634 key := GetKeyPath(IgmpChannelPath) + gName + "/" + device + "/"
635 return db.List(key)
636}
637
638// GetIgmpChannels to get multiple igmp channels
639func (db *Database) GetIgmpChannels(mvlan of.VlanType, gName, device string) (map[string]*kvstore.KVPair, error) {
640 key := GetKeyPath(IgmpChannelPath) + mvlan.String() + "/" + gName + "/" + device + "/"
641 return db.List(key)
642}
643
644// GetIgmpChannel to get igmp channel
645func (db *Database) GetIgmpChannel(mvlan of.VlanType, gName string, device string, gip net.IP) (string, error) {
646 key := GetKeyPath(IgmpChannelPath) + mvlan.String() + "/" + gName + "/" + device + "/" + gip.String()
647 return db.Get(key)
648}
649
650// PutIgmpChannel to add igmp channel info
651func (db *Database) PutIgmpChannel(mvlan of.VlanType, gName string, device string, gip net.IP, value string) error {
652 key := GetKeyPath(IgmpChannelPath) + mvlan.String() + "/" + gName + "/" + device + "/" + gip.String()
653 return db.kvc.Put(context.Background(), key, value)
654}
655
656// DelIgmpChannel to delete igmp channel info
657func (db *Database) DelIgmpChannel(mvlan of.VlanType, gName string, device string, gip net.IP) error {
658 key := GetKeyPath(IgmpChannelPath) + mvlan.String() + "/" + gName + "/" + device + "/" + gip.String()
659 if err := db.kvc.Delete(context.Background(), key); err != nil {
Tinoj Joseph1d108322022-07-13 10:07:39 +0530660 logger.Warnw(ctx, "The key doesn't exist", log.Fields{"key": key, "Error": err})
Naveen Sampath04696f72022-06-13 15:19:14 +0530661 return err
662 }
663 return nil
664}
665
666// IGMP group receivers
667
668// GetAllIgmpRcvrs to get all igmp receivers info
669func (db *Database) GetAllIgmpRcvrs() (map[string]*kvstore.KVPair, error) {
670 key := GetKeyPath(IgmpPortPath)
671 return db.List(key)
672}
673
674// GetPrevIgmpRcvrs to get previous igmp receivers info
675func (db *Database) GetPrevIgmpRcvrs(gip net.IP, device string) (map[string]*kvstore.KVPair, error) {
676 key := GetKeyPath(IgmpPortPath) + gip.String() + "/" + device + "/"
677 return db.List(key)
678}
679
680// GetIgmpRcvrs to get multiple igmp receivers info
681func (db *Database) GetIgmpRcvrs(mvlan of.VlanType, gip net.IP, device string) (map[string]*kvstore.KVPair, error) {
682 key := GetKeyPath(IgmpPortPath) + mvlan.String() + "/" + gip.String() + "/" + device + "/"
683 return db.List(key)
684}
685
686// GetIgmpRcvr to get igmp receiver info
687func (db *Database) GetIgmpRcvr(mvlan of.VlanType, gip net.IP, device string, rcvr string) (string, error) {
688 key := GetKeyPath(IgmpPortPath) + mvlan.String() + "/" + gip.String() + "/" + device + "/" + rcvr
689 return db.Get(key)
690}
691
692// PutIgmpRcvr to add igmp receiver info
693func (db *Database) PutIgmpRcvr(mvlan of.VlanType, gip net.IP, device string, rcvr string, value string) error {
694 key := GetKeyPath(IgmpPortPath) + mvlan.String() + "/" + gip.String() + "/" + device + "/" + rcvr
695 return db.kvc.Put(context.Background(), key, value)
696}
697
698// DelIgmpRcvr to delete igmp receiver info
699func (db *Database) DelIgmpRcvr(mvlan of.VlanType, gip net.IP, device string, rcvr string) error {
700 key := GetKeyPath(IgmpPortPath) + mvlan.String() + "/" + gip.String() + "/" + device + "/" + rcvr
701 if err := db.kvc.Delete(context.Background(), key); err != nil {
Tinoj Joseph1d108322022-07-13 10:07:39 +0530702 logger.Warnw(ctx, "The key doesn't exist", log.Fields{"key": key, "Error": err})
Naveen Sampath04696f72022-06-13 15:19:14 +0530703 return err
704 }
705 return nil
706}
707
708// DelAllIgmpRcvr to delete all igmp receiver info
709func (db *Database) DelAllIgmpRcvr(mvlan of.VlanType, gip net.IP, device string) error {
710 key := GetKeyPath(IgmpPortPath) + mvlan.String() + "/" + gip.String() + "/" + device + "/"
711 if err := db.DeleteAll(key); err != nil {
Tinoj Joseph1d108322022-07-13 10:07:39 +0530712 logger.Warnw(ctx, "Delete All failed: The key doesn't exist", log.Fields{"key": key, "Error": err})
Naveen Sampath04696f72022-06-13 15:19:14 +0530713 return err
714 }
715 return nil
716}
717
718// DelAllRoutesForDevice to delete all routes for device
719func (db *Database) DelAllRoutesForDevice(device string) error {
720 /* service/vgc/v1/devices/<deviceID>/flows/ */
721 logger.Infow(ctx, "Deleting all the flows for device", log.Fields{"device": device})
722 key := fmt.Sprintf(GetKeyPath(DeviceFlowPath), device)
723 if err := db.DeleteAllUnderHashKey(key); err != nil {
Tinoj Joseph1d108322022-07-13 10:07:39 +0530724 logger.Warnw(ctx, "Delete All failed: The key doesn't exist", log.Fields{"key": key, "Error": err})
Naveen Sampath04696f72022-06-13 15:19:14 +0530725 return err
726 }
727 return nil
728}
729
730// PutNbDevicePort to add device port info
731func (db *Database) PutNbDevicePort(device string, ponPortID uint32, value string) {
732 key := GetKeyPath(NbDevicePath) + device + "/pon-port/" + fmt.Sprintf("%v", ponPortID)
733
734 if err := db.kvc.Put(context.Background(), key, value); err != nil {
Tinoj Joseph1d108322022-07-13 10:07:39 +0530735 logger.Warnw(ctx, "Put Device Port failed", log.Fields{"key": key})
Naveen Sampath04696f72022-06-13 15:19:14 +0530736 }
737}
738
739// DelNbDevicePort to delete device port
740func (db *Database) DelNbDevicePort(device string, ponPortID uint32) {
741 key := GetKeyPath(NbDevicePath) + device + "/pon-port/" + fmt.Sprintf("%v", ponPortID)
742
743 if err := db.kvc.Delete(context.Background(), key); err != nil {
Tinoj Joseph1d108322022-07-13 10:07:39 +0530744 logger.Warnw(ctx, "Delete Device Port failed", log.Fields{"key": key})
Naveen Sampath04696f72022-06-13 15:19:14 +0530745 }
746}
747
748// GetAllNbPorts to get all ports info
749func (db *Database) GetAllNbPorts(deviceID string) (map[string]*kvstore.KVPair, error) {
750 key := GetKeyPath(NbDevicePath) + deviceID + "/pon-port/"
751 return db.List(key)
752}
753
754//Functions for migration database
755
756// GetMigrationInfo to get migration info
757func (db *Database) GetMigrationInfo() (string, error) {
758 key := GetKeyPath(MigrationInfoPath)
759 return db.Get(key)
760}
761
762// PutMigrationInfo to add migration info
763func (db *Database) PutMigrationInfo(value string) error {
764 key := GetKeyPath(MigrationInfoPath)
765 return db.kvc.Put(context.Background(), key, value)
766}
767
768// DelMigrationInfo to delete migration info
769func (db *Database) DelMigrationInfo() error {
770 key := GetKeyPath(MigrationInfoPath)
771 if err := db.kvc.Delete(context.Background(), key); err != nil {
Tinoj Joseph1d108322022-07-13 10:07:39 +0530772 logger.Errorw(ctx, "The key doesn't exist", log.Fields{"key": key, "Error": err})
Naveen Sampath04696f72022-06-13 15:19:14 +0530773 return err
774 }
775 return nil
776}
777
778//PON counters
779
780// GetAllPonCounters to get all pon counters info
781func (db *Database) GetAllPonCounters(device string) (map[string]*kvstore.KVPair, error) {
782 key := GetKeyPath(PonCounterPath) + device
783 return db.List(key)
784}
785
786// GetPonCounter to get pon counter info
787func (db *Database) GetPonCounter(device, ponID string) (string, error) {
788 key := GetKeyPath(PonCounterPath) + device + "/" + ponID
789 return db.Get(key)
790}
791
792// PutPonCounter to add pon counter info
793func (db *Database) PutPonCounter(device, ponID, value string) error {
794 key := GetKeyPath(PonCounterPath) + device + "/" + ponID
795 return db.kvc.Put(context.Background(), key, value)
796}
797
798// DelPonCounter to delete pon counter info
799func (db *Database) DelPonCounter(device, ponID string) error {
800 key := GetKeyPath(PonCounterPath) + device + "/" + ponID
801 if err := db.kvc.Delete(context.Background(), key); err != nil {
Tinoj Joseph1d108322022-07-13 10:07:39 +0530802 logger.Errorw(ctx, "The key doesn't exist", log.Fields{"key": key, "Error": err})
Naveen Sampath04696f72022-06-13 15:19:14 +0530803 return err
804 }
805 return nil
806}
807
808//PON Channel counters
809
810// GetAllPonChannelCounters to get all pon channel counters
811func (db *Database) GetAllPonChannelCounters(device, ponID string) (map[string]*kvstore.KVPair, error) {
812 key := GetKeyPath(PonCounterPath) + device + "/" + ponID + "/" + ChannelCounterPath
813 return db.List(key)
814}
815
816// GetPonChannelCounter to get pon channel counter
817func (db *Database) GetPonChannelCounter(device, ponID, channel string) (string, error) {
818 key := GetKeyPath(PonCounterPath) + device + "/" + ponID + "/" + ChannelCounterPath + channel
819 return db.Get(key)
820}
821
822// PutPonChannelCounter to add pon channel counter
823func (db *Database) PutPonChannelCounter(device, ponID, channel, value string) error {
824 key := GetKeyPath(PonCounterPath) + device + "/" + ponID + "/" + ChannelCounterPath + channel
825 return db.kvc.Put(context.Background(), key, value)
826}
827
828// DelPonChannelCounter to delete pon channel counter
829func (db *Database) DelPonChannelCounter(device, ponID, channel string) error {
830 key := GetKeyPath(PonCounterPath) + device + "/" + ponID + "/" + ChannelCounterPath + channel
831 if err := db.kvc.Delete(context.Background(), key); err != nil {
Tinoj Joseph1d108322022-07-13 10:07:39 +0530832 logger.Errorw(ctx, "The key doesn't exist", log.Fields{"key": key, "Error": err})
Naveen Sampath04696f72022-06-13 15:19:14 +0530833 return err
834 }
835 return nil
836}
837
838// DelAllPONCounters to delete all pon channel counters
839func (db *Database) DelAllPONCounters(device string) error {
840 key := GetKeyPath(PonCounterPath) + device + "/"
841 return db.DeleteAll(key)
842}
843
844// DelPONCounters to delete pon counters
845func (db *Database) DelPONCounters(device string, ponID string) {
846 key := GetKeyPath(PonCounterPath) + device + "/" + ponID + "/"
847 if err := db.DeleteAll(key); err != nil {
Tinoj Joseph1d108322022-07-13 10:07:39 +0530848 logger.Warnw(ctx, "Delete Pon counters failed", log.Fields{"key": key})
Naveen Sampath04696f72022-06-13 15:19:14 +0530849 }
850 //DeletePonCounter(device, ponID)
851}
852
853// PutOltIgmpCounters to add Olt Igmp counter info
854func (db *Database) PutOltIgmpCounters(device, value string) error {
855 key := GetKeyPath(OltIgmpCounterPath) + device
856 return db.kvc.Put(context.Background(), key, value)
857}
858
859// GetOltIgmpCounter to get Olt Igmp counter info
860func (db *Database) GetOltIgmpCounter(device string) (string, error) {
861 key := GetKeyPath(OltIgmpCounterPath) + device
862 return db.Get(key)
863}
864
865//Service Channel counters
866
867// GetAllServiceChannelCounters to get all service channel counters info
868func (db *Database) GetAllServiceChannelCounters(serviceName string) (map[string]*kvstore.KVPair, error) {
869 key := GetKeyPath(ServiceCounterPath) + serviceName + "/" + ChannelCounterPath
870 return db.List(key)
871}
872
873// GetServiceChannelCounter to get service channel counter info
874func (db *Database) GetServiceChannelCounter(serviceName, channel string) (string, error) {
875 key := GetKeyPath(ServiceCounterPath) + serviceName + "/" + ChannelCounterPath + channel
876 return db.Get(key)
877}
878
879// PutServiceChannelCounter to add service channel counter
880func (db *Database) PutServiceChannelCounter(serviceName, channel, value string) error {
881 key := GetKeyPath(ServiceCounterPath) + serviceName + "/" + ChannelCounterPath + channel
882 return db.kvc.Put(context.Background(), key, value)
883}
884
885// DelServiceChannelCounter to delete service channel counter
886func (db *Database) DelServiceChannelCounter(serviceName, channel string) error {
887 key := GetKeyPath(ServiceCounterPath) + serviceName + "/" + ChannelCounterPath + channel
888 if err := db.kvc.Delete(context.Background(), key); err != nil {
Tinoj Joseph1d108322022-07-13 10:07:39 +0530889 logger.Errorw(ctx, "The key doesn't exist", log.Fields{"key": key, "Error": err})
Naveen Sampath04696f72022-06-13 15:19:14 +0530890 return err
891 }
892 return nil
893}
894
895// DelAllServiceChannelCounter to delete all service channel counter
896func (db *Database) DelAllServiceChannelCounter(serviceName string) error {
897 key := GetKeyPath(ServiceCounterPath) + serviceName + "/" + ChannelCounterPath
898 return db.DeleteAllUnderHashKey(key)
899}
900
901// OltExists to know if the ONU is added to the database
902func (db *Database) OltExists(deviceID string) bool {
903 if _, err := db.GetOlt(deviceID); err != nil {
904 return false
905 }
906 return true
907
908}
909
910// PutFlowHash to add flowhash for the device
911func (db *Database) PutFlowHash(deviceID string, value string) error {
912 key := fmt.Sprintf(GetKeyPath(DeviceFlowPath), deviceID)
913 return db.kvc.Put(context.Background(), key, value)
914}
915
916// GetFlowHash gets the flow hash for the device
917func (db *Database) GetFlowHash(deviceID string) (string, error) {
918 key := fmt.Sprintf(GetKeyPath(DeviceFlowPath), deviceID)
919 return db.Get(key)
920}
921
922// PutPortAlarmProfile to add port alarm profile
923func (db *Database) PutPortAlarmProfile(portAlarmProfileID string, value string) {
924 key := GetKeyPath(PortAlarmProfilePath) + fmt.Sprintf("%v", portAlarmProfileID)
925 if err := db.kvc.Put(context.Background(), key, value); err != nil {
Tinoj Joseph1d108322022-07-13 10:07:39 +0530926 logger.Warnw(ctx, "Put PortAlarmProfile failed", log.Fields{"key": key})
Naveen Sampath04696f72022-06-13 15:19:14 +0530927 }
928}
929
930// DelPortAlarmProfile to delete port alarm profile
931func (db *Database) DelPortAlarmProfile(portAlarmProfileID string) {
932 key := GetKeyPath(PortAlarmProfilePath) + fmt.Sprintf("%v", portAlarmProfileID)
933 if err := db.kvc.Delete(context.Background(), key); err != nil {
Tinoj Joseph1d108322022-07-13 10:07:39 +0530934 logger.Warnw(ctx, "Delete PortAlarmProfile failed", log.Fields{"key": key})
Naveen Sampath04696f72022-06-13 15:19:14 +0530935 }
936}
937
938// GetPortAlarmProfile to get port alarm profile
939func (db *Database) GetPortAlarmProfile(portAlarmProfileID string) (map[string]*kvstore.KVPair, error) {
940 key := GetKeyPath(PortAlarmProfilePath) + fmt.Sprintf("%v", portAlarmProfileID)
941 return db.List(key)
942}
943
944// PutPortAlarmData to add port alarm data
945func (db *Database) PutPortAlarmData(deviceID string, portID uint32, value string) {
946 key := fmt.Sprintf(GetKeyPath(PortAlarmDataPath), deviceID) + fmt.Sprintf("%v", portID)
947 if err := db.kvc.Put(context.Background(), key, value); err != nil {
Tinoj Joseph1d108322022-07-13 10:07:39 +0530948 logger.Warnw(ctx, "Put PortAlarmData failed", log.Fields{"key": key})
Naveen Sampath04696f72022-06-13 15:19:14 +0530949 }
950}
951
952// DelPortAlarmData to delete port alarm data
953func (db *Database) DelPortAlarmData(deviceID string, portID uint32) {
954 key := fmt.Sprintf(GetKeyPath(PortAlarmDataPath), deviceID) + fmt.Sprintf("%v", portID)
955 if err := db.kvc.Delete(context.Background(), key); err != nil {
Tinoj Joseph1d108322022-07-13 10:07:39 +0530956 logger.Warnw(ctx, "Delete PortAlarmData failed", log.Fields{"key": key})
Naveen Sampath04696f72022-06-13 15:19:14 +0530957 }
958}
959
960// GetPortAlarmData to get port alarm data
961func (db *Database) GetPortAlarmData(deviceID string, portID uint32) (string, error) {
962 key := fmt.Sprintf(GetKeyPath(PortAlarmDataPath), deviceID) + fmt.Sprintf("%v", portID)
963 return db.Get(key)
964}
965
966// GetAllPortAlarmData to get port alarm data for all ports
967func (db *Database) GetAllPortAlarmData(deviceID string) (map[string]*kvstore.KVPair, error) {
968 key := fmt.Sprintf(GetKeyPath(PortAlarmDataPath), deviceID)
969 return db.List(key)
970}
971
972// PutSubAlarmData to add subscriber alarm data
973func (db *Database) PutSubAlarmData(deviceID string, portName string, value string) {
974 key := fmt.Sprintf(GetKeyPath(SubAlarmDataPath), deviceID) + fmt.Sprintf("%v", portName)
975 if err := db.kvc.Put(context.Background(), key, value); err != nil {
Tinoj Joseph1d108322022-07-13 10:07:39 +0530976 logger.Warnw(ctx, "Put Subscriber AlarmData failed", log.Fields{"key": key})
Naveen Sampath04696f72022-06-13 15:19:14 +0530977 }
978}
979
980// DelSubAlarmData to delete subscriber alarm data
981func (db *Database) DelSubAlarmData(deviceID string, portName string) {
982 key := fmt.Sprintf(GetKeyPath(SubAlarmDataPath), deviceID) + fmt.Sprintf("%v", portName)
983 if err := db.kvc.Delete(context.Background(), key); err != nil {
Tinoj Joseph1d108322022-07-13 10:07:39 +0530984 logger.Warnw(ctx, "Delete Subscriber AlarmData failed", log.Fields{"key": key})
Naveen Sampath04696f72022-06-13 15:19:14 +0530985 }
986}
987
988// GetSubAlarmData to get subscriber alarm data
989func (db *Database) GetSubAlarmData(deviceID string, portName string) (string, error) {
990 key := fmt.Sprintf(GetKeyPath(SubAlarmDataPath), deviceID) + fmt.Sprintf("%v", portName)
991 return db.Get(key)
992}
993
994// GetAllSubAlarmData to get sub alarm data for all subscribers
995func (db *Database) GetAllSubAlarmData(deviceID string) (map[string]*kvstore.KVPair, error) {
996 key := fmt.Sprintf(GetKeyPath(SubAlarmDataPath), deviceID)
997 return db.List(key)
998}
999
1000// Migrate Service req specific database actions
1001
1002// PutMigrateServicesReq to add MigrateServicesReq info
1003func (db *Database) PutMigrateServicesReq(deviceID string, vnet string, value string) error {
1004 key := fmt.Sprintf(GetKeyPath(ServicesMigrateReqPath), deviceID) + vnet
1005 return db.kvc.Put(context.Background(), key, value)
1006}
1007
1008// GetMigrateServicesReq to get MigrateServicesReq info
1009func (db *Database) GetMigrateServicesReq(deviceID string, vnet string) (string, error) {
1010 key := fmt.Sprintf(GetKeyPath(ServicesMigrateReqPath), deviceID) + vnet
1011 return db.Get(key)
1012}
1013
1014// GetAllMigrateServicesReq to get multiple MigrateServicesReq info
1015func (db *Database) GetAllMigrateServicesReq(deviceID string) (map[string]*kvstore.KVPair, error) {
1016 key := fmt.Sprintf(GetKeyPath(ServicesMigrateReqPath), deviceID)
1017 return db.List(key)
1018}
1019
1020// DelMigrateServicesReq to delete MigrateServicesReq info
1021func (db *Database) DelMigrateServicesReq(deviceID string, vnet string) error {
1022 key := fmt.Sprintf(GetKeyPath(ServicesMigrateReqPath), deviceID) + vnet
1023 if err := db.kvc.Delete(context.Background(), key); err != nil {
Tinoj Joseph1d108322022-07-13 10:07:39 +05301024 logger.Errorw(ctx, "The key doesn't exist", log.Fields{"key": key, "Error": err})
Naveen Sampath04696f72022-06-13 15:19:14 +05301025 return err
1026 }
1027 return nil
1028}
1029
1030// DelAllMigrateServicesReq to delete all MigrateServicesReq info
1031func (db *Database) DelAllMigrateServicesReq(deviceID string) error {
1032 key := fmt.Sprintf(GetKeyPath(ServicesMigrateReqPath), deviceID)
1033 if err := db.DeleteAllUnderHashKey(key); err != nil {
Tinoj Joseph1d108322022-07-13 10:07:39 +05301034 logger.Warnw(ctx, "Delete All failed: The key doesn't exist", log.Fields{"key": key, "Error": err})
Naveen Sampath04696f72022-06-13 15:19:14 +05301035 return err
1036 }
1037 logger.Infow(ctx, "Deleting all the Update Vnet Requests for device", log.Fields{"device": deviceID})
1038 return nil
1039}
1040
1041func init() {
Tinoj Joseph1d108322022-07-13 10:07:39 +05301042 // Setup this package so that it's log level can be modified at run time
1043 var err error
1044 logger, err = log.AddPackageWithDefaultParam()
1045 if err != nil {
1046 panic(err)
1047 }
Naveen Sampath04696f72022-06-13 15:19:14 +05301048}