"""``get_vm_storage_pools``: datastores.""" from __future__ import annotations from typing import Any from napalm_device_types.models import StorageVolumeDict def storage_pools(datastores: list[dict[str, Any]]) -> dict[str, StorageVolumeDict]: """Datastores keyed by name. ``enabled`` means currently accessible.""" result: dict[str, StorageVolumeDict] = {} for ds in datastores: summary = ds.get("summary") or {} name = ds.get("name") or summary.get("name", ds["_moref"]) total = int(summary.get("capacity") or 0) free = int(summary.get("freeSpace") or 0) result[name] = { "name": name, "type": str(summary.get("type", "")).lower(), "total": total, "used": total - free, "available": free, "enabled": bool(summary.get("accessible", False)), "shared": bool(summary.get("multipleHostAccess", False)), } return result