def main():
    rpc.register_opts(FLAGS)
    FLAGS.register_opts([
            cfg.StrOpt('datafile',
                       default=None,
                       help='Data file to read or write',
                       ),
            cfg.BoolOpt('record',
                        help='Record events',
                        ),
            cfg.BoolOpt('replay',
                        help='Replay events',
                        ),
            ])

    remaining_args = FLAGS(sys.argv)
    utils.monkey_patch()

    parser = argparse.ArgumentParser(
        description='record or play back notification events',
        )
    parser.add_argument('mode',
                        choices=('record', 'replay', 'monitor'),
                        help='operating mode',
                        )
    parser.add_argument('data_file',
                        default='msgs.dat',
                        nargs='?',
                        help='the data file to read or write',
                        )
    parser.add_argument('--topic',
                        default='notifications.info',
                        help='the exchange topic to listen for',
                        )
    args = parser.parse_args(remaining_args[1:])

    console = logging.StreamHandler(sys.stderr)
    console.setLevel(logging.DEBUG)
    formatter = logging.Formatter('%(message)s')
    console.setFormatter(formatter)
    root_logger = logging.getLogger('')
    root_logger.addHandler(console)
    root_logger.setLevel(logging.DEBUG)

    connection = rpc.create_connection()
    try:
        if args.mode == 'replay':
            with open(args.data_file, 'rb') as input:
                send_messages(connection, args.topic, input)
        elif args.mode == 'record':
            with open(args.data_file, 'wb') as output:
                record_messages(connection, args.topic, output)
        elif args.mode == 'monitor':
            monitor_messages(connection, args.topic)
    finally:
        connection.close()

    return 0
Exemple #2
0
from __future__ import absolute_import

import itertools

from keystoneclient.v2_0 import client as ksclient
from glance.registry import client

from ceilometer import plugin
from ceilometer.counter import Counter
from ceilometer.openstack.common import cfg
from ceilometer.openstack.common import timeutils

cfg.CONF.register_opts([
    cfg.StrOpt('glance_registry_host',
               default='localhost',
               help="URL of Glance API server"),
    cfg.IntOpt('glance_registry_port',
               default=9191,
               help="URL of Glance API server"),
])


class _Base(plugin.PollsterBase):
    @staticmethod
    def get_registry_client():
        k = ksclient.Client(username=cfg.CONF.os_username,
                            password=cfg.CONF.os_password,
                            tenant_id=cfg.CONF.os_tenant_id,
                            tenant_name=cfg.CONF.os_tenant_name,
                            auth_url=cfg.CONF.os_auth_url)
Exemple #3
0
from ceilometer.openstack.common.gettextutils import _
from ceilometer.openstack.common import importutils
from ceilometer.openstack.common import jsonutils
from ceilometer.openstack.common.rpc import common as rpc_common

# for convenience, are not modified.
pformat = pprint.pformat
Timeout = eventlet.timeout.Timeout
LOG = rpc_common.LOG
RemoteError = rpc_common.RemoteError
RPCException = rpc_common.RPCException

