Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return NmEdge(self._anm, self._overlay_id,
edge.src, edge.dst, edge.ekey)
elif (self._graph.has_edge(edge.src, edge.dst)):
return NmEdge(self._anm, self._overlay_id,
edge.src, edge.dst)
if isinstance(edge_to_find, NmEdge):
src_id = edge_to_find.src
dst_id = edge_to_find.dst
search_key = key
if self.is_multigraph():
for (src, dst, rkey) in self._graph.edges(src_id,
keys=True):
if dst == dst_id and rkey == search_key:
return NmEdge(self._anm, self._overlay_id, src,
dst, search_key)
for (src, dst) in self._graph.edges(src_id):
if dst == dst_id:
return NmEdge(self._anm, self._overlay_id, src, dst)
# from here on look for (src, dst) pairs
src = edge_to_find
dst = dst_to_find
if (isinstance(src, basestring) and isinstance(dst, basestring)):
src = src.lower()
dst = dst.lower()
if self.is_multigraph():
if self._graph.has_edge(src, dst, key=key):
return NmEdge(self._anm, self._overlay_id, src,
dst, search_key)
for (src, dst) in self._graph.edges(src_id):
if dst == dst_id:
return NmEdge(self._anm, self._overlay_id, src, dst)
# from here on look for (src, dst) pairs
src = edge_to_find
dst = dst_to_find
if (isinstance(src, basestring) and isinstance(dst, basestring)):
src = src.lower()
dst = dst.lower()
if self.is_multigraph():
if self._graph.has_edge(src, dst, key=key):
return NmEdge(self._anm, self._overlay_id, src,
dst, key)
elif self._graph.has_edge(src, dst):
return NmEdge(self._anm, self._overlay_id, src, dst)
if isinstance(src, NmNode) and isinstance(dst, NmNode):
src_id = src.node_id
dst_id = dst.node_id
if self.is_multigraph():
if self._graph.has_edge(src_id, dst_id, key):
return NmEdge(self._anm, self._overlay_id, src, dst, key)
else:
if self._graph.has_edge(src_id, dst_id):
return NmEdge(self._anm, self._overlay_id, src, dst)
if isinstance(edge_to_find, NmEdge):
src_id = edge_to_find.src
dst_id = edge_to_find.dst
search_key = key
if self.is_multigraph():
for (src, dst, rkey) in self._graph.edges(src_id,
keys=True):
if dst == dst_id and rkey == search_key:
return NmEdge(self._anm, self._overlay_id, src,
dst, search_key)
for (src, dst) in self._graph.edges(src_id):
if dst == dst_id:
return NmEdge(self._anm, self._overlay_id, src, dst)
# from here on look for (src, dst) pairs
src = edge_to_find
dst = dst_to_find
if (isinstance(src, basestring) and isinstance(dst, basestring)):
src = src.lower()
dst = dst.lower()
if self.is_multigraph():
if self._graph.has_edge(src, dst, key=key):
return NmEdge(self._anm, self._overlay_id, src,
dst, key)
elif self._graph.has_edge(src, dst):
return NmEdge(self._anm, self._overlay_id, src, dst)
if isinstance(src, NmNode) and isinstance(dst, NmNode):
>>> eth0_r2 = anm["phy"].node("r2").interface("eth0")
>>> anm["phy"].has_edge(eth0_r1, eth0_r2)
True
>>> anm["phy"].has_edge(eth3_r1, eth0_r2)
False
'''
# TODO: handle multigraphs
if isinstance(edge_to_find, NmEdge):
# TODO: tidy this logic
edge = edge_to_find # alias for neater code
if (edge.is_multigraph() and self.is_multigraph()
and self._graph.has_edge(edge.src,
edge.dst, key=edge.ekey)):
return NmEdge(self._anm, self._overlay_id,
edge.src, edge.dst, edge.ekey)
elif (self._graph.has_edge(edge.src, edge.dst)):
return NmEdge(self._anm, self._overlay_id,
edge.src, edge.dst)
if isinstance(edge_to_find, NmEdge):
src_id = edge_to_find.src
dst_id = edge_to_find.dst
search_key = key
if self.is_multigraph():
for (src, dst, rkey) in self._graph.edges(src_id,
keys=True):
if dst == dst_id and rkey == search_key:
return NmEdge(self._anm, self._overlay_id, src,
dst, search_key)
valid_edges = list((src, dst, default_key)
for (src, dst) in self._graph.edges(src_nbunch))
if dst_nbunch:
try:
dst_nbunch = dst_nbunch.node_id
dst_nbunch = set([dst_nbunch])
except AttributeError:
dst_nbunch = (n.node_id for n in dst_nbunch)
dst_nbunch = set(dst_nbunch)
valid_edges = list((src, dst, key) for (src, dst, key) in
valid_edges if dst in dst_nbunch)
if len(args) or len(kwargs):
all_edges = [NmEdge(self._anm, self._overlay_id, src, dst,
key) for (src, dst, key) in valid_edges]
result = list(edge for edge in all_edges
if filter_func(edge))
else:
result = list(NmEdge(self._anm, self._overlay_id, src, dst,
key) for (src, dst, key) in valid_edges)
return list(result)
if dst == dst_id:
return NmEdge(self._anm, self._overlay_id, src, dst)
# from here on look for (src, dst) pairs
src = edge_to_find
dst = dst_to_find
if (isinstance(src, basestring) and isinstance(dst, basestring)):
src = src.lower()
dst = dst.lower()
if self.is_multigraph():
if self._graph.has_edge(src, dst, key=key):
return NmEdge(self._anm, self._overlay_id, src,
dst, key)
elif self._graph.has_edge(src, dst):
return NmEdge(self._anm, self._overlay_id, src, dst)
if isinstance(src, NmNode) and isinstance(dst, NmNode):
src_id = src.node_id
dst_id = dst.node_id
if self.is_multigraph():
if self._graph.has_edge(src_id, dst_id, key):
return NmEdge(self._anm, self._overlay_id, src, dst, key)
else:
if self._graph.has_edge(src_id, dst_id):
return NmEdge(self._anm, self._overlay_id, src, dst)
if isinstance(src, NmPort) and isinstance(dst, NmPort):
# further filter result by ports
if bidirectional:
edges_to_add.append((dst, src, dict(data)))
#TODO: warn if not multigraph
self._graph.add_edges_from(edges_to_add)
all_edges += edges_to_add
if self.is_multigraph():
return [
NmEdge(self.anm, self._overlay_id, src, dst, ekey) if ekey
else NmEdge(self.anm, self._overlay_id, src, dst) # default no ekey set
for src, dst, ekey, _ in all_edges]
else:
return [NmEdge(self.anm, self._overlay_id, src, dst)
for src, dst, _ in all_edges]
>>> anm["phy"].has_edge(eth3_r1, eth0_r2)
False
'''
# TODO: handle multigraphs
if isinstance(edge_to_find, NmEdge):
# TODO: tidy this logic
edge = edge_to_find # alias for neater code
if (edge.is_multigraph() and self.is_multigraph()
and self._graph.has_edge(edge.src,
edge.dst, key=edge.ekey)):
return NmEdge(self._anm, self._overlay_id,
edge.src, edge.dst, edge.ekey)
elif (self._graph.has_edge(edge.src, edge.dst)):
return NmEdge(self._anm, self._overlay_id,
edge.src, edge.dst)
if isinstance(edge_to_find, NmEdge):
src_id = edge_to_find.src
dst_id = edge_to_find.dst
search_key = key
if self.is_multigraph():
for (src, dst, rkey) in self._graph.edges(src_id,
keys=True):
if dst == dst_id and rkey == search_key:
return NmEdge(self._anm, self._overlay_id, src,
dst, search_key)
for (src, dst) in self._graph.edges(src_id):
if dst == dst_id:
>>> e1 == e2
False
>>> autonetkit.update_http(anm)
>>> eth0_r1 = anm["phy"].node("r1").interface("eth0")
>>> eth3_r1 = anm["phy"].node("r1").interface("eth3")
>>> eth0_r2 = anm["phy"].node("r2").interface("eth0")
>>> anm["phy"].has_edge(eth0_r1, eth0_r2)
True
>>> anm["phy"].has_edge(eth3_r1, eth0_r2)
False
'''
# TODO: handle multigraphs
if isinstance(edge_to_find, NmEdge):
# TODO: tidy this logic
edge = edge_to_find # alias for neater code
if (edge.is_multigraph() and self.is_multigraph()
and self._graph.has_edge(edge.src,
edge.dst, key=edge.ekey)):
return NmEdge(self._anm, self._overlay_id,
edge.src, edge.dst, edge.ekey)
elif (self._graph.has_edge(edge.src, edge.dst)):
return NmEdge(self._anm, self._overlay_id,
edge.src, edge.dst)
if isinstance(edge_to_find, NmEdge):
src_id = edge_to_find.src
dst_id = edge_to_find.dst
search_key = key