diff --git a/akanda/rug/debug.py b/akanda/rug/debug.py new file mode 100644 index 00000000..a29bb607 --- /dev/null +++ b/akanda/rug/debug.py @@ -0,0 +1,61 @@ +import logging +import os +import sys + +from oslo.config import cfg + +from akanda.rug import main +from akanda.rug import state + + +class Fake(object): + def __init__(self, crud): + self.crud = crud + + +def delete_callback(self): + print 'DELETE' + + +def bandwidth_callback(self, *args, **kwargs): + print 'BANDWIDTH:', args, kwargs + + +def debug_one_router(args=sys.argv[1:]): + + main.register_and_load_opts(args) + + # Add our extra option for specifying the router-id to debug + cfg.CONF.register_cli_opts([ + cfg.StrOpt('router-id', + required=True, + help='The UUID for the router to debug', + ), + ]) + cfg.CONF(args, project='akanda') + + logging.basicConfig( + level=logging.DEBUG, + format=':'.join('%(' + n + ')s' + for n in ['processName', + 'threadName', + 'name', + 'levelname', + 'message']), + ) + + log = logging.getLogger(__name__) + log.debug('Proxy settings: %r', os.getenv('no_proxy')) + + a = state.Automaton( + cfg.CONF.router_id, + delete_callback, + bandwidth_callback + ) + + a.send_message(Fake('update')) + + import pdb + pdb.set_trace() + + a.update() diff --git a/akanda/rug/main.py b/akanda/rug/main.py index 0ade3041..9e0ebdf4 100644 --- a/akanda/rug/main.py +++ b/akanda/rug/main.py @@ -141,11 +141,10 @@ def register_and_load_opts(argv): help='name of the exchange where we receive RPC calls'), ]) - cfg.CONF(argv, project='akanda') - def main(argv=sys.argv[1:]): register_and_load_opts(argv) + cfg.CONF(argv, project='akanda') log.setup('akanda-rug') cfg.CONF.log_opt_values(LOG, logging.INFO) diff --git a/setup.py b/setup.py index 3d99db62..d1665940 100644 --- a/setup.py +++ b/setup.py @@ -13,7 +13,9 @@ setup( 'httplib2>=0.7.2', 'python-neutronclient>=2.1', 'oslo.config', - 'kombu>=2.4.8' + 'kombu>=2.4.8', + 'webob', + 'python-novaclient', ], namespace_packages=['akanda'], packages=find_packages(exclude=['test']), @@ -22,6 +24,7 @@ setup( entry_points={ 'console_scripts': [ 'akanda-rug-service=akanda.rug.main:main', + 'akanda-debug-router=akanda.rug.debug:debug_one_router', ] }, )