本文整理汇总了Python中mininet.link.Link.__new__方法的典型用法代码示例。如果您正苦于以下问题:Python Link.__new__方法的具体用法?Python Link.__new__怎么用?Python Link.__new__使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mininet.link.Link
的用法示例。
在下文中一共展示了Link.__new__方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _create_links
# 需要导入模块: from mininet.link import Link [as 别名]
# 或者: from mininet.link.Link import __new__ [as 别名]
def _create_links(self, links):
def is_remote(node):
return isinstance(node, RemoteSwitch)
def is_local(node):
return not is_remote(node)
self._info('**** Create %d link(s)' % len(links))
for id, link in links.iteritems():
self._debug('\tCreate link %s with params: %s' % (id, link))
node1 = self.net.get(link['node1'])
node2 = self.net.get(link['node2'])
name_to_node = {'node1': node1, 'node2': node2}
link.update(name_to_node)
remote = filter(is_remote, [node1, node2])
local = filter(is_local, [node1, node2])
if not remote:
self.net.addLink(**link)
else:
sw = local[0]
r = remote[0]
intfName = r.params['local_intf_name']
r_mac = None # unknown, r.params['remote_mac']
r_port = r.params['remote_port']
self._debug('\tadd hw interface (%s) to node (%s)' % (intfName, sw.name))
# This hack avoids calling __init__ which always makeIntfPair()
link = Link.__new__(Link)
i1 = Intf(intfName, node=sw, link=link)
i2 = Intf(intfName, node=r, mac=r_mac, port=r_port, link=link)
i2.mac = r_mac # mn runs 'ifconfig', which resets mac to None
#
link.intf1, link.intf2 = i1, i2