From 86fbf2936dfc255f0af96a65f4a11548b2e52360 Mon Sep 17 00:00:00 2001 From: Jan Tluka Date: Tue, 17 Sep 2024 14:55:54 +0200 Subject: [PATCH 1/3] domain/networks_manager.py: use specified driver in IPAMConfig When user specifies a IPAM driver through IPAMConfig, the driver value was ignored and not translated to json used in network create command. This patch fixes the issue by translating the IPAM driver configuration in network_create json data. Signed-off-by: Jan Tluka --- podman/domain/networks_manager.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/podman/domain/networks_manager.py b/podman/domain/networks_manager.py index 6f33202b..2deb175c 100644 --- a/podman/domain/networks_manager.py +++ b/podman/domain/networks_manager.py @@ -76,6 +76,9 @@ def create(self, name: str, **kwargs) -> Network: return self.prepare_model(attrs=response.json()) def _prepare_ipam(self, data: Dict[str, Any], ipam: Dict[str, Any]): + if "Driver" in ipam: + data["ipam_options"] = {"driver": ipam["Driver"]} + if "Config" not in ipam: return From 71e53c7adec5751b97a99aa5f62313e0474637ff Mon Sep 17 00:00:00 2001 From: Jan Tluka Date: Wed, 18 Sep 2024 09:31:24 +0200 Subject: [PATCH 2/3] domain/ipam.py: fix default value of ipam driver Signed-off-by: Jan Tluka --- podman/domain/ipam.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/podman/domain/ipam.py b/podman/domain/ipam.py index 98a78350..2cf445e4 100644 --- a/podman/domain/ipam.py +++ b/podman/domain/ipam.py @@ -40,7 +40,7 @@ class IPAMConfig(dict): def __init__( self, - driver: Optional[str] = "default", + driver: Optional[str] = "host-local", pool_configs: Optional[List[IPAMPool]] = None, options: Optional[Mapping[str, Any]] = None, ): From 210c9dcb1d9f1a979c623db3fa3bebf37559490b Mon Sep 17 00:00:00 2001 From: Nicola Sella Date: Tue, 24 Sep 2024 16:49:14 +0200 Subject: [PATCH 3/3] Fix/Disable Pylint R0917 Two ways of fixing this: - Ignore R0917 for internal functions such as __int__ - Fix the positional arguments with * Only exception is for run(image, command=None) for which it is convenient to run with two positional args. Example: run('fedora:latest', 'ls -la /') Testing against Pylint stable. Source of Pylint 3.3.1 docs https://pylint.readthedocs.io/en/stable/user_guide/messages/refactor/too-many-positional-arguments.html Signed-off-by: Nicola Sella --- podman/api/client.py | 8 +++++++- podman/api/ssh.py | 2 +- podman/api/uds.py | 2 +- podman/client.py | 1 + podman/domain/containers.py | 7 ++++--- podman/domain/containers_run.py | 1 + podman/domain/system.py | 2 +- podman/errors/exceptions.py | 2 +- 8 files changed, 17 insertions(+), 8 deletions(-) diff --git a/podman/api/client.py b/podman/api/client.py index 7f5e3f37..9e0f987d 100644 --- a/podman/api/client.py +++ b/podman/api/client.py @@ -102,7 +102,7 @@ def __init__( use_ssh_client=True, max_pool_size=None, **kwargs, - ): # pylint: disable=unused-argument + ): # pylint: disable=unused-argument,too-many-positional-arguments """Instantiate APIClient object. Args: @@ -199,6 +199,7 @@ def _normalize_url(base_url: str) -> urllib.parse.ParseResult: def delete( self, path: Union[str, bytes], + *, params: Union[None, bytes, Mapping[str, str]] = None, headers: Optional[Mapping[str, str]] = None, timeout: _Timeout = None, @@ -233,6 +234,7 @@ def delete( def get( self, path: Union[str, bytes], + *, params: Union[None, bytes, Mapping[str, List[str]]] = None, headers: Optional[Mapping[str, str]] = None, timeout: _Timeout = None, @@ -267,6 +269,7 @@ def get( def head( self, path: Union[str, bytes], + *, params: Union[None, bytes, Mapping[str, str]] = None, headers: Optional[Mapping[str, str]] = None, timeout: _Timeout = None, @@ -301,6 +304,7 @@ def head( def post( self, path: Union[str, bytes], + *, params: Union[None, bytes, Mapping[str, str]] = None, data: _Data = None, headers: Optional[Mapping[str, str]] = None, @@ -338,6 +342,7 @@ def post( def put( self, path: Union[str, bytes], + *, params: Union[None, bytes, Mapping[str, str]] = None, data: _Data = None, headers: Optional[Mapping[str, str]] = None, @@ -376,6 +381,7 @@ def _request( self, method: str, path: Union[str, bytes], + *, data: _Data = None, params: Union[None, bytes, Mapping[str, str]] = None, headers: Optional[Mapping[str, str]] = None, diff --git a/podman/api/ssh.py b/podman/api/ssh.py index 621efff0..dd1f808e 100644 --- a/podman/api/ssh.py +++ b/podman/api/ssh.py @@ -250,7 +250,7 @@ def __init__( max_retries: int = DEFAULT_RETRIES, pool_block: int = DEFAULT_POOLBLOCK, **kwargs, - ): + ): # pylint: disable=too-many-positional-arguments """Initialize SSHAdapter. Args: diff --git a/podman/api/uds.py b/podman/api/uds.py index 3eaf6953..c2583061 100644 --- a/podman/api/uds.py +++ b/podman/api/uds.py @@ -137,7 +137,7 @@ def __init__( max_retries=DEFAULT_RETRIES, pool_block=DEFAULT_POOLBLOCK, **kwargs, - ): + ): # pylint: disable=too-many-positional-arguments """Initialize UDSAdapter. Args: diff --git a/podman/client.py b/podman/client.py index b02056dd..5785f6b9 100644 --- a/podman/client.py +++ b/podman/client.py @@ -82,6 +82,7 @@ def __exit__(self, exc_type, exc_value, traceback) -> None: @classmethod def from_env( cls, + *, version: str = "auto", timeout: Optional[int] = None, max_pool_size: Optional[int] = None, diff --git a/podman/domain/containers.py b/podman/domain/containers.py index 07ef47c4..6f9ec7f2 100644 --- a/podman/domain/containers.py +++ b/podman/domain/containers.py @@ -126,10 +126,11 @@ def diff(self) -> List[Dict[str, int]]: response.raise_for_status() return response.json() - # pylint: disable=too-many-arguments,unused-argument + # pylint: disable=too-many-arguments def exec_run( self, cmd: Union[str, List[str]], + *, stdout: bool = True, stderr: bool = True, stdin: bool = False, @@ -137,8 +138,8 @@ def exec_run( privileged: bool = False, user=None, detach: bool = False, - stream: bool = False, - socket: bool = False, + stream: bool = False, # pylint: disable=unused-argument + socket: bool = False, # pylint: disable=unused-argument environment: Union[Mapping[str, str], List[str]] = None, workdir: str = None, demux: bool = False, diff --git a/podman/domain/containers_run.py b/podman/domain/containers_run.py index 7b7c9023..798c6a26 100644 --- a/podman/domain/containers_run.py +++ b/podman/domain/containers_run.py @@ -18,6 +18,7 @@ def run( self, image: Union[str, Image], command: Union[str, List[str], None] = None, + *, stdout=True, stderr=False, remove: bool = False, diff --git a/podman/domain/system.py b/podman/domain/system.py index dd965717..4c72bf2c 100644 --- a/podman/domain/system.py +++ b/podman/domain/system.py @@ -36,7 +36,7 @@ def info(self, *_, **__) -> Dict[str, Any]: response.raise_for_status() return response.json() - def login( + def login( # pylint: disable=too-many-arguments,too-many-positional-arguments,unused-argument self, username: str, password: Optional[str] = None, diff --git a/podman/errors/exceptions.py b/podman/errors/exceptions.py index 5e532f61..7cf5970a 100644 --- a/podman/errors/exceptions.py +++ b/podman/errors/exceptions.py @@ -115,7 +115,7 @@ def __init__( command: Union[str, List[str]], image: str, stderr: Optional[Iterable[str]] = None, - ): + ): # pylint: disable=too-many-positional-arguments """Initialize ContainerError. Args: