MCPcopy
hub / github.com/lxc/incus / clusterGet

Function clusterGet

cmd/incusd/api_cluster.go:113–155  ·  view source on GitHub ↗

swagger:operation GET /1.0/cluster cluster cluster_get Get the cluster configuration Gets the current cluster configuration. --- produces: - application/json responses: "200": description: Cluster configuration schema: type: object description: Sync response

(d *Daemon, r *http.Request)

Source from the content-addressed store, hash-verified

111// "500":
112// $ref: "#/responses/InternalServerError"
113func clusterGet(d *Daemon, r *http.Request) response.Response {
114 s := d.State()
115 serverName := s.ServerName
116
117 // If the name is set to the hard-coded default node name, then
118 // clustering is not enabled.
119 if serverName == "none" {
120 serverName = ""
121 }
122
123 memberConfig, err := clusterGetMemberConfig(r.Context(), s.DB.Cluster)
124 if err != nil {
125 return response.SmartError(err)
126 }
127
128 // Sort the member config.
129 sort.Slice(memberConfig, func(i, j int) bool {
130 left := memberConfig[i]
131 right := memberConfig[j]
132
133 if left.Entity != right.Entity {
134 return left.Entity < right.Entity
135 }
136
137 if left.Name != right.Name {
138 return left.Name < right.Name
139 }
140
141 if left.Key != right.Key {
142 return left.Key < right.Key
143 }
144
145 return left.Description < right.Description
146 })
147
148 clusterInfo := api.Cluster{
149 ServerName: serverName,
150 Enabled: serverName != "",
151 MemberConfig: memberConfig,
152 }
153
154 return response.SyncResponseETag(true, clusterInfo, clusterInfo)
155}
156
157// Fetch information about all node-specific configuration keys set on the
158// storage pools and networks of this cluster.

Callers

nothing calls this directly

Calls 5

SmartErrorFunction · 0.92
SyncResponseETagFunction · 0.92
clusterGetMemberConfigFunction · 0.85
ContextMethod · 0.80
StateMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…