summaryrefslogtreecommitdiff
path: root/cmd/podman/network_create.go
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2020-04-16 14:04:58 -0700
committerGitHub <noreply@github.com>2020-04-16 14:04:58 -0700
commit0d2b5532c417c58bd24e71a56c5c55b43e423a59 (patch)
tree4001e8e47a022bb1b9bfbf2332c42e1aeb802f9e /cmd/podman/network_create.go
parent88c6fd06cd54fb9a8826306dfdf1a77e400de5de (diff)
parent241326a9a8c20ad7f2bcf651416b836e7778e090 (diff)
downloadpodman-0d2b5532c417c58bd24e71a56c5c55b43e423a59.tar.gz
podman-0d2b5532c417c58bd24e71a56c5c55b43e423a59.tar.bz2
podman-0d2b5532c417c58bd24e71a56c5c55b43e423a59.zip
Merge pull request #5852 from baude/v1prune
Podman V2 birth
Diffstat (limited to 'cmd/podman/network_create.go')
-rw-r--r--cmd/podman/network_create.go83
1 files changed, 0 insertions, 83 deletions
diff --git a/cmd/podman/network_create.go b/cmd/podman/network_create.go
deleted file mode 100644
index 886607885..000000000
--- a/cmd/podman/network_create.go
+++ /dev/null
@@ -1,83 +0,0 @@
-// +build !remoteclient
-
-package main
-
-import (
- "fmt"
- "net"
-
- "github.com/containers/libpod/cmd/podman/cliconfig"
- "github.com/containers/libpod/libpod"
- "github.com/containers/libpod/pkg/adapter"
- "github.com/containers/libpod/pkg/network"
- "github.com/containers/libpod/pkg/rootless"
- "github.com/pkg/errors"
- "github.com/spf13/cobra"
-)
-
-var (
- networkCreateCommand cliconfig.NetworkCreateValues
- networkCreateDescription = `create CNI networks for containers and pods`
- _networkCreateCommand = &cobra.Command{
- Use: "create [flags] [NETWORK]",
- Short: "network create",
- Long: networkCreateDescription,
- RunE: func(cmd *cobra.Command, args []string) error {
- networkCreateCommand.InputArgs = args
- networkCreateCommand.GlobalFlags = MainGlobalOpts
- networkCreateCommand.Remote = remoteclient
- return networkcreateCmd(&networkCreateCommand)
- },
- Example: `podman network create podman1`,
- }
-)
-
-func init() {
- networkCreateCommand.Command = _networkCreateCommand
- networkCreateCommand.SetHelpTemplate(HelpTemplate())
- networkCreateCommand.SetUsageTemplate(UsageTemplate())
- flags := networkCreateCommand.Flags()
- flags.StringVarP(&networkCreateCommand.Driver, "driver", "d", "bridge", "driver to manage the network")
- flags.IPVar(&networkCreateCommand.Gateway, "gateway", nil, "IPv4 or IPv6 gateway for the subnet")
- flags.BoolVar(&networkCreateCommand.Internal, "internal", false, "restrict external access from this network")
- flags.IPNetVar(&networkCreateCommand.IPRange, "ip-range", net.IPNet{}, "allocate container IP from range")
- flags.StringVar(&networkCreateCommand.MacVLAN, "macvlan", "", "create a Macvlan connection based on this device")
- // TODO not supported yet
- //flags.StringVar(&networkCreateCommand.IPamDriver, "ipam-driver", "", "IP Address Management Driver")
- // TODO enable when IPv6 is working
- //flags.BoolVar(&networkCreateCommand.IPV6, "IPv6", false, "enable IPv6 networking")
- flags.IPNetVar(&networkCreateCommand.Network, "subnet", net.IPNet{}, "subnet in CIDR format")
- flags.BoolVar(&networkCreateCommand.DisableDNS, "disable-dns", false, "disable dns plugin")
-}
-
-func networkcreateCmd(c *cliconfig.NetworkCreateValues) error {
- var (
- fileName string
- err error
- )
- if err := network.IsSupportedDriver(c.Driver); err != nil {
- return err
- }
- if rootless.IsRootless() && !remoteclient {
- return errors.New("network create is not supported for rootless mode")
- }
- if len(c.InputArgs) > 1 {
- return errors.Errorf("only one network can be created at a time")
- }
- if len(c.InputArgs) > 0 && !libpod.NameRegex.MatchString(c.InputArgs[0]) {
- return libpod.RegexError
- }
- runtime, err := adapter.GetRuntimeNoStore(getContext(), &c.PodmanCommand)
- if err != nil {
- return err
- }
- if len(c.MacVLAN) > 0 {
- fileName, err = runtime.NetworkCreateMacVLAN(c)
- } else {
- fileName, err = runtime.NetworkCreateBridge(c)
- }
- if err == nil {
- fmt.Println(fileName)
- }
- return err
-}