// setupTapDevice creates persistent tap device
// and returns a newly created netlink.Link structure
321668
func setupTapDevice(podID types.UUID) (netlink.Link, error) {
	// network device names are limited to 16 characters
	// the suffix %d will be replaced by the kernel with a suitable number
	nameTemplate := fmt.Sprintf("rkt-%s-tap%%d", podID.String()[0:4])
	ifName, err := tuntap.CreatePersistentIface(nameTemplate, tuntap.Tap)
	if err != nil {
		return nil, errwrap.Wrap(errors.New("tuntap persist"), err)
	}

	link, err := netlink.LinkByName(ifName)
	if err != nil {
		return nil, errwrap.Wrap(fmt.Errorf("cannot find link %q", ifName), err)
	}

	if err := netlink.LinkSetUp(link); err != nil {
		return nil, errwrap.Wrap(fmt.Errorf("cannot set link up %q", ifName), err)
	}
	return link, nil
}
1088542
func (p *PHYPayload) SetUplinkJoinMIC(key AES128Key) error {
	mic, err := p.calculateUplinkJoinMIC(key)
	if err != nil {
		return err
	}
	p.MIC = mic
	return nil
}
542828
func (s *UpdateNetworkProfileInput) SetUplinkDelayMs(v int64) *UpdateNetworkProfileInput {
	s.UplinkDelayMs = &v
	return s
}
937169
func (d *DockerMonitor) setupHostMode(puID string, runtimeInfo policy.RuntimeReader, dockerInfo *types.ContainerJSON) (err error) {

	pausePUID := puID
	if dockerInfo.HostConfig.NetworkMode == constants.DockerHostMode {
		if err = d.netcls.Creategroup(puID); err != nil {
			return err
		}

		// Clean the cgroup on exit, if we have failed t activate.
		defer func() {
			if err != nil {
				if derr := d.netcls.DeleteCgroup(puID); derr != nil {
					zap.L().Warn("Failed to clean cgroup",
						zap.String("puID", puID),
						zap.Error(derr),
						zap.Error(err),
					)
				}
			}
		}()

		markval := runtimeInfo.Options().CgroupMark
		if markval == "" {
			return errors.New("mark value not found")
		}

		mark, _ := strconv.ParseUint(markval, 10, 32)
		if err := d.netcls.AssignMark(puID, mark); err != nil {
			return err
		}
	} else {
		// Add the container pid that is linked to hostnet to
		// the cgroup of the parent container.

		pausePUID = getPausePUID(policyExtensions(runtimeInfo))
	}

	return d.netcls.AddProcess(pausePUID, dockerInfo.State.Pid)
}
913496
func setup(c *caddy.Controller) error {
	cfg := httpserver.GetConfig(c)
	root := cfg.Root

	rules, err := basicAuthParse(c)
	if err != nil {
		return err
	}

	basic := BasicAuth{Rules: rules}

	cfg.AddMiddleware(func(next httpserver.Handler) httpserver.Handler {
		basic.Next = next
		basic.SiteRoot = root
		return basic
	})

	return 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
}
1311116
func (s *Finding) SetUpdatedAt(v time.Time) *Finding {
	s.UpdatedAt = &v
	return s
}
343148
func (s *InvokeDeviceMethodInput) SetDeviceMethodParameters(v string) *InvokeDeviceMethodInput {
	s.DeviceMethodParameters = &v
	return s
}
1104925
func (s *TaskSet) SetUpdatedAt(v time.Time) *TaskSet {
	s.UpdatedAt = &v
	return s
}
682231
func (a *StorageAPI) AddToUnit(args params.StoragesAddParams) (params.AddStorageResults, error) {
	return a.addToUnit(args)
}
56114
func (m *MockMachine) SetDevicesAddresses(arg0 ...state.LinkLayerDeviceAddress) error {
	varargs := []interface{}{}
	for _, a := range arg0 {
		varargs = append(varargs, a)
	}
	ret := m.ctrl.Call(m, "SetDevicesAddresses", varargs...)
	ret0, _ := ret[0].(error)
	return ret0
}
799036
func (p *PoolDevice) createDevice(ctx context.Context, info *DeviceInfo) error {
	if err := p.transition(ctx, info.Name, Creating, Created, func() error {
		return dmsetup.CreateDevice(p.poolName, info.DeviceID)
	}); err != nil {
		return errors.Wrapf(err, "failed to create new thin device %q (dev: %d)", info.Name, info.DeviceID)
	}

	return nil
}
424477
func (a *StorageAPIv3) AddToUnit(args params.StoragesAddParams) (params.ErrorResults, error) {
	v4results, err := a.addToUnit(args)
	if err != nil {
		return params.ErrorResults{}, err
	}
	v3results := make([]params.ErrorResult, len(v4results.Results))
	for i, result := range v4results.Results {
		v3results[i].Error = result.Error
	}
	return params.ErrorResults{v3results}, nil
}
291728
func (c *CloudAPI) SetupHTTP(mux *httprouter.Router) {
	baseRoute := "/" + c.ServiceInstance.UserAccount

	mux.NotFound = NotFound{}
	mux.MethodNotAllowed = MethodNotAllowed{}

	// keys
	keysRoute := baseRoute + "/keys"
	mux.GET(keysRoute, c.handler((*CloudAPI).handleListKeys))
	mux.POST(keysRoute, c.handler((*CloudAPI).handleCreateKey))

	// key
	keyRoute := keysRoute + "/:id"
	mux.GET(keyRoute, c.handler((*CloudAPI).handleGetKey))
	mux.DELETE(keyRoute, c.handler((*CloudAPI).handleDeleteKey))

	// images
	imagesRoute := baseRoute + "/images"
	mux.GET(imagesRoute, c.handler((*CloudAPI).handleListImages))

	// image
	imageRoute := imagesRoute + "/:id"
	mux.GET(imageRoute, c.handler((*CloudAPI).handleGetImage))
	mux.POST(imageRoute, c.handler((*CloudAPI).handleCreateImageFromMachine))
	mux.DELETE(imageRoute, c.handler((*CloudAPI).handleDeleteImage))

	// packages
	packagesRoute := baseRoute + "/packages"
	mux.GET(packagesRoute, c.handler((*CloudAPI).handleListPackages))

	// package
	packageRoute := packagesRoute + "/:id"
	mux.GET(packageRoute, c.handler((*CloudAPI).handleGetPackage))

	// machines
	machinesRoute := baseRoute + "/machines"
	mux.GET(machinesRoute, c.handler((*CloudAPI).handleListMachines))
	mux.HEAD(machinesRoute, c.handler((*CloudAPI).handleCountMachines))
	mux.POST(machinesRoute, c.handler((*CloudAPI).handleCreateMachine))

	// machine
	machineRoute := machinesRoute + "/:id"
	mux.GET(machineRoute, c.handler((*CloudAPI).handleGetMachine))
	mux.POST(machineRoute, c.handler((*CloudAPI).handleUpdateMachine))
	mux.DELETE(machineRoute, c.handler((*CloudAPI).handleDeleteMachine))

	// machine metadata
	machineMetadataRoute := machineRoute + "/metadata"
	mux.GET(machineMetadataRoute, c.handler((*CloudAPI).handleGetMachineMetadata))
	mux.POST(machineMetadataRoute, c.handler((*CloudAPI).handleUpdateMachineMetadata))
	mux.DELETE(machineMetadataRoute, c.handler((*CloudAPI).handleDeleteAllMachineMetadata))

	// machine metadata (individual key)
	machineMetadataKeyRoute := machineMetadataRoute + "/:key"
	mux.DELETE(machineMetadataKeyRoute, c.handler((*CloudAPI).handleDeleteMachineMetadata))

	// machine tags
	machineTagsRoute := machineRoute + "/tags"
	mux.GET(machineTagsRoute, c.handler((*CloudAPI).handleListMachineTags))
	mux.POST(machineTagsRoute, c.handler((*CloudAPI).handleAddMachineTags))
	mux.PUT(machineTagsRoute, c.handler((*CloudAPI).handleReplaceMachineTags))
	mux.DELETE(machineTagsRoute, c.handler((*CloudAPI).handleDeleteMachineTags))

	// machine tag
	machineTagRoute := machineTagsRoute + "/:tag"
	mux.GET(machineTagRoute, c.handler((*CloudAPI).handleGetMachineTag))
	mux.DELETE(machineTagRoute, c.handler((*CloudAPI).handleDeleteMachineTag))

	// machine firewall rules
	machineFWRulesRoute := machineRoute + "/fwrules"
	mux.GET(machineFWRulesRoute, c.handler((*CloudAPI).handleMachineFirewallRules))

	// machine NICs
	machineNICsRoute := machineRoute + "/nics"
	mux.GET(machineNICsRoute, c.handler((*CloudAPI).handleListNICs))
	mux.POST(machineNICsRoute, c.handler((*CloudAPI).handleAddNIC))

	// machine NIC
	machineNICRoute := machineNICsRoute + "/:mac"
	mux.GET(machineNICRoute, c.handler((*CloudAPI).handleGetNIC))
	mux.DELETE(machineNICRoute, c.handler((*CloudAPI).handleRemoveNIC))

	// firewall rules
	firewallRulesRoute := baseRoute + "/fwrules"
	mux.GET(firewallRulesRoute, c.handler((*CloudAPI).handleListFirewallRules))
	mux.POST(firewallRulesRoute, c.handler((*CloudAPI).handleCreateFirewallRule))

	// firewall rule
	firewallRuleRoute := firewallRulesRoute + "/:id"
	mux.GET(firewallRuleRoute, c.handler((*CloudAPI).handleGetFirewallRule))
	mux.POST(firewallRuleRoute, c.handler((*CloudAPI).handleUpdateFirewallRule))
	mux.DELETE(firewallRuleRoute, c.handler((*CloudAPI).handleDeleteFirewallRule))
	mux.POST(firewallRuleRoute+"/enable", c.handler((*CloudAPI).handleEnableFirewallRule))
	mux.POST(firewallRuleRoute+"/disable", c.handler((*CloudAPI).handleDisableFirewallRule))

	// networks
	networksRoute := baseRoute + "/networks"
	mux.GET(networksRoute, c.handler((*CloudAPI).handleListNetworks))

	// network
	networkRoute := networksRoute + "/:id"
	mux.GET(networkRoute, c.handler((*CloudAPI).handleGetNetwork))

	// fabric VLANs
	fabricVLANsRoute := baseRoute + "/fabrics/:fabric/vlans"
	mux.GET(fabricVLANsRoute, c.handler((*CloudAPI).handleListFabricVLANs))
	mux.POST(fabricVLANsRoute, c.handler((*CloudAPI).handleCreateFabricVLAN))

	// fabric VLAN
	fabricVLANRoute := fabricVLANsRoute + "/:id"
	mux.GET(fabricVLANRoute, c.handler((*CloudAPI).handleGetFabricVLAN))
	mux.PUT(fabricVLANRoute, c.handler((*CloudAPI).handleUpdateFabricVLAN))
	mux.DELETE(fabricVLANRoute, c.handler((*CloudAPI).handleDeleteFabricVLAN))

	// fabric VLAN networks
	fabricVLANNetworksRoute := fabricVLANRoute + "/networks"
	mux.GET(fabricVLANNetworksRoute, c.handler((*CloudAPI).handleListFabricNetworks))
	mux.POST(fabricVLANNetworksRoute, c.handler((*CloudAPI).handleCreateFabricNetwork))

	// fabric VLAN network
	fabricVLANNetworkRoute := fabricVLANNetworksRoute + "/:network"
	mux.GET(fabricVLANNetworkRoute, c.handler((*CloudAPI).handleGetFabricNetwork))
	mux.DELETE(fabricVLANNetworkRoute, c.handler((*CloudAPI).handleDeleteFabricNetwork))

	// services
	servicesRoute := baseRoute + "/services"
	mux.GET(servicesRoute, c.handler((*CloudAPI).handleGetServices))
}
359166
func (s *NetworkProfile) SetUplinkDelayMs(v int64) *NetworkProfile {
	s.UplinkDelayMs = &v
	return s
}
875615
func (s *RenewalSummary) SetUpdatedAt(v time.Time) *RenewalSummary {
	s.UpdatedAt = &v
	return s
}
135400
func setup(c *caddy.Controller) error {
	ctx := log.LoggerNewContext(context.Background())

	pfconfigdriver.PfconfigPool.AddStruct(ctx, &pfconfigdriver.Config.Cluster.HostsIp)

	pfipset, err := buildPfipsetHandler(ctx)

	if err != nil {
		return err
	}

	httpserver.GetConfig(c).AddMiddleware(func(next httpserver.Handler) httpserver.Handler {
		pfipset.Next = next
		return pfipset
	})

	return nil
}