]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Update Cinder's latest copy of OSLO grizzly stable
authorWalter A. Boring IV <walter.boring@hp.com>
Wed, 20 Mar 2013 20:18:12 +0000 (13:18 -0700)
committerWalter A. Boring IV <walter.boring@hp.com>
Wed, 20 Mar 2013 21:55:55 +0000 (14:55 -0700)
This patch updates all the files from oslo under
stable/grizzly but policy.py.  policy.py is a high risk
change at this date and it has lots of changes since the
last time we updated it.

Fixes bug #1157126

Change-Id: I399a1cd8474f718ed5196def90d2fea546fb01f5

41 files changed:
bin/cinder-rootwrap
bin/cinder-rpc-zmq-receiver
cinder/openstack/common/context.py
cinder/openstack/common/exception.py
cinder/openstack/common/excutils.py
cinder/openstack/common/fileutils.py
cinder/openstack/common/importutils.py
cinder/openstack/common/jsonutils.py
cinder/openstack/common/local.py
cinder/openstack/common/lockutils.py
cinder/openstack/common/network_utils.py
cinder/openstack/common/notifier/__init__.py
cinder/openstack/common/notifier/api.py
cinder/openstack/common/notifier/log_notifier.py
cinder/openstack/common/notifier/no_op_notifier.py
cinder/openstack/common/notifier/rpc_notifier.py [new file with mode: 0644]
cinder/openstack/common/notifier/rpc_notifier2.py [new file with mode: 0644]
cinder/openstack/common/notifier/test_notifier.py
cinder/openstack/common/rootwrap/__init__.py
cinder/openstack/common/rootwrap/filters.py
cinder/openstack/common/rootwrap/wrapper.py
cinder/openstack/common/rpc/amqp.py
cinder/openstack/common/rpc/impl_fake.py
cinder/openstack/common/rpc/impl_kombu.py
cinder/openstack/common/rpc/impl_qpid.py
cinder/openstack/common/rpc/impl_zmq.py
cinder/openstack/common/scheduler/filter.py
cinder/openstack/common/scheduler/filters/__init__.py
cinder/openstack/common/scheduler/filters/availability_zone_filter.py
cinder/openstack/common/scheduler/filters/capabilities_filter.py
cinder/openstack/common/scheduler/filters/extra_specs_ops.py
cinder/openstack/common/scheduler/filters/json_filter.py
cinder/openstack/common/scheduler/weight.py
cinder/openstack/common/scheduler/weights/__init__.py
cinder/openstack/common/setup.py
cinder/openstack/common/strutils.py
cinder/openstack/common/timeutils.py
cinder/openstack/common/version.py
etc/cinder/cinder.conf.sample
tools/flakes.py
tools/install_venv_common.py

index 959c9ff9095859c5e42feae2f3aedbe3bc1069fd..cb2a92f5eaf2dc0b2703f38e94cf3f98b3b7a695 100755 (executable)
@@ -1,7 +1,7 @@
 #!/usr/bin/env python
 # vim: tabstop=4 shiftwidth=4 softtabstop=4
 
-# Copyright (c) 2011 OpenStack, LLC.
+# Copyright (c) 2011 OpenStack Foundation.
 # All Rights Reserved.
 #
 #    Licensed under the Apache License, Version 2.0 (the "License"); you may
index 0e73727d97aaa0eed0b0a3fa5da01f6d2a09f0a8..e8dbf0effe009399434022b8bc7e6fc2b825646c 100755 (executable)
@@ -1,7 +1,7 @@
 #!/usr/bin/env python
 # vim: tabstop=4 shiftwidth=4 softtabstop=4
 
-#    Copyright 2011 OpenStack LLC
+#    Copyright 2011 OpenStack Foundation
 #
 #    Licensed under the Apache License, Version 2.0 (the "License"); you may
 #    not use this file except in compliance with the License. You may obtain
index dd7dd04c38a7846e7dd8d6da85fcf351632473f6..e9cfd73cc110a1d67ff18cb6e1cf12f481c3f063 100644 (file)
@@ -1,6 +1,6 @@
 # vim: tabstop=4 shiftwidth=4 softtabstop=4
 
-# Copyright 2011 OpenStack LLC.
+# Copyright 2011 OpenStack Foundation.
 # All Rights Reserved.
 #
 #    Licensed under the Apache License, Version 2.0 (the "License"); you may
