def BoundedSemaphore(count): warnings.warn( "The BoundedSemaphore class has moved! Please " "use semaphore.BoundedSemaphore instead.", DeprecationWarning, stacklevel=2) return semaphoremod.BoundedSemaphore(count)
def acquire_lock(obj_id, session): with _mutex: if obj_id not in _locks: _locks[obj_id] = (session, semaphore.BoundedSemaphore(1)) tup = _locks.get(obj_id) tup[1].acquire() # Make sure to update the dictionary once the lock is acquired # to adjust session ownership. _locks[obj_id] = (session, tup[1])
def __init__(self): super(BaseFilter, self).__init__() # Configuration check if (CONF.pxe_filter.deny_unknown_macs and CONF.processing.node_not_found_hook): msg = _('Configuration error: [pxe_filter]deny_unknown_macs is' 'enabled and [processing]node_not_found_hook is enabled.' 'These options cannot both be enabled simultaneously.') raise utils.Error(msg) self.lock = semaphore.BoundedSemaphore() self.fsm.initialize(start_state=States.uninitialized)
from eventlet import semaphore from oslo_config import cfg from ironic_inspector.common.i18n import _ from ironic_inspector.common import ironic as ir_utils from ironic_inspector import introspection_state as istate from ironic_inspector import node_cache from ironic_inspector.pxe_filter import base as pxe_filter from ironic_inspector import utils CONF = cfg.CONF LOG = utils.getProcessingLogger(__name__) _LAST_INTROSPECTION_TIME = 0 _LAST_INTROSPECTION_LOCK = semaphore.BoundedSemaphore() def introspect(node_id, manage_boot=True, token=None): """Initiate hardware properties introspection for a given node. :param node_id: node UUID or name :param manage_boot: whether to manage boot for this node :param token: authentication token :raises: Error """ ironic = ir_utils.get_client(token) node = ir_utils.get_node(node_id, ironic=ironic) ir_utils.check_provision_state(node) if manage_boot:
import subprocess from eventlet import semaphore from oslo_config import cfg from oslo_log import log from ironic_inspector.common.i18n import _LE, _LW from ironic_inspector.common import ironic as ir_utils from ironic_inspector import node_cache CONF = cfg.CONF LOG = log.getLogger("ironic_inspector.firewall") NEW_CHAIN = None CHAIN = None INTERFACE = None LOCK = semaphore.BoundedSemaphore() BASE_COMMAND = None BLACKLIST_CACHE = None ENABLED = True def _iptables(*args, **kwargs): # NOTE(dtantsur): -w flag makes it wait for xtables lock cmd = BASE_COMMAND + args ignore = kwargs.pop('ignore', False) LOG.debug('Running iptables %s', args) kwargs['stderr'] = subprocess.STDOUT try: subprocess.check_output(cmd, **kwargs) except subprocess.CalledProcessError as exc: output = exc.output.replace('\n', '. ')
def __init__(self): super(BaseFilter, self).__init__() self.lock = semaphore.BoundedSemaphore() self.fsm.initialize(start_state=States.uninitialized)
def __init__(self): self._trusts_keystone_client = None self._token_keystone_client = None self._cache = {} self._semaphore = semaphore.BoundedSemaphore()
def __init__(self, environment): self._trusts_keystone_client = None self._token_keystone_client = None self._cache = {} self._semaphore = semaphore.BoundedSemaphore() self._environment = weakref.proxy(environment)