// ResetNetwork resets all properties of a network to its initial (empty) state
1728
func (s *Server) ResetNetwork(w http.ResponseWriter, req *http.Request) {
	s.network.Reset()

	w.WriteHeader(http.StatusOK)
}
1002927
func CreateNetwork(obj *Network) error {
	// Validate parameters
	err := ValidateNetwork(obj)
	if err != nil {
		log.Errorf("ValidateNetwork retruned error for: %+v. Err: %v", obj, err)
		return err
	}

	// Check if we handle this object
	if objCallbackHandler.NetworkCb == nil {
		log.Errorf("No callback registered for network object")
		return errors.New("Invalid object type")
	}

	saveObj := obj

	collections.networkMutex.Lock()
	key := collections.networks[obj.Key]
	collections.networkMutex.Unlock()

	// Check if object already exists
	if key != nil {
		// Perform Update callback
		err = objCallbackHandler.NetworkCb.NetworkUpdate(collections.networks[obj.Key], obj)
		if err != nil {
			log.Errorf("NetworkUpdate retruned error for: %+v. Err: %v", obj, err)
			return err
		}

		// save the original object after update
		collections.networkMutex.Lock()
		saveObj = collections.networks[obj.Key]
		collections.networkMutex.Unlock()
	} else {
		// save it in cache
		collections.networkMutex.Lock()
		collections.networks[obj.Key] = obj
		collections.networkMutex.Unlock()

		// Perform Create callback
		err = objCallbackHandler.NetworkCb.NetworkCreate(obj)
		if err != nil {
			log.Errorf("NetworkCreate retruned error for: %+v. Err: %v", obj, err)
			collections.networkMutex.Lock()
			delete(collections.networks, obj.Key)
			collections.networkMutex.Unlock()
			return err
		}
	}

	// Write it to modeldb
	collections.networkMutex.Lock()
	err = saveObj.Write()
	collections.networkMutex.Unlock()
	if err != nil {
		log.Errorf("Error saving network %s to db. Err: %v", saveObj.Key, err)
		return err
	}

	return nil
}
563455
func Reset() {
	var d net.Dialer
	OverrideDial(d.DialContext)
	OverrideResolve(net.ResolveTCPAddr)
	OverrideListenUDP(func(network string, laddr *net.UDPAddr) (net.PacketConn, error) {
		return net.ListenUDP(network, laddr)
	})
	OverrideDialUDP(func(network string, laddr, raddr *net.UDPAddr) (net.PacketConn, error) {
		return net.DialUDP(network, laddr, raddr)
	})
}
211606
func (d *OvsDriver) DeleteNetwork(id, subnet, nwType, encap string, pktTag, extPktTag int, gateway string, tenant string) error {
	log.Infof("delete net %s, nwType %s, encap %s, tags: %d/%d", id, nwType, encap, pktTag, extPktTag)

	// Find the switch based on network type
	var sw *OvsSwitch
	if encap == "vxlan" {
		sw = d.switchDb["vxlan"]
	} else {
		sw = d.switchDb["vlan"]
	}

	// Delete infra nw endpoint if present
	if nwType == "infra" {
		hostName, _ := os.Hostname()
		epID := id + "-" + hostName

		epOper := drivers.OperEndpointState{}
		epOper.StateDriver = d.oper.StateDriver
		err := epOper.Read(epID)
		if err == nil {
			err = sw.DeletePort(&epOper, true)
			if err != nil {
				log.Errorf("Error deleting endpoint: %+v. Err: %v", epOper, err)
			}
			epOper.Clear()
		}
	}

	return sw.DeleteNetwork(uint16(pktTag), uint32(extPktTag), gateway, tenant)
}
592920
func (r *configs) Reset() {
	r.mu.Lock()
	defer r.mu.Unlock()
	r.m = make(map[string]*api.Config)
}
1180182
func (c *client) ResetConfiguration(ctx context.Context, throttlerName string) ([]string, error) {
	response, err := c.gRPCClient.ResetConfiguration(ctx, &throttlerdatapb.ResetConfigurationRequest{
		ThrottlerName: throttlerName,
	})
	if err != nil {
		return nil, vterrors.FromGRPC(err)
	}
	return response.Names, nil
}
1114643
func (p *NetPlugin) Reinit(cfg Config) {
	var err error

	p.Lock()
	defer p.Unlock()
	if p.NetworkDriver != nil {
		logrus.Infof("Reinit de-initializing NetworkDriver")
		p.NetworkDriver.Deinit()
		p.NetworkDriver = nil
	}

	cfg.Instance.StateDriver, _ = utils.GetStateDriver()
	p.NetworkDriver, err = utils.NewNetworkDriver(cfg.Drivers.Network, &cfg.Instance)
	logrus.Infof("Reinit Initializing NetworkDriver")

	if err != nil {
		logrus.Errorf("Reinit De-initializing due to error: %v", err)
		p.NetworkDriver.Deinit()
	}
}
108508
func (n *builderNode) reset() {
	n.final = false
	n.finalOutput = 0
	for i := range n.trans {
		n.trans[i] = emptyTransition
	}
	n.trans = n.trans[:0]
	n.next = nil
}
50820
func (s *DvbNitSettings) SetNetworkName(v string) *DvbNitSettings {
	s.NetworkName = &v
	return s
}
1182757
func (s *Service) Reset([]byte) ([]byte, error) {
	s.SendGuestInfo() // Send the IP info ASAP

	return []byte("ATR " + s.name), nil
}
1216290
func (c *Client) CreateNetwork(p *CreateNetworkParameter) (*Network, error) {
	obj, err := c.Request("createNetwork", convertParamToMap(p))
	if err != nil {
		return nil, err
	}
	return obj.(*Network), err
}
427062
func (r *Application) SetNetwork(name string, mode PodNetworkMode) *Application {
	if r.Networks == nil {
		r.EmptyNetworks()
	}

	network := PodNetwork{Name: name, Mode: mode}
	networks := *r.Networks
	networks = append(networks, network)
	r.Networks = &networks
	return r
}
603755
func (c *Cluster) RemoveNetwork(input string) error {
	return c.lockedManagerAction(func(ctx context.Context, state nodeState) error {
		network, err := getNetwork(ctx, state.controlClient, input)
		if err != nil {
			return err
		}

		_, err = state.controlClient.RemoveNetwork(ctx, &swarmapi.RemoveNetworkRequest{NetworkID: network.ID})
		return err
	})
}
1269537
func Reset(c *gc.C) {
	logger.Infof("reset model")
	dummy.mu.Lock()
	dummy.ops = discardOperations
	oldState := dummy.state
	dummy.controllerState = nil
	dummy.state = make(map[string]*environState)
	dummy.newStatePolicy = stateenvirons.GetNewPolicyFunc()
	dummy.supportsSpaces = true
	dummy.supportsSpaceDiscovery = false
	dummy.mu.Unlock()

	// NOTE(axw) we must destroy the old states without holding
	// the provider lock, or we risk deadlocking. Destroying
	// state involves closing the embedded API server, which
	// may require waiting on RPC calls that interact with the
	// EnvironProvider (e.g. EnvironProvider.Open).
	for _, s := range oldState {
		if s.httpServer != nil {
			logger.Debugf("closing httpServer")
			s.httpServer.Close()
		}
		s.destroy()
	}
	if mongoAlive() {
		err := retry.Call(retry.CallArgs{
			Func: gitjujutesting.MgoServer.Reset,
			// Only interested in retrying the intermittent
			// 'unexpected message'.
			IsFatalError: func(err error) bool {
				return !strings.HasSuffix(err.Error(), "unexpected message")
			},
			Delay:    time.Millisecond,
			Clock:    clock.WallClock,
			Attempts: 5,
		})
		c.Assert(err, jc.ErrorIsNil)
	}
}
841363
func (s *NetworkService) DeleteNetwork(p *DeleteNetworkParams) (*DeleteNetworkResponse, error) {
	resp, err := s.cs.newRequest("deleteNetwork", p.toURLValues())
	if err != nil {
		return nil, err
	}

	var r DeleteNetworkResponse
	if err := json.Unmarshal(resp, &r); err != nil {
		return nil, err
	}

	// If we have a async client, we need to wait for the async result
	if s.cs.async {
		b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout)
		if err != nil {
			if err == AsyncTimeoutErr {
				return &r, err
			}
			return nil, err
		}

		if err := json.Unmarshal(b, &r); err != nil {
			return nil, err
		}
	}

	return &r, nil
}
1094718
func (p *NetPlugin) DeleteNetwork(id, subnet, nwType, encap string, pktTag, extPktTag int, Gw string, tenant string) error {
	p.Lock()
	defer p.Unlock()
	return p.NetworkDriver.DeleteNetwork(id, subnet, nwType, encap, pktTag, extPktTag, Gw, tenant)
}
512786
func (daemon *Daemon) updateNetwork(container *container.Container) error {
	var (
		start = time.Now()
		ctrl  = daemon.netController
		sid   = container.NetworkSettings.SandboxID
	)

	sb, err := ctrl.SandboxByID(sid)
	if err != nil {
		return fmt.Errorf("error locating sandbox id %s: %v", sid, err)
	}

	// Find if container is connected to the default bridge network
	var n libnetwork.Network
	for name, v := range container.NetworkSettings.Networks {
		sn, err := daemon.FindNetwork(getNetworkID(name, v.EndpointSettings))
		if err != nil {
			continue
		}
		if sn.Name() == runconfig.DefaultDaemonNetworkMode().NetworkName() {
			n = sn
			break
		}
	}

	if n == nil {
		// Not connected to the default bridge network; Nothing to do
		return nil
	}

	options, err := daemon.buildSandboxOptions(container)
	if err != nil {
		return fmt.Errorf("Update network failed: %v", err)
	}

	if err := sb.Refresh(options...); err != nil {
		return fmt.Errorf("Update network failed: Failure in refresh sandbox %s: %v", sid, err)
	}

	networkActions.WithValues("update").UpdateSince(start)

	return nil
}