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


Python family.SAFI类代码示例

本文整理汇总了Python中exabgp.protocol.family.SAFI的典型用法代码示例。如果您正苦于以下问题:Python SAFI类的具体用法?Python SAFI怎么用?Python SAFI使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: RouteRefresh

class RouteRefresh (Message):
	ID = Message.ID.ROUTE_REFRESH
	TYPE = chr(Message.ID.ROUTE_REFRESH)

	request = 0
	start = 1
	end = 2

	def __init__ (self,afi,safi,reserved=0):
		self.afi = AFI(afi)
		self.safi = SAFI(safi)
		self.reserved = Reserved(reserved)

	def messages (self,negotitated):
		return [self._message('%s%s%s' % (self.afi.pack(),chr(self.reserved),self.safi.pack())),]

	def __str__ (self):
		return "REFRESH"

	def extensive (self):
		return 'route refresh %s/%d/%s' % (self.afi,self.reserved,self.safi)

	def families (self):
		return self._families[:]

	@classmethod
	def unpack_message (cls,data,negotitated):
		try:
			afi,reserved,safi = unpack('!HBB',data)
		except error:
			raise Notify(7,1,'invalid route-refresh message')
		if reserved not in (0,1,2):
			raise Notify(7,2,'invalid route-refresh message subtype')
		return RouteRefresh(afi,safi,reserved)
开发者ID:Krychuu,项目名称:exabgp,代码行数:34,代码来源:refresh.py

示例2: __init__

	def __init__ (self,what,afi,safi,data=''):
		self.afi = AFI(afi)
		self.safi = SAFI(afi)
		Operational.__init__(
			self,what,
			'%s%s%s' % (self.afi.pack(),self.safi.pack(),data)
		)
开发者ID:ajufrancis,项目名称:exabgp,代码行数:7,代码来源:operational.py

示例3: unpack

	def unpack (capability,instance,data):
		# XXX: FIXME: should check that we have not yet seen the capability
		while data:
			afi = AFI.unpack(data[:2])
			safi = SAFI.unpack(data[2])
			sr = ord(data[3])
			instance.add_path(afi,safi,sr)
			data = data[4:]
		return instance
开发者ID:Krychuu,项目名称:exabgp,代码行数:9,代码来源:addpath.py

示例4: unpack_capability

	def unpack_capability (instance, data, capability=None):  # pylint: disable=W0613
		# XXX: FIXME: should check that we have not yet seen the capability
		while data:
			afi = AFI.unpack(data[:2])
			safi = SAFI.unpack(data[2])
			sr = ord(data[3])
			instance.add_path(afi,safi,sr)
			data = data[4:]
		return instance
开发者ID:SaveTheRbtz,项目名称:exabgp,代码行数:9,代码来源:addpath.py

示例5: parse_api_refresh

	def parse_api_refresh (self,command):
		tokens = formated(command).split(' ')[2:]
		if len(tokens) != 2:
			return False
		afi = AFI.value(tokens.pop(0))
		safi = SAFI.value(tokens.pop(0))
		if afi is None or safi is None:
			return False
		return RouteRefresh(afi,safi)
开发者ID:PowerDNS,项目名称:exabgp,代码行数:9,代码来源:decoding.py

示例6: unpack_capability

	def unpack_capability (instance, data, capability=None):  # pylint: disable=W0613
		# XXX: FIXME: we should complain if we have twice the same AFI/SAFI
		# XXX: FIXME: should check that we have not yet seen the capability
		while data:
			afi = AFI.unpack(data[:2])
			safi = SAFI.unpack(data[3])
			nexthop = AFI.unpack(data[4:6])
			instance.add_nexthop(afi, safi, nexthop)
			data = data[6:]
		return instance
开发者ID:Exa-Networks,项目名称:exabgp,代码行数:10,代码来源:nexthop.py

示例7: OperationalFamily

class OperationalFamily (Operational):
	def __init__ (self,what,afi,safi,data=''):
		self.afi = AFI(afi)
		self.safi = SAFI(afi)
		Operational.__init__(
			self,what,
			'%s%s%s' % (self.afi.pack(),self.safi.pack(),data)
		)

	def family (self):
		return (self.afi,self.safi)
开发者ID:ajufrancis,项目名称:exabgp,代码行数:11,代码来源:operational.py

示例8: unpack_nlri

	def unpack_nlri (cls, afi, safi, data, action, addpath):
		if not cls.logger:
			cls.logger = Logger()

		a,s = AFI.create(afi),SAFI.create(safi)
		cls.logger.debug(LazyNLRI(a,s,addpath,data),'parser')

		key = '%s/%s' % (a, s)
		if key in cls.registered_nlri:
			return cls.registered_nlri[key].unpack_nlri(a,s,data,action,addpath)
		raise Notify(3,0,'trying to decode unknown family %s/%s' % (a,s))
开发者ID:Exa-Networks,项目名称:exabgp,代码行数:11,代码来源:nlri.py

