Example #1
0
def forwarder():
    """Listens probes_endpoints and forwards messages to the plugins."""
    LOG = log.getLogger('kwapi')
    LOG.info('Forwarder listening to %s' % cfg.CONF.probes_endpoint)
    context = zmq.Context.instance()
    frontend = context.socket(zmq.XPUB)
    frontend.bind(cfg.CONF.forwarder_endpoint)
    backend = context.socket(zmq.XSUB)
    for endpoint in cfg.CONF.probes_endpoint:
        backend.connect(endpoint)
    poll = zmq.Poller()
    poll.register(frontend, zmq.POLLIN)
    poll.register(backend, zmq.POLLIN)
    while True:
        items = dict(poll.poll(1000))
        if items.get(backend) == zmq.POLLIN:
            msg = backend.recv_multipart()
            frontend.send_multipart(msg)
        elif items.get(frontend) == zmq.POLLIN:
            msg = frontend.recv()
            backend.send(msg)
Example #2
0
def forwarder():
    """Listens probes_endpoints and forwards messages to the plugins."""
    LOG = log.getLogger('kwapi')
    LOG.info('Forwarder listening to %s' % cfg.CONF.probes_endpoint)
    context = zmq.Context.instance()
    frontend = context.socket(zmq.XPUB)
    frontend.bind(cfg.CONF.forwarder_endpoint)
    backend = context.socket(zmq.XSUB)
    for endpoint in cfg.CONF.probes_endpoint:
        backend.connect(endpoint)
    poll = zmq.Poller()
    poll.register(frontend, zmq.POLLIN)
    poll.register(backend, zmq.POLLIN)
    while True:
        items = dict(poll.poll(1000))
        if items.get(backend) == zmq.POLLIN:
            msg = backend.recv_multipart()
            frontend.send_multipart(msg)
        elif items.get(frontend) == zmq.POLLIN:
            msg = frontend.recv()
            backend.send(msg)
Example #3
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 json
from threading import Thread, Event

from oslo.config import cfg
import zmq

from kwapi.openstack.common import log
from kwapi import security

LOG = log.getLogger(__name__)

driver_opts = [
    cfg.BoolOpt('enable_signing',
                required=True,
                ),
    cfg.StrOpt('metering_secret',
               required=True,
               ),
]

cfg.CONF.register_opts(driver_opts)


class Driver(Thread):
    """Generic driver class, derived from Thread."""