8 Commits

Author SHA1 Message Date
Mark McLoughlin
68f28d257c Add CINDER_LOCALEDIR env variable
Part of fixing bug #995287

Syncs these two commits from oslo-incubator:

  Support overriding oslo localedir too
  Add a gettextutils.install() helper function

to get a new gettextutils.install() function which allows the default
localedir to be overwritten via an environment variable.

Note that gettextutils.install() must be called before any other cinder
modules are imported since some modules attempt to translate strings
at import time (e.g. in cinder.flags). This is broken and inefficient,
but fixing it involves adding something like sphinx's l_() function and
would be very invaisve.

Change-Id: I86562b3a65d371673bb21f7179eecc7602bc0775
2013-05-13 23:17:59 +08:00
Mark McLoughlin
7cfb0388ff Remove gettext.install() from cinder/__init__.py
The gettext.install() function installs a builtin _() function which
translates a string in the translation domain supplied to the install()
function. If gettext.install() is called multiple times, it's the last
call to the function which wins and the last supplied translation domain
which is used e.g.

 >>> import os
 >>> os.environ['LANG'] = 'ja.UTF-8'
 >>> import gettext
 >>> gettext.install('keystone', unicode=1, localedir='/opt/stack/keystone/keystone/locale')
 >>> print _('Invalid syslog facility')
  n無効な syslog ファシリティ
 >>> gettext.install('cinder', unicode=1, localedir='/opt/stack/nova/cinder/locale')
 >>> print _('Invalid syslog facility')
 Invalid syslog facility

Usually this function is called early on in a toplevel script and we
assume that no other code will call it and override the installed _().
However, in Cinder, we have taken a shortcut to avoid having to call it
explicitly from each script and instead call it from cinder/__init__.py.

This shortcut would be perfectly fine if we were absolutely sure that
nova modules would never be imported from another program. It's probably
quite incorrect for a program to use cinder code (indeed, if we wanted
to support this, Cinder code shouldn't use the default _() function) but
nevertheless there are some corner cases where it happens. For example,
the keystoneclient auth_token middleware tries to import cfg from
cinder.openstack and this in turn causes gettext.install('cinder') in
other projects like glance or quantum.

To avoid any doubt here, let's just rip out the shortcut and always
call gettext.install() from the top-level script.

However, there's a bit of an annoying detail here - by default,
nosetests starts in the current directly and tries to import all modules
it finds to look for tests. Without the _() builtin installed, importing
some modules like cinder.flags will fail.

Since it only ever makes sense to load tests from the cinder/tests dir,
we can ask nose to do that by using the --tests argument via setup.cfg.

Note, this means that if you previously did this:

  $> tox -- cinder.tests.foo cinder.tests.bar

then you must now do this:

  $> tox -- --tests cinder.tests.foo,cinder.tests.bar

Change-Id: If4125d6bcbde63df95de129ac5c83b4a6d6f130a
2013-05-13 18:45:25 +08:00
John Griffith
44a2b8949f Revert changes to monkey_patch.
As a work-around to deal with bug 1075838, we modified
monkey_patch in the Cinder binaries.  The root cause of the
issue is/was actually a bug in eventlet but this was a quick
work-around.

Since the change Change-Id: I69ba75136e32e95c6fdf108f0c4fe21a5e3bdbe6
to do this landed, the problem has also been addressed in Keystone.

So, let's revert this patch to get back the greenthread performance
that we may have lost with this change.  For now, everything should
be addressed as long as we don't implement multi api worker in Cinder,
if we do and the evenlet fix hasn't been released we'll need to turn
the modification back on for bin/cinder-api.

Change-Id: Ie845bade85dbceacd91f15e082325602d9a79c74
2012-11-28 12:23:28 -07:00
Vishvananda Ishaya
4e619fbef8 Fix 401 from auth_token middleware
The openssl popen call to verify the token returns an error code
of 2 when a file doesn't exist. Normally this is caught and the
relevant file is downloaded, but monkeypatching os causes this
error code to be eaten and cinder to return a 401. Note that this
is likely a race condition that depends on exactly when greenthreads
are switching that is causing the return code from Popen to get
overwritten.

It is possible that this is exposing an underlying bug in eventlet
but the workaround is simply to make sure that we don't monkeypatch
os.

Fixes bug 1075838

Change-Id: I69ba75136e32e95c6fdf108f0c4fe21a5e3bdbe6
2012-11-06 20:17:12 -08:00
Chmouel Boudjnah
fe716c0ee4 Use openstack.common.log for logging.
- We are not using openstack.common.notifier just yet so handedit
  openstack.common.log to use cinder.notifier now.

Change-Id: I9d912904c53a8ef5d90b4ab5792f5577701b6817
2012-07-20 12:12:12 +00:00
Mark McLoughlin
e435bca718 Use cfg's new global CONF object
Cherry picks 00786bc from Nova.

Implements blueprint cfg-global-object

Replace cinder.flags.FLAGS with openstack.common.cfg.CONF.

In future, we can do a s/FLAGS/CONF/ across the codebase.

Change-Id: If213a4a5da1faf96aac82f34b18d1e0b061495c0
2012-07-19 17:20:18 +01:00
Ghe Rivero
da97aa46d8 Remove old flagfile support
Cherry-picks 7e3e9b8 from Nova.

Change-Id: Id5a0ffabf7c6eab0bbda1b130a39a6581b26e350
2012-07-16 21:52:59 +01:00
Jenkins
c53d8e343e Initial fork out of Nova. 2012-05-03 10:48:26 -07:00