示例9: _add

	def _add (self,tokeniser,afi_name,safi_names):
		self._check_duplicate(tokeniser,RaisedFamily)
		known = self.content.setdefault(AFI(AFI.value(afi_name)),[])

		for (idx_line,idx_column,line,safi_name) in safi_names:
			if safi_name not in AFI.implemented_safi(afi_name):
				raise RaisedFamily(Location(idx_line,idx_column,line),'the family pair afi/safi %s/%s is unimplemented' % (afi_name,safi_name))

			safi = SAFI(SAFI.value(safi_name))
			if safi in known:
				raise RaisedFamily(Location(idx_line,idx_column,line),'afi/safi pair already defined in this family')
			known.append(safi)
开发者ID:lochiiconnectivity,项目名称:exabgp,代码行数:12,代码来源:family.py

示例10: _family

	def _family (self, tokeniser, afi, safis, nhafis):
		safi = tokeniser().lower()
		if safi not in safis:
			raise ValueError('invalid afi/safi pair %s/%s' % (afi, safi))

		nhafi = tokeniser().lower()
		if nhafi not in nhafis:
			raise ValueError('invalid nexthop afi %s' % nhafi)

		seen = (AFI.fromString(afi), SAFI.fromString(safi), AFI.fromString(nhafi))
		self._seen.append(seen)
		return seen
开发者ID:Exa-Networks,项目名称:exabgp,代码行数:12,代码来源:nexthop.py

示例11: register_nlri

		def register_nlri (klass):
			new = (AFI.create(afi),SAFI.create(safi))
			if new in cls.registered_nlri:
				if force:
					# python has a bug and does not allow %ld/%ld (pypy does)
					cls.registered_nlri['%s/%s' % new] = klass
				else:
					raise RuntimeError('Tried to register %s/%s twice' % new)
			else:
				# python has a bug and does not allow %ld/%ld (pypy does)
				cls.registered_nlri['%s/%s' % new] = klass
				cls.registered_families.append(new)
			return klass
开发者ID:Exa-Networks,项目名称:exabgp,代码行数:13,代码来源:nlri.py

示例12: unpack_capability

	def unpack_capability (instance, data, capability=None):  # pylint: disable=W0613
		# XXX: FIXME: should raise if instance was already setup
		restart = unpack('!H',data[:2])[0]
		restart_flag = restart >> 12
		restart_time = restart & Graceful.TIME_MASK
		data = data[2:]
		families = []
		while data:
			afi = AFI.unpack(data[:2])
			safi = SAFI.unpack(data[2])
			flag_family = ord(data[3])
			families.append((afi,safi,flag_family))
			data = data[4:]
		return instance.set(restart_flag,restart_time,families)
开发者ID:Empia,项目名称:exabgp,代码行数:14,代码来源:graceful.py

示例13: unpack

	def unpack (what,instance,data):
		# XXX: FIXME: should raise if instance was already setup
		restart = unpack('!H',data[:2])[0]
		restart_flag = restart >> 12
		restart_time = restart & Graceful.TIME_MASK
		data = data[2:]
		families = []
		while data:
			afi = AFI.unpack(data[:2])
			safi = SAFI.unpack(data[2])
			flag_family = ord(data[0])
			families.append((afi,safi,flag_family))
			data = data[4:]
		return instance.set(restart_flag,restart_time,families)
开发者ID:Krychuu,项目名称:exabgp,代码行数:14,代码来源:graceful.py

示例14: RouteRefresh

class RouteRefresh (Message):
	ID = Message.CODE.ROUTE_REFRESH
	TYPE = chr(Message.CODE.ROUTE_REFRESH)

	request = 0
	start = 1
	end = 2

	def __init__ (self, afi, safi, reserved=0):
		self.afi = AFI(afi)
		self.safi = SAFI(safi)
		self.reserved = Reserved(reserved)

	def message (self,negotiated=None):
		return self._message('%s%s%s' % (self.afi.pack(),chr(self.reserved),self.safi.pack()))

	def __str__ (self):
		return "REFRESH"

	def extensive (self):
		return 'route refresh %s/%d/%s' % (self.afi,self.reserved,self.safi)

	def families (self):
		return self._families[:]

	@classmethod
	def unpack_message (cls, data, _):
		try:
			afi,reserved,safi = unpack('!HBB',data)
		except error:
			raise Notify(7,1,'invalid route-refresh message')
		if reserved not in (0,1,2):
			raise Notify(7,2,'invalid route-refresh message subtype')
		return RouteRefresh(afi,safi,reserved)

	def __eq__ (self, other):
		if not isinstance(other, RouteRefresh):
			return False
		if self.afi != other.afi:
			return False
		if self.safi != other.safi:
			return False
		if self.reserved != other.reserved:
			return False
		return True

	def __ne__ (self, other):
		return not self.__eq__(other)
开发者ID:CadeLaRen,项目名称:exabgp,代码行数:48,代码来源:refresh.py

示例15: api_eor

	def api_eor (self, command):
		tokens = formated(command).split(' ')[2:]
		number = len(tokens)

		if not number:
			return Family(1,1)

		if number != 2:
			return False

		afi = AFI.fromString(tokens[0])
		if afi == AFI.undefined:
			return False

		safi = SAFI.fromString(tokens[1])
		if safi == SAFI.undefined:
			return False

		return Family(afi,safi)
开发者ID:tomwalsh,项目名称:exabgp,代码行数:19,代码来源:text.py


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