@@ -37,9 +37,9 @@ class RequestContext(object):
     accesses the system, as well as additional request information.
     """
 
-    def __init__(self, auth_tok=None, user=None, tenant=None, is_admin=False,
+    def __init__(self, auth_token=None, user=None, tenant=None, is_admin=False,
                  read_only=False, show_deleted=False, request_id=None):
-        self.auth_tok = auth_tok
+        self.auth_token = auth_token
         self.user = user
         self.tenant = tenant
         self.is_admin = is_admin
@@ -55,7 +55,7 @@ class RequestContext(object):
                 'is_admin': self.is_admin,
                 'read_only': self.read_only,
                 'show_deleted': self.show_deleted,
-                'auth_token': self.auth_tok,
+                'auth_token': self.auth_token,
                 'request_id': self.request_id}
 
 
index ba32da550b01a1b353becc043b544fecde474eb7..c8690157f5797473b435a8ba8480c9d85c42027a 100644 (file)
@@ -1,6 +1,6 @@
 # vim: tabstop=4 shiftwidth=4 softtabstop=4
 
-# Copyright 2011 OpenStack LLC.
+# Copyright 2011 OpenStack Foundation.
 # All Rights Reserved.
 #
 #    Licensed under the Apache License, Version 2.0 (the "License"); you may
@@ -21,17 +21,9 @@ Exceptions common to OpenStack projects
 
 import logging
 
+from cinder.openstack.common.gettextutils import _
 
-class ProcessExecutionError(IOError):
-    def __init__(self, stdout=None, stderr=None, exit_code=None, cmd=None,
-                 description=None):
-        if description is None:
-            description = "Unexpected error while running command."
-        if exit_code is None:
-            exit_code = '-'
-        message = "%s\nCommand: %s\nExit code: %s\nStdout: %r\nStderr: %r" % (
-                  description, cmd, exit_code, stdout, stderr)
-        IOError.__init__(self, message)
+_FATAL_EXCEPTION_FORMAT_ERRORS = False
 
 
 class Error(Exception):
@@ -109,7 +101,7 @@ def wrap_exception(f):
         except Exception, e:
             if not isinstance(e, Error):
                 #exc_type, exc_value, exc_traceback = sys.exc_info()
-                logging.exception('Uncaught exception')
+                logging.exception(_('Uncaught exception'))
                 #logging.error(traceback.extract_stack(exc_traceback))
                 raise Error(str(e))
             raise
@@ -131,9 +123,12 @@ class OpenstackException(Exception):
         try:
             self._error_string = self.message % kwargs
 
-        except Exception:
-            # at least get the core message out if something happened
-            self._error_string = self.message
+        except Exception as e:
+            if _FATAL_EXCEPTION_FORMAT_ERRORS:
+                raise e
+            else:
+                # at least get the core message out if something happened
+                self._error_string = self.message
 
     def __str__(self):
         return self._error_string
index 9cfabcf4a853ed8f63442155c447c30d175d6aef..ccb2d072e9c47c77bcd6716186d9e398d9ac1e48 100644 (file)
@@ -1,6 +1,6 @@
 # vim: tabstop=4 shiftwidth=4 softtabstop=4
 
-# Copyright 2011 OpenStack LLC.
+# Copyright 2011 OpenStack Foundation.
 # Copyright 2012, Red Hat, Inc.
 #
 #    Licensed under the Apache License, Version 2.0 (the "License"); you may
index 4746ad4981417bbb0f9eb5727b2d38398bc5fff8..b988ad03d5c94ae7ead50051a2f6609032fac2aa 100644 (file)
@@ -1,6 +1,6 @@
 # vim: tabstop=4 shiftwidth=4 softtabstop=4
 
-# Copyright 2011 OpenStack LLC.
+# Copyright 2011 OpenStack Foundation.
 # All Rights Reserved.
 #
 #    Licensed under the Apache License, Version 2.0 (the "License"); you may
index 9dec764fb4097bf5860c562a514baec88571fe79..3bd277f47e2d4fc503c4b17f9f9b6b6c18473d41 100644 (file)
@@ -1,6 +1,6 @@
 # vim: tabstop=4 shiftwidth=4 softtabstop=4
 
-# Copyright 2011 OpenStack LLC.
+# Copyright 2011 OpenStack Foundation.
 # All Rights Reserved.
 #
 #    Licensed under the Apache License, Version 2.0 (the "License"); you may
index d3026744407c00499e332f3aeb2dced241dfafea..1e9262ed0df845483c48eef11870863019733040 100644 (file)
@@ -34,6 +34,7 @@ This module provides a few things:
 
 
 import datetime
+import functools
 import inspect
 import itertools
 import json
@@ -42,7 +43,8 @@ import xmlrpclib
 from cinder.openstack.common import timeutils
 
 
-def to_primitive(value, convert_instances=False, level=0):
+def to_primitive(value, convert_instances=False, convert_datetime=True,
+                 level=0, max_depth=3):
     """Convert a complex object into primitives.
 
     Handy for JSON serialization. We can optionally handle instances,
@@ -78,12 +80,17 @@ def to_primitive(value, convert_instances=False, level=0):
     if getattr(value, '__module__', None) == 'mox':
         return 'mock'
 
-    if level > 3:
+    if level > max_depth:
         return '?'
 
     # The try block may not be necessary after the class check above,
     # but just in case ...
     try:
+        recursive = functools.partial(to_primitive,
+                                      convert_instances=convert_instances,
+                                      convert_datetime=convert_datetime,
+                                      level=level,
+                                      max_depth=max_depth)
         # It's not clear why xmlrpclib created their own DateTime type, but
         # for our purposes, make it a datetime type which is explicitly
         # handled
