mirror of
https://github.com/containers/podman.git
synced 2025-10-25 10:16:43 +08:00
add macvlan as a supported network driver
instead of using the --macvlan to indicate that you want to make a macvlan network, podman network create now honors the driver name of *macvlan*. Any options to macvlan, like the parent device, should be specified as a -o option. For example, -o parent=eth0. the --macvlan option was marked as deprecated in the man page but is still supported for the duration of 3.0. Signed-off-by: baude <bbaude@redhat.com>
This commit is contained in:
@ -1,6 +1,7 @@
|
||||
package integration
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"math/rand"
|
||||
@ -794,3 +795,12 @@ func (p *PodmanTestIntegration) removeCNINetwork(name string) {
|
||||
session.WaitWithDefaultTimeout()
|
||||
Expect(session.ExitCode()).To(BeNumerically("<=", 1))
|
||||
}
|
||||
|
||||
func (p *PodmanSessionIntegration) jq(jqCommand string) (string, error) {
|
||||
var out bytes.Buffer
|
||||
cmd := exec.Command("jq", jqCommand)
|
||||
cmd.Stdin = strings.NewReader(p.OutputToString())
|
||||
cmd.Stdout = &out
|
||||
err := cmd.Run()
|
||||
return strings.TrimRight(out.String(), "\n"), err
|
||||
}
|
||||
|
||||
@ -457,6 +457,47 @@ var _ = Describe("Podman network", func() {
|
||||
Expect(nc.ExitCode()).To(Equal(0))
|
||||
})
|
||||
|
||||
It("podman network create/remove macvlan as driver (-d) no device name", func() {
|
||||
net := "macvlan" + stringid.GenerateNonCryptoID()
|
||||
nc := podmanTest.Podman([]string{"network", "create", "-d", "macvlan", net})
|
||||
nc.WaitWithDefaultTimeout()
|
||||
defer podmanTest.removeCNINetwork(net)
|
||||
Expect(nc.ExitCode()).To(Equal(0))
|
||||
|
||||
inspect := podmanTest.Podman([]string{"network", "inspect", net})
|
||||
inspect.WaitWithDefaultTimeout()
|
||||
Expect(inspect.ExitCode()).To(BeZero())
|
||||
|
||||
out, err := inspect.jq(".[0].plugins[0].master")
|
||||
Expect(err).To(BeNil())
|
||||
Expect(out).To(Equal("\"\""))
|
||||
|
||||
nc = podmanTest.Podman([]string{"network", "rm", net})
|
||||
nc.WaitWithDefaultTimeout()
|
||||
Expect(nc.ExitCode()).To(Equal(0))
|
||||
})
|
||||
|
||||
It("podman network create/remove macvlan as driver (-d) with device name", func() {
|
||||
net := "macvlan" + stringid.GenerateNonCryptoID()
|
||||
nc := podmanTest.Podman([]string{"network", "create", "-d", "macvlan", "-o", "parent=lo", net})
|
||||
nc.WaitWithDefaultTimeout()
|
||||
defer podmanTest.removeCNINetwork(net)
|
||||
Expect(nc.ExitCode()).To(Equal(0))
|
||||
|
||||
inspect := podmanTest.Podman([]string{"network", "inspect", net})
|
||||
inspect.WaitWithDefaultTimeout()
|
||||
Expect(inspect.ExitCode()).To(BeZero())
|
||||
fmt.Println(inspect.OutputToString())
|
||||
|
||||
out, err := inspect.jq(".[0].plugins[0].master")
|
||||
Expect(err).To(BeNil())
|
||||
Expect(out).To(Equal("\"lo\""))
|
||||
|
||||
nc = podmanTest.Podman([]string{"network", "rm", net})
|
||||
nc.WaitWithDefaultTimeout()
|
||||
Expect(nc.ExitCode()).To(Equal(0))
|
||||
})
|
||||
|
||||
It("podman network exists", func() {
|
||||
net := "net" + stringid.GenerateNonCryptoID()
|
||||
session := podmanTest.Podman([]string{"network", "create", net})
|
||||
|
||||
Reference in New Issue
Block a user