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

Method GetNodeStorages

pkg/api/node.go:379–411  ·  view source on GitHub ↗

GetNodeStorages retrieves all storages available on a specific node.

(nodeName string)

Source from the content-addressed store, hash-verified

377
378// GetNodeStorages retrieves all storages available on a specific node.
379func (c *Client) GetNodeStorages(nodeName string) ([]*Storage, error) {
380 var res map[string]interface{}
381 if err := c.GetWithCache(fmt.Sprintf("/nodes/%s/storage", nodeName), &res, NodeDataTTL); err != nil {
382 return nil, fmt.Errorf("failed to get node storages: %w", err)
383 }
384
385 data, ok := res["data"].([]interface{})
386 if !ok {
387 return nil, fmt.Errorf("invalid storage response format")
388 }
389
390 var storages []*Storage
391 for _, item := range data {
392 if sData, ok := item.(map[string]interface{}); ok {
393 // Skip storages not active on this node. Proxmox returns all cluster-
394 // configured storages but marks inaccessible ones (e.g., local storage
395 // belonging to a different cluster node) with active=0.
396 if _, exists := sData["active"]; exists && !getBool(sData, "active") {
397 continue
398 }
399 storage := &Storage{
400 Name: getString(sData, "storage"),
401 Content: getString(sData, "content"),
402 Plugintype: getString(sData, "type"),
403 Disk: int64(getFloat(sData, "used")),
404 MaxDisk: int64(getFloat(sData, "total")),
405 Node: nodeName,
406 }
407 storages = append(storages, storage)
408 }
409 }
410 return storages, nil
411}

Callers 7

GetBackupsMethod · 0.95
fetchStorageRowsFunction · 0.80
runStorageShowFunction · 0.80
completeStorageNamesFunction · 0.80
ShowCreateFormMethod · 0.80

Calls 4

GetWithCacheMethod · 0.95
getBoolFunction · 0.85
getStringFunction · 0.85
getFloatFunction · 0.85

Tested by

no test coverage detected