from neutron.agent.linux import utils as linux_utils
from neutron.common import utils
+from neutron.openstack.common import lockutils
from neutron.openstack.common import log as logging
LOG = logging.getLogger(__name__)
self._apply()
- @utils.synchronized('iptables', external=True)
def _apply(self):
+ lock_name = 'iptables'
+ if self.namespace:
+ lock_name += '-' + self.namespace
+
+ try:
+ with lockutils.lock(lock_name, utils.SYNCHRONIZED_PREFIX, True):
+ LOG.debug(_('Got semaphore / lock "%s"'), lock_name)
+ return self._apply_synchronized()
+ finally:
+ LOG.debug(_('Semaphore / lock released "%s"'), lock_name)
+
+ def _apply_synchronized(self):
"""Apply the current in-memory set of iptables rules.
This will blow away any rules left over from previous runs of the
TIME_FORMAT = "%Y-%m-%dT%H:%M:%SZ"
LOG = logging.getLogger(__name__)
+SYNCHRONIZED_PREFIX = 'neutron-'
-synchronized = lockutils.synchronized_with_prefix('neutron-')
+synchronized = lockutils.synchronized_with_prefix(SYNCHRONIZED_PREFIX)
def read_cached_file(filename, cache_info, reload_func=None):