summaryrefslogtreecommitdiff
path: root/server/sandbox_network.go
diff options
context:
space:
mode:
authorMatthew Heon <matthew.heon@gmail.com>2017-11-01 13:22:04 -0400
committerMatthew Heon <matthew.heon@gmail.com>2017-11-01 13:22:04 -0400
commitc13f61798aa7bcf7b4de7ee31aa30148a3b08d97 (patch)
tree6f0c3297f91ecbe259d8dc5ff1b0ab3d63e44744 /server/sandbox_network.go
parent92b31c0ff7c75fab3b875fb6b10c14f8e2c031e7 (diff)
downloadpodman-c13f61798aa7bcf7b4de7ee31aa30148a3b08d97.tar.gz
podman-c13f61798aa7bcf7b4de7ee31aa30148a3b08d97.tar.bz2
podman-c13f61798aa7bcf7b4de7ee31aa30148a3b08d97.zip
Prune Server package. Convert to new github location.
Signed-off-by: Matthew Heon <matthew.heon@gmail.com>
Diffstat (limited to 'server/sandbox_network.go')
-rw-r--r--server/sandbox_network.go70
1 files changed, 0 insertions, 70 deletions
diff --git a/server/sandbox_network.go b/server/sandbox_network.go
deleted file mode 100644
index 15cf99c8f..000000000
--- a/server/sandbox_network.go
+++ /dev/null
@@ -1,70 +0,0 @@
-package server
-
-import (
- "fmt"
- "net"
-
- "github.com/kubernetes-incubator/cri-o/libkpod/sandbox"
- "github.com/sirupsen/logrus"
- "k8s.io/kubernetes/pkg/kubelet/network/hostport"
-)
-
-// networkStart sets up the sandbox's network and returns the pod IP on success
-// or an error
-func (s *Server) networkStart(hostNetwork bool, sb *sandbox.Sandbox) (string, error) {
- if hostNetwork {
- return s.BindAddress(), nil
- }
-
- podNetwork := newPodNetwork(sb)
- err := s.netPlugin.SetUpPod(podNetwork)
- if err != nil {
- return "", fmt.Errorf("failed to create pod network sandbox %s(%s): %v", sb.Name(), sb.ID(), err)
- }
-
- var ip string
- if ip, err = s.netPlugin.GetPodNetworkStatus(podNetwork); err != nil {
- return "", fmt.Errorf("failed to get network status for pod sandbox %s(%s): %v", sb.Name(), sb.ID(), err)
- }
-
- if len(sb.PortMappings()) > 0 {
- ip4 := net.ParseIP(ip).To4()
- if ip4 == nil {
- return "", fmt.Errorf("failed to get valid ipv4 address for sandbox %s(%s)", sb.Name(), sb.ID())
- }
-
- if err = s.hostportManager.Add(sb.ID(), &hostport.PodPortMapping{
- Name: sb.Name(),
- PortMappings: sb.PortMappings(),
- IP: ip4,
- HostNetwork: false,
- }, "lo"); err != nil {
- return "", fmt.Errorf("failed to add hostport mapping for sandbox %s(%s): %v", sb.Name(), sb.ID(), err)
- }
-
- }
- return ip, nil
-}
-
-// networkStop cleans up and removes a pod's network. It is best-effort and
-// must call the network plugin even if the network namespace is already gone
-func (s *Server) networkStop(hostNetwork bool, sb *sandbox.Sandbox) error {
- if !hostNetwork {
- if err := s.hostportManager.Remove(sb.ID(), &hostport.PodPortMapping{
- Name: sb.Name(),
- PortMappings: sb.PortMappings(),
- HostNetwork: false,
- }); err != nil {
- logrus.Warnf("failed to remove hostport for pod sandbox %s(%s): %v",
- sb.Name(), sb.ID(), err)
- }
-
- podNetwork := newPodNetwork(sb)
- if err := s.netPlugin.TearDownPod(podNetwork); err != nil {
- logrus.Warnf("failed to destroy network for pod sandbox %s(%s): %v",
- sb.Name(), sb.ID(), err)
- }
- }
-
- return nil
-}