~ubuntu-branches/ubuntu/natty/nova/natty

« back to all changes in this revision

Viewing changes to nova/flags.py

  • Committer: Bazaar Package Importer
  • Author(s): Chuck Short, Chuck Short, Thierry Carrez
  • Date: 2011-02-25 14:01:06 UTC
  • mfrom: (1.1.10 upstream)
  • Revision ID: james.westby@ubuntu.com-20110225140106-0gfh4sof7wafe9ra
Tags: 2011.2~bzr740-0ubuntu1

[Chuck Short]
* New upstream release.

[Thierry Carrez]
* Add python-distutils-extra as build-dep (for i18n)
* Ship .mo files in /usr/share/locale
* Add lvdisplay to nova_sudoers, clean up dupe entries

Show diffs side-by-side

added added

removed removed

Lines of Context:
160
160
        raise KeyError(name)
161
161
 
162
162
 
163
 
FLAGS = FlagValues()
164
 
gflags.FLAGS = FLAGS
165
 
gflags.DEFINE_flag(gflags.HelpFlag(), FLAGS)
 
163
# Copied from gflags with small mods to get the naming correct.
 
164
# Originally gflags checks for the first module that is not gflags that is
 
165
# in the call chain, we want to check for the first module that is not gflags
 
166
# and not this module.
 
167
def _GetCallingModule():
 
168
    """Returns the name of the module that's calling into this module.
 
169
 
 
170
    We generally use this function to get the name of the module calling a
 
171
    DEFINE_foo... function.
 
172
    """
 
173
    # Walk down the stack to find the first globals dict that's not ours.
 
174
    for depth in range(1, sys.getrecursionlimit()):
 
175
        if not sys._getframe(depth).f_globals is globals():
 
176
            module_name = __GetModuleName(sys._getframe(depth).f_globals)
 
177
            if module_name == 'gflags':
 
178
                continue
 
179
            if module_name is not None:
 
180
                return module_name
 
181
    raise AssertionError("No module was found")
 
182
 
 
183
 
 
184
# Copied from gflags because it is a private function
 
185
def __GetModuleName(globals_dict):
 
186
    """Given a globals dict, returns the name of the module that defines it.
 
187
 
 
188
    Args:
 
189
    globals_dict: A dictionary that should correspond to an environment
 
190
      providing the values of the globals.
 
191
 
 
192
    Returns:
 
193
    A string (the name of the module) or None (if the module could not
 
194
    be identified.
 
195
    """
 
196
    for name, module in sys.modules.iteritems():
 
197
        if getattr(module, '__dict__', None) is globals_dict:
 
198
            if name == '__main__':
 
199
                return sys.argv[0]
 
200
            return name
 
201
    return None
166
202
 
167
203
 
168
204
def _wrapper(func):
173
209
    return _wrapped
174
210
 
175
211
 
 
212
FLAGS = FlagValues()
 
213
gflags.FLAGS = FLAGS
 
214
gflags._GetCallingModule = _GetCallingModule
 
215
 
 
216
 
176
217
DEFINE = _wrapper(gflags.DEFINE)
177
218
DEFINE_string = _wrapper(gflags.DEFINE_string)
178
219
DEFINE_integer = _wrapper(gflags.DEFINE_integer)
185
226
DEFINE_multistring = _wrapper(gflags.DEFINE_multistring)
186
227
DEFINE_multi_int = _wrapper(gflags.DEFINE_multi_int)
187
228
DEFINE_flag = _wrapper(gflags.DEFINE_flag)
188
 
 
189
 
 
190
229
HelpFlag = gflags.HelpFlag
191
230
HelpshortFlag = gflags.HelpshortFlag
192
231
HelpXMLFlag = gflags.HelpXMLFlag
285
324
DEFINE_string('logdir', None, 'output to a per-service log file in named '
286
325
                              'directory')
287
326
 
 
327
DEFINE_string('sqlite_db', 'nova.sqlite', 'file name for sqlite')
288
328
DEFINE_string('sql_connection',
289
 
              'sqlite:///$state_path/nova.sqlite',
 
329
              'sqlite:///$state_path/$sqlite_db',
290
330
              'connection string for sql database')
291
331
DEFINE_integer('sql_idle_timeout',
292
332
              3600,