Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,15 @@

import oslo_serialization.jsonutils as jsonutils

from neutron.common import rpc as n_rpc
from oslo_config import cfg
from oslo_log import log as logging
import oslo_messaging
import pecan

from gbpservice.nfp.pecan import base_controller
from gbpservice.nfp.core import rpc

LOG = logging.getLogger(__name__)
n_rpc.init(cfg.CONF)


class Controller(base_controller.BaseController):
Expand Down Expand Up @@ -212,7 +211,7 @@ def __init__(self, topic):
target = oslo_messaging.Target(
topic=self.topic,
version=self.API_VERSION)
self.client = n_rpc.get_client(target)
self.client = rpc.get_client(target)

def call(self, method_name):
"""Method for sending call request on behalf of REST Controller.
Expand Down
11 changes: 9 additions & 2 deletions gbpservice/contrib/nfp/configurator/agents/loadbalancer_v1.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
# License for the specific language governing permissions and limitations
# under the License.

from neutron import context

from gbpservice.contrib.nfp.configurator.agents import agent_base
from gbpservice.contrib.nfp.configurator.lib import data_filter
Expand Down Expand Up @@ -406,7 +405,15 @@ def __init__(self, sc, drivers, rpcmgr):
poll event like collect_stats() does not have context, creating
context here, but should get rid of this in future.
"""
self.context = context.get_admin_context_without_session()
"""(mak)
Configurator will pass empty context.
Proxy agent will check if there is no context in response,
will get the admin context without session and does the
required rpc.
"""

# self.context = context.get_admin_context_without_session()
self.context = {}

def _get_driver(self, service_vendor):
"""Retrieves service driver instance based on service type
Expand Down
44 changes: 44 additions & 0 deletions gbpservice/contrib/nfp/configurator/lib/rpc.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import oslo_messaging
from oslo_service import service as oslo_service
from oslo_config import cfg as oslo_config

from gbpservice.nfp.core import log as nfp_logging

CONF = oslo_config.CONF
TRANSPORT = oslo_messaging.get_transport(CONF)

LOG = nfp_logging.getLogger(__name__)

def get_client(topic):
target = oslo_messaging.Target(topic=topic)
return oslo_messaging.RPCClient(TRANSPORT, target)


class RpcAgent(oslo_service.Service):
def __init__(self, host=None, topic=None, manager=None):
super(RpcAgent, self).__init__()
self.host = host
self.topic = topic
self.manager = manager
self.rpc_server = None

def start(self):
super(RpcAgent, self).start()
target = oslo_messaging.Target(
topic=self.topic,
server=self.host)
server = oslo_messaging.get_rpc_server(
TRANSPORT, target, [self.manager],
'eventlet')
server.start()
self.rpc_server = server


def stop(self):
try:
self.rpc_server.stop()
self.rpc_server.wait()
except Exception as exc:
LOG.error("Exception - %s" %(str(exc))

super(RPCAgent, self).stop()
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ def init_rpc(sc, cm, conf, demuxer):

# Initializes RPC client
rpc_mgr = ConfiguratorRpcManager(sc, cm, conf, demuxer)
configurator_agent = rpc.RpcAgent(sc,
configurator_agent = rpc.RpcAgent(
topic=const.CONFIGURATOR_RPC_TOPIC,
manager=rpc_mgr)

Expand Down