mirror of
https://github.com/lxc/incus.git
synced 2026-02-05 09:46:19 +01:00
client: Add support for cluster group preseeding
Closes #2499 Signed-off-by: Stéphane Graber <stgraber@stgraber.org>
This commit is contained in:
@@ -573,5 +573,33 @@ func (r *ProtocolIncus) ApplyServerPreseed(config api.InitPreseed) error {
|
||||
}
|
||||
}
|
||||
|
||||
// Apply cluster group configurations.
|
||||
if len(config.Server.ClusterGroups) > 0 {
|
||||
for _, clusterGroup := range config.Server.ClusterGroups {
|
||||
// Check if it already exists.
|
||||
existing, etag, err := r.GetClusterGroup(clusterGroup.Name)
|
||||
if err == nil && existing != nil {
|
||||
// Keep existing members if none specified (set of empty slice to empty).
|
||||
if clusterGroup.Members == nil {
|
||||
clusterGroup.Members = existing.Members
|
||||
}
|
||||
|
||||
// Update the existing group.
|
||||
err = r.UpdateClusterGroup(clusterGroup.Name, clusterGroup.ClusterGroupPut, etag)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Failed to update cluster group")
|
||||
}
|
||||
|
||||
continue
|
||||
}
|
||||
|
||||
// Create the new group.
|
||||
err = r.CreateClusterGroup(clusterGroup)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Failed to create cluster group")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user