common Package

_i18n Module

oslo.i18n integration module.

See http://docs.openstack.org/developer/oslo.i18n/usage.html

eventlet_backdoor Module

exception keystone.openstack.common.eventlet_backdoor.EventletBackdoorConfigValueError(port_range, help_msg, ex)[source]

Bases: exceptions.Exception

keystone.openstack.common.eventlet_backdoor.initialize_if_enabled()[source]
keystone.openstack.common.eventlet_backdoor.list_opts()[source]

Entry point for oslo-config-generator.

fileutils Module

keystone.openstack.common.fileutils.delete_cached_file(filename)[source]

Delete cached file if present.

Parameters:filename – filename to delete
keystone.openstack.common.fileutils.delete_if_exists(path, remove=<built-in function unlink>)[source]

Delete a file, but ignore file not found error.

Parameters:
  • path – File to delete
  • remove – Optional function to remove passed path
keystone.openstack.common.fileutils.ensure_tree(path, mode=511)[source]

Create a directory (and any ancestor directories required)

Parameters:
  • path – Directory to create
  • mode – Directory creation permissions
keystone.openstack.common.fileutils.file_open(*args, **kwargs)[source]

Open file

see built-in open() documentation for more details

Note: The reason this is kept in a separate module is to easily be able to provide a stub module that doesn’t alter system state at all (for unit tests)

keystone.openstack.common.fileutils.read_cached_file(filename, force_reload=False)[source]

Read from a file if it has been modified.

Parameters:force_reload – Whether to reload the file.
Returns:A tuple with a boolean specifying if the data is fresh or not.
keystone.openstack.common.fileutils.remove_path_on_error(*args, **kwds)[source]

Protect code that wants to operate on PATH atomically. Any exception will cause PATH to be removed.

Parameters:
  • path – File to work with
  • remove – Optional function to remove passed path
keystone.openstack.common.fileutils.write_to_tempfile(content, path=None, suffix='', prefix='tmp')[source]

Create temporary file or use existing file.

This util is needed for creating temporary file with specified content, suffix and prefix. If path is not None, it will be used for writing content. If the path doesn’t exist it’ll be created.

Parameters:
  • content – content for temporary file.
  • path – same as parameter ‘dir’ for mkstemp
  • suffix – same as parameter ‘suffix’ for mkstemp
  • prefix – same as parameter ‘prefix’ for mkstemp

For example: it can be used in database tests for creating configuration files.

loopingcall Module

class keystone.openstack.common.loopingcall.DynamicLoopingCall(f=None, *args, **kw)[source]

Bases: keystone.openstack.common.loopingcall.LoopingCallBase

A looping call which sleeps until the next known event.

The function called should return how long to sleep for before being called again.

start(initial_delay=None, periodic_interval_max=None)[source]
class keystone.openstack.common.loopingcall.FixedIntervalLoopingCall(f=None, *args, **kw)[source]

Bases: keystone.openstack.common.loopingcall.LoopingCallBase

A fixed interval looping call.

start(interval, initial_delay=None)[source]
class keystone.openstack.common.loopingcall.LoopingCallBase(f=None, *args, **kw)[source]

Bases: object

stop()[source]
wait()[source]
exception keystone.openstack.common.loopingcall.LoopingCallDone(retvalue=True)[source]

Bases: exceptions.Exception

Exception to break out and stop a LoopingCallBase.

The poll-function passed to LoopingCallBase can raise this exception to break out of the loop normally. This is somewhat analogous to StopIteration.

An optional return-value can be included as the argument to the exception; this return-value will be returned by LoopingCallBase.wait()

service Module

Generic Node base class for all workers that run on hosts.

class keystone.openstack.common.service.Launcher[source]

Bases: object

Launch one or more services and wait for them to complete.

launch_service(service)[source]

Load and start the given service.

Parameters:service – The service you would like to start.
Returns:None
restart()[source]

Reload config files and restart service.

Returns:None
stop()[source]

Stop all services which are currently running.

Returns:None
wait()[source]

Waits until all services have been stopped, and then returns.

Returns:None
class keystone.openstack.common.service.ProcessLauncher(wait_interval=0.01)[source]

Bases: object

handle_signal()[source]
launch_service(service, workers=1)[source]
stop()[source]

Terminate child processes and wait on each.

wait()[source]

Loop waiting on children to die and respawning as necessary.

class keystone.openstack.common.service.Service(threads=1000)[source]

Bases: object

Service object for binaries running on hosts.

reset()[source]
start()[source]
stop(graceful=False)[source]
wait()[source]
class keystone.openstack.common.service.ServiceLauncher[source]

Bases: keystone.openstack.common.service.Launcher

handle_signal()[source]
wait(ready_callback=None)[source]
class keystone.openstack.common.service.ServiceWrapper(service, workers)[source]

Bases: object

class keystone.openstack.common.service.Services[source]

Bases: object

