// LinkSpeed implements ChaosMonkey.LinkSpeed
505238
func (j *Jim) LinkSpeed() *linkio.Throughput {
	rand.Seed(time.Now().Unix())
	if rand.Float64() < j.LinkSpeedAffect {
		lsDiff := j.LinkSpeedMax - j.LinkSpeedMin
		lsAffect := j.LinkSpeedMin + (lsDiff * rand.Float64())
		f := linkio.Throughput(lsAffect) * linkio.BytePerSecond
		j.logf("Jim: Restricting throughput to %s\n", f)
		return &f
	}
	j.logf("Jim: Allowing unrestricted throughput")
	return nil
}
1191503
func SlowBlink(arg interface{}) Value {
	if val, ok := arg.(Value); ok {
		return val.SlowBlink()
	}
	return value{value: arg, color: SlowBlinkFm}
}
419798
func (r *FlatChain) LinkHandleFunc(h http.HandlerFunc) FlatChains {
	fh := FlatChainWrap(h, r.log)
	r.Link(fh)
	return fh
}
919064
func (d *Domain) BlockJobSetSpeed(disk string, bandwidth uint64, flags DomainBlockJobSetSpeedFlags) error {
	cdisk := C.CString(disk)
	defer C.free(unsafe.Pointer(cdisk))
	var err C.virError
	ret := C.virDomainBlockJobSetSpeedWrapper(d.ptr, cdisk, C.ulong(bandwidth), C.uint(flags), &err)
	if ret == -1 {
		return makeError(&err)
	}
	return nil
}
1356242
func (r *FlatChain) LinkFlat(h FlatHandler) FlatChains {
	fh := NewFlatChain(h, r.log)
	r.Link(fh)
	return fh
}
501727
func (h *Handle) LinkDel(link Link) error {
	base := link.Attrs()

	h.ensureIndex(base)

	req := h.newNetlinkRequest(unix.RTM_DELLINK, unix.NLM_F_ACK)

	msg := nl.NewIfInfomsg(unix.AF_UNSPEC)
	msg.Index = int32(base.Index)
	req.AddData(msg)

	_, err := req.Execute(unix.NETLINK_ROUTE, 0)
	return err
}
265839
func (t *Term) SetSpeed(baud int) error {
	return t.SetOption(Speed(baud))
}
1368998
func (s *UpdateNetworkProfileInput) SetUplinkLossPercent(v int64) *UpdateNetworkProfileInput {
	s.UplinkLossPercent = &v
	return s
}
469572
func (c *LinkManagerContext) Port(p uint32) LinkPort {
	for _, port := range c.Ports {
		if port.Port == p {
			return port
		}
	}

	return LinkPort{}
}
811697
func (l Links) Link(rel, href string, args ...interface{}) Links {
	if len(args) != 0 {
		href = fmt.Sprintf(href, args...)
	}

	templated, _ := regexp.Match("{.*?}", []byte(href))

	return l.Add(rel, Link{Href: href, Templated: templated})
}
955127
func (c *ALIModelContext) LinkLoadBalancer() *alitasks.LoadBalancer {
	return &alitasks.LoadBalancer{Name: s(c.GetNameForLoadBalancer())}
}
1015286
func (h *Client) LinkID(linkID string) *Client {
	h.linkID = linkID
	h.linkIDSet = true
	return h
}
580632
func (c *LinkCache) Len() int {
	c.Lock()
	defer c.Unlock()
	return len(c.cache)
}
1329246
func (c *ChatPostMessageCall) LinkNames(linkNames bool) *ChatPostMessageCall {
	c.linkNames = linkNames
	return c
}
675421
func (t *Track) LinkOffset(offset time.Duration) *Link {
	offsetMs := C.int(offset / time.Millisecond)
	sp_link := C.sp_link_create_from_track(t.sp_track, offsetMs)
	return newLink(t.session, sp_link, false)
}
335554
func (e *Ethtool) LinkState(intf string) (uint32, error) {
	x := ethtoolLink{
		cmd: ETHTOOL_GLINK,
	}

	if err := e.ioctl(intf, uintptr(unsafe.Pointer(&x))); err != nil {
		return 0, err
	}

	return x.data, nil
}
1011248
func (p *Process) runLinker() {
	processSock := path.Join(p.containerPath, "processes", fmt.Sprintf("%s.sock", p.ID()))

	link, err := link.Create(processSock, p.stdout, p.stderr)
	if err != nil {
		p.completed(-1, err)
		return
	}

	p.stdin.AddSink(link)

	p.link = link
	close(p.linked)

	p.completed(p.link.Wait())

	// don't leak stdin pipe
	p.stdin.Close()
}