@@ -91,33 +98,19 @@ def to_primitive(value, convert_instances=False, level=0):
             value = datetime.datetime(*tuple(value.timetuple())[:6])
 
         if isinstance(value, (list, tuple)):
-            o = []
-            for v in value:
-                o.append(to_primitive(v, convert_instances=convert_instances,
-                                      level=level))
-            return o
+            return [recursive(v) for v in value]
         elif isinstance(value, dict):
-            o = {}
-            for k, v in value.iteritems():
-                o[k] = to_primitive(v, convert_instances=convert_instances,
-                                    level=level)
-            return o
-        elif isinstance(value, datetime.datetime):
+            return dict((k, recursive(v)) for k, v in value.iteritems())
+        elif convert_datetime and isinstance(value, datetime.datetime):
             return timeutils.strtime(value)
         elif hasattr(value, 'iteritems'):
-            return to_primitive(dict(value.iteritems()),
-                                convert_instances=convert_instances,
-                                level=level + 1)
+            return recursive(dict(value.iteritems()), level=level + 1)
         elif hasattr(value, '__iter__'):
-            return to_primitive(list(value),
-                                convert_instances=convert_instances,
-                                level=level)
+            return recursive(list(value))
         elif convert_instances and hasattr(value, '__dict__'):
             # Likely an instance of something. Watch for cycles.
             # Ignore class member vars.
-            return to_primitive(value.__dict__,
-                                convert_instances=convert_instances,
-                                level=level + 1)
+            return recursive(value.__dict__, level=level + 1)
         else:
             return value
     except TypeError:
index 19d962732c18f61339bac06a4e503da8189725bf..f1bfc824bf6103c18f357c0dbcf57da9a76e4551 100644 (file)
@@ -1,6 +1,6 @@
 # vim: tabstop=4 shiftwidth=4 softtabstop=4
 
-# Copyright 2011 OpenStack LLC.
+# Copyright 2011 OpenStack Foundation.
 # All Rights Reserved.
 #
 #    Licensed under the Apache License, Version 2.0 (the "License"); you may
@@ -26,6 +26,9 @@ class WeakLocal(corolocal.local):
     def __getattribute__(self, attr):
         rval = corolocal.local.__getattribute__(self, attr)
         if rval:
+            # NOTE(mikal): this bit is confusing. What is stored is a weak
+            # reference, not the value itself. We therefore need to lookup
+            # the weak reference and return the inner value here.
             rval = rval()
         return rval
 
@@ -34,4 +37,12 @@ class WeakLocal(corolocal.local):
         return corolocal.local.__setattr__(self, attr, value)
 
 
+# NOTE(mikal): the name "store" should be deprecated in the future
 store = WeakLocal()
+
+# A "weak" store uses weak references and allows an object to fall out of scope
+# when it falls out of scope in the code that uses the thread local storage. A
+# "strong" store will hold a reference to the object so that it never falls out
+# of scope.
+weak_store = WeakLocal()
+strong_store = corolocal.local
index 7b0b22a0194faebe6563ab11ae72bdead0316d02..f5d260c213ecbeec2ec8f7f0d067399e8a235dc3 100644 (file)
@@ -1,6 +1,6 @@
 # vim: tabstop=4 shiftwidth=4 softtabstop=4
 
-# Copyright 2011 OpenStack LLC.
+# Copyright 2011 OpenStack Foundation.
 # All Rights Reserved.
 #
 #    Licensed under the Apache License, Version 2.0 (the "License"); you may
@@ -29,8 +29,10 @@ from oslo.config import cfg
 
 from cinder.openstack.common import fileutils
 from cinder.openstack.common.gettextutils import _
+from cinder.openstack.common import local
 from cinder.openstack.common import log as logging
 
+
 LOG = logging.getLogger(__name__)
 
 
@@ -38,9 +40,8 @@ util_opts = [
     cfg.BoolOpt('disable_process_locking', default=False,
                 help='Whether to disable inter-process locks'),
     cfg.StrOpt('lock_path',
-               default=os.path.abspath(os.path.join(os.path.dirname(__file__),
-                                                    '../')),
-               help='Directory to use for lock files')
+               help=('Directory to use for lock files. Default to a '
+                     'temp directory'))
 ]
 
 
@@ -106,10 +107,10 @@ class _InterProcessLock(object):
 
 class _WindowsLock(_InterProcessLock):
     def trylock(self):
-        msvcrt.locking(self.lockfile, msvcrt.LK_NBLCK, 1)
+        msvcrt.locking(self.lockfile.fileno(), msvcrt.LK_NBLCK, 1)
 
     def unlock(self):
-        msvcrt.locking(self.lockfile, msvcrt.LK_UNLCK, 1)
+        msvcrt.locking(self.lockfile.fileno(), msvcrt.LK_UNLCK, 1)
 
 
 class _PosixLock(_InterProcessLock):
