// getOvsPortName returns OVS port name depending on if we use Veth pairs
// For infra nw, dont use Veth pair
348263
func getOvsPortName(intfName string, skipVethPair bool) string {
	var ovsPortName string

	if useVethPair && !skipVethPair {
		ovsPortName = strings.Replace(intfName, "port", "vport", 1)
	} else {
		ovsPortName = intfName
	}

	return ovsPortName
}
870425
func getPortContext(r *rest.Request) (string, string, string, error) {
	glog.V(1).Infof("in getPortContext()")

	serviceID, err := url.QueryUnescape(r.PathParam("serviceId"))
	if err != nil {
		glog.Errorf("Failed getting serviceID: %v", err)
		return "", "", "", err
	}

	application, err := url.QueryUnescape(r.PathParam("application"))
	if err != nil {
		glog.Errorf("Failed getting application: %v", err)
		return "", "", "", err
	}

	// Validate the port number
	portName, err := url.QueryUnescape(r.PathParam("portname"))
	if err != nil {
		err := fmt.Errorf("Failed getting port name for service (%s): %v", serviceID, err)
		return "", "", "", err
	}

	// Validate the port number
	_, err = strconv.Atoi(strings.Split(portName, ":")[1])
	if err != nil {
		err := fmt.Errorf("Port must be a number between 1 and 65536")
		return "", "", "", err
	}

	return serviceID, application, portName, nil
}
713185
func NameFromEnv() string {
	n := os.Getenv(EnvName)
	if n == "" {
		return os.Getenv("HOSTNAME")
	}
	return n
}
682480
func (service *VboxPortType) IHostgetDomainName(request *IHostgetDomainName) (*IHostgetDomainNameResponse, error) {
	response := new(IHostgetDomainNameResponse)
	err := service.client.Call("", request, response)
	if err != nil {
		return nil, err
	}

	return response, nil
}
320048
func (_class SDNControllerClass) GetPort(sessionID SessionRef, self SDNControllerRef) (_retval int, _err error) {
	_method := "SDN_controller.get_port"
	_sessionIDArg, _err := convertSessionRefToXen(fmt.Sprintf("%s(%s)", _method, "session_id"), sessionID)
	if _err != nil {
		return
	}
	_selfArg, _err := convertSDNControllerRefToXen(fmt.Sprintf("%s(%s)", _method, "self"), self)
	if _err != nil {
		return
	}
	_result, _err := _class.client.APICall(_method, _sessionIDArg, _selfArg)
	if _err != nil {
		return
	}
	_retval, _err = convertIntToGo(_method + " -> ", _result.Value)
	return
}
460674
func (n *Mounter) GetDeviceNameFromMount(mountPath, pluginMountDir string) (string, error) {
	return mount.GetDeviceNameFromMountLinux(n, mountPath, pluginMountDir)
}
337638
func (s *Server) GetPortHTTP() string {
	hostPort := s.HostPortHTTP
	hostPortSplit := strings.Split(hostPort, ":")
	port := hostPortSplit[len(hostPortSplit)-1]
	return port
}
115143
func (vrsConnection VRSConnection) GetPortState(name string) (map[port.StateKey]interface{}, error) {

	readRowArgs := ovsdb.ReadRowArgs{
		Columns: []string{ovsdb.NuagePortTableColumnIPAddress, ovsdb.NuagePortTableColumnSubnetMask,
			ovsdb.NuagePortTableColumnGateway, ovsdb.NuagePortTableColumnEVPNID,
			ovsdb.NuagePortTableColumnVRFId},
		Condition: []string{ovsdb.NuagePortTableColumnName, "==", name},
	}

	var row map[string]interface{}
	var err error
	if row, err = vrsConnection.portTable.ReadRow(vrsConnection.ovsdbClient, readRowArgs); err != nil {
		return make(map[port.StateKey]interface{}), fmt.Errorf("Unable to obtain the port row %v", err)
	}

	portState := make(map[port.StateKey]interface{})
	portState[port.StateKeyIPAddress] = row[ovsdb.NuagePortTableColumnIPAddress]
	portState[port.StateKeySubnetMask] = row[ovsdb.NuagePortTableColumnSubnetMask]
	portState[port.StateKeyGateway] = row[ovsdb.NuagePortTableColumnGateway]
	portState[port.StateKeyVrfID] = row[ovsdb.NuagePortTableColumnVRFId]
	portState[port.StateKeyEvpnID] = row[ovsdb.NuagePortTableColumnEVPNID]

	return portState, nil
}
767535
func (o *VSC) MonitoringPorts(info *bambou.FetchingInfo) (MonitoringPortsList, *bambou.Error) {

	var list MonitoringPortsList
	err := bambou.CurrentSession().FetchChildren(o, MonitoringPortIdentity, &list, info)
	return list, err
}
553340
func GetPortFromKubeConfig(filename, machineName string) (int, error) {
	con, err := ReadConfigOrNew(filename)
	if err != nil {
		return 0, errors.Wrap(err, "Error getting kubeconfig status")
	}
	cluster, ok := con.Clusters[machineName]
	if !ok {
		return 0, errors.Errorf("Kubeconfig does not have a record of the machine cluster")
	}
	kurl, err := url.Parse(cluster.Server)
	if err != nil {
		return APIServerPort, nil
	}
	_, kport, err := net.SplitHostPort(kurl.Host)
	if err != nil {
		return APIServerPort, nil
	}
	port, err := strconv.Atoi(kport)
	return port, err
}
1207087
func (b *GenericAccessDriver) GetDeviceName() string {
	c, _ := b.adaptor().ReadCharacteristic("2a00")
	buf := bytes.NewBuffer(c)
	val := buf.String()
	return val
}
424561
func (service *VboxPortType) IHostVideoInputDevicegetAlias(request *IHostVideoInputDevicegetAlias) (*IHostVideoInputDevicegetAliasResponse, error) {
	response := new(IHostVideoInputDevicegetAliasResponse)
	err := service.client.Call("", request, response)
	if err != nil {
		return nil, err
	}

	return response, nil
}
855555
func (c *Connect) GetHostname() (string, error) {
	var err C.virError
	str := C.virConnectGetHostnameWrapper(c.ptr, &err)
	if str == nil {
		return "", makeError(&err)
	}
	hostname := C.GoString(str)
	C.free(unsafe.Pointer(str))
	return hostname, nil
}
1013524
func (s *Server) getPortForward(req *pb.PortForwardRequest) (*pb.PortForwardResponse, error) {
	return s.stream.streamServer.GetPortForward(req)
}
498141
func (service *VboxPortType) IUSBDeviceFiltergetName(request *IUSBDeviceFiltergetName) (*IUSBDeviceFiltergetNameResponse, error) {
	response := new(IUSBDeviceFiltergetNameResponse)
	err := service.client.Call("", request, response)
	if err != nil {
		return nil, err
	}

	return response, nil
}
1355826
func (s *DomainSnapshot) GetName() (string, error) {
	var err C.virError
	name := C.virDomainSnapshotGetNameWrapper(s.ptr, &err)
	if name == nil {
		return "", makeError(&err)
	}
	return C.GoString(name), nil
}
2396
func getFreePort(host string, ports ...int) (int, error) {
	for _, port := range ports {
		c, err := net.Listen("tcp", fmt.Sprintf("%s:%d", host, port))
		if err == nil {
			c.Close()
			return port, nil
		}
	}

	c, err := net.Listen("tcp", host+":0")
	if err != nil {
		return 0, err
	}
	addr := c.Addr().(*net.TCPAddr)
	c.Close()
	return addr.Port, nil
}