1
0
mirror of https://github.com/lxc/incus.git synced 2026-02-05 09:46:19 +01:00

Merge pull request #2508 from stgraber/cluster

Add cluster group preseeding
This commit is contained in:
Stéphane Graber
2025-09-25 20:12:19 -04:00
committed by GitHub
6 changed files with 48 additions and 1 deletions

View File

@@ -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
}