@@ -139,7 +140,7 @@ def synchronized(name, lock_file_prefix, external=False, lock_path=None):
         def foo(self, *args):
            ...
 
-    ensures that only one thread will execute the bar method at a time.
+    ensures that only one thread will execute the foo method at a time.
 
     Different methods can share the same lock::
 
@@ -183,54 +184,66 @@ def synchronized(name, lock_file_prefix, external=False, lock_path=None):
                 LOG.debug(_('Got semaphore "%(lock)s" for method '
                             '"%(method)s"...'), {'lock': name,
                                                  'method': f.__name__})
-                if external and not CONF.disable_process_locking:
-                    LOG.debug(_('Attempting to grab file lock "%(lock)s" for '
-                                'method "%(method)s"...'),
-                              {'lock': name, 'method': f.__name__})
-                    cleanup_dir = False
-
-                    # We need a copy of lock_path because it is non-local
-                    local_lock_path = lock_path
-                    if not local_lock_path:
-                        local_lock_path = CONF.lock_path
-
-                    if not local_lock_path:
-                        cleanup_dir = True
-                        local_lock_path = tempfile.mkdtemp()
-
-                    if not os.path.exists(local_lock_path):
-                        cleanup_dir = True
-                        fileutils.ensure_tree(local_lock_path)
-
-                    # NOTE(mikal): the lock name cannot contain directory
-                    # separators
-                    safe_name = name.replace(os.sep, '_')
-                    lock_file_name = '%s%s' % (lock_file_prefix, safe_name)
-                    lock_file_path = os.path.join(local_lock_path,
-                                                  lock_file_name)
-
-                    try:
-                        lock = InterProcessLock(lock_file_path)
-                        with lock:
-                            LOG.debug(_('Got file lock "%(lock)s" at %(path)s '
-                                        'for method "%(method)s"...'),
+
+                # NOTE(mikal): I know this looks odd
+                if not hasattr(local.strong_store, 'locks_held'):
+                    local.strong_store.locks_held = []
+                local.strong_store.locks_held.append(name)
+
+                try:
+                    if external and not CONF.disable_process_locking:
+                        LOG.debug(_('Attempting to grab file lock "%(lock)s" '
+                                    'for method "%(method)s"...'),
+                                  {'lock': name, 'method': f.__name__})
+                        cleanup_dir = False
+
+                        # We need a copy of lock_path because it is non-local
+                        local_lock_path = lock_path
+                        if not local_lock_path:
+                            local_lock_path = CONF.lock_path
+
+                        if not local_lock_path:
+                            cleanup_dir = True
+                            local_lock_path = tempfile.mkdtemp()
+
+                        if not os.path.exists(local_lock_path):
+                            cleanup_dir = True
+                            fileutils.ensure_tree(local_lock_path)
+
+                        # NOTE(mikal): the lock name cannot contain directory
+                        # separators
+                        safe_name = name.replace(os.sep, '_')
+                        lock_file_name = '%s%s' % (lock_file_prefix, safe_name)
+                        lock_file_path = os.path.join(local_lock_path,
+                                                      lock_file_name)
+
+                        try:
+                            lock = InterProcessLock(lock_file_path)
+                            with lock:
+                                LOG.debug(_('Got file lock "%(lock)s" at '
+                                            '%(path)s for method '
+                                            '"%(method)s"...'),
+                                          {'lock': name,
+                                           'path': lock_file_path,
+                                           'method': f.__name__})
+                                retval = f(*args, **kwargs)
+                        finally:
+                            LOG.debug(_('Released file lock "%(lock)s" at '
+                                        '%(path)s for method "%(method)s"...'),
                                       {'lock': name,
                                        'path': lock_file_path,
                                        'method': f.__name__})
-                            retval = f(*args, **kwargs)
-                    finally:
-                        LOG.debug(_('Released file lock "%(lock)s" at %(path)s'
-                                    ' for method "%(method)s"...'),
-                                  {'lock': name,
-                                   'path': lock_file_path,
-                                   'method': f.__name__})
-                        # NOTE(vish): This removes the tempdir if we needed
-                        #             to create one. This is used to cleanup
-                        #             the locks left behind by unit tests.
-                        if cleanup_dir:
-                            shutil.rmtree(local_lock_path)
-                else:
-                    retval = f(*args, **kwargs)
+                            # NOTE(vish): This removes the tempdir if we needed
+                            #             to create one. This is used to
+                            #             cleanup the locks left behind by unit
+                            #             tests.
+                            if cleanup_dir:
+                                shutil.rmtree(local_lock_path)
+                    else:
+                        retval = f(*args, **kwargs)
+
+                finally:
+                    local.strong_store.locks_held.remove(name)
 
             return retval
         return inner
index 69f67321636c571d2c28b6a4f3cbd32e2f1901a8..5224e01aa9495faac90a3074b1677a4ebb430f79 100644 (file)
@@ -1,6 +1,6 @@
 # vim: tabstop=4 shiftwidth=4 softtabstop=4
 
-# Copyright 2012 OpenStack LLC.
+# Copyright 2012 OpenStack Foundation.
 # All Rights Reserved.
 #
 #    Licensed under the Apache License, Version 2.0 (the "License"); you may
index 482d54e4fdd3d796e779c26331ce834846463163..45c3b46ae93ba49d1f4f665a1a26dfa5aec94eed 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright 2011 OpenStack LLC.
+# Copyright 2011 OpenStack Foundation.
 # All Rights Reserved.
 #
 #    Licensed under the Apache License, Version 2.0 (the "License"); you may
index aa6c87d02940e9d3dca86e3cfb46cdcf0c5528fb..38b2daba738c3c5f9c12cd3ecb0a3c21bb5eeaf7 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright 2011 OpenStack LLC.
+# Copyright 2011 OpenStack Foundation.
 # All Rights Reserved.
 #
 #    Licensed under the Apache License, Version 2.0 (the "License"); you may
@@ -24,6 +24,7 @@ from cinder.openstack.common import jsonutils
 from cinder.openstack.common import log as logging
 from cinder.openstack.common import timeutils
 
+
 LOG = logging.getLogger(__name__)
 
 notifier_opts = [
index 800ab5dccf976fe7c2c1c286594f18fc233739c5..010d29cea3d777f5b1aff96260ea2dab24343b4b 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright 2011 OpenStack LLC.
+# Copyright 2011 OpenStack Foundation.
 # All Rights Reserved.
 #
 #    Licensed under the Apache License, Version 2.0 (the "License"); you may
@@ -18,6 +18,7 @@ from oslo.config import cfg
 from cinder.openstack.common import jsonutils
 from cinder.openstack.common import log as logging
 
+
 CONF = cfg.CONF
 
 
index ee1ddbdcac3a07b25036d0d7725df35c86715c31..bc7a56ca7ac0209c97dc9a1b83255b6850dcb77b 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright 2011 OpenStack LLC.
+# Copyright 2011 OpenStack Foundation.
 # All Rights Reserved.
 #
 #    Licensed under the Apache License, Version 2.0 (the "License"); you may
diff --git a/cinder/openstack/common/notifier/rpc_notifier.py b/cinder/openstack/common/notifier/rpc_notifier.py
new file mode 100644 (file)
index 0000000..46a95a1
--- /dev/null
@@ -0,0 +1,46 @@
+# Copyright 2011 OpenStack Foundation.
+# All Rights Reserved.
+#
+#    Licensed under the Apache License, Version 2.0 (the "License"); you may
+#    not use this file except in compliance with the License. You may obtain
+#    a copy of the License at
+#
+#         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 oslo.config import cfg
+
+from cinder.openstack.common import context as req_context
+from cinder.openstack.common.gettextutils import _
+from cinder.openstack.common import log as logging
+from cinder.openstack.common import rpc
+
+LOG = logging.getLogger(__name__)
+
+notification_topic_opt = cfg.ListOpt(
+    'notification_topics', default=['notifications', ],
+    help='AMQP topic used for openstack notifications')
+
+CONF = cfg.CONF
+CONF.register_opt(notification_topic_opt)
+
+
+def notify(context, message):
+    """Sends a notification via RPC"""
+    if not context:
+        context = req_context.get_admin_context()
+    priority = message.get('priority',
+                           CONF.default_notification_level)
+    priority = priority.lower()
+    for topic in CONF.notification_topics:
+        topic = '%s.%s' % (topic, priority)
+        try:
+            rpc.notify(context, topic, message)
+        except Exception:
+            LOG.exception(_("Could not send notification to %(topic)s. "
+                            "Payload=%(message)s"), locals())
diff --git a/cinder/openstack/common/notifier/rpc_notifier2.py b/cinder/openstack/common/notifier/rpc_notifier2.py
new file mode 100644 (file)
index 0000000..62a8eda
--- /dev/null
@@ -0,0 +1,52 @@
+# Copyright 2011 OpenStack Foundation.
+# All Rights Reserved.
+#
+#    Licensed under the Apache License, Version 2.0 (the "License"); you may
+#    not use this file except in compliance with the License. You may obtain
+#    a copy of the License at
+#
+#         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.
+
+'''messaging based notification driver, with message envelopes'''
+
+from oslo.config import cfg
+
+from cinder.openstack.common import context as req_context
+from cinder.openstack.common.gettextutils import _
+from cinder.openstack.common import log as logging
+from cinder.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)
+
+
+def notify(context, message):
+    """Sends a notification via RPC"""
+    if not context:
+        context = req_context.get_admin_context()
+    priority = message.get('priority',
+                           CONF.default_notification_level)
+    priority = priority.lower()
+    for topic in CONF.rpc_notifier2.topics:
+        topic = '%s.%s' % (topic, priority)
+        try:
+            rpc.notify(context, topic, message, envelope=True)
+        except Exception:
+            LOG.exception(_("Could not send notification to %(topic)s. "
+                            "Payload=%(message)s"), locals())
index 5e348803dc140625cfcbf13d8eea1654cbd8d2b3..96c1746bf42a175e3285a51f6751921eef7eb449 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright 2011 OpenStack LLC.
+# Copyright 2011 OpenStack Foundation.
 # All Rights Reserved.
 #
 #    Licensed under the Apache License, Version 2.0 (the "License"); you may
index 671d3c173e23ddcfd40b194a71dbaf272a8afba1..2d32e4ef3182127d96c73681c4788f2fd5ed5e54 100644 (file)
@@ -1,6 +1,6 @@
 # vim: tabstop=4 shiftwidth=4 softtabstop=4
 
-# Copyright (c) 2011 OpenStack, LLC.
+# Copyright (c) 2011 OpenStack Foundation.
 # All Rights Reserved.
 #
 #    Licensed under the Apache License, Version 2.0 (the "License"); you may
index 905bbabea76ac9bc827d511c3ade743fb7dd7315..eadda256ca8a5ce04da71c3304116e54bbaa6606 100644 (file)
@@ -1,6 +1,6 @@
 # vim: tabstop=4 shiftwidth=4 softtabstop=4
 
-# Copyright (c) 2011 OpenStack, LLC.
+# Copyright (c) 2011 OpenStack Foundation.
 # All Rights Reserved.
 #
 #    Licensed under the Apache License, Version 2.0 (the "License"); you may
index 06b121e659a01fdb69e1748a2256d8f27092b419..a8ab1239059c719d40ba79ba8589d30c114870f2 100644 (file)
@@ -1,6 +1,6 @@
 # vim: tabstop=4 shiftwidth=4 softtabstop=4
 
-# Copyright (c) 2011 OpenStack, LLC.
+# Copyright (c) 2011 OpenStack Foundation.
 # All Rights Reserved.
 #
 #    Licensed under the Apache License, Version 2.0 (the "License"); you may
index de90b528a4d4b7cf1bbaed41c8499a64d5344849..832511cd73f289f519e10482fe8720812977f9a9 100644 (file)
@@ -443,9 +443,11 @@ class ProxyCallback(_ThreadPoolWithWait):
                        connection_pool=self.connection_pool,
                        log_failure=False)
         except Exception:
