From 5126efec5ca991d9a17cc679e0195c5157f3f75a Mon Sep 17 00:00:00 2001 From: root Date: Tue, 1 Dec 2015 17:50:12 +0100 Subject: [PATCH] new oslo conf for rpc wamp server - removed useless code --- etc/iotronic/iotronic.conf | 5 ++++- iotronic/api/controllers/v1/node.py | 1 - iotronic/conductor/manager.py | 2 +- iotronic/db/sqlalchemy/api.py | 23 ----------------------- iotronic/objects/sessionwp.py | 4 +++- iotronic/wamp/functions.py | 4 +--- iotronic/wamp/rpcwampserver.py | 22 ++++++++++++++++++++-- 7 files changed, 29 insertions(+), 32 deletions(-) diff --git a/etc/iotronic/iotronic.conf b/etc/iotronic/iotronic.conf index c73b0d3..767caa4 100644 --- a/etc/iotronic/iotronic.conf +++ b/etc/iotronic/iotronic.conf @@ -23,4 +23,7 @@ auth_strategy=noauth [database] connection = mysql://:@/iotronic - +[wamp] +#wamp_ip = +#wamp_port = +#wamp_realm = s4t diff --git a/iotronic/api/controllers/v1/node.py b/iotronic/api/controllers/v1/node.py index d75189c..1874323 100644 --- a/iotronic/api/controllers/v1/node.py +++ b/iotronic/api/controllers/v1/node.py @@ -10,7 +10,6 @@ from iotronic.api.controllers import base from iotronic.common import exception import wsme import pecan -from pecan import rest import code diff --git a/iotronic/conductor/manager.py b/iotronic/conductor/manager.py index cf76333..773a3a2 100644 --- a/iotronic/conductor/manager.py +++ b/iotronic/conductor/manager.py @@ -718,7 +718,7 @@ class ConductorManager(periodic_task.PeriodicTasks): self.del_host() from iotronic.wamp.rpcwampserver import RPC_Wamp_Server - c=RPC_Wamp_Server('127.0.0.1','8181','s4t') + RPC_Wamp_Server() diff --git a/iotronic/db/sqlalchemy/api.py b/iotronic/db/sqlalchemy/api.py index f39a3b5..cc3e7b0 100644 --- a/iotronic/db/sqlalchemy/api.py +++ b/iotronic/db/sqlalchemy/api.py @@ -280,29 +280,6 @@ class Connection(api.Connection): raise exception.DuplicateCode(code=values['code']) raise exception.BoardAlreadyExists(uuid=values['uuid']) return node - """ - if 'uuid' not in values: - values['uuid'] = uuidutils.generate_uuid() - if 'power_state' not in values: - values['power_state'] = states.NOSTATE - if 'provision_state' not in values: - # TODO(deva): change this to ENROLL - values['provision_state'] = states.AVAILABLE - - node = models.Node() - node.update(values) - try: - node.save() - except db_exc.DBDuplicateEntry as exc: - if 'name' in exc.columns: - raise exception.DuplicateName(name=values['name']) - elif 'instance_uuid' in exc.columns: - raise exception.InstanceAssociated( - instance_uuid=values['instance_uuid'], - node=values['uuid']) - raise exception.NodeAlreadyExists(uuid=values['uuid']) - return node - """ def get_node_by_id(self, node_id): query = model_query(models.Node).filter_by(id=node_id) diff --git a/iotronic/objects/sessionwp.py b/iotronic/objects/sessionwp.py index b2b66e0..684c470 100644 --- a/iotronic/objects/sessionwp.py +++ b/iotronic/objects/sessionwp.py @@ -117,6 +117,7 @@ class SessionWP(base.IotronicObject): sort_dir=sort_dir) return SessionWP._from_db_object_list(db_sessions, cls, context) + ''' @base.remotable_classmethod def list_by_node_id(cls, context, node_id, limit=None, marker=None, sort_key=None, sort_dir=None): @@ -136,7 +137,8 @@ class SessionWP(base.IotronicObject): sort_key=sort_key, sort_dir=sort_dir) return SessionWP._from_db_object_list(db_sessions, cls, context) - + ''' + @base.remotable def create(self,context=None): """Create a SessionWP record in the DB. diff --git a/iotronic/wamp/functions.py b/iotronic/wamp/functions.py index 9b21c12..6ae816a 100644 --- a/iotronic/wamp/functions.py +++ b/iotronic/wamp/functions.py @@ -41,6 +41,4 @@ def registration(code_node,session_num): session.create() session.save() - return unicode(response) - - ''' \ No newline at end of file + return unicode(response) \ No newline at end of file diff --git a/iotronic/wamp/rpcwampserver.py b/iotronic/wamp/rpcwampserver.py index f2730e3..efd0470 100644 --- a/iotronic/wamp/rpcwampserver.py +++ b/iotronic/wamp/rpcwampserver.py @@ -3,9 +3,24 @@ from autobahn.twisted.wamp import ApplicationSession, ApplicationRunner import multiprocessing from twisted.internet import reactor from oslo_log import log +from oslo_config import cfg LOG = log.getLogger(__name__) +wamp_opts = [ + cfg.StrOpt('wamp_ip', + default='127.0.0.1', + help=('URL of wamp broker')), + cfg.IntOpt('wamp_port', + default=8181, + help='port wamp broker'), + cfg.StrOpt('wamp_realm', + default='s4t', + help=('realm broker')), +] +CONF = cfg.CONF +CONF.register_opts(wamp_opts, 'wamp') + class RPCWampManager(ApplicationSession): def __init__(self, config=None): @@ -61,8 +76,11 @@ class RPCWampServer: class RPC_Wamp_Server: - def __init__(self,ip,port,realm): - server = RPCWampServer(ip,port,realm) + def __init__(self): + self.ip=unicode(CONF.wamp.wamp_ip) + self.port=unicode(CONF.wamp.wamp_port) + self.realm=unicode(CONF.wamp.wamp_realm) + server = RPCWampServer(self.ip,self.port,self.realm) server.start() multi = multiprocessing.Process(target=reactor.run,args=()) multi.start()