Ejemplo n.º 1
0
import eventlet
import greenlet
import kombu
import kombu.connection
import kombu.entity
import kombu.messaging

from billing.openstack.common import cfg
from billing.openstack.common.gettextutils import _
from billing.openstack.common.rpc import amqp as rpc_amqp
from billing.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', default=5672, help='the RabbitMQ port'),
    cfg.BoolOpt('rabbit_use_ssl',
                default=False,
Ejemplo n.º 2
0
"""
A remote procedure call (rpc) abstraction.

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

from billing.openstack.common import cfg
from billing.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',
Ejemplo n.º 3
0
Routines for configuring Billing
"""

import logging
import logging.config
import logging.handlers
import os
import sys

from paste import deploy

from billing.openstack.common import cfg
from billing import version

paste_deploy_opts = [
    cfg.StrOpt('flavor'),
    cfg.StrOpt('config_file'),
    ]
common_opts = [
    cfg.IntOpt('limit_param_default', default=25,
               help=_('Default value for the number of items returned by a '
               'request if not specified explicitly in the request')),
    cfg.IntOpt('api_limit_max', default=1000,
               help=_('Maximum permissible number of items that could be '
               'returned by a request')),
]

CONF = cfg.CONF
CONF.register_opts(paste_deploy_opts, group='paste_deploy')
CONF.register_opts(common_opts)
Ejemplo n.º 4
0
import datetime
import math

from billing.common import timeutils
from billing import exception
from billing.openstack import nova as nova_client
from billing.openstack.common import cfg
from billing.openstack.common import log

LOG = log.getLogger(__name__)

price_opts = [
    cfg.ListOpt('supported_items',
                default=['cpu', 'memory'],
                help='List of items supported for record.'),
    cfg.StrOpt('cpu_price', default=1,
               help='Per cpu price per minute'),
    cfg.StrOpt('memory_price', default=1,
               help='512M memory price per minute'),
]

CONF = cfg.CONF
CONF.register_opts(price_opts)


class PriceList(object):
    def __init__(self):
        self.value = None
        self.seconds = None
        self.price = None

    def get_price(self, item, value, seconds, price=None):
Ejemplo n.º 5
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 billing.openstack.common import cfg

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):
Ejemplo n.º 6
0
from billing.openstack.common.gettextutils import _
from billing.openstack.common import importutils
from billing.openstack.common import jsonutils
from billing.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='billing.'
               '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'),
    cfg.IntOpt('rpc_zmq_contexts',
               default=1,
Ejemplo n.º 7
0
#
#         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.

from billing.openstack.common import cfg
from billing.openstack.common import importutils

sql_connection_opt = [
    cfg.StrOpt('billing_sql_connection',
               default='sqlite:///billing.sqlite',
               metavar='CONNECTION',
               help='A valid SQLAlchemy connection '
               'string for the registry database. '
               'Default: %default'),
    cfg.StrOpt('data_api',
               default='billing.db.sqlalchemy.api',
               help='Python module path of data access API'),
]

CONF = cfg.CONF
CONF.register_opts(sql_connection_opt)


def add_cli_options():
    """
    Adds any configuration options that the db layer might have.
Ejemplo n.º 8
0
import logging.handlers
import os
import stat
import sys
import traceback

from billing.openstack.common import cfg
from billing.openstack.common import jsonutils
from billing.openstack.common import local
from billing.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=[
Ejemplo n.º 9
0
import inspect
import uuid

from billing.openstack.common import cfg
from billing.openstack.common import context
from billing.openstack.common import importutils
from billing.openstack.common import jsonutils
from billing.openstack.common import log as logging
from billing.openstack.common import timeutils

LOG = logging.getLogger(__name__)

notifier_opts = [
    cfg.StrOpt('notification_driver',
               default='billing.openstack.common.notifier.no_op_notifier',
               help='Default driver for 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'
Ejemplo n.º 10
0
from billing.openstack.common import cfg
from ceilometer import storage

from nova import manager

from billing.openstack import nova as nova_client
from billing import db
from billing import exception
from billing.common import timeutils
from billing.agent import price

LOG = log.getLogger(__name__)

user_opts = [
    cfg.StrOpt('admin_user',
               default='admin',
               help=_('Username of keystone admin user')),
    cfg.StrOpt('admin_password',
               default='secrete',
               help=_('Password of keystone admin user')),
]

METER_STORAGE_OPTS = [
    cfg.StrOpt(
        'metering_storage_engine',
        default='mongodb',
        help='The name of the storage engine to use',
    ),
    cfg.StrOpt(
        'database_connection',
        default='mongodb://localhost:27017/ceilometer',
Ejemplo n.º 11
0
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.

from billing.openstack.base import url_for

from billing.openstack.common import cfg

from novaclient.v1_1 import client as nova_client

from keystoneclient import service_catalog
from keystoneclient.v2_0 import client as keystone_client


keystone_urls = [
        cfg.StrOpt('auth_url', default='http://127.0.0.1:5000/v2.0',
                   help='Keystone auth url'),
        cfg.StrOpt('admin_url', default='http://127.0.0.1:35357/v2.0',
                   help='Keystone admin url')
]

CONF = cfg.CONF
CONF.register_opts(keystone_urls)


def keystoneclient(username=None, password=None,
                   tenant_id=None, token_id=None, admin=False):
    if admin:
        auth_url = CONF.admin_url
    else:
        auth_url = CONF.auth_url
    c = keystone_client.Client(username=username,
Ejemplo n.º 12
0
except ImportError:
    # FIXME(dhellmann): Trying to prevent errors
    # running the tests on stackforge, where qpid
    # is not installed.
    pass

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

LOG = logging.getLogger(__name__)

qpid_opts = [
    cfg.StrOpt('qpid_hostname',
               default='localhost',
               help='Qpid broker hostname'),
    cfg.StrOpt('qpid_port', default='5672', help='Qpid broker port'),
    cfg.StrOpt('qpid_username',
               default='',
               help='Username for qpid connection'),
    cfg.StrOpt('qpid_password',
               default='',
               help='Password for qpid connection'),
    cfg.StrOpt('qpid_sasl_mechanisms',
               default='',
               help='Space separated list of SASL mechanisms to use for auth'),
    cfg.BoolOpt('qpid_reconnect', default=True,
                help='Automatically reconnect'),
    cfg.IntOpt('qpid_reconnect_timeout',
               default=0,