// ConnParamsWithUname returns  ConnParams to connect to the DB with the Uname set to the provided value.
544345
func (db *DB) ConnParamsWithUname(uname string) *mysql.ConnParams {
	return &mysql.ConnParams{
		UnixSocket: db.socketFile,
		Uname:      uname,
		Pass:       "password1",
		Charset:    "utf8",
	}
}
18439
func (s *BaremetalService) NewAddBaremetalPxePingServerParams(password string, physicalnetworkid string, pingdir string, pingstorageserverip string, pxeservertype string, tftpdir string, url string, username string) *AddBaremetalPxePingServerParams {
	p := &AddBaremetalPxePingServerParams{}
	p.p = make(map[string]interface{})
	p.p["password"] = password
	p.p["physicalnetworkid"] = physicalnetworkid
	p.p["pingdir"] = pingdir
	p.p["pingstorageserverip"] = pingstorageserverip
	p.p["pxeservertype"] = pxeservertype
	p.p["tftpdir"] = tftpdir
	p.p["url"] = url
	p.p["username"] = username
	return p
}
11587
func NewDBConnNoPool(params *mysql.ConnParams, dbaPool *dbconnpool.ConnectionPool) (*DBConn, error) {
	c, err := dbconnpool.NewDBConnection(params, tabletenv.MySQLStats)
	if err != nil {
		return nil, err
	}
	return &DBConn{
		conn:    c,
		info:    params,
		dbaPool: dbaPool,
		pool:    nil,
	}, nil
}
29548
func (dbcfgs *DBConfigs) makeParams(userKey string, withDB bool) *mysql.ConnParams {
	orig := dbcfgs.userConfigs[userKey]
	if orig == nil {
		return &mysql.ConnParams{}
	}
	result := orig.param
	if withDB {
		result.DbName = dbcfgs.DBName.Get()
	}
	return &result
}
290071
func (s *VirtualMachineService) NewAddNicToVirtualMachineParams(networkid string, virtualmachineid string) *AddNicToVirtualMachineParams {
	p := &AddNicToVirtualMachineParams{}
	p.p = make(map[string]interface{})
	p.p["networkid"] = networkid
	p.p["virtualmachineid"] = virtualmachineid
	return p
}
841736
func (c *Network) SetRequestInterceptionWithParams(v *NetworkSetRequestInterceptionParams) (*gcdmessage.ChromeResponse, error) {
	return gcdmessage.SendDefaultRequest(c.target, c.target.GetSendCh(), &gcdmessage.ParamRequest{Id: c.target.GetId(), Method: "Network.setRequestInterception", Params: v})
}
789150
func connectForReplication(cp *mysql.ConnParams) (*mysql.Conn, error) {
	params, err := dbconfigs.WithCredentials(cp)
	if err != nil {
		return nil, err
	}

	ctx := context.Background()
	conn, err := mysql.Connect(ctx, params)
	if err != nil {
		return nil, err
	}

	// Tell the server that we understand the format of events
	// that will be used if binlog_checksum is enabled on the server.
	if _, err := conn.ExecuteFetch("SET @master_binlog_checksum=@@global.binlog_checksum", 0, false); err != nil {
		return nil, fmt.Errorf("failed to set @master_binlog_checksum=@@global.binlog_checksum: %v", err)
	}

	return conn, nil
}
806285
func (s *NiciraNVPService) NewAddNiciraNvpDeviceParams(hostname string, password string, physicalnetworkid string, transportzoneuuid string, username string) *AddNiciraNvpDeviceParams {
	p := &AddNiciraNvpDeviceParams{}
	p.p = make(map[string]interface{})
	p.p["hostname"] = hostname
	p.p["password"] = password
	p.p["physicalnetworkid"] = physicalnetworkid
	p.p["transportzoneuuid"] = transportzoneuuid
	p.p["username"] = username
	return p
}
451458
func paramsToASNECIES(params *ECIESParams) (asnParams asnECIESParameters) {
	if nil == params {
		return
	}
	asnParams.KDF = asnNISTConcatenationKDF
	asnParams.MAC = hmacFull
	switch params.KeyLen {
	case 16:
		asnParams.Sym = aes128CTRinECIES
	case 24:
		asnParams.Sym = aes192CTRinECIES
	case 32:
		asnParams.Sym = aes256CTRinECIES
	}
	return
}
190301
func (s *NetworkService) NewListStorageNetworkIpRangeParams() *ListStorageNetworkIpRangeParams {
	p := &ListStorageNetworkIpRangeParams{}
	p.p = make(map[string]interface{})
	return p
}
153497
func (u *UniterAPI) NetworkInfo(args params.NetworkInfoParams) (params.NetworkInfoResults, error) {
	canAccess, err := u.accessUnit()
	if err != nil {
		return params.NetworkInfoResults{}, err
	}

	unitTag, err := names.ParseUnitTag(args.Unit)
	if err != nil {
		return params.NetworkInfoResults{}, err
	}

	if !canAccess(unitTag) {
		return params.NetworkInfoResults{}, common.ErrPerm
	}

	unit, err := u.getUnit(unitTag)
	if err != nil {
		return params.NetworkInfoResults{}, err
	}

	result := params.NetworkInfoResults{
		Results: make(map[string]params.NetworkInfoResult),
	}

	spaces := set.NewStrings()
	bindingsToSpace := make(map[string]string)
	bindingsToEgressSubnets := make(map[string][]string)
	bindingsToIngressAddresses := make(map[string][]string)

	model, err := u.st.Model()
	if err != nil {
		return params.NetworkInfoResults{}, err
	}
	modelCfg, err := model.ModelConfig()
	if err != nil {
		return params.NetworkInfoResults{}, err
	}
	for _, binding := range args.Bindings {
		if boundSpace, err := unit.GetSpaceForBinding(binding); err != nil {
			result.Results[binding] = params.NetworkInfoResult{Error: common.ServerError(err)}
		} else {
			spaces.Add(boundSpace)
			bindingsToSpace[binding] = boundSpace
		}
		bindingsToEgressSubnets[binding] = modelCfg.EgressSubnets()
	}

	if args.RelationId != nil {
		// We're in a relation context.
		rel, err := u.st.Relation(*args.RelationId)
		if err != nil {
			return params.NetworkInfoResults{}, err
		}
		endpoint, err := rel.Endpoint(unit.ApplicationName())
		if err != nil {
			return params.NetworkInfoResults{}, err
		}
		boundSpace, ingress, egress, err := state.NetworksForRelation(endpoint.Name, unit, rel, modelCfg.EgressSubnets())
		if err != nil {
			return params.NetworkInfoResults{}, err
		}
		spaces.Add(boundSpace)
		if len(egress) > 0 {
			bindingsToEgressSubnets[endpoint.Name] = egress
		}
		bindingsToIngressAddresses[endpoint.Name] = ingress
	}

	var (
		networkInfos            map[string]state.MachineNetworkInfoResult
		defaultIngressAddresses []string
	)

	if unit.ShouldBeAssigned() {
		machineID, err := unit.AssignedMachineId()
		if err != nil {
			return params.NetworkInfoResults{}, err
		}
		machine, err := u.st.Machine(machineID)
		if err != nil {
			return params.NetworkInfoResults{}, err
		}
		networkInfos = machine.GetNetworkInfoForSpaces(spaces)
	} else {
		// For CAAS units, we build up a minimal result struct
		// based on the default space and unit public/private addresses,
		// ie the addresses of the CAAS service.
		addr, err := unit.AllAddresses()
		if err != nil {
			return params.NetworkInfoResults{}, err
		}
		network.SortAddresses(addr)

		// We record the interface addresses as the machine local ones - these
		// are used later as the binding addresses.
		// For CAAS models, we need to default ingress addresses to all available
		// addresses so record those in the default ingress address slice.
		var interfaceAddr []network.InterfaceAddress
		for _, a := range addr {
			if a.Scope == network.ScopeMachineLocal {
				interfaceAddr = append(interfaceAddr, network.InterfaceAddress{Address: a.Value})
			}
			defaultIngressAddresses = append(defaultIngressAddresses, a.Value)
		}
		networkInfos = make(map[string]state.MachineNetworkInfoResult)
		networkInfos[environs.DefaultSpaceName] = state.MachineNetworkInfoResult{
			NetworkInfos: []network.NetworkInfo{{Addresses: interfaceAddr}},
		}
	}

	for binding, space := range bindingsToSpace {
		// The binding address information based on link layer devices.
		info := networkingcommon.MachineNetworkInfoResultToNetworkInfoResult(networkInfos[space])

		// Set egress and ingress address information.
		info.EgressSubnets = bindingsToEgressSubnets[binding]
		info.IngressAddresses = bindingsToIngressAddresses[binding]

		// If there is no ingress address explicitly defined for a given binding,
		// set the ingress addresses to either any defaults set above, or the binding addresses.
		if len(info.IngressAddresses) == 0 {
			for _, addr := range defaultIngressAddresses {
				info.IngressAddresses = append(info.IngressAddresses, addr)
			}
		}
		if len(info.IngressAddresses) == 0 {
			for _, nwInfo := range info.Info {
				for _, addr := range nwInfo.Addresses {
					info.IngressAddresses = append(info.IngressAddresses, addr.Address)
				}
			}
		}

		// If there is no egress subnet explicitly defined for a given binding,
		// default to the first ingress address. This matches the behaviour when
		// there's a relation in place.
		if len(info.EgressSubnets) == 0 && len(info.IngressAddresses) > 0 {
			info.EgressSubnets, err = network.FormatAsCIDR([]string{info.IngressAddresses[0]})
			if err != nil {
				return result, errors.Trace(err)
			}
		}

		result.Results[binding] = info
	}

	return result, nil
}
831791
func (s *NuageVSPService) NewAddNuageVspDeviceParams(hostname string, password string, physicalnetworkid string, port int, username string) *AddNuageVspDeviceParams {
	p := &AddNuageVspDeviceParams{}
	p.p = make(map[string]interface{})
	p.p["hostname"] = hostname
	p.p["password"] = password
	p.p["physicalnetworkid"] = physicalnetworkid
	p.p["port"] = port
	p.p["username"] = username
	return p
}
833342
func (c *Network) SetBypassServiceWorkerWithParams(v *NetworkSetBypassServiceWorkerParams) (*gcdmessage.ChromeResponse, error) {
	return gcdmessage.SendDefaultRequest(c.target, c.target.GetSendCh(), &gcdmessage.ParamRequest{Id: c.target.GetId(), Method: "Network.setBypassServiceWorker", Params: v})
}
281446
func ValidateNetworkRangeParams(ipRange string, subnetLen uint) error {
	rangeMin, _ := ipv4ToUint32(getFirstAddrInRange(ipRange))
	rangeMax, _ := ipv4ToUint32(getLastAddrInRange(ipRange, subnetLen))
	firstAddr, _ := ipv4ToUint32(GetSubnetAddr(ipRange, subnetLen))
	lastAddr, _ := ipv4ToUint32(getLastAddrInSubnet(ipRange, subnetLen))

	if rangeMin < firstAddr || rangeMax > lastAddr || rangeMin > rangeMax {
		return core.Errorf("Network subnet format not valid")
	}

	if subnetLen > 32 || subnetLen < 8 {
		return core.Errorf("subnet length %d not supported", subnetLen)
	}
	return nil
}
617729
func (db *Conn) WithParam(param string, value interface{}) *Conn {
	return newConn(db.ctx, db.baseDB.WithParam(param, value))
}
1101088
func (ctx *context) URLParams() map[string]string {
	values := map[string]string{}

	q := ctx.request.URL.Query()
	if q != nil {
		for k, v := range q {
			values[k] = strings.Join(v, ",")
		}
	}

	return values
}
1046898
func NewConnWith(eng *stats.Engine, c net.Conn) net.Conn {
	nc := &conn{Conn: c, eng: eng}

	proto := c.LocalAddr().Network()
	nc.r.metrics.protocol = proto
	nc.w.metrics.protocol = proto

	eng.Incr("conn.open:count", stats.T("protocol", proto))
	return nc
}