// AddInterface NIC追加
9430
func (s *VPCRouterSetting) AddInterface(vip string, ipaddress []string, maskLen int) {
	if s.Interfaces == nil {
		s.Interfaces = []*VPCRouterInterface{nil}
	}
	s.Interfaces = append(s.Interfaces, &VPCRouterInterface{
		VirtualIPAddress: vip,
		IPAddress:        ipaddress,
		NetworkMaskLen:   maskLen,
	})
}
781044
func (enc *Encoder) AddInterface(value interface{}) {
	switch vt := value.(type) {
	case string:
		enc.AddString(vt)
	case bool:
		enc.AddBool(vt)
	case MarshalerJSONArray:
		enc.AddArray(vt)
	case MarshalerJSONObject:
		enc.AddObject(vt)
	case int:
		enc.AddInt(vt)
	case int64:
		enc.AddInt(int(vt))
	case int32:
		enc.AddInt(int(vt))
	case int8:
		enc.AddInt(int(vt))
	case uint64:
		enc.AddUint64(vt)
	case uint32:
		enc.AddInt(int(vt))
	case uint16:
		enc.AddInt(int(vt))
	case uint8:
		enc.AddInt(int(vt))
	case float64:
		enc.AddFloat(vt)
	case float32:
		enc.AddFloat32(vt)
	default:
		if vt != nil {
			enc.err = InvalidMarshalError(fmt.Sprintf(invalidMarshalErrorMsg, vt))
			return
		}
		return
	}
}
1024425
func (_m *ClientInterface) AddHost(h host.Host) ([]byte, error) {
	ret := _m.Called(h)

	var r0 []byte
	if rf, ok := ret.Get(0).(func(host.Host) []byte); ok {
		r0 = rf(h)
	} else {
		if ret.Get(0) != nil {
			r0 = ret.Get(0).([]byte)
		}
	}

	var r1 error
	if rf, ok := ret.Get(1).(func(host.Host) error); ok {
		r1 = rf(h)
	} else {
		r1 = ret.Error(1)
	}

	return r0, r1
}
1232834
func (s *ServiceCache) Add(e *common.Service, id string, data interface{}, local bool) error {
	s.Lock()
	defer s.Unlock()

	record := &entry{
		ports: e.Ports,
		data:  data,
		id:    id,
	}
	if err := s.addPorts(e, record, local); err != nil {
		return err
	}

	if err := s.addHostService(e, record, local); err != nil {
		return err
	}

	return s.addIPService(e, record, local)
}
515793
func (az *Cloud) createOrUpdateInterfaceWithRetry(service *v1.Service, nic network.Interface) error {
	return wait.ExponentialBackoff(az.requestBackoff(), func() (bool, error) {
		ctx, cancel := getContextWithCancel()
		defer cancel()

		resp, err := az.InterfacesClient.CreateOrUpdate(ctx, az.ResourceGroup, *nic.Name, nic)
		klog.V(10).Infof("InterfacesClient.CreateOrUpdate(%s): end", *nic.Name)
		return az.processHTTPRetryResponse(service, "CreateOrUpdateInterface", resp, err)
	})
}
450836
func (client *Client) CreateRouterInterface(args *CreateRouterInterfaceArgs) (response *CreateRouterInterfaceResponse, err error) {
	response = &CreateRouterInterfaceResponse{}
	err = client.Invoke("CreateRouterInterface", args, &response)
	if err != nil {
		return response, err
	}
	return response, nil
}
993990
func newInterface(nlh *netlink.Handle, config *networkConfiguration) (*bridgeInterface, error) {
	var err error
	i := &bridgeInterface{nlh: nlh}

	// Initialize the bridge name to the default if unspecified.
	if config.BridgeName == "" {
		config.BridgeName = DefaultBridgeName
	}

	// Attempt to find an existing bridge named with the specified name.
	i.Link, err = nlh.LinkByName(config.BridgeName)
	if err != nil {
		logrus.Debugf("Did not find any interface with name %s: %v", config.BridgeName, err)
	} else if _, ok := i.Link.(*netlink.Bridge); !ok {
		return nil, fmt.Errorf("existing interface %s is not a bridge", i.Link.Attrs().Name)
	}
	return i, nil
}
1251884
func makeNetInterfaceName(base string) string {
	for {
		name := base + randomString(6)
		if _, err := net.InterfaceByName(name); err == nil {
			continue
		}

		return name
	}
}
782318
func AddrFamily(ip net.IP) int {
	if len(ip) == v4Length {
		return IPv4
	}

	if len(ip) == v6Length && bytes.HasPrefix(ip, v4Prefix) {
		return IPv4
	}

	return IPv6
}
391958
func (api *VPCRouterAPI) AddPremiumInterface(routerID int64, switchID int64, ipaddresses []string, maskLen int, virtualIP string) (*sacloud.VPCRouter, error) {
	return api.addInterface(routerID, switchID, &sacloud.VPCRouterInterface{
		IPAddress:        ipaddresses,
		NetworkMaskLen:   maskLen,
		VirtualIPAddress: virtualIP,
	})
}
1353194
func (c *Client) AddNIC(machineID, networkID string) (*NIC, error) {
	resp := new(NIC)
	req := request{
		method:         client.POST,
		url:            makeURL(apiMachines, machineID, apiNICs),
		reqValue:       addNICOptions{networkID},
		resp:           resp,
		expectedStatus: http.StatusCreated,
	}
	if _, err := c.sendRequest(req); err != nil {
		return nil, errors.Newf(err, "failed to add NIC to machine %s on network: %s", machineID, networkID)
	}
	return resp, nil
}
708027
func (s *VolumeiSCSIAttributes) SetNetworkInterfaceId(v string) *VolumeiSCSIAttributes {
	s.NetworkInterfaceId = &v
	return s
}
114389
func (vm *VM) GetInterfaces() ([]NIC, error) {
	nics := []NIC{}
	stdout, err := runner.RunCombinedError("showvminfo", vm.Name)
	if err != nil {
		return nil, err
	}

	for _, line := range strings.Split(stdout, "\n") {
		// See if this is a NIC
		if match := nicRegexp.FindStringSubmatch(line); match != nil {
			var nic NIC
			// Get the nic index and the backing
			// substr is the nic index with a trailing `:`
			substr := strings.Split(match[0], " ")[1]
			//Remove the trailing `:` and convert to an integer
			idx, err := strconv.Atoi(strings.TrimSuffix(substr, ":"))
			if err != nil {
				return nil, err
			}
			nic.Idx = idx
			if match := backingRegexp.FindStringSubmatch(line); match != nil {
				nic.Backing = Nat
			} else if match := disabledRegexp.FindStringSubmatch(line); match != nil {
				nic.Backing = Disabled
			} else {
				nic.Backing = Unsupported
			}
			nics = append(nics, nic)
		}
	}
	return nics, nil
}
451326
func AddNIC(vm *VM, nic NIC) error {
	var err error
	switch nic.Backing {
	case Nat:
		_, _, err = runner.Run("modifyvm", vm.Name, fmt.Sprintf("--nic%d", nic.Idx), getStringFromBacking(nic.Backing))
	case Bridged:
		_, _, err = runner.Run("modifyvm", vm.Name, fmt.Sprintf("--nic%d", nic.Idx), getStringFromBacking(nic.Backing), fmt.Sprintf("--bridgeadapter%d", nic.Idx), nic.BackingDevice)
	}
	return err
}
1300372
func (a *AnimationSystem) AddByInterface(i ecs.Identifier) {
	o, _ := i.(Animationable)
	a.Add(o.GetBasicEntity(), o.GetAnimationComponent(), o.GetRenderComponent())
}
900961
func (pm *PluginManager) RegisterInterface(cfg PluginInterfaceConfig) error {
	// ensure the identifier is unique and hasn't been registered
	// before
	if _, exists := pm.interfaces[cfg.Identifier]; exists {
		return errors.New("Plugin interface already defined")
	}

	if reflect.TypeOf(cfg.Factory).Kind() != reflect.Struct {
		return errors.New("Factory is not a struct")
	}

	// ensure the Factory implements the interface
	if !implements(reflect.TypeOf(cfg.Factory), reflect.TypeOf(cfg.Interface)) {
		return errors.New("Given factory does not implement the registered plugin interface")
	}

	// ensure the Factory implements the goplugin.Plugin interface,
	// which means by extension means the Registered Interface
	// implements the goplugin.Plugin interface
	if _, ok := (cfg.Factory).(Plugin); !ok {
		return errors.New("Defined plugin interface does not implement the goplugin.Plugin interface")
	}

	// load all the method signatures of the interface
	// config
	factory := reflect.TypeOf(cfg.Factory)
	for i := 0; i < factory.NumMethod(); i++ {
		method := factory.Method(i)
		cfg.methods = append(cfg.methods, method.Name)
	}

	// save the plugin interface definition
	pm.interfaces[cfg.Identifier] = cfg
	return nil
}
631529
func (b *serverBuilder) AddPublicNWConnectedNIC() {
	b.nicConnections = append(b.nicConnections, "shared")
	b.displayIPAddresses = append(b.displayIPAddresses, "")
}