zmq_opts = [
    cfg.StrOpt('rpc_zmq_bind_address',
               default='*',
               help='ZeroMQ bind address. Should be a wildcard (*), '
               'an ethernet interface, or IP. '
               'The "host" option should point or resolve to this '
               'address.'),

    # The module.Class to use for matchmaking.
    cfg.StrOpt(
        'rpc_zmq_matchmaker',
        default=('ceilometer.openstack.common.rpc.'
                 'matchmaker.MatchMakerLocalhost'),
        help='MatchMaker driver',
    ),

    # The following port is unassigned by IANA as of 2012-05-21
    cfg.IntOpt('rpc_zmq_port',
               default=9501,
               help='ZeroMQ receiver listening port'),
Exemple #4
0
#    License for the specific language governing permissions and limitations
#    under the License.
"""
A remote procedure call (rpc) abstraction.

For some wrappers that add message versioning to rpc, see:
    rpc.dispatcher
    rpc.proxy
"""

from ceilometer.openstack.common import cfg
from ceilometer.openstack.common import importutils

rpc_opts = [
    cfg.StrOpt('rpc_backend',
               default='%s.impl_kombu' % __package__,
               help="The messaging module to use, defaults to kombu."),
    cfg.IntOpt('rpc_thread_pool_size',
               default=64,
               help='Size of RPC thread pool'),
    cfg.IntOpt('rpc_conn_pool_size',
               default=30,
               help='Size of RPC connection pool'),
    cfg.IntOpt('rpc_response_timeout',
               default=60,
               help='Seconds to wait for a response from call or multicall'),
    cfg.IntOpt('rpc_cast_timeout',
               default=30,
               help='Seconds to wait before a cast expires (TTL). '
               'Only supported by impl_zmq.'),
    cfg.ListOpt('allowed_rpc_exception_modules',
Exemple #5
0
import os

from nova import flags

from ceilometer.openstack.common import log
from ceilometer.openstack.common import cfg

cfg.CONF.register_opts([
    cfg.IntOpt('periodic_interval',
               default=60,
               help='seconds between running periodic tasks')
])

CLI_OPTIONS = [
    cfg.StrOpt('os-username',
               default=os.environ.get('OS_USERNAME', 'glance'),
               help='Username to use for openstack service access'),
    cfg.StrOpt('os-password',
               default=os.environ.get('OS_PASSWORD', 'admin'),
               help='Password to use for openstack service access'),
    cfg.StrOpt('os-tenant-id',
               default=os.environ.get('OS_TENANT_ID', ''),
               help='Tenant ID to use for openstack service access'),
    cfg.StrOpt('os-tenant-name',
               default=os.environ.get('OS_TENANT_NAME', 'admin'),
               help='Tenant name to use for openstack service access'),
    cfg.StrOpt('os-auth-url',
               default=os.environ.get('OS_AUTH_URL',
                                      'http://localhost:5000/v2.0'),
               help='Auth URL to use for openstack service access'),
]
Exemple #6
0
import eventlet
import greenlet
import kombu
import kombu.connection
import kombu.entity
import kombu.messaging

from ceilometer.openstack.common import cfg
from ceilometer.openstack.common.gettextutils import _
from ceilometer.openstack.common.rpc import amqp as rpc_amqp
from ceilometer.openstack.common.rpc import common as rpc_common

kombu_opts = [
    cfg.StrOpt('kombu_ssl_version',
               default='',
               help='SSL version to use (valid only if SSL enabled)'),
    cfg.StrOpt('kombu_ssl_keyfile',
               default='',
               help='SSL key file (valid only if SSL enabled)'),
    cfg.StrOpt('kombu_ssl_certfile',
               default='',
               help='SSL cert file (valid only if SSL enabled)'),
    cfg.StrOpt('kombu_ssl_ca_certs',
               default='',
               help=('SSL certification authority file '
                     '(valid only if SSL enabled)')),
    cfg.StrOpt('rabbit_host',
               default='localhost',
               help='the RabbitMQ host'),
    cfg.IntOpt('rabbit_port',
Exemple #7
0
The MatchMaker classes should except a Topic or Fanout exchange key and
return keys for direct exchanges, per (approximate) AMQP parlance.
"""

import contextlib
import itertools
import json
import logging

from ceilometer.openstack.common import cfg
from ceilometer.openstack.common.gettextutils import _

matchmaker_opts = [
    # Matchmaker ring file
    cfg.StrOpt('matchmaker_ringfile',
               default='/etc/nova/matchmaker_ring.json',
               help='Matchmaker ring file (JSON)'),
]

CONF = cfg.CONF
CONF.register_opts(matchmaker_opts)
LOG = logging.getLogger(__name__)
contextmanager = contextlib.contextmanager


class MatchMakerException(Exception):
    """Signified a match could not be found."""
    message = _("Match not found by MatchMaker.")


class Exchange(object):
Exemple #8
0
# 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.
"""Compute the signature of a metering message.
"""

import hashlib
import hmac
import uuid

from ceilometer.openstack.common import cfg

METER_OPTS = [
    cfg.StrOpt('metering_secret',
               default='change this or be hacked',
               help='Secret value for signing metering messages',
               ),
    cfg.StrOpt('metering_topic',
               default='metering',
               help='the topic ceilometer uses for metering messages',
               ),
    ]

cfg.CONF.register_opts(METER_OPTS)


def recursive_keypairs(d):
    """Generator that produces sequence of keypairs for nested dictionaries.
    """
    for name, value in sorted(d.iteritems()):
        if isinstance(value, dict):
Exemple #9
0
from ceilometer.openstack.common.gettextutils import _
from ceilometer.openstack.common import importutils
from ceilometer.openstack.common import jsonutils
from ceilometer.openstack.common import log as logging
from ceilometer.openstack.common import timeutils


LOG = logging.getLogger(__name__)

notifier_opts = [
    cfg.MultiStrOpt('notification_driver',
                    default=[],
                    deprecated_name='list_notifier_drivers',
                    help='Driver or drivers to handle sending notifications'),
    cfg.StrOpt('default_notification_level',
               default='INFO',
               help='Default notification level for outgoing notifications'),
    cfg.StrOpt('default_publisher_id',
               default='$host',
               help='Default publisher_id for outgoing notifications'),
]

CONF = cfg.CONF
CONF.register_opts(notifier_opts)

WARN = 'WARN'
INFO = 'INFO'
ERROR = 'ERROR'
CRITICAL = 'CRITICAL'
DEBUG = 'DEBUG'
Exemple #10
0
import logging.handlers
import os
import stat
import sys
import traceback

from ceilometer.openstack.common import cfg
from ceilometer.openstack.common.gettextutils import _
from ceilometer.openstack.common import jsonutils
from ceilometer.openstack.common import local
from ceilometer.openstack.common import notifier

log_opts = [
    cfg.StrOpt('logging_context_format_string',
               default='%(asctime)s %(levelname)s %(name)s [%(request_id)s '
               '%(user_id)s %(project_id)s] %(instance)s'
               '%(message)s',
               help='format string to use for log messages with context'),
    cfg.StrOpt('logging_default_format_string',
               default='%(asctime)s %(levelname)s %(name)s [-] %(instance)s'
               '%(message)s',
               help='format string to use for log messages without context'),
    cfg.StrOpt('logging_debug_format_suffix',
               default='from (pid=%(process)d) %(funcName)s '
               '%(pathname)s:%(lineno)d',
               help='data to append to log format when level is DEBUG'),
    cfg.StrOpt('logging_exception_prefix',
               default='%(asctime)s TRACE %(name)s %(instance)s',
               help='prefix each line of exception output with this format'),
    cfg.ListOpt('default_log_levels',
                default=[