network create: support "-o parent=XXX" for ipvlan
Just like macvlan the ipvlan driver accepts a specific parent interface. Fixes #16621 Signed-off-by: Paul Holzinger <pholzing@redhat.com>
This commit is contained in:
		
							parent
							
								
									41af424cd8
								
							
						
					
					
						commit
						c9961e18c0
					
				| 
						 | 
					@ -125,7 +125,7 @@ func networkCreate(cmd *cobra.Command, args []string) error {
 | 
				
			||||||
		logrus.Warn("The --macvlan option is deprecated, use `--driver macvlan --opt parent=<device>` instead")
 | 
							logrus.Warn("The --macvlan option is deprecated, use `--driver macvlan --opt parent=<device>` instead")
 | 
				
			||||||
		network.Driver = types.MacVLANNetworkDriver
 | 
							network.Driver = types.MacVLANNetworkDriver
 | 
				
			||||||
		network.NetworkInterface = networkCreateOptions.MacVLAN
 | 
							network.NetworkInterface = networkCreateOptions.MacVLAN
 | 
				
			||||||
	} else if networkCreateOptions.Driver == types.MacVLANNetworkDriver {
 | 
						} else if networkCreateOptions.Driver == types.MacVLANNetworkDriver || networkCreateOptions.Driver == types.IPVLANNetworkDriver {
 | 
				
			||||||
		// new -d macvlan --opt parent=... syntax
 | 
							// new -d macvlan --opt parent=... syntax
 | 
				
			||||||
		if parent, ok := network.Options["parent"]; ok {
 | 
							if parent, ok := network.Options["parent"]; ok {
 | 
				
			||||||
			network.NetworkInterface = parent
 | 
								network.NetworkInterface = parent
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -658,6 +658,35 @@ var _ = Describe("Podman network", func() {
 | 
				
			||||||
		Expect(nc).Should(Exit(0))
 | 
							Expect(nc).Should(Exit(0))
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						It("podman network create/remove ipvlan as driver (-d) with device name", func() {
 | 
				
			||||||
 | 
							// Netavark currently does not support ipvlan
 | 
				
			||||||
 | 
							SkipIfNetavark(podmanTest)
 | 
				
			||||||
 | 
							net := "ipvlan" + stringid.GenerateRandomID()
 | 
				
			||||||
 | 
							nc := podmanTest.Podman([]string{"network", "create", "-d", "ipvlan", "-o", "parent=lo", net})
 | 
				
			||||||
 | 
							nc.WaitWithDefaultTimeout()
 | 
				
			||||||
 | 
							defer podmanTest.removeNetwork(net)
 | 
				
			||||||
 | 
							Expect(nc).Should(Exit(0))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							inspect := podmanTest.Podman([]string{"network", "inspect", net})
 | 
				
			||||||
 | 
							inspect.WaitWithDefaultTimeout()
 | 
				
			||||||
 | 
							Expect(inspect).Should(Exit(0))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							var results []types.Network
 | 
				
			||||||
 | 
							err := json.Unmarshal([]byte(inspect.OutputToString()), &results)
 | 
				
			||||||
 | 
							Expect(err).ToNot(HaveOccurred())
 | 
				
			||||||
 | 
							Expect(results).To(HaveLen(1))
 | 
				
			||||||
 | 
							result := results[0]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							Expect(result).To(HaveField("Driver", "ipvlan"))
 | 
				
			||||||
 | 
							Expect(result).To(HaveField("NetworkInterface", "lo"))
 | 
				
			||||||
 | 
							Expect(result.IPAMOptions).To(HaveKeyWithValue("driver", "dhcp"))
 | 
				
			||||||
 | 
							Expect(result.Subnets).To(HaveLen(0))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							nc = podmanTest.Podman([]string{"network", "rm", net})
 | 
				
			||||||
 | 
							nc.WaitWithDefaultTimeout()
 | 
				
			||||||
 | 
							Expect(nc).Should(Exit(0))
 | 
				
			||||||
 | 
						})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	It("podman network exists", func() {
 | 
						It("podman network exists", func() {
 | 
				
			||||||
		net := "net" + stringid.GenerateRandomID()
 | 
							net := "net" + stringid.GenerateRandomID()
 | 
				
			||||||
		session := podmanTest.Podman([]string{"network", "create", net})
 | 
							session := podmanTest.Podman([]string{"network", "create", net})
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue