Update patches
[openstack-build/cinder-build.git] / rpm / SOURCES / 0002-Use-updated-parallel-install-versions-of-epel-packag.patch
1 From c8b9384ccf0e9c69f35978f3abbb5e5d5638d859 Mon Sep 17 00:00:00 2001
2 From: =?UTF-8?q?P=C3=A1draig=20Brady?= <P@draigBrady.com>
3 Date: Wed, 24 Oct 2012 13:44:37 +0100
4 Subject: [PATCH] Use updated parallel install versions of epel package
5
6 Use sqlalchemy >= 0.6.3 WebOb >= 1.2 Routes >= 1.12.3 PasteDeploy >= 1.5.0
7 and depend on the parallel installable
8 versions of these packages to satisfy those requirements.
9
10 Delve into pkg_resources a little to get it to modify sys.path,
11 so that our parallel installed egg takes precedence over the
12 system default module versions.
13 ---
14  bin/cinder-manage                 |  4 +++-
15  cinder/__init__.py                | 30 ++++++++++++++++++++++++++++++
16  cinder/db/sqlalchemy/migration.py |  7 ++++++-
17  3 files changed, 39 insertions(+), 2 deletions(-)
18
19 diff --git a/bin/cinder-manage b/bin/cinder-manage
20 index 3c05d77..9474e2e 100755
21 --- a/bin/cinder-manage
22 +++ b/bin/cinder-manage
23 @@ -62,7 +62,6 @@ import sys
24  
25  from oslo.config import cfg
26  
27 -
28  # If ../cinder/__init__.py exists, add ../ to Python search path, so that
29  # it will override what happens to be installed in /usr/(local/)lib/python...
30  POSSIBLE_TOPDIR = os.path.normpath(os.path.join(os.path.abspath(sys.argv[0]),
31 @@ -84,6 +83,9 @@ from cinder.openstack.common import uuidutils
32  from cinder import utils
33  from cinder import version
34  
35 +from sqlalchemy import create_engine, MetaData, Table
36 +from sqlalchemy.ext.declarative import declarative_base
37 +from sqlalchemy.orm import sessionmaker
38  
39  CONF = cfg.CONF
40  
41 diff --git a/cinder/__init__.py b/cinder/__init__.py
42 index d765b08..720320e 100644
43 --- a/cinder/__init__.py
44 +++ b/cinder/__init__.py
45 @@ -30,3 +30,33 @@
46  .. moduleauthor:: Manish Singh <yosh@gimp.org>
47  .. moduleauthor:: Andy Smith <andy@anarkystic.com>
48  """
49 +
50 +import sys
51 +import pkg_resources
52 +
53 +# If there is a conflicting non egg module,
54 +# i.e. an older standard system module installed,
55 +# then replace it with this requirement
56 +def replace_dist(requirement):
57 +    try:
58 +        return pkg_resources.require(requirement)
59 +    except pkg_resources.VersionConflict:
60 +        e = sys.exc_info()[1]
61 +        dist=e.args[0]
62 +        req=e.args[1]
63 +        if dist.key == req.key and not dist.location.endswith('.egg'):
64 +            del pkg_resources.working_set.by_key[dist.key]
65 +            # We assume there is no need to adjust sys.path
66 +            # and the associated pkg_resources.working_set.entries
67 +            return pkg_resources.require(requirement)
68 +
69 +replace_dist("WebOb >= 1.2")
70 +replace_dist("SQLAlchemy >= 0.6.3")
71 +replace_dist("Routes >= 1.12.3")
72 +
73 +replace_dist("PasteDeploy >= 1.5.0")
74 +# This hack is needed because replace_dist() results in
75 +# the standard paste module path being at the start of __path__.
76 +# TODO: See can we get pkg_resources to do the right thing directly
77 +import paste
78 +paste.__path__.insert(0, paste.__path__.pop(-1))
79 diff --git a/cinder/db/sqlalchemy/migration.py b/cinder/db/sqlalchemy/migration.py
80 index e2463bc..9ba7b73 100644
81 --- a/cinder/db/sqlalchemy/migration.py
82 +++ b/cinder/db/sqlalchemy/migration.py
83 @@ -56,7 +56,12 @@ if (not hasattr(migrate, '__version__') or
84  
85  
86  # NOTE(jkoelker) Delay importing migrate until we are patched
87 -from migrate import exceptions as versioning_exceptions
88 +try:
89 +    # Try the more specific path first (migrate <= 0.6)
90 +    from migrate.versioning import exceptions as versioning_exceptions
91 +except ImportError:
92 +    # Use the newer path (migrate >= 0.7)
93 +    from migrate import exceptions as versioning_exceptions
94  from migrate.versioning import api as versioning_api
95  from migrate.versioning.repository import Repository
96