-            LOG.exception(_('Exception during message handling'))
-            ctxt.reply(None, sys.exc_info(),
-                       connection_pool=self.connection_pool)
+            # sys.exc_info() is deleted by LOG.exception().
+            exc_info = sys.exc_info()
+            LOG.error(_('Exception during message handling'),
+                      exc_info=exc_info)
+            ctxt.reply(None, exc_info, connection_pool=self.connection_pool)
 
 
 class MulticallProxyWaiter(object):
index dfdcd5d9433465998cf6c338fdae4b9f83d60779..0f2f53500189cef17e858a0cea84b670ab1d9a40 100644 (file)
@@ -1,6 +1,6 @@
 # vim: tabstop=4 shiftwidth=4 softtabstop=4
 
-#    Copyright 2011 OpenStack LLC
+#    Copyright 2011 OpenStack Foundation
 #
 #    Licensed under the Apache License, Version 2.0 (the "License"); you may
 #    not use this file except in compliance with the License. You may obtain
index 3094a5e7f5f209d45c211b4520f6d83c4f796e95..681f531843d3fe580f99ca3264ab52367c188f5e 100644 (file)
@@ -1,6 +1,6 @@
 # vim: tabstop=4 shiftwidth=4 softtabstop=4
 
-#    Copyright 2011 OpenStack LLC
+#    Copyright 2011 OpenStack Foundation
 #
 #    Licensed under the Apache License, Version 2.0 (the "License"); you may
 #    not use this file except in compliance with the License. You may obtain
