summaryrefslogtreecommitdiff
path: root/libpod/container.go
diff options
context:
space:
mode:
authorbaude <bbaude@redhat.com>2020-11-11 09:45:07 -0600
committerbaude <bbaude@redhat.com>2020-11-19 08:16:19 -0600
commita3e0b7d117251944375fd32449f6b26d65edf367 (patch)
tree824e4acb1529fb72276630fdd4d57127c07aadc8 /libpod/container.go
parent286d356db03a2511722155022c19855f8aee73cf (diff)
downloadpodman-a3e0b7d117251944375fd32449f6b26d65edf367.tar.gz
podman-a3e0b7d117251944375fd32449f6b26d65edf367.tar.bz2
podman-a3e0b7d117251944375fd32449f6b26d65edf367.zip
add network connect|disconnect compat endpoints
this enables the ability to connect and disconnect a container from a given network. it is only for the compatibility layer. some code had to be refactored to avoid circular imports. additionally, tests are being deferred temporarily due to some incompatibility/bug in either docker-py or our stack. Signed-off-by: baude <bbaude@redhat.com>
Diffstat (limited to 'libpod/container.go')
-rw-r--r--libpod/container.go24
1 files changed, 24 insertions, 0 deletions
diff --git a/libpod/container.go b/libpod/container.go
index 9009a4ec8..4b9e6a5ba 100644
--- a/libpod/container.go
+++ b/libpod/container.go
@@ -206,6 +206,10 @@ type ContainerState struct {
// and not delegated to the OCI runtime.
ExtensionStageHooks map[string][]spec.Hook `json:"extensionStageHooks,omitempty"`
+ // NetInterfaceDescriptions describe the relationship between a CNI
+ // network and an interface names
+ NetInterfaceDescriptions ContainerNetworkDescriptions `json:"networkDescriptions,omitempty"`
+
// containerPlatformState holds platform-specific container state.
containerPlatformState
}
@@ -244,6 +248,10 @@ type ContainerImageVolume struct {
ReadWrite bool `json:"rw"`
}
+// ContainerNetworkDescriptions describes the relationship between the CNI
+// network and the ethN where N is an integer
+type ContainerNetworkDescriptions map[string]int
+
// Config accessors
// Unlocked
@@ -1102,3 +1110,19 @@ func (c *Container) networksByNameIndex() (map[string]int, error) {
}
return networkNamesByIndex, nil
}
+
+// add puts the new given CNI network name into the tracking map
+// and assigns it a new integer based on the map length
+func (d ContainerNetworkDescriptions) add(networkName string) {
+ d[networkName] = len(d)
+}
+
+// getInterfaceByName returns a formatted interface name for a given
+// network along with a bool as to whether the network existed
+func (d ContainerNetworkDescriptions) getInterfaceByName(networkName string) (string, bool) {
+ val, exists := d[networkName]
+ if !exists {
+ return "", exists
+ }
+ return fmt.Sprintf("eth%d", val), exists
+}