Skip to content

Commit

Permalink
support commandline application initialization
Browse files Browse the repository at this point in the history
You can run your Ryu applicaiton in the following way:

$ ryu-manager yourapp.py

Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Reviewed-by: Isaku Yamahata <yamahata@valinux.co.jp>
  • Loading branch information
fujita committed Jun 9, 2012
1 parent 63cc493 commit c9f6b1b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
11 changes: 6 additions & 5 deletions bin/ryu-manager
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env python
#
# Copyright (C) 2011 Nippon Telegraph and Telephone Corporation.
# Copyright (C) 2011, 2012 Nippon Telegraph and Telephone Corporation.
# Copyright (C) 2011 Isaku Yamahata <yamahata at valinux co jp>
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -35,17 +35,18 @@ from ryu.controller import controller

FLAGS = gflags.FLAGS
gflags.DEFINE_multistring('app_lists',
['ryu.app.simple_isolation',
'ryu.app.rest',
],
[],
'application module name to run')


def main():
utils.find_flagfile()
_args = FLAGS(sys.argv)
args = FLAGS(sys.argv)
log.init_log()

if len(args) > 1:
FLAGS.app_lists += args[1:]

app_mgr = AppManager()
app_mgr.load_apps(FLAGS.app_lists)
contexts = app_mgr.create_contexts()
Expand Down
10 changes: 9 additions & 1 deletion ryu/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,15 @@


def import_module(modname):
__import__(modname)
try:
__import__(modname)
except:
sys.path.append(os.path.dirname(os.path.abspath(modname)))
name = os.path.basename(modname)
if name.endswith('.py'):
name = name[:-3]
__import__(name)
return sys.modules[name]
return sys.modules[modname]


Expand Down

0 comments on commit c9f6b1b

Please sign in to comment.