当前位置: 首页>>代码示例>>Golang>>正文


Golang Switch.Get_id方法代码示例

本文整理汇总了Golang中github.com/att/tegu/gizmos.Switch.Get_id方法的典型用法代码示例。如果您正苦于以下问题:Golang Switch.Get_id方法的具体用法?Golang Switch.Get_id怎么用?Golang Switch.Get_id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/att/tegu/gizmos.Switch的用法示例。


在下文中一共展示了Switch.Get_id方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: find_all_paths

/*
	This is a helper function for find_paths(). It is used to find all possible paths between h1 and h2 starting at ssw.
	The resulting path is a "scramble" meaning that the set of links is a unique set of links that are traversed by
	one or more paths. The list of links can be traversed without the need to dup check which is beneficial for
	increasing/decreasing the utilisaition on the link.  From a scramble, only end point queues can be set as the
	middle switches are NOT maintained.

	usr is the name of the user that the reservation is being processed for (project in openstack). The usr_max value
	is a percentage (1-100)  that defines the maximum of any link that the user may have reservations against or a hard
	limit if larger than 100.

*/
func (n *Network) find_all_paths(ssw *gizmos.Switch, h1 *gizmos.Host, h2 *gizmos.Host, usr *string, commence int64, conclude int64, inc_cap int64, usr_max int64) (path *gizmos.Path, err error) {

	net_sheep.Baa(1, "find_all: searching for all paths between %s  and  %s", *(h1.Get_mac()), *(h2.Get_mac()))

	links, epsw, err := ssw.All_paths_to(h2.Get_mac(), commence, conclude, inc_cap, usr, usr_max)
	if err != nil {
		return
	}

	path = gizmos.Mk_path(h1, h2)
	path.Set_scramble(true)
	path.Set_bandwidth(inc_cap)
	path.Add_switch(ssw)
	path.Add_switch(epsw)

	lnk := n.find_vlink(*(ssw.Get_id()), h1.Get_port(ssw), -1, nil, nil) // add endpoint -- a virtual link out from switch to h1
	lnk.Add_lbp(*(h1.Get_mac()))
	lnk.Set_forward(ssw)
	path.Add_endpoint(lnk)

	lnk = n.find_vlink(*(epsw.Get_id()), h2.Get_port(epsw), -1, nil, nil) // add endpoint -- a virtual link out from switch to h2
	lnk.Add_lbp(*(h2.Get_mac()))
	lnk.Set_forward(epsw)
	path.Add_endpoint(lnk)

	for i := range links {
		path.Add_link(links[i])
	}

	return
}
开发者ID:att,项目名称:tegu,代码行数:43,代码来源:network_path.go

示例2: find_relaxed_path

/*
	A helper function for find_paths() that is used when running in 'relaxed' mode. In relaxed mode we don't
	actually find a path between the endpoints as we aren't doign admission control, but need to simulate
	a path in order to set up the flow-mods on the endpoints correctly.
*/
func (n *Network) find_relaxed_path(sw1 *gizmos.Switch, h1 *gizmos.Host, sw2 *gizmos.Switch, h2 *gizmos.Host) (path *gizmos.Path, err error) {

	net_sheep.Baa(1, "find_lax: creating relaxed path between %s and %s", *(h1.Get_mac()), *(h2.Get_mac()))

	if sw1 == nil || sw2 == nil {
		return nil, fmt.Errorf("one endpoint switch was unknown; cannot create a virtual (relaxed) path")
	}

	path = gizmos.Mk_path(h1, h2)
	path.Set_bandwidth(0)
	path.Add_switch(sw1)
	path.Add_switch(sw2)

	lnk := n.find_vlink(*(sw1.Get_id()), h1.Get_port(sw1), -1, nil, nil) // add endpoint -- a virtual from sw1 out to the host h1
	lnk.Add_lbp(*(h1.Get_mac()))
	lnk.Set_forward(sw1)
	path.Add_endpoint(lnk)

	lnk = n.find_swvlink(*(sw1.Get_id()), *(sw2.Get_id())) // suss out or create a virtual link between the two
	lnk.Set_forward(sw2)
	lnk.Set_backward(sw1)
	path.Add_link(lnk)

	lnk = n.find_vlink(*(sw2.Get_id()), h2.Get_port(sw2), -1, nil, nil) // add endpoint -- a virtual link on sw2 out to the host h2
	lnk.Add_lbp(*(h2.Get_mac()))
	lnk.Set_forward(sw2)
	path.Add_endpoint(lnk)

	return
}
开发者ID:att,项目名称:tegu,代码行数:35,代码来源:network_path.go

示例3: find_paths

