X-Git-Url: https://osm.etsi.org/gitweb/?p=osm%2Fvim-emu.git;a=blobdiff_plain;f=src%2Femuvim%2Fexamples%2Fprofiling.py;h=fd53317d65ab6d8f847f9267be3454a4d5f57626;hp=daac301fae3fee2cb55b79b44a6c423917385bb2;hb=ec3a23ed1a1dc21d511c49adbe1fe3d3ab8ff8c3;hpb=e83dcab8d3402c36509baea7b99920856f6caf58 diff --git a/src/emuvim/examples/profiling.py b/src/emuvim/examples/profiling.py old mode 100644 new mode 100755 index daac301..fd53317 --- a/src/emuvim/examples/profiling.py +++ b/src/emuvim/examples/profiling.py @@ -1,5 +1,5 @@ """ -Copyright (c) 2015 SONATA-NFV +Copyright (c) 2017 SONATA-NFV and Paderborn University ALL RIGHTS RESERVED. Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +14,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. -Neither the name of the SONATA-NFV [, ANY ADDITIONAL AFFILIATION] +Neither the name of the SONATA-NFV, Paderborn University nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. @@ -61,7 +61,6 @@ class GracefulKiller: """ A simple topology with only one data center which will stop when another thread tells it to or when a time limit is reached. - :args: an argument list which may contain the time limit """ class Profiling: @@ -69,22 +68,23 @@ class Profiling: """ Set up a simple topology and start it + :port: the port the REST interface will be using, port+1 will be in use as well """ - def __init__(self): + def __init__(self, port=5000): GracefulKiller(self) # create topology self.net = DCNetwork(controller=RemoteController, monitor=False, enable_learning=False) self.dc = self.net.addDatacenter("dc1") # add the command line interface endpoint to each DC (REST API) - self.rapi1 = RestApiEndpoint("0.0.0.0", 5001) + self.rapi1 = RestApiEndpoint("0.0.0.0", port+1) self.rapi1.connectDCNetwork(self.net) self.rapi1.connectDatacenter(self.dc) # run API endpoint server (in another thread, don't block) self.rapi1.start() # add the SONATA dummy gatekeeper to each DC - self.sdkg1 = SonataDummyGatekeeperEndpoint("0.0.0.0", 5000, deploy_sap=False) + self.sdkg1 = SonataDummyGatekeeperEndpoint("0.0.0.0", port, deploy_sap=False) self.sdkg1.connectDatacenter(self.dc) # run the dummy gatekeeper (in another thread, don't block) self.sdkg1.start() @@ -106,11 +106,11 @@ class Profiling: def main(args): setLogLevel('info') # set Mininet loglevel - p = Profiling() + p = Profiling(args.get('port')) if __name__ == '__main__': parser = argparse.ArgumentParser(description="Run a simple topology") - parser.add_argument('--time', '-t', metavar='seconds', type=float, help='a time limit', default=-1, required=False, dest='time') + parser.add_argument('--port', '-p', type=int, help='the port for the REST interface', default=5000, required=False, dest='port') arg_list = vars(parser.parse_args(sys.argv[1:])) main(arg_list)