index 6a4b4f3ac2249bd7b50a543177e904927db52c0e..5f181cdd2c5cc3c8305fb8fc897c9b83267acc3a 100644 (file)
@@ -1,6 +1,6 @@
 # vim: tabstop=4 shiftwidth=4 softtabstop=4
 
-#    Copyright 2011 OpenStack LLC
+#    Copyright 2011 OpenStack Foundation
 #    Copyright 2011 - 2012, Red Hat, Inc.
 #
 #    Licensed under the Apache License, Version 2.0 (the "License"); you may
index 864f873040ceb679ad05bf44dec121bbffbae1d4..6e3d93bada4ef70ca2dd6f8eabaf0901ed472f4a 100644 (file)
@@ -16,6 +16,7 @@
 
 import os
 import pprint
+import re
 import socket
 import sys
 import types
@@ -431,6 +432,8 @@ class ZmqProxy(ZmqBaseReactor):
 
     def __init__(self, conf):
         super(ZmqProxy, self).__init__(conf)
+        pathsep = set((os.path.sep or '', os.path.altsep or '', '/', '\\'))
+        self.badchars = re.compile(r'[%s]' % re.escape(''.join(pathsep)))
 
         self.topic_proxy = {}
 
@@ -456,6 +459,13 @@ class ZmqProxy(ZmqBaseReactor):
                 LOG.info(_("Creating proxy for topic: %s"), topic)
 
                 try:
