aboutsummaryrefslogtreecommitdiff
path: root/libpod/boltdb_state.go
diff options
context:
space:
mode:
Diffstat (limited to 'libpod/boltdb_state.go')
-rw-r--r--libpod/boltdb_state.go151
1 files changed, 1 insertions, 150 deletions
diff --git a/libpod/boltdb_state.go b/libpod/boltdb_state.go
index d322ccc53..9669cf921 100644
--- a/libpod/boltdb_state.go
+++ b/libpod/boltdb_state.go
@@ -1063,7 +1063,7 @@ func (s *BoltState) GetNetworks(ctr *Container) (map[string]types.PerNetworkOpti
return errors.Wrapf(err, "error creating networks bucket for container %s", ctr.ID())
}
// the container has no networks in the db lookup config and write to the db
- networkList = ctr.config.Networks
+ networkList = ctr.config.NetworksDeprecated
// if there are no networks we have to add the default
if len(networkList) == 0 {
networkList = []string{ctr.runtime.config.Network.DefaultNetwork}
@@ -1146,155 +1146,6 @@ func (s *BoltState) GetNetworks(ctr *Container) (map[string]types.PerNetworkOpti
return networks, nil
}
-// GetNetworkAliases retrieves the network aliases for the given container in
-// the given CNI network.
-func (s *BoltState) GetNetworkAliases(ctr *Container, network string) ([]string, error) {
- if !s.valid {
- return nil, define.ErrDBClosed
- }
-
- if !ctr.valid {
- return nil, define.ErrCtrRemoved
- }
-
- if network == "" {
- return nil, errors.Wrapf(define.ErrInvalidArg, "network names must not be empty")
- }
-
- if s.namespace != "" && s.namespace != ctr.config.Namespace {
- return nil, errors.Wrapf(define.ErrNSMismatch, "container %s is in namespace %q, does not match our namespace %q", ctr.ID(), ctr.config.Namespace, s.namespace)
- }
-
- ctrID := []byte(ctr.ID())
-
- db, err := s.getDBCon()
- if err != nil {
- return nil, err
- }
- defer s.deferredCloseDBCon(db)
-
- aliases := []string{}
-
- err = db.View(func(tx *bolt.Tx) error {
- ctrBucket, err := getCtrBucket(tx)
- if err != nil {
- return err
- }
-
- dbCtr := ctrBucket.Bucket(ctrID)
- if dbCtr == nil {
- ctr.valid = false
- return errors.Wrapf(define.ErrNoSuchCtr, "container %s does not exist in database", ctr.ID())
- }
-
- ctrNetworkBkt := dbCtr.Bucket(networksBkt)
- if ctrNetworkBkt == nil {
- // No networks joined, so no aliases
- return nil
- }
-
- inNetwork := ctrNetworkBkt.Get([]byte(network))
- if inNetwork == nil {
- return errors.Wrapf(define.ErrNoAliases, "container %s is not part of network %s, no aliases found", ctr.ID(), network)
- }
-
- ctrAliasesBkt := dbCtr.Bucket(aliasesBkt)
- if ctrAliasesBkt == nil {
- // No aliases
- return nil
- }
-
- netAliasesBkt := ctrAliasesBkt.Bucket([]byte(network))
- if netAliasesBkt == nil {
- // No aliases for this specific network.
- return nil
- }
-
- return netAliasesBkt.ForEach(func(alias, v []byte) error {
- aliases = append(aliases, string(alias))
- return nil
- })
- })
- if err != nil {
- return nil, err
- }
-
- return aliases, nil
-}
-
-// GetAllNetworkAliases retrieves the network aliases for the given container in
-// all CNI networks.
-func (s *BoltState) GetAllNetworkAliases(ctr *Container) (map[string][]string, error) {
- if !s.valid {
- return nil, define.ErrDBClosed
- }
-
- if !ctr.valid {
- return nil, define.ErrCtrRemoved
- }
-
- if s.namespace != "" && s.namespace != ctr.config.Namespace {
- return nil, errors.Wrapf(define.ErrNSMismatch, "container %s is in namespace %q, does not match our namespace %q", ctr.ID(), ctr.config.Namespace, s.namespace)
- }
-
- ctrID := []byte(ctr.ID())
-
- db, err := s.getDBCon()
- if err != nil {
- return nil, err
- }
- defer s.deferredCloseDBCon(db)
-
- aliases := make(map[string][]string)
-
- err = db.View(func(tx *bolt.Tx) error {
- ctrBucket, err := getCtrBucket(tx)
- if err != nil {
- return err
- }
-
- dbCtr := ctrBucket.Bucket(ctrID)
- if dbCtr == nil {
- ctr.valid = false
- return errors.Wrapf(define.ErrNoSuchCtr, "container %s does not exist in database", ctr.ID())
- }
-
- ctrAliasesBkt := dbCtr.Bucket(aliasesBkt)
- if ctrAliasesBkt == nil {
- // No aliases present
- return nil
- }
-
- ctrNetworkBkt := dbCtr.Bucket(networksBkt)
- if ctrNetworkBkt == nil {
- // No networks joined, so no aliases
- return nil
- }
-
- return ctrNetworkBkt.ForEach(func(network, v []byte) error {
- netAliasesBkt := ctrAliasesBkt.Bucket(network)
- if netAliasesBkt == nil {
- return nil
- }
-
- netAliases := []string{}
-
- _ = netAliasesBkt.ForEach(func(alias, v []byte) error {
- netAliases = append(netAliases, string(alias))
- return nil
- })
-
- aliases[string(network)] = netAliases
- return nil
- })
- })
- if err != nil {
- return nil, err
- }
-
- return aliases, nil
-}
-
// NetworkConnect adds the given container to the given network. If aliases are
// specified, those will be added to the given network.
func (s *BoltState) NetworkConnect(ctr *Container, network string, opts types.PerNetworkOptions) error {