diff options
author | baude <bbaude@redhat.com> | 2019-07-03 19:21:38 -0500 |
---|---|---|
committer | baude <bbaude@redhat.com> | 2019-08-15 12:49:12 -0500 |
commit | 6220ef1488d3e135c332c265fdb6a3c7b240b561 (patch) | |
tree | b4882936936c4d8c308c57ff0c460b3ae98897f3 /cmd/podman/network_list.go | |
parent | 3f1657d729b4f4c367b3e124621a6f3a9a5769d4 (diff) | |
download | podman-6220ef1488d3e135c332c265fdb6a3c7b240b561.tar.gz podman-6220ef1488d3e135c332c265fdb6a3c7b240b561.tar.bz2 podman-6220ef1488d3e135c332c265fdb6a3c7b240b561.zip |
inclusion of podman network
adding podman network and the subcommands inspect, list, and rm. the
inspect subcommand displays the raw cni network configuration. the list
subcommand displays a summary of the cni networks ala ps. and the rm
subcommand removes a cni network.
Signed-off-by: baude <bbaude@redhat.com>
Diffstat (limited to 'cmd/podman/network_list.go')
-rw-r--r-- | cmd/podman/network_list.go | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/cmd/podman/network_list.go b/cmd/podman/network_list.go new file mode 100644 index 000000000..16edf743b --- /dev/null +++ b/cmd/podman/network_list.go @@ -0,0 +1,53 @@ +// +build !remoteclient + +package main + +import ( + "errors" + "github.com/containers/libpod/cmd/podman/cliconfig" + "github.com/containers/libpod/pkg/adapter" + "github.com/containers/libpod/pkg/rootless" + "github.com/spf13/cobra" +) + +var ( + networklistCommand cliconfig.NetworkListValues + networklistDescription = `List networks` + _networklistCommand = &cobra.Command{ + Use: "ls", + Args: noSubArgs, + Short: "network list", + Long: networklistDescription, + RunE: func(cmd *cobra.Command, args []string) error { + networklistCommand.InputArgs = args + networklistCommand.GlobalFlags = MainGlobalOpts + networklistCommand.Remote = remoteclient + return networklistCmd(&networklistCommand) + }, + Example: `podman network list`, + } +) + +func init() { + networklistCommand.Command = _networklistCommand + networklistCommand.SetHelpTemplate(HelpTemplate()) + networklistCommand.SetUsageTemplate(UsageTemplate()) + flags := networklistCommand.Flags() + // TODO enable filters based on something + //flags.StringSliceVarP(&networklistCommand.Filter, "filter", "f", []string{}, "Pause all running containers") + flags.BoolVarP(&networklistCommand.Quiet, "quiet", "q", false, "display only names") +} + +func networklistCmd(c *cliconfig.NetworkListValues) error { + if rootless.IsRootless() && !remoteclient { + return errors.New("network list is not supported for rootless mode") + } + if len(c.InputArgs) > 0 { + return errors.New("network list takes no arguments") + } + runtime, err := adapter.GetRuntimeNoStore(getContext(), &c.PodmanCommand) + if err != nil { + return err + } + return runtime.NetworkList(c) +} |