enable fallback to a non-CIDR version if iptools is not installed
This commit is contained in:
parent
53047a4a26
commit
098545a2cd
@ -17,7 +17,18 @@ import collections
|
||||
from urllib import unquote
|
||||
import copy
|
||||
|
||||
from iptools import IpRangeList
|
||||
# conditionalize the return_ips method based on whether or not iptools
|
||||
# is present in the system. Without iptools, you will lack CIDR support.
|
||||
try:
|
||||
from iptools import IpRangeList
|
||||
|
||||
def return_ips(conf, conf_tag):
|
||||
return IpRangeList(*[x.strip() for x in
|
||||
conf.get(conf_tag, '').split(',') if x.strip()])
|
||||
except:
|
||||
def return_ips(conf, conf_tag):
|
||||
return ([x.strip() for x in conf.get(conf_tag, '').split(',')
|
||||
if x.strip()])
|
||||
|
||||
from swift.common.utils import split_path, get_logger
|
||||
|
||||
@ -33,9 +44,7 @@ class AccessLogProcessor(object):
|
||||
self.server_name = conf.get('server_name', 'proxy-server')
|
||||
for conf_tag in ['lb_private_ips', 'service_ips',
|
||||
'service_log_sources']:
|
||||
setattr(self, conf_tag, IpRangeList(*
|
||||
[x.strip() for x in conf.get(conf_tag, '').split(',') \
|
||||
if x.strip()]))
|
||||
setattr(self, conf_tag, return_ips(conf, conf_tag))
|
||||
self.warn_percent = float(conf.get('warn_percent', '0.8'))
|
||||
self.logger = get_logger(conf, log_route='access-processor')
|
||||
|
||||
|
@ -10,7 +10,6 @@ from tempfile import NamedTemporaryFile
|
||||
from eventlet.green import socket
|
||||
from tempfile import mkdtemp
|
||||
from shutil import rmtree
|
||||
#from test import get_config
|
||||
from ConfigParser import MissingSectionHeaderError
|
||||
from StringIO import StringIO
|
||||
from swift.common.utils import readconf, TRUE_VALUES
|
||||
|
Loading…
x
Reference in New Issue
Block a user