From 85e8fbf7f33717ef6a0d6cf9e2143b52c874c2de Mon Sep 17 00:00:00 2001 From: Paul Holzinger Date: Mon, 16 Aug 2021 16:11:26 +0200 Subject: Wire network interface into libpod Make use of the new network interface in libpod. This commit contains several breaking changes: - podman network create only outputs the new network name and not file path. - podman network ls shows the network driver instead of the cni version and plugins. - podman network inspect outputs the new network struct and not the cni conflist. - The bindings and libpod api endpoints have been changed to use the new network structure. The container network status is stored in a new field in the state. The status should be received with the new `c.getNetworkStatus`. This will migrate the old status to the new format. Therefore old containers should contine to work correctly in all cases even when network connect/ disconnect is used. New features: - podman network reload keeps the ip and mac for more than one network. - podman container restore keeps the ip and mac for more than one network. - The network create compat endpoint can now use more than one ipam config. The man pages and the swagger doc are updated to reflect the latest changes. Signed-off-by: Paul Holzinger --- test/apiv2/35-networks.at | 70 ++++++++++++++++++++++++++++------------------- 1 file changed, 42 insertions(+), 28 deletions(-) (limited to 'test/apiv2/35-networks.at') diff --git a/test/apiv2/35-networks.at b/test/apiv2/35-networks.at index 7a36b605f..a4cb5a480 100644 --- a/test/apiv2/35-networks.at +++ b/test/apiv2/35-networks.at @@ -6,42 +6,52 @@ t GET networks/non-existing-network 404 \ .cause='network not found' -t POST libpod/networks/create?name=network1 200 \ - .Filename~.*/network1\\.conflist - -# --data '{"Subnet":{"IP":"10.10.254.0","Mask":[255,255,255,0]},"Labels":{"abc":"val"}}' -t POST libpod/networks/create?name=network2 \ - Subnet='{"IP":"10.10.254.0","Mask":[255,255,255,0]}' \ - Labels='{"abc":"val"}' \ +t POST libpod/networks/create name='"network1"' 200 \ + .name=network1 + .created~[0-9]\\{4\\}-[0-9]\\{2\\}-[0-9]\\{2\\}.* \ + +# --data '{"name":"network2","subnets":[{"subnet":"10.10.254.0/24"}],"Labels":{"abc":"val"}}' +t POST libpod/networks/create name='"network2"' \ + subnets='[{"subnet":"10.10.254.0/24"}]' \ + labels='{"abc":"val"}' \ 200 \ - .Filename~.*/network2\\.conflist - -# --data '{"Subnet":{"IP":"10.10.133.0","Mask":[255,255,255,0]},"Labels":{"xyz":"val"}}' -t POST libpod/networks/create?name=network3 \ - Subnet='{"IP":"10.10.133.0","Mask":[255,255,255,0]}' \ - Labels='{"xyz":"val"}' \ + .name=network2 \ + .subnets[0].subnet=10.10.254.0/24 \ + .subnets[0].gateway=10.10.254.1 \ + .labels.abc=val + +# --data '{"name":"network3","subnets":[{"subnet":"10.10.133.0/24"}],"Labels":{"xyz":"val"}}' +t POST libpod/networks/create name="network3" \ + subnets='[{"subnet":"10.10.133.0/24"}]' \ + labels='{"xyz":"val"}' \ 200 \ - .Filename~.*/network3\\.conflist - -# --data '{"Subnet":{"IP":"10.10.134.0","Mask":[255,255,255,0]},"Labels":{"zaq":"val"}}' -t POST libpod/networks/create?name=network4 \ - Subnet='{"IP":"10.10.134.0","Mask":[255,255,255,0]}' \ - Labels='{"zaq":"val"}' \ + .name=network3 \ + .subnets[0].subnet=10.10.133.0/24 \ + .subnets[0].gateway=10.10.133.1 \ + .labels.xyz=val + +# --data '{"name":"network4","subnets":[{"subnet":"10.10.134.0/24"}],"Labels":{"zaq":"val"}}' +t POST libpod/networks/create name="network4" \ + subnets='[{"subnet":"10.10.134.0/24"}]' \ + labels='{"zaq":"val"}' \ 200 \ - .Filename~.*/network4\\.conflist + .name=network4 \ + .subnets[0].subnet=10.10.134.0/24 \ + .subnets[0].gateway=10.10.134.1 \ + .labels.zaq=val # test for empty mask -t POST libpod/networks/create Subnet='{"IP":"10.10.1.0","Mask":[]}' 500 \ - .cause~'.*cannot be empty' +t POST libpod/networks/create subnets='[{"subnet":"10.10.134.0"}]' 500 \ + .cause~'.*invalid CIDR address: 10.10.134.0' # test for invalid mask -t POST libpod/networks/create Subnet='{"IP":"10.10.1.0","Mask":[0,255,255,0]}' 500 \ - .cause~'.*mask is invalid' +t POST libpod/networks/create subnets='[{"subnet":"10.10.134.0/65"}]' 500 \ + .cause~'.*invalid CIDR address: 10.10.134.0/65' # network list t GET libpod/networks/json 200 t GET libpod/networks/json?filters='{"name":["network1"]}' 200 \ length=1 \ - .[0].Name=network1 + .[0].name=network1 t GET networks 200 #inspect network @@ -121,7 +131,8 @@ t DELETE libpod/networks/network2 200 \ .[0].Err=null # test until filter - libpod api -podman network create network5 --label xyz +t POST libpod/networks/create name='"network5"' labels='{"xyz":""}' 200 \ + .name=network5 # with date way back in the past, network should not be deleted t POST libpod/networks/prune?filters='{"until":["500000"]}' 200 @@ -132,7 +143,8 @@ t POST libpod/networks/prune?filters='{"until":["5000000000"]}' 200 t GET libpod/networks/json?filters='{"label":["xyz"]}' 200 length=0 # test until filter - compat api -podman network create network6 --label zaq +t POST networks/create Name='"network6"' Labels='{"zaq":""}' 201 \ + .Id~[0-9a-f]\\{64\\} # with date way back in the past, network should not be deleted t POST networks/prune?filters='{"until":["500000"]}' 200 @@ -143,7 +155,9 @@ t POST networks/prune?filters='{"until":["5000000000"]}' 200 t GET networks?filters='{"label":["zaq"]}' 200 length=0 # test macvlan network response -podman network create --driver macvlan macvlan1 +t POST libpod/networks/create name='"macvlan1"' driver="macvlan" 200 \ + .name=macvlan1 \ + .driver=macvlan # libpod api inspect the macvlan network t GET libpod/networks/macvlan1/json 200 .name="macvlan1" -- cgit v1.2.3-54-g00ecf