volumes¶
卷资源的模型和管理器。
- class Volume(attrs: Mapping[str, Any] | None = None, client: APIClient | None = None, collection: Manager | None = None, podman_client: PodmanClient | None = None)[source]¶
-
由 Podman 服务管理的卷的详细信息和配置。
初始化 PodmanResource 的基类。
- 参数:
attrs – Podman 服务资源属性的映射。
client – Podman 服务的配置连接。
collection – 此类资源的管理器,为了兼容性命名为 collection
podman_client – 配置为连接到 Podman 对象的 PodmanClient()。
- inspect(**kwargs) dict [source]¶
检查此卷
- 关键字参数:
tls_verify (bool) – True。
- 返回:
显示卷的属性。
- 抛出:
APIError – 当服务报告错误时
- reload(**kwargs) None ¶
从服务刷新此对象的数据。
- 关键字参数:
compatible (bool) – 使用 Docker 兼容端点
- remove(force: bool | None = None) None [source]¶
删除此卷。
- 参数:
force – 当为 True 时,强制删除正在使用的卷
- 抛出:
APIError – 当服务报告错误时
- property id¶
返回对象的标识符。
- 类型:
str
- property name¶
返回卷的名称。
- 类型:
str
- property short_id¶
返回截断的标识符。当包含在 id 中时,保留“sha256”。
不尝试确保返回的值对所有资源都具有语义意义。
- 类型:
str
- class VolumesManager(client: APIClient | None = None, podman_client: PodmanClient | None = None)[source]¶
基类:
Manager
卷资源的专用管理器。
初始化 Manager() 对象。
- 参数:
client – 配置为连接到 Podman 服务的 APIClient()。
podman_client – 配置为连接到 Podman 对象的 PodmanClient()。
- create(name: str | None = None, **kwargs) Volume [source]¶
创建一个卷。
- 参数:
name – 新卷的名称
- 关键字参数:
driver (str) – 要使用的卷驱动程序
driver_opts (dict[str, str]) – 与驱动程序一起使用的选项
labels (dict[str, str]) – 要应用于卷的标签
- 抛出:
APIError – 当服务报告错误时
- get(volume_id: str) Volume [source]¶
通过名称或 ID 返回卷。
- 参数:
volume_id – 要搜索的卷 ID 或名称
- 抛出:
NotFound – 未找到卷时
APIError – 当服务报告错误时
- list(*_, **kwargs) list[Volume] [source]¶
报告卷。
- 关键字参数:
filters (dict[str, str]) –
筛选卷列表的条件
driver (str): 按驱动程序筛选卷
label (dict[str, str]): 按标签和/或值筛选
name (str): 按卷名称筛选
- prepare_model(attrs: PodmanResource | Mapping[str, Any]) PodmanResourceType ¶
从一组属性创建模型。
- prune(filters: dict[str, str] | None = None) dict[Literal['VolumesDeleted', 'SpaceReclaimed'], Any] [source]¶
删除未使用的卷。
- 参数:
filters – 用于选择要删除的卷的条件。忽略。
- 抛出:
APIError – 当服务报告错误时