From 9eda56caf9973d1cc38b80dafc8ed196ecada217 Mon Sep 17 00:00:00 2001 From: Muayyad alsadi Date: Tue, 21 Jun 2022 21:48:45 +0300 Subject: [PATCH] FIXES #507: respecte mac_address --- examples/hello-python/App/web.py | 2 +- podman_compose.py | 23 +++++++++++++++-------- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/examples/hello-python/App/web.py b/examples/hello-python/App/web.py index f2b16c5..25c584e 100644 --- a/examples/hello-python/App/web.py +++ b/examples/hello-python/App/web.py @@ -30,7 +30,7 @@ app.add_routes(routes) def main(): - web.run_app(app) + web.run_app(app, port=8080) if __name__ == "__main__": diff --git a/podman_compose.py b/podman_compose.py index 1866db6..799b24c 100755 --- a/podman_compose.py +++ b/podman_compose.py @@ -738,19 +738,26 @@ def assert_cnt_nets(compose, cnt): def get_net_args(compose, cnt): service_name = cnt["service_name"] + net_args = [] + mac_address = cnt.get("mac_address", None) + if mac_address: + net_args.extend(["--mac_address", mac_address]) net = cnt.get("network_mode", None) if net: if net == "host": - return ["--network", net] - if net.startswith("slirp4netns:"): - return ["--network", net] - if net.startswith("service:"): + net_args.extend(["--network", net]) + elif net.startswith("slirp4netns:"): + net_args.extend(["--network", net]) + elif net.startswith("service:"): other_srv = net.split(":", 1)[1].strip() other_cnt = compose.container_names_by_service[other_srv][0] - return ["--network", f"container:{other_cnt}"] - if net.startswith("container:"): + net_args.extend(["--network", f"container:{other_cnt}"]) + elif net.startswith("container:"): other_cnt = net.split(":", 1)[1].strip() - return ["--network", f"container:{other_cnt}"] + net_args.extend(["--network", f"container:{other_cnt}"]) + else: + print(f"unknown network_mode [{net}]") + exit(1) proj_name = compose.project_name default_net = compose.default_net nets = compose.networks @@ -779,7 +786,7 @@ def get_net_args(compose, cnt): ) net_names.add(net_name) net_names_str = ",".join(net_names) - net_args = ["--net", net_names_str, "--network-alias", ",".join(aliases)] + net_args.extend(["--net", net_names_str, "--network-alias", ",".join(aliases)]) if ip: net_args.append(f"--ip={ip}") return net_args