> Hi,
> 
> I referred to app/wsgi.py and wrote the application using simple
> oslo.config on Ryu2.2(patched) for testing the patch. However, it became
> the following errors when I execute the application. Do I misunderstand
> some?
> 
> ----------8<----------8<----------
> from oslo.config import cfg
> from ryu.base import app_manager
> 
> CONF = cfg.CONF
> CONF.register_cli_opts([

you can't use register_cli_opts for non-builtin modules.
you can use register_opts.

YAMAMOTO Takashi

>     cfg.StrOpt('hoge', default='', help=''),
> ])
> 
> class SampleApp(app_manager.RyuApp):
> 
>     def __init__(self, *args, **kwargs):
>         super(SampleApp, self).__init__(*args, **kwargs)
>         self.hoge = CONF.hoge
> ----------8<----------8<----------
> 
> ----------8<----------8<----------
> $ ryu-manager sample.py
> \x85(snip)\x85
> Traceback (most recent call last):
>   File "/home/satoshi/.virtualenvs/ryu22/bin/ryu-manager", line 86, in
> <module>
>     main()
>   File "/home/satoshi/.virtualenvs/ryu22/bin/ryu-manager", line 64, in main
>     app_mgr.load_apps(app_lists)
>   File
> "/home/satoshi/.virtualenvs/ryu22/lib/python2.6/site-packages/ryu/base/app_manager.py",
> line 171, in load_apps
>     cls = self.load_app(app_cls_name)
>   File
> "/home/satoshi/.virtualenvs/ryu22/lib/python2.6/site-packages/ryu/base/app_manager.py",
> line 153, in load_app
>     mod = utils.import_module(name)
>   File
> "/home/satoshi/.virtualenvs/ryu22/lib/python2.6/site-packages/ryu/utils.py",
> line 63, in import_module
>     return sys.modules[name]
> KeyError: 'sample'
> ----------8<----------8<----------
> 
> Thanks,
> Satoshi
> 
> 2013/8/28 FUJITA Tomonori <[email protected]>
> 
>> On Wed, 28 Aug 2013 12:45:12 +0900 (JST)
>> [email protected] (YAMAMOTO Takashi) wrote:
>>
>> > i don't think the patch makes sense.
>> >
>> > the real problem is that your command ends up with importing
>> > two copies of switches module.  you can avoid the problem by:
>> >     ryu-manager --verbose --observe-links ryu.topology.switches
>>
>> I guess that we had better to support passing a file name as a command
>> line option. Here is a workaround.
>>
>> diff --git a/ryu/utils.py b/ryu/utils.py
>> index d5b4479..13415ea 100644
>> --- a/ryu/utils.py
>> +++ b/ryu/utils.py
>> @@ -20,6 +20,7 @@ import logging
>>  import os
>>  import sys
>>  import re
>> +from oslo.config import cfg
>>
>>  LOG = logging.getLogger('ryu.utils')
>>
>> @@ -32,7 +33,17 @@ def import_module(modname):
>>          name = os.path.basename(modname)
>>          if name.endswith('.py'):
>>              name = name[:-3]
>> -        __import__(name)
>> +        try:
>> +            __import__(name)
>> +        except cfg.ArgsAlreadyParsedError:
>> +        # ryu-manager needs to import modules calling
>> +        # register_cli_opts. Thus, passing a imported file as a
>> +        # command line option for ryu-manager results in double import
>> +        # (e.g. ryu.topology.switches). The following code is not
>> +        # perfect but better than nothing.
>> +            for key in sys.modules.keys():
>> +                if key.endswith(name):
>> +                    return sys.modules[key]
>>          return sys.modules[name]
>>      return sys.modules[modname]
>>
>>
> 
> 
> -- 
> Satoshi Kobayashi <[email protected]>

------------------------------------------------------------------------------
Learn the latest--Visual Studio 2012, SharePoint 2013, SQL 2012, more!
Discover the easy way to master current and previous Microsoft technologies
and advance your career. Get an incredible 1,500+ hours of step-by-step
tutorial videos with LearnDevNow. Subscribe today and save!
http://pubads.g.doubleclick.net/gampad/clk?id=58040911&iu=/4140/ostg.clktrk
_______________________________________________
Ryu-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ryu-devel

Reply via email to