Пример #1
0
def notify(_context, message):
    """Notifies the recipient of the desired event given the model.
    Log notifications using openstack's default logging system"""

    priority = message.get('priority',
                           CONF.default_notification_level)
    priority = priority.lower()
    logger = logging.getLogger(
        'sm_api.openstack.common.notification.%s' %
        message['event_type'])
    getattr(logger, priority)(jsonutils.dumps(message))
Пример #2
0
def main():
    LOG = log.getLogger(__name__)
    LOG.info("Wait for sm to start...")
    # wait until sm start configuring before starting
    while not os.path.exists("/var/run/sm/sm.db"):
        time.sleep(5)

    sm_api_service.prepare_service(sys.argv)

    # Build and start the WSGI app
    host = CONF.sm_api_bind_ip or socket.gethostname()
    port = CONF.sm_api_port

    addrinfo_list = socket.getaddrinfo(host, port)
    addrinfo = addrinfo_list[0]
    socket_family = addrinfo[0]

    server_cls = simple_server.WSGIServer
    if socket.AF_INET6 == socket_family:
        server_cls = get_ipv6_server_cls()

    wsgi = simple_server.make_server(host,
                                     port,
                                     app.VersionSelectorApplication(),
                                     server_class=server_cls,
                                     handler_class=get_handler_cls())

    LOG.info("Serving on http://%(host)s:%(port)s" % {
        'host': host,
        'port': port
    })
    LOG.info("Configuration:")
    CONF.log_opt_values(LOG, logging.INFO)

    try:
        wsgi.serve_forever()
    except KeyboardInterrupt:
        pass
Пример #3
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.
#
# Copyright (c) 2013-2014 Wind River Systems, Inc.
#
'''messaging based notification driver, with message envelopes'''

from oslo_config import cfg

from sm_api.openstack.common import context as req_context
from sm_api.openstack.common.gettextutils import _
from sm_api.openstack.common import log as logging
from sm_api.openstack.common import rpc

LOG = logging.getLogger(__name__)

notification_topic_opt = cfg.ListOpt(
    'topics',
    default=[
        'notifications',
    ],
    help='AMQP topic(s) used for openstack notifications')

opt_group = cfg.OptGroup(name='rpc_notifier2',
                         title='Options for rpc_notifier2')

CONF = cfg.CONF
CONF.register_group(opt_group)
CONF.register_opt(notification_topic_opt, opt_group)
Пример #4
0
#    under the License.
#
# Copyright (c) 2013-2014 Wind River Systems, Inc.
#
"""Sm common internal object model"""

import collections

from sm_api.common import exception
from sm_api.objects import utils as obj_utils
from sm_api.openstack.common import context
from sm_api.openstack.common import log as logging
from sm_api.openstack.common.rpc import common as rpc_common
from sm_api.openstack.common.rpc import serializer as rpc_serializer

LOG = logging.getLogger('object')


def get_attrname(name):
    """Return the mangled name of the attribute's underlying storage."""
    return '_%s' % name


def make_class_properties(cls):
    # NOTE(danms): Inherit Sm_apiObject's base fields only
    cls.fields.update(Sm_apiObject.fields)
    for name, typefn in cls.fields.items():

        def getter(self, name=name):
            attrname = get_attrname(name)
            if not hasattr(self, attrname):