add(service)[source]
restart()[source]
static run_service(service, done)[source]

Service start wrapper.

Parameters:
  • service – service to run
  • done – event to wait on until a shutdown is triggered
Returns:

None

stop()[source]
wait()[source]
exception keystone.openstack.common.service.SignalExit(signo, exccode=1)[source]

Bases: exceptions.SystemExit

keystone.openstack.common.service.launch(service, workers=1)[source]

systemd Module

Helper module for systemd service readiness notification.

keystone.openstack.common.systemd.notify()[source]

Send notification to Systemd that service is ready.

For details see http://www.freedesktop.org/software/systemd/man/sd_notify.html

keystone.openstack.common.systemd.notify_once()[source]

Send notification once to Systemd that service is ready.

Systemd sets NOTIFY_SOCKET environment variable with the name of the socket listening for notifications from services. This method removes the NOTIFY_SOCKET environment variable to ensure notification is sent only once.

keystone.openstack.common.systemd.onready(notify_socket, timeout)[source]

Wait for systemd style notification on the socket.

Parameters:
  • notify_socket (string) – local socket address
  • timeout (float) – socket timeout
Returns:

0 service ready 1 service not ready 2 timeout occurred

threadgroup Module

class keystone.openstack.common.threadgroup.Thread(thread, group)[source]

Bases: object

Wrapper around a greenthread, that holds a reference to the ThreadGroup. The Thread will notify the ThreadGroup when it has done so it can be removed from the threads list.

stop()[source]
wait()[source]
class keystone.openstack.common.threadgroup.ThreadGroup(thread_pool_size=10)[source]

Bases: object

The point of the ThreadGroup class is to:

  • keep track of timers and greenthreads (making it easier to stop them when need be).
  • provide an easy API to add timers.
add_dynamic_timer(callback, initial_delay=None, periodic_interval_max=None, *args, **kwargs)[source]
add_thread(callback, *args, **kwargs)[source]
add_timer(interval, callback, initial_delay=None, *args, **kwargs)[source]
stop(graceful=False)[source]

stop function has the option of graceful=True/False.

  • In case of graceful=True, wait for all threads to be finished. Never kill threads.
  • In case of graceful=False, kill threads immediately.
stop_timers()[source]
thread_done(thread)[source]
wait()[source]

versionutils Module

Helpers for comparing version strings.

exception keystone.openstack.common.versionutils.DeprecatedConfig(msg)[source]

Bases: exceptions.Exception

message = u'Fatal call to deprecated config: %(msg)s'
class keystone.openstack.common.versionutils.deprecated(as_of, in_favor_of=None, remove_in=2, what=None)[source]

Bases: object

A decorator to mark callables as deprecated.

This decorator logs a deprecation message when the callable it decorates is used. The message will include the release where the callable was deprecated, the release where it may be removed and possibly an optional replacement.

Examples:

  1. Specifying the required deprecated release
>>> @deprecated(as_of=deprecated.ICEHOUSE)
... def a(): pass
  1. Specifying a replacement:
>>> @deprecated(as_of=deprecated.ICEHOUSE, in_favor_of='f()')
... def b(): pass
  1. Specifying the release where the functionality may be removed:
>>> @deprecated(as_of=deprecated.ICEHOUSE, remove_in=+1)
... def c(): pass

4. Specifying the deprecated functionality will not be removed: >>> @deprecated(as_of=deprecated.ICEHOUSE, remove_in=0) ... def d(): pass

5. Specifying a replacement, deprecated functionality will not be removed: >>> @deprecated(as_of=deprecated.ICEHOUSE, in_favor_of=’f()’, remove_in=0) ... def e(): pass

BEXAR = 'B'
FOLSOM = 'F'
GRIZZLY = 'G'
HAVANA = 'H'
ICEHOUSE = 'I'
JUNO = 'J'
KILO = 'K'
LIBERTY = 'L'
keystone.openstack.common.versionutils.is_compatible(requested_version, current_version, same_major=True)[source]

Determine whether requested_version is satisfied by current_version; in other words, current_version is >= requested_version.

Parameters:
  • requested_version – version to check for compatibility
  • current_version – version to check against
  • same_major – if True, the major version must be identical between requested_version and current_version. This is used when a major-version difference indicates incompatibility between the two versions. Since this is the common-case in practice, the default is True.
Returns:

True if compatible, False if not

keystone.openstack.common.versionutils.list_opts()[source]

Entry point for oslo.config-generator.

keystone.openstack.common.versionutils.report_deprecated_feature(logger, msg, *args, **kwargs)[source]

Call this function when a deprecated feature is used.

If the system is configured for fatal deprecations then the message is logged at the ‘critical’ level and DeprecatedConfig will be raised.

Otherwise, the message will be logged (once) at the ‘warn’ level.

Raises :DeprecatedConfig if the system is configured for fatal deprecations.

Table Of Contents

Previous topic

openstack Package

Next topic

policy Package

This Page