Skip to content

Commit

Permalink
examples: updated python switch example to show the need to use ids f…
Browse files Browse the repository at this point in the history
…or switch/hub interfaces
  • Loading branch information
bharnden committed Nov 10, 2022
1 parent 568b136 commit c6898c7
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions package/examples/grpc/switch.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from core.api.grpc import client
from core.api.grpc import client, wrappers
from core.api.grpc.wrappers import NodeType, Position

# interface helper
Expand All @@ -20,10 +20,12 @@
node2 = session.add_node(3, position=position)

# create links
iface1 = iface_helper.create_iface(node1.id, 0)
session.add_link(node1=node1, node2=switch, iface1=iface1)
iface1 = iface_helper.create_iface(node2.id, 0)
session.add_link(node1=node2, node2=switch, iface1=iface1)
node1_iface1 = iface_helper.create_iface(node1.id, 0)
switch_iface1 = wrappers.Interface(0)
session.add_link(node1=node1, node2=switch, iface1=node1_iface1, iface2=switch_iface1)
node2_iface1 = iface_helper.create_iface(node2.id, 0)
switch_iface2 = wrappers.Interface(1)
session.add_link(node1=node2, node2=switch, iface1=node2_iface1, iface2=switch_iface2)

# start session
core.start_session(session)

0 comments on commit c6898c7

Please sign in to comment.