// CreateSocket does nothing
166169
func (s *StdoutClient) CreateSocket() error {
	if s.FD == nil {
		s.FD = os.Stdout
	}
	return nil
}
861597
func (d *Driver) createNetwork() error {
	conn, err := getConnection()
	if err != nil {
		return errors.Wrap(err, "getting libvirt connection")
	}
	defer conn.Close()

	// network: default
	// It is assumed that the libvirt/kvm installation has already created this network

	// network: private

	// Only create the private network if it does not already exist
	if _, err := conn.LookupNetworkByName(d.PrivateNetwork); err != nil {
		// create the XML for the private network from our networkTmpl
		tmpl := template.Must(template.New("network").Parse(networkTmpl))
		var networkXML bytes.Buffer
		if err := tmpl.Execute(&networkXML, d); err != nil {
			return errors.Wrap(err, "executing network template")
		}

		// define the network using our template
		network, err := conn.NetworkDefineXML(networkXML.String())
		if err != nil {
			return errors.Wrapf(err, "defining network from xml: %s", networkXML.String())
		}

		// and finally create it
		if err := network.Create(); err != nil {
			return errors.Wrapf(err, "creating network %s", d.PrivateNetwork)
		}
	}

	return nil
}
746940
func (process *TeleportProcess) createListener(listenerType, address string) (net.Listener, error) {
	listener, err := net.Listen("tcp", address)
	if err != nil {
		return nil, trace.Wrap(err)
	}
	process.Lock()
	defer process.Unlock()
	r := RegisteredListener{Type: listenerType, Address: address, Listener: listener}
	process.registeredListeners = append(process.registeredListeners, r)
	return listener, nil
}
1358585
func (network *HNSNetwork) Create() (*HNSNetwork, error) {
	operation := "Create"
	title := "hcsshim::HNSNetwork::" + operation
	logrus.Debugf(title+" id=%s", network.Id)

	for _, subnet := range network.Subnets {
		if (subnet.AddressPrefix != "") && (subnet.GatewayAddress == "") {
			return nil, errors.New("network create error, subnet has address prefix but no gateway specified")
		}
	}

	jsonString, err := json.Marshal(network)
	if err != nil {
		return nil, err
	}
	return HNSNetworkRequest("POST", "", string(jsonString))
}
670556
func (s *NetworkOfferingService) CreateNetworkOffering(p *CreateNetworkOfferingParams) (*CreateNetworkOfferingResponse, error) {
	resp, err := s.cs.newRequest("createNetworkOffering", p.toURLValues())
	if err != nil {
		return nil, err
	}

	if resp, err = getRawValue(resp); err != nil {
		return nil, err
	}

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

	return &r, nil
}
73143
func newSocket(s *Server) *Socket {
	a := &Socket{
		writeChan: make(chan string, global.WriteChanSize),
		readChan:  make(chan string, global.ReadChanSize),
	}

	// Set the closer function.
	a.closer = closer.New(func() {
		// Remove the ajax socket from the map.
		if len(a.uid) > 0 {
			func() {
				s.socketsMutex.Lock()
				defer s.socketsMutex.Unlock()

				delete(s.sockets, a.uid)
			}()
		}
	})

	return a
}
1016336
func CreateSecureWebSocketServer(address string, config *tls.Config) (*WebSocketServer, error) {
	listener, err := tls.Listen("tcp", address, config)
	if err != nil {
		return nil, err
	}

	return NewWebSocketServer(listener), nil
}
997450
func CreateDockNet(tenantName, networkName, serviceName string, nwCfg *mastercfg.CfgNetworkState) error {
	var nwID string
	var subnetCIDRv6 = ""

	if nwCfg.IPv6Subnet != "" {
		subnetCIDRv6 = fmt.Sprintf("%s/%d", nwCfg.IPv6Subnet, nwCfg.IPv6SubnetLen)
	}

	// Trim default tenant name
	docknetName := GetDocknetName(tenantName, networkName, serviceName)

	// connect to docker
	defaultHeaders := map[string]string{"User-Agent": "Docker-Client/" + dockerversion.Version + " (" + runtime.GOOS + ")"}
	docker, err := dockerclient.NewClient("unix:///var/run/docker.sock", "v1.23", nil, defaultHeaders)
	if err != nil {
		log.Errorf("Unable to connect to docker. Error %v", err)
		return fmt.Errorf("Unable to connect to docker: %s", err.Error())
	}

	// Check if the network already exists
	nw, err := docker.NetworkInspect(context.Background(), docknetName)
	if err == nil && nw.Driver == netDriverName {
		log.Infof("docker network: %s already exists", docknetName)
		nwID = nw.ID
	} else if err == nil && nw.Driver != netDriverName {
		log.Errorf("Network name %s used by another driver %s", docknetName, nw.Driver)
		return errors.New("network name used by another driver")
	} else if err != nil {
		// plugin options to be sent to docker
		netPluginOptions := make(map[string]string)
		netPluginOptions["tenant"] = nwCfg.Tenant
		netPluginOptions["encap"] = nwCfg.PktTagType
		if nwCfg.PktTagType == "vxlan" {
			netPluginOptions["pkt-tag"] = strconv.Itoa(nwCfg.ExtPktTag)
		} else {
			netPluginOptions["pkt-tag"] = strconv.Itoa(nwCfg.PktTag)
		}

		subnetCIDR := fmt.Sprintf("%s/%d", nwCfg.SubnetIP, nwCfg.SubnetLen)

		var ipams []network.IPAMConfig
		var IPAMv4 = network.IPAMConfig{
			Subnet:  subnetCIDR,
			Gateway: nwCfg.Gateway,
		}
		ipams = append(ipams, IPAMv4)
		var IPAMv6 network.IPAMConfig
		if subnetCIDRv6 != "" {
			IPAMv6 = network.IPAMConfig{
				Subnet:  subnetCIDRv6,
				Gateway: nwCfg.IPv6Gateway,
			}
			ipams = append(ipams, IPAMv6)
		}
		ipamOptions := make(map[string]string)
		ipamOptions["tenant"] = nwCfg.Tenant
		ipamOptions["network"] = nwCfg.NetworkName
		if len(serviceName) > 0 {
			ipamOptions["group"] = serviceName
		}

		ipamCfg := network.IPAM{
			Driver:  ipamDriverName,
			Config:  ipams,
			Options: ipamOptions,
		}
		// Build network parameters
		nwCreate := types.NetworkCreate{
			CheckDuplicate: true,
			Driver:         netDriverName,
			IPAM:           &ipamCfg,
			Options:        netPluginOptions,
			Attachable:     true,
			EnableIPv6:     (subnetCIDRv6 != ""),
		}

		log.Infof("Creating docker network: %+v", nwCreate)
		log.Infof("         docker ipam config: %+v", *nwCreate.IPAM)

		// Create network
		resp, err := docker.NetworkCreate(context.Background(), docknetName, nwCreate)
		if err != nil {
			log.Errorf("Error creating network %s. Err: %v", docknetName, err)
			return err
		}

		nwID = resp.ID
	}

	return CreateDockNetState(tenantName, networkName, serviceName, nwID)
}
865086
func (builder *OnBuild) CreateDockerfile(config *api.Config) error {
	buffer := bytes.Buffer{}
	uploadDir := filepath.Join(config.WorkingDir, "upload", "src")
	buffer.WriteString(fmt.Sprintf("FROM %s\n", config.BuilderImage))
	entrypoint, err := GuessEntrypoint(builder.fs, uploadDir)
	if err != nil {
		return err
	}
	env, err := scripts.GetEnvironment(filepath.Join(config.WorkingDir, constants.Source))
	if err != nil {
		glog.V(1).Infof("Environment: %v", err)
	} else {
		buffer.WriteString(scripts.ConvertEnvironmentToDocker(env))
	}
	// If there is an assemble script present, run it as part of the build process
	// as the last thing.
	if builder.hasAssembleScript(config) {
		buffer.WriteString("RUN sh assemble\n")
	}
	// FIXME: This assumes that the WORKDIR is set to the application source root
	//        directory.
	buffer.WriteString(fmt.Sprintf(`ENTRYPOINT ["./%s"]`+"\n", entrypoint))
	return builder.fs.WriteFile(filepath.Join(uploadDir, "Dockerfile"), buffer.Bytes())
}
334560
func (r Network_Interconnect_Tenant) CreateConnection(templateObject *datatypes.Network_Interconnect_Tenant) (resp string, err error) {
	params := []interface{}{
		templateObject,
	}
	err = r.Session.DoRequest("SoftLayer_Network_Interconnect_Tenant", "createConnection", params, &r.Options, &resp)
	return
}
31737
func CreateNetServer(address string) (*NetServer, error) {
	listener, err := net.Listen("tcp", address)
	if err != nil {
		return nil, err
	}

	return NewNetServer(listener), nil
}
635045
func (p *Plugin) GetSocket() string {
	p.mu.RLock()
	defer p.mu.RUnlock()

	return p.PluginObj.Config.Interface.Socket
}
1111080
func (_m *APIClient) NetworkCreate(ctx context.Context, name string, options types.NetworkCreate) (types.NetworkCreateResponse, error) {
	ret := _m.Called(ctx, name, options)

	var r0 types.NetworkCreateResponse
	if rf, ok := ret.Get(0).(func(context.Context, string, types.NetworkCreate) types.NetworkCreateResponse); ok {
		r0 = rf(ctx, name, options)
	} else {
		r0 = ret.Get(0).(types.NetworkCreateResponse)
	}

	var r1 error
	if rf, ok := ret.Get(1).(func(context.Context, string, types.NetworkCreate) error); ok {
		r1 = rf(ctx, name, options)
	} else {
		r1 = ret.Error(1)
	}

	return r0, r1
}
488465
func CreateSocket(mark int, deviceName string) (SocketWriter, error) {
	fd, _ := syscall.Socket(syscall.AF_INET, syscall.SOCK_RAW, syscall.IPPROTO_RAW)
	if err := syscall.SetsockoptInt(fd, syscall.SOL_SOCKET, syscall.SO_MARK, mark); err != nil {
		syscall.Close(fd) // nolint
		return nil, fmt.Errorf("Received error %s while setting socket Option SO_MARK", err)
	}

	if err := syscall.SetsockoptInt(fd, syscall.IPPROTO_IP, syscall.IP_HDRINCL, 1); err != nil {
		syscall.Close(fd) // nolint
		return nil, fmt.Errorf("Received error %s while setting socket Option IP_HDRINCL", err)
	}
	insock := &syscall.SockaddrInet4{
		Port: 0,
	}

	return &rawsocket{
		fd:     fd,
		insock: insock,
	}, nil

}
819019
func (d *driver) CreateNetwork(nid string, option map[string]interface{}, nInfo driverapi.NetworkInfo, ipV4Data, ipV6Data []driverapi.IPAMData) error {
	defer osl.InitOSContext()()
	kv, err := kernel.GetKernelVersion()
	if err != nil {
		return fmt.Errorf("failed to check kernel version for %s driver support: %v", macvlanType, err)
	}
	// ensure Kernel version is >= v3.9 for macvlan support
	if kv.Kernel < macvlanKernelVer || (kv.Kernel == macvlanKernelVer && kv.Major < macvlanMajorVer) {
		return fmt.Errorf("kernel version failed to meet the minimum macvlan kernel requirement of %d.%d, found %d.%d.%d",
			macvlanKernelVer, macvlanMajorVer, kv.Kernel, kv.Major, kv.Minor)
	}
	// reject a null v4 network
	if len(ipV4Data) == 0 || ipV4Data[0].Pool.String() == "0.0.0.0/0" {
		return fmt.Errorf("ipv4 pool is empty")
	}
	// parse and validate the config and bind to networkConfiguration
	config, err := parseNetworkOptions(nid, option)
	if err != nil {
		return err
	}
	config.ID = nid
	err = config.processIPAM(nid, ipV4Data, ipV6Data)
	if err != nil {
		return err
	}
	// verify the macvlan mode from -o macvlan_mode option
	switch config.MacvlanMode {
	case "", modeBridge:
		// default to macvlan bridge mode if -o macvlan_mode is empty
		config.MacvlanMode = modeBridge
	case modePrivate:
		config.MacvlanMode = modePrivate
	case modePassthru:
		config.MacvlanMode = modePassthru
	case modeVepa:
		config.MacvlanMode = modeVepa
	default:
		return fmt.Errorf("requested macvlan mode '%s' is not valid, 'bridge' mode is the macvlan driver default", config.MacvlanMode)
	}
	// loopback is not a valid parent link
	if config.Parent == "lo" {
		return fmt.Errorf("loopback interface is not a valid %s parent link", macvlanType)
	}
	// if parent interface not specified, create a dummy type link to use named dummy+net_id
	if config.Parent == "" {
		config.Parent = getDummyName(stringid.TruncateID(config.ID))
		// empty parent and --internal are handled the same. Set here to update k/v
		config.Internal = true
	}
	err = d.createNetwork(config)
	if err != nil {
		return err
	}
	// update persistent db, rollback on fail
	err = d.storeUpdate(config)
	if err != nil {
		d.deleteNetwork(config.ID)
		logrus.Debugf("encountered an error rolling back a network create for %s : %v", config.ID, err)
		return err
	}

	return nil
}
294166
func CreateNetwork(tx Tx, n *api.Network) error {
	// Ensure the name is not already in use.
	if tx.lookup(tableNetwork, indexName, strings.ToLower(n.Spec.Annotations.Name)) != nil {
		return ErrNameConflict
	}

	return tx.create(tableNetwork, n)
}
241464
func NewBusSocket() (*BusSocket, error) {
	s, err := NewSocket(AF_SP, BUS)
	return &BusSocket{s}, err
}