Пример #1
0
 def __enter__(self):
     self.conntrack_handler = nfct.nfct_open(
         nl_constants.CONNTRACK, nl_constants.NFNL_SUBSYS_CTNETLINK)
     if not self.conntrack_handler:
         msg = _("Failed to open new conntrack handler")
         LOG.critical(msg)
         raise exceptions.CTZoneExhaustedError()
     return self
Пример #2
0
 def delete_entries(self, entries):
     conntrack = nfct.nfct_new()
     try:
         for entry in entries:
             self._set_attributes(conntrack, entry)
             self._query(nl_constants.NFCT_Q_DESTROY, conntrack)
     except Exception as e:
         msg = _("Failed to delete conntrack entries %s") % e
         LOG.critical(msg)
         raise exceptions.CTZoneExhaustedError()
     finally:
         nfct.nfct_destroy(conntrack)
Пример #3
0
 def _find_open_zone(self):
     # call set to dedup because old ports may be mapped to the same zone.
     zones_in_use = sorted(set(self._device_zone_map.values()))
     if not zones_in_use:
         return 1
     # attempt to increment onto the highest used zone first. if we hit the
     # end, go back and look for any gaps left by removed devices.
     last = zones_in_use[-1]
     if last < MAX_CONNTRACK_ZONES:
         return last + 1
     for index, used in enumerate(zones_in_use):
         if used - index != 1:
             # gap found, let's use it!
             return index + 1
     # conntrack zones exhausted :( :(
     raise n_exc.CTZoneExhaustedError()