/*
	Find a set of connected switches that can be used as a path beteeen
	hosts 1 and 2 (given by name; mac or ip).  Further, all links between from and the final switch must be able to
	support the additional capacity indicated by inc_cap during the time window between
	commence and conclude (unix timestamps).

	If the network is 'split' a host may appear to be attached to multiple switches; one with a real connection and
	the others are edge switches were we see an 'entry' point for the host from the portion of the network that we
	cannot visualise.  We must attempt to find a path between h1 using all of it's attached switches, and thus the
	return is an array of paths rather than a single path.


	h1nm and h2nm are likely going to be ip addresses as the main function translates any names that would have
	come in from the requestor.

	Extip is an external IP address that will need to be associated with the flow-mods and thus needs to be
	added to any path we generate.

	If mlag_paths is true, then we will find shortest path but add usage to all related mlag links in the path.

	If find_all is set, and mlog_paths is false, then we will suss out all possible paths between h1 and h2 and not
	just the shortest path.
*/
func (n *Network) find_paths(h1nm *string, h2nm *string, usr *string, commence int64, conclude int64, inc_cap int64, extip *string, ext_flag *string, find_all bool) (pcount int, path_list []*gizmos.Path, cap_trip bool) {
	var (
		path      *gizmos.Path
		ssw       *gizmos.Switch // starting switch
		h1        *gizmos.Host
		h2        *gizmos.Host
		lnk       *gizmos.Link
		plidx     int = 0
		swidx     int = 0 // index into host's switch list
		err       error
		lcap_trip bool = false // local capacity trip flag; indicates one or more paths blocked by capacity limits
	)

	if h1nm == nil || h2nm == nil {
		net_sheep.Baa(1, "IER:	find_paths: one/both names is/are nil  h1 nil=%v  h2 nil=%v", h1nm == nil, h2nm == nil)
		return 0, nil, false
	}

	h1 = n.hosts[*h1nm]
	if h1 == nil {
		path_list = nil
		net_sheep.Baa(1, "find-path: cannot find host(1) in network -- not reported by SDNC? %s", *h1nm)
		return
	}
	h1nm = h1.Get_mac() // must have the host's mac as our flowmods are at that level

	h2 = n.hosts[*h2nm] // do the same for the second host
	if h2 == nil {
		path_list = nil
		net_sheep.Baa(1, "find-path: cannot find host(2) in network -- not reported by the SDNC? %s", *h2nm)
		return
	}
	h2nm = h2.Get_mac()

	if h1nm == nil || h2nm == nil { // this has never happened, but be parinoid
		pcount = 0
		path_list = nil
		net_sheep.Baa(0, "CRI: find-path: internal error: either h1nm or h2nm was nil after get mac  [TGUNET005]")
		return
	}

	path_list = make([]*gizmos.Path, len(n.links)) // we cannot have more in our path than the number of links (needs to be changed as this isn't good in the long run)
	pcount = 0

	for { // we'll break after we've looked at all of the connection points for h1
		if plidx >= len(path_list) {
			net_sheep.Baa(0, "CRI: find-path: internal error -- path size > num of links.  [TGUNET006]")
			return
		}

		ssw, _ = h1.Get_switch_port(swidx) // get next switch that lists h1 as attached; we'll work 'out' from it toward h2
		if ssw == nil {                    // no more source switches which h1 thinks it's attached to
			pcount = plidx
			if pcount <= 0 || swidx == 0 {
				net_sheep.Baa(1, "find-path: early exit? no switch/port returned for h1 (%s) at index %d captrip=%v", *h1nm, swidx, lcap_trip)
			}
			path_list = path_list[0:pcount] // slice it down to size
			cap_trip = lcap_trip            // set with overall state
			return
		}

		fence := n.get_fence(usr)
		if ssw.Has_host(h1nm) && ssw.Has_host(h2nm) { // if both hosts are on the same switch, there's no path if they both have the same port (both external to our view)
			p1 := h1.Get_port(ssw)
			p2 := h2.Get_port(ssw)
			if p1 < 0 || p1 != p2 { // when ports differ we'll create/find the vlink between them	(in Tegu-lite port == -128 is legit and will dup)
				m1 := h1.Get_mac()
				m2 := h2.Get_mac()

				lnk = n.find_vlink(*(ssw.Get_id()), p1, p2, m1, m2)
				has_room := true // always room if relaxed mode, so start this way
				if n.relaxed {
					has_room = ssw.Has_capacity_out(commence, conclude, inc_cap, fence.Name, fence.Get_limit_max()) // ensure cap on all outbound links from switch
				}

				if has_room { // room for the reservation
					lnk.Add_lbp(*h1nm)
//.........这里部分代码省略.........
开发者ID:att,项目名称:tegu,代码行数:101,代码来源:network_path.go


注:本文中的github.com/att/tegu/gizmos.Switch.Get_id方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。