// AddVserverEntry adds an VserverEntry to a Vserver.
489923
func (v *Vserver) AddVserverEntry(e *VserverEntry) error {
	key := e.Key()
	if _, ok := v.Entries[key]; ok {
		return fmt.Errorf("Vserver %q already contains VserverEntry %q", v.Name, key)
	}
	v.Entries[key] = e
	return nil
}
114494
func (f *Facade) AddPublicEndpointVHost(ctx datastore.Context, serviceid, endpointName, vhostName string, isEnabled, restart bool) (*servicedefinition.VHost, error) {
	defer ctx.Metrics().Stop(ctx.Metrics().Start("Facade.AddPublicEndpointVHost"))
	alog := f.auditLogger.Message(ctx, "Adding Public Endpoint VHost").Action(audit.Update).ID(serviceid).
		WithFields(logrus.Fields{
			"endpointname": endpointName,
			"vhostname":    vhostName,
			"isenabled":    isEnabled,
		})
	// Get the service for this service id.
	svc, err := f.GetService(ctx, serviceid)
	if err != nil {
		err = fmt.Errorf("Could not find service %s: %s", serviceid, err)
		glog.Error(err)
		return nil, alog.Error(err)
	}
	alog = alog.Entity(svc)

	// Make sure the name doesn't contain invalid characters.
	if !vhostNameRegex.MatchString(vhostName) {
		err = fmt.Errorf("Invalid virtual host name: %s", vhostName)
		glog.Error(err)
		return nil, alog.Error(err)
	}

	// check other virtual hosts for redundancy
	vhostLowerName := strings.ToLower(vhostName)

	// FIXME: GetAllServices is really expensive. Can this be replaced
	//        with a more targeted method like get-all-services with vhost "blah"?
	services, err := f.GetAllServices(ctx)
	if err != nil {
		err = fmt.Errorf("Could not get the list of services: %s", err)
		glog.Error(err)
		return nil, alog.Error(err)
	}

	for _, otherService := range services {
		if otherService.Endpoints == nil {
			continue
		}
		for _, endpoint := range otherService.Endpoints {
			for _, vhost := range endpoint.VHostList {
				if strings.ToLower(vhost.Name) == vhostLowerName {
					err := fmt.Errorf("vhost %s already defined for service: %s", vhostName, otherService.Name)
					glog.Error(err)
					return nil, alog.Error(err)
				}
			}
		}
	}

	vhost, err := svc.AddVirtualHost(endpointName, vhostName, isEnabled)
	if err != nil {
		err := fmt.Errorf("Error adding vhost (%s) to service (%s): %v", vhostName, svc.Name, err)
		glog.Error(err)
		return nil, alog.Error(err)
	}

	// Make sure no other service currently has zzk data for this vhost -- this would result
	// in the service getting turned off during restart but not being able to start again.
	if err := f.validateServiceStart(ctx, svc); err != nil {
		// We don't call UpdateService() service here; effectively unwinding the svc.AddVirtualHost() call above.
		glog.Error(err)
		return nil, alog.Error(err)
	}

	glog.V(2).Infof("Added vhost public endpoint %s to service %s", vhost.Name, svc.Name)

	if err = f.UpdateService(ctx, *svc); err != nil {
		glog.Error(err)
		return nil, alog.Error(err)
	}

	glog.V(2).Infof("Service (%s) updated", svc.Name)
	alog.Succeeded()
	return vhost, nil
}
747383
func (gs *GRPCClient) AddServer(sv *Server) {
	var host, port, portKey string
	var ok bool

	host, portKey = gs.getServerHost(sv)
	if host == "" {
		logger.Log.Errorf("server %s has no grpcHost specified in metadata", sv.ID)
		return
	}

	if port, ok = sv.Metadata[portKey]; !ok {
		logger.Log.Errorf("server %s has no %s specified in metadata", sv.ID, portKey)
		return
	}

	address := fmt.Sprintf("%s:%s", host, port)
	conn, err := grpc.Dial(address, grpc.WithInsecure())
	if err != nil {
		logger.Log.Errorf("unable to connect to server %s at %s: %v", sv.ID, address, err)
		return
	}
	c := protos.NewPitayaClient(conn)
	gs.clientMap.Store(sv.ID, c)
	logger.Log.Debugf("[grpc client] added server %s at %s", sv.ID, address)
}
839417
func (c *Client) AddPublicEndpointVHost(serviceid, endpointName, vhost string, isEnabled,
	restart bool) (*servicedefinition.VHost, error) {
	request := &PublicEndpointRequest{
		Serviceid:    serviceid,
		EndpointName: endpointName,
		Name:         vhost,
		IsEnabled:    isEnabled,
		Restart:      restart,
	}
	var result servicedefinition.VHost
	err := c.call("AddPublicEndpointVHost", request, &result)
	return &result, err
}
509391
func (srv *Server) AddHostKey(key Signer) {
	// these are later added via AddHostKey on ServerConfig, which performs the
	// check for one of every algorithm.
	srv.HostSigners = append(srv.HostSigners, key)
}
198351
func (d *OvsDriver) AddPeerHost(node core.ServiceInfo) error {
	// Nothing to do if this is our own IP
	if node.HostAddr == d.localIP {
		return nil
	}

	log.Infof("CreatePeerHost for %+v", node)

	// Add the VTEP for the peer in vxlan switch.
	err := d.switchDb["vxlan"].CreateVtep(node.HostAddr)
	if err != nil {
		log.Errorf("Error adding the VTEP %s. Err: %s", node.HostAddr, err)
		return err
	}

	return nil
}
610596
func (c *Gcd) AddEnvironmentVars(vars []string) {
	c.env = append(c.env, vars...)
}
1285856
func (c *Cluster) AddVserver(vserver *Vserver) error {
	key := vserver.Key()
	if _, ok := c.Vservers[key]; ok {
		return fmt.Errorf("Cluster %q already contains Vserver %q", c.Site, key)
	}
	c.Vservers[key] = vserver
	return nil
}
18235
func (c *Client) AddVirtualIP(requestVirtualIP pool.VirtualIP) error {
	return c.call("AddVirtualIP", requestVirtualIP, nil)
}
506283
func (u *FakeVolumeUtil) AddNewDirEntries(mountDir string, dirFiles map[string][]*FakeDirEntry) {
	for dir, files := range dirFiles {
		mountedPath := filepath.Join(mountDir, dir)
		curFiles := u.directoryFiles[mountedPath]
		if curFiles == nil {
			curFiles = []*FakeDirEntry{}
		}
		glog.Infof("Adding to directory %q: files %v\n", dir, files)
		u.directoryFiles[mountedPath] = append(curFiles, files...)
	}
}
83732
func (sw *OvsSwitch) AddHostPort(intfName string, intfNum, network int, isHostNS bool) (string, error) {
	var err error

	// some error checking
	if sw.netType != "vxlan" {
		log.Fatalf("Can not add host port to OVS type %s.", sw.netType)
	}

	ovsPortType := ""
	ovsPortName := getOvsPortName(intfName, isHostNS)
	if isHostNS {
		ovsPortType = "internal"
	} else {
		log.Infof("Host port in container name space -- ignore")
		return "", nil
	}

	portID := "host" + intfName

	// If the port already exists in OVS, remove it first
	if sw.ovsdbDriver.IsPortNamePresent(ovsPortName) {
		log.Infof("Removing existing interface entry %s from OVS", ovsPortName)

		// Delete it from ovsdb
		err := sw.ovsdbDriver.DeletePort(ovsPortName)
		if err != nil {
			log.Errorf("Error deleting port %s from OVS. Err: %v", ovsPortName, err)
		}
	}

	// Ask OVSDB driver to add the port as an access port
	err = sw.ovsdbDriver.CreatePort(ovsPortName, ovsPortType, portID, hostVLAN, 0, 0)
	if err != nil {
		log.Errorf("Error adding hostport %s to OVS. Err: %v", intfName, err)
		return "", err
	}

	// Get the openflow port number for the interface
	ofpPort, err := sw.ovsdbDriver.GetOfpPortNo(ovsPortName)
	if err != nil {
		log.Errorf("Could not find the OVS port %s. Err: %v", intfName, err)
		return "", err
	}

	// Assign an IP based on the intfnumber
	ipStr, macStr := netutils.PortToHostIPMAC(intfNum, network)
	mac, _ := net.ParseMAC(macStr)

	portInfo := ofnet.HostPortInfo{
		PortNo:  ofpPort,
		MacAddr: mac,
		IpAddr:  ipStr,
		Kind:    "NAT",
	}
	// Add to ofnet if this is the hostNS port.
	netutils.SetInterfaceMac(intfName, macStr)
	netutils.SetInterfaceIP(intfName, ipStr)
	err = setLinkUp(intfName)

	if sw.ofnetAgent != nil {
		err = sw.ofnetAgent.AddHostPort(portInfo)
		if err != nil {
			log.Errorf("Error adding host port %s. Err: %v", intfName, err)
			return "", err
		}
	}

	log.Infof("Added host port %s to OVS switch %s.", intfName, sw.bridgeName)

	defer func() {
		if err != nil {
			sw.ovsdbDriver.DeletePort(intfName)
		}
	}()

	return ipStr, nil
}
473836
func (g *GSLB) AddGSLBServer(server *GSLBServer) {
	var isExist = false
	for i := range g.Settings.GSLB.Servers {
		if g.Settings.GSLB.Servers[i].IPAddress == server.IPAddress {
			g.Settings.GSLB.Servers[i].Enabled = server.Enabled
			g.Settings.GSLB.Servers[i].Weight = server.Weight
			isExist = true
		}
	}

	if !isExist {
		g.Settings.GSLB.Servers = append(g.Settings.GSLB.Servers, *server)
	}
}
52407
func (v *Vserver) AddBackend(backend *seesaw.Backend) error {
	key := backend.Key()
	if _, ok := v.Backends[key]; ok {
		return fmt.Errorf("Vserver %q already contains Backend %q", v.Name, key)
	}
	v.Backends[key] = backend
	return nil
}
395923
func AddService(svc *Service) error {
	if defaultDevice == nil {
		return ErrDefaultDevice
	}
	return defaultDevice.AddService(svc)
}
737516
func (g *Graph) AddPV(pv *corev1.PersistentVolume) {
	g.lock.Lock()
	defer g.lock.Unlock()

	// clear existing edges
	g.deleteVertex_locked(pvVertexType, "", pv.Name)

	// if we have a pvc, establish new edges
	if pv.Spec.ClaimRef != nil {
		pvVertex := g.getOrCreateVertex_locked(pvVertexType, "", pv.Name)

		// since we don't know the other end of the pvc -> pod -> node chain (or it may not even exist yet), we can't decorate these edges with kubernetes node info
		g.graph.SetEdge(simple.Edge{F: pvVertex, T: g.getOrCreateVertex_locked(pvcVertexType, pv.Spec.ClaimRef.Namespace, pv.Spec.ClaimRef.Name)})
		pvutil.VisitPVSecretNames(pv, func(namespace, secret string, kubeletVisible bool) bool {
			// This grants access to the named secret in the same namespace as the bound PVC
			if kubeletVisible {
				g.graph.SetEdge(simple.Edge{F: g.getOrCreateVertex_locked(secretVertexType, namespace, secret), T: pvVertex})
			}
			return true
		})
	}
}
527457
func vserverEnabled(config *config.Vserver, os seesaw.OverrideState) bool {
	switch {
	case config == nil:
		return false
	case os == seesaw.OverrideDisable:
		return false
	case os == seesaw.OverrideEnable:
		return true
	}
	return config.Enabled
}
721279
func (runner *runner) AddRealServer(vs *VirtualServer, rs *RealServer) error {
	svc, err := toIPVSService(vs)
	if err != nil {
		return err
	}
	dst, err := toIPVSDestination(rs)
	if err != nil {
		return err
	}
	runner.mu.Lock()
	defer runner.mu.Unlock()
	return runner.ipvsHandle.NewDestination(svc, dst)
}