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 /pkg/network | |
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 'pkg/network')
-rw-r--r-- | pkg/network/config.go | 4 | ||||
-rw-r--r-- | pkg/network/network.go | 26 |
2 files changed, 30 insertions, 0 deletions
diff --git a/pkg/network/config.go b/pkg/network/config.go new file mode 100644 index 000000000..d282f66b6 --- /dev/null +++ b/pkg/network/config.go @@ -0,0 +1,4 @@ +package network + +// CNIConfigDir is the path where CNI config files exist +const CNIConfigDir = "/etc/cni/net.d" diff --git a/pkg/network/network.go b/pkg/network/network.go new file mode 100644 index 000000000..9d04340a3 --- /dev/null +++ b/pkg/network/network.go @@ -0,0 +1,26 @@ +package network + +import ( + "sort" + + "github.com/containernetworking/cni/libcni" +) + +// LoadCNIConfsFromDir loads all the CNI configurations from a dir +func LoadCNIConfsFromDir(dir string) ([]*libcni.NetworkConfigList, error) { + var configs []*libcni.NetworkConfigList + files, err := libcni.ConfFiles(dir, []string{".conflist"}) + if err != nil { + return nil, err + } + sort.Strings(files) + + for _, confFile := range files { + conf, err := libcni.ConfListFromFile(confFile) + if err != nil { + return nil, err + } + configs = append(configs, conf) + } + return configs, nil +} |