From c6898c7c0e1b9f29d386104b077a582b9e47c0a6 Mon Sep 17 00:00:00 2001 From: Blake Harnden <32446120+bharnden@users.noreply.github.com> Date: Thu, 10 Nov 2022 09:54:31 -0800 Subject: [PATCH] examples: updated python switch example to show the need to use ids for switch/hub interfaces --- package/examples/grpc/switch.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/package/examples/grpc/switch.py b/package/examples/grpc/switch.py index 1b693cb6..85670728 100644 --- a/package/examples/grpc/switch.py +++ b/package/examples/grpc/switch.py @@ -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 @@ -20,10 +20,12 @@ position = Position(x=300, y=100) 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)