MCPcopy Create free account
hub / github.com/jetkvm/kvm / SetConfig

Method SetConfig

pkg/nmlite/interface.go:351–376  ·  view source on GitHub ↗

SetConfig updates the interface configuration

(config *types.NetworkConfig)

Source from the content-addressed store, hash-verified

349
350// SetConfig updates the interface configuration
351func (im *InterfaceManager) SetConfig(config *types.NetworkConfig) error {
352 if config == nil {
353 return fmt.Errorf("config cannot be nil")
354 }
355
356 // Validate and set defaults
357 if err := confparser.SetDefaultsAndValidate(config); err != nil {
358 return fmt.Errorf("invalid config: %w", err)
359 }
360
361 im.config = config
362
363 // Apply the new configuration
364 if err := im.applyConfiguration(); err != nil {
365 im.logger.Error().Err(err).Msg("failed to apply new configuration")
366 return err
367 }
368
369 // Notify callback
370 if im.onConfigChange != nil {
371 im.onConfigChange(config)
372 }
373
374 im.logger.Info().Msg("configuration updated")
375 return nil
376}
377
378// RenewDHCPLease renews the DHCP lease
379func (im *InterfaceManager) RenewDHCPLease() error {

Callers 1

SetInterfaceConfigMethod · 0.45

Calls 5

applyConfigurationMethod · 0.95
SetDefaultsAndValidateFunction · 0.92
ErrorfMethod · 0.80
ErrorMethod · 0.80
InfoMethod · 0.80

Tested by

no test coverage detected