pods_manager¶
PodmanResource 管理器子类,用于网络。
- class PodsManager(client: APIClient | None = None, podman_client: PodmanClient | None = None)[源]¶
基类:
Manager
用于 Pod 资源的专用管理器。
初始化 Manager() 对象。
- 参数:
client – 配置为连接到 Podman 服务的 APIClient()。
podman_client – 配置为连接到 Podman 对象的 PodmanClient()。
- create(name: str, **kwargs) Pod [源]¶
创建一个 Pod。
- 关键字参数:
参阅 (API 文档) – https://docs.podman.org.cn/en/latest/_static/api.html#operation/CreatePod] 获取完整的关键词列表。
- get(pod_id: str) Pod [源]¶
按名称或 ID 返回 Pod 的信息。
- 参数:
pod_id – Pod 名称或 ID。
- 抛出:
NotFound – 当网络不存在时
APIError – 当服务返回错误时
- list(**kwargs) list[Pod] [源]¶
报告 Pod。
- 关键字参数:
filters (Mapping[str, str]) –
列出 Pod 的条件。可用过滤器
ctr-ids (list[str]):要过滤的容器 ID 列表。
ctr-names (list[str]):要过滤的容器名称列表。
ctr-number (list[int]):列出具有给定数量容器的 Pod。
ctr-status (list[str]):列出处于给定状态的容器的 Pod。合法值为:“created”、“running”、“paused”、“stopped”、“exited”或“unknown”
id (str) - 列出具有此 ID 的 Pod。
name (str) - 列出具有此名称的 Pod。
status (list[str]):列出处于给定状态的 Pod。合法值为:“created”、“running”、“paused”、“stopped”、“exited”或“unknown”
label (list[str]):列出具有给定标签的 Pod。
network (list[str]):列出与给定网络 ID(而非名称)关联的 Pod。
- 抛出:
APIError – 当服务返回错误时
- prepare_model(attrs: PodmanResource | Mapping[str, Any]) PodmanResourceType ¶
从一组属性创建模型。
- prune(filters: dict[str, str] | None = None) dict[str, Any] [源]¶
删除未使用的 Pod。
- 返回:
PodsDeleted (list[str]):已删除的 Pod ID 列表。
SpaceReclaimed (int):始终为零。
- 返回类型:
字典键
- 抛出:
APIError – 当服务报告错误时
- remove(pod_id: Pod | str, force: bool | None = None) None [源]¶
删除 Pod。
- 参数:
pod_id – 要删除的 Pod 的标识符。
force – 当为 True 时,停止并删除 Pod 中的所有容器,然后删除 Pod。
- 抛出:
NotFound – 当未找到 Pod 时
APIError – 当服务报告错误时
备注
仅限 Podman。
- stats(**kwargs) list[dict[str, Any]] | Iterator[list[dict[str, Any]]] [源]¶
Pod 中容器的资源使用统计。
- 关键字参数:
all (bool) – 提供所有正在运行的 Pod 的统计信息。
name (Union[str, list[str]]) – 要包含在报告中的 Pod。
stream (bool) – 流式传输统计信息,直到取消。默认值:False。
decode (bool) – 如果为 True,响应将被解码为字典。默认值:False。
- 抛出:
NotFound – 当未找到 Pod 时
APIError – 当服务报告错误时
- property resource¶
prepare_model() 将创建 Pod 类。
- 类型:
Type[Pod]