summaryrefslogtreecommitdiffstats
path: root/keystone/__init__.py
diff options
context:
space:
mode:
authorBrant Knudson <bknudson@us.ibm.com>2013-05-09 17:32:24 -0500
committerBrant Knudson <bknudson@us.ibm.com>2013-05-09 21:09:45 -0500
commit6219f94b3a1103a16bd5f16ed8ffdd41a85280e1 (patch)
tree276cb0c43e0ecbcf45e405b5c7e13f4e41af83ec /keystone/__init__.py
parent693a486f39c9faca20383d211a7d30f6e5748168 (diff)
downloadkeystone-6219f94b3a1103a16bd5f16ed8ffdd41a85280e1.tar.gz
keystone-6219f94b3a1103a16bd5f16ed8ffdd41a85280e1.tar.xz
keystone-6219f94b3a1103a16bd5f16ed8ffdd41a85280e1.zip
Disable eventlet monkey-patching of DNS
This change avoids eventlet's monkey-patching of DNS resolution. eventlet's doesn't support IPv6, for example. The way to avoid eventlet's DNS is to set an environment variable. The trick is the environment variable needs to be set before eventlet is imported. A similar change was made in nova, so this is just copying that code and technique to keystone. This allows re-enabling the IPv6 tests, too. Change-Id: I30524a1cebd43580d692fd88ef32be45e62758c5
Diffstat (limited to 'keystone/__init__.py')
-rw-r--r--keystone/__init__.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/keystone/__init__.py b/keystone/__init__.py
index e69de29b..bfbd31a2 100644
--- a/keystone/__init__.py
+++ b/keystone/__init__.py
@@ -0,0 +1,15 @@
+
+import os
+import sys
+
+# NOTE(mikal): All of this is because if dnspython is present in your
+# environment then eventlet monkeypatches socket.getaddrinfo() with an
+# implementation which doesn't work for IPv6. What we're checking here is
+# that the magic environment variable was set when the import happened.
+if ('eventlet' in sys.modules and os.environ.get(
+ 'EVENTLET_NO_GREENDNS', '').lower() != 'yes'):
+ raise ImportError('eventlet imported before keystone '
+ '(env var set to %s)'
+ % os.environ.get('EVENTLET_NO_GREENDNS'))
+
+os.environ['EVENTLET_NO_GREENDNS'] = 'yes'