Ejemplo n.º 1
0
 def test_try_import_returns_default(self):
     foo = importutils.try_import('foo.bar')
     self.assertEqual(None, foo)
Ejemplo n.º 2
0
import time

import eventlet
import greenlet
from oslo.config import cfg
import six

from openstack.common import excutils
from openstack.common.gettextutils import _, _LE, _LI
from openstack.common import importutils
from openstack.common import jsonutils
from openstack.common import log as logging
from openstack.common.rpc import amqp as rpc_amqp
from openstack.common.rpc import common as rpc_common

qpid_codec = importutils.try_import("qpid.codec010")
qpid_messaging = importutils.try_import("qpid.messaging")
qpid_exceptions = importutils.try_import("qpid.messaging.exceptions")

LOG = logging.getLogger(__name__)

qpid_opts = [
    cfg.StrOpt('qpid_hostname',
               default='localhost',
               help='Qpid broker hostname'),
    cfg.IntOpt('qpid_port',
               default=5672,
               help='Qpid broker port'),
    cfg.ListOpt('qpid_hosts',
                default=['$qpid_hostname:$qpid_port'],
                help='Qpid HA cluster host:port pairs'),
Ejemplo n.º 3
0
 def test_try_import(self):
     dt = importutils.try_import('datetime')
     self.assertEqual(sys.modules['datetime'], dt)
Ejemplo n.º 4
0
 def test_try_import(self):
     dt = importutils.try_import('datetime')
     self.assertEqual(sys.modules['datetime'], dt)
Ejemplo n.º 5
0
 def test_try_import_returns_default(self):
     foo = importutils.try_import('foo.bar')
     self.assertEqual(None, foo)
Ejemplo n.º 6
0
        import simplejson as json
        is_simplejson = True
    except ImportError:
        import json
else:
    import json

import six
import six.moves.xmlrpc_client as xmlrpclib

from openstack.common import gettextutils
from openstack.common import importutils
from openstack.common import strutils
from openstack.common import timeutils

netaddr = importutils.try_import("netaddr")

_nasty_type_tests = [
    inspect.ismodule, inspect.isclass, inspect.ismethod, inspect.isfunction,
    inspect.isgeneratorfunction, inspect.isgenerator, inspect.istraceback,
    inspect.isframe, inspect.iscode, inspect.isbuiltin, inspect.isroutine,
    inspect.isabstract
]

_simple_types = (six.string_types + six.integer_types +
                 (type(None), bool, float))


def to_primitive(value,
                 convert_instances=False,
                 convert_datetime=True,
Ejemplo n.º 7
0
import sys
import time

import eventlet
from eventlet import event
import logging as std_logging
from oslo.config import cfg

from openstack.common import eventlet_backdoor
from openstack.common.gettextutils import _  # noqa
from openstack.common import importutils
from openstack.common import log as logging
from openstack.common import threadgroup


rpc = importutils.try_import('openstack.common.rpc')
CONF = cfg.CONF
LOG = logging.getLogger(__name__)


def _sighup_supported():
    return hasattr(signal, 'SIGHUP')


def _is_sighup(signo):
    return _sighup_supported() and signo == signal.SIGHUP


def _signo_to_signame(signo):
    signals = {signal.SIGTERM: 'SIGTERM',
               signal.SIGINT: 'SIGINT'}
Ejemplo n.º 8
0
import string
import sys
import types
import uuid

import eventlet
import greenlet

from openstack.common import cfg
from openstack.common.gettextutils import _
from openstack.common import importutils
from openstack.common import jsonutils
from openstack.common import processutils as utils
from openstack.common.rpc import common as rpc_common

zmq = importutils.try_import('eventlet.green.zmq')

# 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.'),
Ejemplo n.º 9
0
    try:
        import simplejson as json
    except ImportError:
        import json
else:
    import json

import six
import six.moves.xmlrpc_client as xmlrpclib

from openstack.common import gettextutils
from openstack.common import importutils
from openstack.common import strutils
from openstack.common import timeutils

netaddr = importutils.try_import("netaddr")

_nasty_type_tests = [inspect.ismodule, inspect.isclass, inspect.ismethod,
                     inspect.isfunction, inspect.isgeneratorfunction,
                     inspect.isgenerator, inspect.istraceback, inspect.isframe,
                     inspect.iscode, inspect.isbuiltin, inspect.isroutine,
                     inspect.isabstract]

_simple_types = (six.string_types + six.integer_types
                 + (type(None), bool, float))


def to_primitive(value, convert_instances=False, convert_datetime=True,
                 level=0, max_depth=3):
    """Convert a complex object into primitives.
Ejemplo n.º 10
0
import itertools
import time
import uuid

import eventlet
import greenlet
from oslo.config import cfg

from openstack.common.gettextutils import _
from openstack.common import importutils
from openstack.common import jsonutils
from openstack.common import log as logging
from openstack.common.rpc import amqp as rpc_amqp
from openstack.common.rpc import common as rpc_common

qpid_messaging = importutils.try_import("qpid.messaging")
qpid_exceptions = importutils.try_import("qpid.messaging.exceptions")

LOG = logging.getLogger(__name__)

qpid_opts = [
    cfg.StrOpt('qpid_hostname',
               default='localhost',
               help='Qpid broker hostname'),
    cfg.IntOpt('qpid_port', default=5672, help='Qpid broker port'),
    cfg.ListOpt('qpid_hosts',
                default=['$qpid_hostname:$qpid_port'],
                help='Qpid HA cluster host:port pairs'),
    cfg.StrOpt('qpid_username',
               default='',
               help='Username for qpid connection'),
Ejemplo n.º 11
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.
"""
The MatchMaker classes should accept a Topic or Fanout exchange key and
return keys for direct exchanges, per (approximate) AMQP parlance.
"""

from oslo.config import cfg

from openstack.common import importutils
from openstack.common import log as logging
from openstack.common.rpc import matchmaker as mm_common

redis = importutils.try_import('redis')


matchmaker_redis_opts = [
    cfg.StrOpt('host',
               default='127.0.0.1',
               help='Host to locate redis'),
    cfg.IntOpt('port',
               default=6379,
               help='Use this port to connect to redis host.'),
    cfg.StrOpt('password',
               default=None,
               help='Password for Redis server. (optional)'),
]

CONF = cfg.CONF
Ejemplo n.º 12
0
from eventlet import db_pool
from eventlet import greenthread
from oslo.config import cfg
from sqlalchemy.exc import DisconnectionError, OperationalError, IntegrityError
import sqlalchemy.interfaces
import sqlalchemy.orm
from sqlalchemy.pool import NullPool, StaticPool
from sqlalchemy.sql.expression import literal_column

from openstack.common import importutils
from openstack.common import log as logging
from openstack.common.gettextutils import _
from openstack.common import timeutils

MySQLdb = importutils.try_import('MySQLdb')
if MySQLdb is not None:
    from MySQLdb.constants import CLIENT as mysql_client_constants

sql_opts = [
    cfg.StrOpt('sql_connection',
               default='sqlite:///' +
                       os.path.abspath(os.path.join(os.path.dirname(__file__),
                       '../', '$sqlite_db')),
               help='The SQLAlchemy connection string used to connect to the '
                    'database'),
    cfg.StrOpt('sqlite_db',
               default='oslo.sqlite',
               help='the filename to use with sqlite'),
    cfg.IntOpt('sql_idle_timeout',
               default=3600,
Ejemplo n.º 13
0
    # Python 2.6
    UnsupportedOperation = None

import eventlet
from eventlet import event
from oslo.config import cfg

from openstack.common import eventlet_backdoor
from openstack.common.gettextutils import _LE, _LI, _LW
from openstack.common import importutils
from openstack.common import log as logging
from openstack.common import systemd
from openstack.common import threadgroup


rpc = importutils.try_import('monasca.openstack.common.rpc')
CONF = cfg.CONF
LOG = logging.getLogger(__name__)


def _sighup_supported():
    return hasattr(signal, 'SIGHUP')


def _is_daemon():
    # The process group for a foreground process will match the
    # process group of the controlling terminal. If those values do
    # not match, or ioctl() fails on the stdout file handle, we assume
    # the process is running in the background as a daemon.
    # http://www.gnu.org/software/bash/manual/bashref.html#Job-Control-Basics
    try:
Ejemplo n.º 14
0
import signal
import sys
import time

import eventlet
import logging as std_logging
from oslo.config import cfg

from openstack.common import eventlet_backdoor
from openstack.common.gettextutils import _
from openstack.common import importutils
from openstack.common import log as logging
from openstack.common import threadgroup


rpc = importutils.try_import("openstack.common.rpc")
CONF = cfg.CONF
LOG = logging.getLogger(__name__)


class Launcher(object):
    """Launch one or more services and wait for them to complete."""

    def __init__(self):
        """Initialize the service launcher.

        :returns: None

        """
        self._services = threadgroup.ThreadGroup()
        self.backdoor_port = eventlet_backdoor.initialize_if_enabled()
Ejemplo n.º 15
0
    # Python 2.6
    UnsupportedOperation = None

import eventlet
from eventlet import event
from oslo.config import cfg

from openstack.common import eventlet_backdoor
from openstack.common.gettextutils import _LE, _LI, _LW
from openstack.common import importutils
from openstack.common import log as logging
from openstack.common import systemd
from openstack.common import threadgroup


rpc = importutils.try_import('openstack.common.rpc')
CONF = cfg.CONF
LOG = logging.getLogger(__name__)


def _sighup_supported():
    return hasattr(signal, 'SIGHUP')


def _is_daemon():
    # The process group for a foreground process will match the
    # process group of the controlling terminal. If those values do
    # not match, or ioctl() fails on the stdout file handle, we assume
    # the process is running in the background as a daemon.
    # http://www.gnu.org/software/bash/manual/bashref.html#Job-Control-Basics
    try:
Ejemplo n.º 16
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.

"""
The MatchMaker classes should accept a Topic or Fanout exchange key and
return keys for direct exchanges, per (approximate) AMQP parlance.
"""

from oslo.config import cfg

from openstack.common import importutils
from openstack.common import log as logging
from openstack.common.rpc import matchmaker as mm_common

redis = importutils.try_import('redis')


matchmaker_redis_opts = [
    cfg.StrOpt('host',
               default='127.0.0.1',
               help='Host to locate redis'),
    cfg.IntOpt('port',
               default=6379,
               help='Use this port to connect to redis host.'),
    cfg.StrOpt('password',
               help='Password for Redis server. (optional)'),
]

CONF = cfg.CONF
opt_group = cfg.OptGroup(name='matchmaker_redis',
Ejemplo n.º 17
0
import sys
import types
import uuid

import eventlet
import greenlet
from oslo.config import cfg

from openstack.common import excutils
from openstack.common.gettextutils import _
from openstack.common import importutils
from openstack.common import jsonutils
from openstack.common import processutils as utils
from openstack.common.rpc import common as rpc_common

zmq = importutils.try_import('eventlet.green.zmq')

# 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.'),
Ejemplo n.º 18
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.
"""
The MatchMaker classes should accept a Topic or Fanout exchange key and
return keys for direct exchanges, per (approximate) AMQP parlance.
"""

from oslo.config import cfg

from openstack.common import importutils
from openstack.common import log as logging
from openstack.common.rpc import matchmaker as mm_common

redis = importutils.try_import("redis")


matchmaker_redis_opts = [
    cfg.StrOpt("host", default="127.0.0.1", help="Host to locate redis"),
    cfg.IntOpt("port", default=6379, help="Use this port to connect to redis host."),
    cfg.StrOpt("password", default=None, help="Password for Redis server. (optional)"),
]

CONF = cfg.CONF
opt_group = cfg.OptGroup(name="matchmaker_redis", title="Options for Redis-based MatchMaker")
CONF.register_group(opt_group)
CONF.register_opts(matchmaker_redis_opts, opt_group)
LOG = logging.getLogger(__name__)