<commit_before># Copyright 2014 IBM Corp.
#
# All Rights Reserved.
#
#    Licensed under the Apache License, Version 2.0 (the "License"); you may
#    not use this file except in compliance with the License. You may obtain
#    a copy of the License at
#
#         http://www.apache.org/licenses/LICENSE-2.0
#
#    Unless required by applicable law or agreed to in writing, software
#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
#    License for the specific language governing permissions and limitations
#    under the License.


import functools

from oslo.config import cfg

from neutron.common import constants as n_const
from neutron.common import exceptions as n_exc
from neutron.common import rpc as n_rpc
from neutron.common import topics
from neutron.db import agents_db
from neutron.db import db_base_plugin_v2
from neutron.db import external_net_db
from neutron.db import l3_gwmode_db
from neutron.db import portbindings_db
from neutron.db import quota_db  # noqa
from neutron.extensions import portbindings
from neutron.openstack.common import excutils
from neutron.openstack.common import log as logging
from neutron.plugins.ibm.common import config  # noqa
from neutron.plugins.ibm.common import constants
from neutron.plugins.ibm.common import exceptions as sdnve_exc
from neutron.plugins.ibm import sdnve_api as sdnve
from neutron.plugins.ibm import sdnve_api_fake as sdnve_fake

LOG = logging.getLogger(__name__)


class SdnveRpcCallbacks():

    def __init__(self, notifier):
        self.notifier = notifier  # used to notify the agent

    def sdnve_info(self, rpc_context, **kwargs):
        '''Update new information.'''
        info = kwargs.get('info')
        # Notify all other listening agents
        self.notifier.info_update(rpc_context, info)
        return info


class AgentNotifierApi(n_rpc.RpcProxy):
    '''Agent side of the SDN-VE rpc API.'''

    BASE_RPC_API_VERSION = '1.0'

    def __init__(self, topic):
        super(AgentNotifierApi, self).__init__(
            topic=topic, default_version=self.BASE_RPC_API_VERSION)

        self.topic_info_update = topics.get_topic_name(topic,
                                                       constants.INFO,
                                                       topics.UPDATE)

    def info_update(self, context, info):
        self.fanout_cast(context,
                         self.make_msg('info_update',
                                       info=info),
                         topic=self.topic_info_update)<commit_msg>Drop RpcProxy usage from ibm plugin<commit_after># Copyright 2014 IBM Corp.
#
# All Rights Reserved.
#
#    Licensed under the Apache License, Version 2.0 (the "License"); you may
#    not use this file except in compliance with the License. You may obtain
#    a copy of the License at
#
#         http://www.apache.org/licenses/LICENSE-2.0
#
#    Unless required by applicable law or agreed to in writing, software
#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
#    License for the specific language governing permissions and limitations
#    under the License.


import functools

from oslo.config import cfg
from oslo import messaging

from neutron.common import constants as n_const
from neutron.common import exceptions as n_exc
from neutron.common import rpc as n_rpc
from neutron.common import topics
from neutron.db import agents_db
from neutron.db import db_base_plugin_v2
from neutron.db import external_net_db
from neutron.db import l3_gwmode_db
from neutron.db import portbindings_db
from neutron.db import quota_db  # noqa
from neutron.extensions import portbindings
from neutron.openstack.common import excutils
from neutron.openstack.common import log as logging
from neutron.plugins.ibm.common import config  # noqa
from neutron.plugins.ibm.common import constants
from neutron.plugins.ibm.common import exceptions as sdnve_exc
from neutron.plugins.ibm import sdnve_api as sdnve
from neutron.plugins.ibm import sdnve_api_fake as sdnve_fake

LOG = logging.getLogger(__name__)


class SdnveRpcCallbacks():

    def __init__(self, notifier):
        self.notifier = notifier  # used to notify the agent

    def sdnve_info(self, rpc_context, **kwargs):
        '''Update new information.'''
        info = kwargs.get('info')
        # Notify all other listening agents
        self.notifier.info_update(rpc_context, info)
        return info


class AgentNotifierApi(object):
    '''Agent side of the SDN-VE rpc API.'''

    def __init__(self, topic):
        target = messaging.Target(topic=topic, version='1.0')
        self.client = n_rpc.get_client(target)
        self.topic_info_update = topics.get_topic_name(topic,
                                                       constants.INFO,
                                                       topics.UPDATE)

    def info_update(self, context, info):
        cctxt = self.client.prepare(topic=self.topic_info_update, fanout=True)
        cctxt.cast(context, 'info_update', info=info)
{'fraction_non_alphanumeric': 0.06724470134874759, 'fraction_numerical': 0.004624277456647399, 'mean_word_length': 3.027152831652444, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 9, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3006779', 'n_tokens_mistral': 1468, 'n_tokens_neox': 1404, 'n_words': 493}