MCPcopy Create free account
hub / github.com/devnullvoid/pvetui / getClusterBasicStatus

Method getClusterBasicStatus

pkg/api/cluster.go:197–235  ·  view source on GitHub ↗

getClusterBasicStatus retrieves basic cluster info and node list.

(cluster *Cluster)

Source from the content-addressed store, hash-verified

195
196// getClusterBasicStatus retrieves basic cluster info and node list.
197func (c *Client) getClusterBasicStatus(cluster *Cluster) error {
198 var statusResp map[string]interface{}
199 if err := c.GetWithCache("/cluster/status", &statusResp, ClusterDataTTL); err != nil {
200 return fmt.Errorf("failed to get cluster status: %w", err)
201 }
202
203 statusData, ok := statusResp["data"].([]interface{})
204 if !ok {
205 return fmt.Errorf("invalid cluster status response format")
206 }
207
208 for _, item := range statusData {
209 itemMap, ok := item.(map[string]interface{})
210 if !ok {
211 continue
212 }
213
214 switch getString(itemMap, "type") {
215 case "cluster":
216 cluster.Name = getString(itemMap, "name")
217 cluster.Quorate = getBool(itemMap, "quorate")
218 cluster.TotalNodes = getInt(itemMap, "nodes")
219 case "node":
220 nodeName := getString(itemMap, "name")
221 nodeIP := getString(itemMap, "ip")
222 // Log the raw IP value from API for debugging issue #56
223 c.logger.Debug("[CLUSTER] Node '%s' IP from API: '%s' (len=%d, bytes=%v, raw_value=%v)",
224 nodeName, nodeIP, len(nodeIP), []byte(nodeIP), itemMap["ip"])
225 cluster.Nodes = append(cluster.Nodes, &Node{
226 ID: nodeName,
227 Name: nodeName,
228 IP: nodeIP,
229 Online: getInt(itemMap, "online") == 1,
230 })
231 }
232 }
233
234 return nil
235}
236
237// enrichMissingNodeDetails selectively enriches nodes with data not available in cluster resources.
238func (c *Client) enrichMissingNodeDetails(cluster *Cluster) error {

Callers 4

GetClusterStatusMethod · 0.95
FastGetClusterStatusMethod · 0.95

Calls 5

GetWithCacheMethod · 0.95
getStringFunction · 0.85
getBoolFunction · 0.85
getIntFunction · 0.85
DebugMethod · 0.65

Tested by

no test coverage detected