... | ... | @@ -115,6 +115,8 @@ Besides saving the new configuration revision, the CM also creates a reverse `su |
|
|
|
|
|
### Configuration Manager API
|
|
|
|
|
|
The following is the CM API which includes functions covering the basic use case to set the configuration using the `config-set` command.
|
|
|
|
|
|
```golang
|
|
|
package config // import "isc.org/stork/server/config"
|
|
|
|
... | ... | @@ -124,39 +126,72 @@ TYPES |
|
|
type KeaModule struct {
|
|
|
manager Manager
|
|
|
}
|
|
|
A Configuration Manager module responsible for Kea configuration.
|
|
|
|
|
|
func newKeaModule(manager Manager) *KeaModule
|
|
|
func (kea *KeaModule) ApplyEdit(ctx context.Context, daemonID int64) error
|
|
|
func (kea *KeaModule) BeginEdit(ctx context.Context, daemonID int64) error
|
|
|
Creates new instance of the Kea configuration module.
|
|
|
|
|
|
func (kea *KeaModule) ApplyEdit(ctx context.Context, daemonID int64, cfg keaconfig.Map) error
|
|
|
Applies configuration changes after editing daemon's configuration file.
|
|
|
|
|
|
func (kea *KeaModule) BeginEdit(ctx context.Context, daemonID int64) (cfg keaconfig.Map, err error)
|
|
|
Begins editing specified daemon's configuration file.
|
|
|
|
|
|
func (kea *KeaModule) SaveConfig(c dbmodel.KeaConfig) error
|
|
|
Saves the specified configuration as a current revision.
|
|
|
|
|
|
type LockKey int64
|
|
|
Represents a configuration lock key.
|
|
|
|
|
|
type Manager interface {
|
|
|
GetKeaModule() *KeaModule
|
|
|
Lock(context.Context, string, ...int64) error
|
|
|
Unlock(context.Context, ...int64)
|
|
|
}
|
|
|
Common place
|
|
|
Common Configuration Manager Interface. It exposes functions for locking and
|
|
|
unlocking selected daemons' configurations for update. It also returns the
|
|
|
CM sub-module to configure Kea instances.
|
|
|
|
|
|
func NewManager() Manager
|
|
|
Creates new Configuration Manager instance.
|
|
|
|
|
|
type lock struct {
|
|
|
key LockKey
|
|
|
user string
|
|
|
}
|
|
|
Represents a configuration lock.
|
|
|
|
|
|
type managerImpl struct {
|
|
|
locks map[int64]lock
|
|
|
key LockKey
|
|
|
kea *KeaModule
|
|
|
}
|
|
|
Configuration Manager implementation.
|
|
|
|
|
|
func (manager *managerImpl) GetKeaModule() *KeaModule
|
|
|
Returns CM's Kea configuration module.
|
|
|
|
|
|
func (manager *managerImpl) Lock(ctx context.Context, user string, daemonIDs ...int64) error
|
|
|
Attempts to lock configurations of the specified daemons for update.
|
|
|
Internally it generates a new lock key and stores it in the context. If an
|
|
|
attempt to lock any of the configurations fails, it will remove already
|
|
|
acquired locks and return an error.
|
|
|
|
|
|
func (manager *managerImpl) Unlock(ctx context.Context, daemonIDs ...int64)
|
|
|
Removes locks from the specified daemons' configurations if the key stored
|
|
|
in the context matches.
|
|
|
|
|
|
func (manager *managerImpl) generateNewKey() LockKey
|
|
|
Creates a key for a newly acquired lock.
|
|
|
|
|
|
func (manager *managerImpl) isLocked(daemonID int64) (string, bool)
|
|
|
Checks if the confguration of the specified daemon is locked for updates.
|
|
|
|
|
|
func (manager *managerImpl) lock(ctx context.Context, user string, daemonID int64) error
|
|
|
Attempts to acuire a lock on the specified daemon's configuration.
|
|
|
|
|
|
func (manager *managerImpl) unlock(ctx context.Context, daemonID int64) bool
|
|
|
Unlocks daemon's conifguration if the lock stored in the context matches.
|
|
|
```
|
|
|
|
|
|
## Configuration Versioning
|
... | ... | |