+                    # The topic is received over the network,
+                    # don't trust this input.
+                    if self.badchars.search(topic) is not None:
+                        emsg = _("Topic contained dangerous characters.")
+                        LOG.warn(emsg)
+                        raise RPCException(emsg)
+
                     out_sock = ZmqSocket("ipc://%s/zmq_topic_%s" %
                                          (ipc_dir, topic),
                                          sock_type, bind=True)
index 0bdb10d0f6e8d3325c38d09b0aad34261e9b4b6a..52c18afa3724f135ef806d20e2fc34d15e30108f 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright (c) 2011-2012 OpenStack, LLC.
+# Copyright (c) 2011-2012 OpenStack Foundation.
 # All Rights Reserved.
 #
 #    Licensed under the Apache License, Version 2.0 (the "License"); you may
index e47f835ba9b0a88a4493ba1f87cdd3dad1e6a769..40bf096a4195476e2e2553a0398a8173742384a1 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright (c) 2011 OpenStack, LLC.
+# Copyright (c) 2011 OpenStack Foundation.
 # All Rights Reserved.
 #
 #    Licensed under the Apache License, Version 2.0 (the "License"); you may
index 0be4bd18ac6647805ca81f6f70baa8bc3d662e56..0c3ca1ef74e82b1de6ee3982280505017fda81b2 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright (c) 2011-2012 OpenStack, LLC.
+# Copyright (c) 2011-2012 OpenStack Foundation.
 # All Rights Reserved.
 #
 #    Licensed under the Apache License, Version 2.0 (the "License"); you may
index cd84460d0d759eac414b6d9eeb8822c763a1a36c..41b638a2cb5668c9d37e65b916aab8f40313b1d7 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright (c) 2011 OpenStack, LLC.
+# Copyright (c) 2011 OpenStack Foundation.
 # All Rights Reserved.
 #
 #    Licensed under the Apache License, Version 2.0 (the "License"); you may
index 1565ff292c8367192579d6f231df81654dba10c4..b3730f5af4740dedc7ed5c9ee91cf36b30a95993 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright (c) 2011 OpenStack, LLC.
+# Copyright (c) 2011 OpenStack Foundation.
 # All Rights Reserved.
 #
 #    Licensed under the Apache License, Version 2.0 (the "License"); you may
index 0e3bb474ac919ba85ea0fcb43bfd689b372598e6..370f23b2ae65dad02531401e2741bbb861936b9b 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright (c) 2011 OpenStack, LLC.
+# Copyright (c) 2011 OpenStack Foundation.
 # All Rights Reserved.
 #
 #    Licensed under the Apache License, Version 2.0 (the "License"); you may
@@ -32,7 +32,7 @@ class JsonFilter(filters.BaseHostFilter):
         if len(args) < 2:
             return False
         if op is operator.contains:
-            bad = not args[0] in args[1:]
+            bad = args[0] not in args[1:]
         else:
             bad = [arg for arg in args[1:]
                    if not op(args[0], arg)]
index c5df9da029e5410fc3f2181c8a4b1f60322ad5ed..82f1d25ee3e9ae0b08694a852821ae12e284edfc 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright (c) 2011-2012 OpenStack, LLC.
+# Copyright (c) 2011-2012 OpenStack Foundation.
 # All Rights Reserved.
 #
 #    Licensed under the Apache License, Version 2.0 (the "License"); you may
index dd4b33209f98865abdef0602ea990f1c588199ad..a2743577d7a102ce5b6a550aa91189bbb756efe9 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright (c) 2011 OpenStack, LLC.
+# Copyright (c) 2011 OpenStack Foundation.
 # All Rights Reserved.
 #
 #    Licensed under the Apache License, Version 2.0 (the "License"); you may
index 80a0ecee88d37a89b99154e84b294d35af6baf98..030df61c99420bfbe02ff6db3bb0585d9b239d21 100644 (file)
@@ -1,6 +1,6 @@
 # vim: tabstop=4 shiftwidth=4 softtabstop=4
 
-# Copyright 2011 OpenStack LLC.
+# Copyright 2011 OpenStack Foundation.
 # Copyright 2012-2013 Hewlett-Packard Development Company, L.P.
 # All Rights Reserved.
 #
@@ -149,7 +149,7 @@ def write_git_changelog():
     git_dir = _get_git_directory()
     if not os.getenv('SKIP_WRITE_GIT_CHANGELOG'):
         if git_dir:
-            git_log_cmd = 'git --git-dir=%s log --stat' % git_dir
+            git_log_cmd = 'git --git-dir=%s log' % git_dir
             changelog = _run_shell_command(git_log_cmd)
             mailmap = _parse_git_mailmap(git_dir)
             with open(new_changelog, "w") as changelog_file:
