X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=emuvim%2Fexample_topology.py;h=a21cdba404730e93bac78af2fd32820ceda85826;hb=9c252b6c886bc254872fd1dfe3c19fab6fe15570;hp=f2be310e457ef163f946ca36f2658edb314014c7;hpb=cbcd4c2d984a354e88febdaa368d53a3e6881c72;p=osm%2Fvim-emu.git diff --git a/emuvim/example_topology.py b/emuvim/example_topology.py index f2be310..a21cdba 100644 --- a/emuvim/example_topology.py +++ b/emuvim/example_topology.py @@ -7,11 +7,13 @@ script. """ import logging from dcemulator.net import DCNetwork +from api.zerorpcapi import ZeroRpcApiEndpoint logging.basicConfig(level=logging.DEBUG) def create_topology1(): + # TODO add long comments to this example to show people how to use this # initialize network net = DCNetwork() @@ -27,12 +29,24 @@ def create_topology1(): net.addLink("dc1", s1) net.addLink(s1, "dc3") net.addLink(s1, dc4) + + # create and start APIs (to access emulated cloud data centers) + zapi1 = ZeroRpcApiEndpoint("0.0.0.0", 4242) + zapi1.connectDatacenter(dc1) + zapi1.connectDatacenter(dc2) + zapi1.start() + # lets also create a second API endpoint on another port to + # demonstrate hat you can have one endpoint for each of + # your data centers + zapi2 = ZeroRpcApiEndpoint("0.0.0.0", 4343) + zapi2.connectDatacenter(dc3) + zapi2.connectDatacenter(dc4) + zapi2.start() + # start network net.start() net.CLI() # TODO remove this when we integrate APIs? net.stop() # TODO remove this when we integrate APIs? - # start APIs (to access emulated cloud data centers) - pass # TODO: how to reflect one API endpoint per DC? def main():