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:
@@ -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
|
||||
}
|
||||
|
||||
@@ -2895,3 +2895,7 @@ headers.
|
||||
## `network_ovn_tunnels`
|
||||
|
||||
This adds support for network tunnels to OVN networks.
|
||||
|
||||
## `init_preseed_cluster_groups`
|
||||
|
||||
This API extension provides the ability to configure cluster groups in preseed init.
|
||||
|
||||
@@ -1282,6 +1282,15 @@ definitions:
|
||||
$ref: '#/definitions/CertificatesPost'
|
||||
type: array
|
||||
x-go-name: Certificates
|
||||
cluster_groups:
|
||||
description: |-
|
||||
Cluster groups to add
|
||||
|
||||
API extension: init_preseed_cluster_groups.
|
||||
items:
|
||||
$ref: '#/definitions/ClusterGroupsPost'
|
||||
type: array
|
||||
x-go-name: ClusterGroups
|
||||
config:
|
||||
additionalProperties:
|
||||
type: string
|
||||
|
||||
@@ -498,6 +498,7 @@ var APIExtensions = []string{
|
||||
"instance_limits_oom",
|
||||
"backup_override_config",
|
||||
"network_ovn_tunnels",
|
||||
"init_preseed_cluster_groups",
|
||||
}
|
||||
|
||||
// APIExtensionsCount returns the number of available API extensions.
|
||||
|
||||
@@ -262,7 +262,7 @@ type ClusterMemberStatePost struct {
|
||||
//
|
||||
// API extension: clustering_groups.
|
||||
type ClusterGroupsPost struct {
|
||||
ClusterGroupPut
|
||||
ClusterGroupPut `yaml:",inline"`
|
||||
|
||||
// The new name of the cluster group
|
||||
// Example: group1
|
||||
|
||||
@@ -45,6 +45,11 @@ type InitLocalPreseed struct {
|
||||
//
|
||||
// API extension: init_preseed_certificates.
|
||||
Certificates []CertificatesPost `json:"certificates" yaml:"certificates"`
|
||||
|
||||
// Cluster groups to add
|
||||
//
|
||||
// API extension: init_preseed_cluster_groups.
|
||||
ClusterGroups []ClusterGroupsPost `json:"cluster_groups" yaml:"cluster_groups"`
|
||||
}
|
||||
|
||||
// InitNetworksProjectPost represents the fields of a new network along with its associated project.
|
||||
|
||||
Reference in New Issue
Block a user