index 7813b64225fdf449faaaea1f8a58fdde0e7e0233..ecf3cfdc4dae25f21a8a00ffeb01116c685e04cd 100644 (file)
@@ -1,6 +1,6 @@
 # vim: tabstop=4 shiftwidth=4 softtabstop=4
 
-# Copyright 2011 OpenStack LLC.
+# Copyright 2011 OpenStack Foundation.
 # All Rights Reserved.
 #
 #    Licensed under the Apache License, Version 2.0 (the "License"); you may
index 5a011e8181fe9f3e6b42504acb26478d2dc8e1f3..60943659076765f0f4838f476239262041a87b22 100644 (file)
@@ -1,6 +1,6 @@
 # vim: tabstop=4 shiftwidth=4 softtabstop=4
 
-# Copyright 2011 OpenStack LLC.
+# Copyright 2011 OpenStack Foundation.
 # All Rights Reserved.
 #
 #    Licensed under the Apache License, Version 2.0 (the "License"); you may
@@ -25,18 +25,22 @@ import datetime
 import iso8601
 
 
-TIME_FORMAT = "%Y-%m-%dT%H:%M:%S"
-PERFECT_TIME_FORMAT = "%Y-%m-%dT%H:%M:%S.%f"
+# ISO 8601 extended time format with microseconds
+_ISO8601_TIME_FORMAT_SUBSECOND = '%Y-%m-%dT%H:%M:%S.%f'
+_ISO8601_TIME_FORMAT = '%Y-%m-%dT%H:%M:%S'
+PERFECT_TIME_FORMAT = _ISO8601_TIME_FORMAT_SUBSECOND
 
 
-def isotime(at=None):
+def isotime(at=None, subsecond=False):
     """Stringify time in ISO 8601 format"""
     if not at:
         at = utcnow()
-    str = at.strftime(TIME_FORMAT)
+    st = at.strftime(_ISO8601_TIME_FORMAT
+                     if not subsecond
+                     else _ISO8601_TIME_FORMAT_SUBSECOND)
     tz = at.tzinfo.tzname(None) if at.tzinfo else 'UTC'
-    str += ('Z' if tz == 'UTC' else tz)
-    return str
+    st += ('Z' if tz == 'UTC' else tz)
+    return st
 
 
 def parse_isotime(timestr):
@@ -179,4 +183,4 @@ def is_soon(dt, window):
     :return: True if expiration is within the given duration
     """
     soon = (utcnow() + datetime.timedelta(seconds=window))
-    return normalize_time(dt) < soon
+    return normalize_time(dt) <= soon
index 3ed28e44c0c83622d52cb8d5a936bc50d8fa84ac..cfcd01b5827cbddf4bfad2c0bb2780f66997d9b5 100644 (file)
@@ -1,5 +1,5 @@
 
-#    Copyright 2012 OpenStack LLC
+#    Copyright 2012 OpenStack Foundation
 #    Copyright 2012-2013 Hewlett-Packard Development Company, L.P.
 #
 #    Licensed under the Apache License, Version 2.0 (the "License"); you may
index d0bd2f4da11b1063331ba3c569a6910bc67258bf..2036f7025ab69140a6ac06493606d7210b230e3f 100644 (file)
 #disable_process_locking=false
 
 # Directory to use for lock files (string value)
-#lock_path=/usr/lib/python/site-packages/cinder/openstack
+#lock_path=<None>
 
 
 #
index 7f96116ca54923aca789f00c3f7ab26a16ca5775..191bd6eabccbaa5142a04ebe54216dd435656f63 100644 (file)
@@ -4,12 +4,21 @@
 
  Synced in from openstack-common
 """
+
+__all__ = ['main']
+
+import __builtin__ as builtins
 import sys
 
-import pyflakes.checker
-from pyflakes.scripts import pyflakes
+import pyflakes.api
+from pyflakes import checker
+
+
+def main():
+    checker.Checker.builtIns = (set(dir(builtins)) |
+                                set(['_']) |
+                                set(checker._MAGIC_GLOBALS))
+    sys.exit(pyflakes.api.main())
 
 if __name__ == "__main__":
-    orig_builtins = set(pyflakes.checker._MAGIC_GLOBALS)
-    pyflakes.checker._MAGIC_GLOBALS = orig_builtins | set(['_'])
-    sys.exit(pyflakes.main())
+    main()
index fca2512299051ea51a6348d983de71bd00c7e2e6..413065640f42ea46bcf1829fb6b40858bb76185d 100644 (file)
@@ -1,6 +1,6 @@
 # vim: tabstop=4 shiftwidth=4 softtabstop=4
 
-# Copyright 2013 OpenStack, LLC
+# Copyright 2013 OpenStack Foundation
 # Copyright 2013 IBM Corp.
 #
 #    Licensed under the Apache License, Version 2.0 (the "License"); you may