Skip to content
Snippets Groups Projects

Initialize AssignForwardingHandler and KeyStoreHandler

Merged Malte Bauch requested to merge init-for-assign-forwarding-handler into master
6 files
+ 183
168
Compare changes
  • Side-by-side
  • Inline
Files
6
@@ -42,27 +42,7 @@ func (yh *KeyStoreHandler) Init(config *handler.Config, publishToSubsFunc func([
return err
}
yh.Config.Lock()
defer yh.Config.Unlock()
copyCurrentConfig, err := ygot.DeepCopy(yh.Config.Data)
if err != nil {
return err
}
newConfig, ok := copyCurrentConfig.(*gnmitargetygot.Gnmitarget)
if !ok {
return fmt.Errorf("Wrong type, exptected: %T, got: %T", (*gnmitargetygot.OpenconfigInterfaces_Interfaces)(nil), copyCurrentConfig)
}
newConfig.GetOrCreateKeyStores()
//validate struct
if err := newConfig.Validate(); err != nil {
return err
}
yh.Config.Data = newConfig
yh.updateOrCreateKeyStores()
// Start the go routine that takes care of any update from the kms
go func() {
@@ -71,7 +51,7 @@ func (yh *KeyStoreHandler) Init(config *handler.Config, publishToSubsFunc func([
case <-yh.events:
log.Println("Update for key stores.")
diff, err := yh.updateOrCreateKeyStores(yh.kms)
diff, err := yh.updateOrCreateKeyStores()
if err != nil {
log.Errorf("Error within key stores subscription goroutine; %v", err)
break
@@ -90,7 +70,7 @@ func (yh *KeyStoreHandler) Update(c ygot.ValidatedGoStruct, jobs []*gnmi.Update)
return nil
}
func (yh *KeyStoreHandler) updateOrCreateKeyStores(kms *kms.KMS) ([]*gnmi.Notification, error) {
func (yh *KeyStoreHandler) updateOrCreateKeyStores() ([]*gnmi.Notification, error) {
yh.Config.Lock()
defer yh.Config.Unlock()
@@ -104,7 +84,7 @@ func (yh *KeyStoreHandler) updateOrCreateKeyStores(kms *kms.KMS) ([]*gnmi.Notifi
return nil, fmt.Errorf("Wrong type, exptected: %T, got: %T", (*gnmitargetygot.Temp_KeyStores)(nil), copyCurrentConfig)
}
kmsPeers := kms.PeersDeepCopy()
kmsPeers := yh.kms.PeersDeepCopy()
confKeyStores := newConfig.GetOrCreateKeyStores()
Loading