summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZuul <zuul@review.openstack.org>2017-10-20 17:26:16 +0000
committerGerrit Code Review <review@openstack.org>2017-10-20 17:26:16 +0000
commit09be7d540477bd6e2e7f0a1f8636530c97eb3fcf (patch)
tree430539acf4ef54cc226c087ce7878a08d35e0674
parentee5a7ee09ef8ca67f7ca753ce92295861db49565 (diff)
parent22af51cc1c5d230a04f512cd1bd85a7f82dcc66b (diff)
Merge "remove unused configuration options"
-rw-r--r--ec2api/api/auth.py6
-rw-r--r--ec2api/paths.py35
-rw-r--r--ec2api/service.py3
-rw-r--r--ec2api/utils.py26
4 files changed, 1 insertions, 69 deletions
diff --git a/ec2api/api/auth.py b/ec2api/api/auth.py
index b731a8e..1aec765 100644
--- a/ec2api/api/auth.py
+++ b/ec2api/api/auth.py
@@ -22,9 +22,6 @@ from oslo_log import log as logging
22 22
23 23
24auth_opts = [ 24auth_opts = [
25 cfg.BoolOpt('api_rate_limit',
26 default=False,
27 help='whether to use per-user rate limiting for the api.'),
28 cfg.BoolOpt('use_forwarded_for', 25 cfg.BoolOpt('use_forwarded_for',
29 default=False, 26 default=False,
30 help='Treat X-Forwarded-For as the canonical remote address. ' 27 help='Treat X-Forwarded-For as the canonical remote address. '
@@ -41,9 +38,6 @@ def pipeline_factory(loader, global_conf, **local_conf):
41 """A paste pipeline replica that keys off of auth_strategy.""" 38 """A paste pipeline replica that keys off of auth_strategy."""
42 auth_strategy = "keystone" 39 auth_strategy = "keystone"
43 pipeline = local_conf[auth_strategy] 40 pipeline = local_conf[auth_strategy]
44 if not CONF.api_rate_limit:
45 limit_name = auth_strategy + '_nolimit'
46 pipeline = local_conf.get(limit_name, pipeline)
47 pipeline = pipeline.split() 41 pipeline = pipeline.split()
48 filters = [loader.get_filter(n) for n in pipeline[:-1]] 42 filters = [loader.get_filter(n) for n in pipeline[:-1]]
49 app = loader.get_app(pipeline[-1]) 43 app = loader.get_app(pipeline[-1])
diff --git a/ec2api/paths.py b/ec2api/paths.py
index 24a7325..0ef00af 100644
--- a/ec2api/paths.py
+++ b/ec2api/paths.py
@@ -13,20 +13,12 @@
13# limitations under the License. 13# limitations under the License.
14 14
15import os 15import os
16import sys
17 16
18from oslo_config import cfg 17from oslo_config import cfg
19 18
20path_opts = [ 19path_opts = [
21 cfg.StrOpt('pybasedir',
22 default=os.path.abspath(os.path.join(os.path.dirname(__file__),
23 '../')),
24 help='Directory where the ec2api python module is installed'),
25 cfg.StrOpt('bindir',
26 default=os.path.join(sys.prefix, 'local', 'bin'),
27 help='Directory where ec2api binaries are installed'),
28 cfg.StrOpt('state_path', 20 cfg.StrOpt('state_path',
29 default='$pybasedir', 21 default='/var/lib/ec2api',
30 help="Top-level directory for maintaining ec2api's state"), 22 help="Top-level directory for maintaining ec2api's state"),
31] 23]
32 24
@@ -34,31 +26,6 @@ CONF = cfg.CONF
34CONF.register_opts(path_opts) 26CONF.register_opts(path_opts)
35 27
36 28
37def basedir_def(*args):
38 """Return an uninterpolated path relative to $pybasedir."""
39 return os.path.join('$pybasedir', *args)
40
41
42def bindir_def(*args):
43 """Return an uninterpolated path relative to $bindir."""
44 return os.path.join('$bindir', *args)
45
46
47def state_path_def(*args): 29def state_path_def(*args):
48 """Return an uninterpolated path relative to $state_path.""" 30 """Return an uninterpolated path relative to $state_path."""
49 return os.path.join('$state_path', *args) 31 return os.path.join('$state_path', *args)
50
51
52def basedir_rel(*args):
53 """Return a path relative to $pybasedir."""
54 return os.path.join(CONF.pybasedir, *args)
55
56
57def bindir_rel(*args):
58 """Return a path relative to $bindir."""
59 return os.path.join(CONF.bindir, *args)
60
61
62def state_path_rel(*args):
63 """Return a path relative to $state_path."""
64 return os.path.join(CONF.state_path, *args)
diff --git a/ec2api/service.py b/ec2api/service.py
index 593afae..dd59e26 100644
--- a/ec2api/service.py
+++ b/ec2api/service.py
@@ -51,9 +51,6 @@ service_opts = [
51 cfg.IntOpt('metadata_workers', 51 cfg.IntOpt('metadata_workers',
52 help='Number of workers for metadata service. The default will ' 52 help='Number of workers for metadata service. The default will '
53 'be the number of CPUs available.'), 53 'be the number of CPUs available.'),
54 cfg.IntOpt('service_down_time',
55 default=60,
56 help='Maximum time since last check-in for up service'),
57] 54]
58 55
59CONF = cfg.CONF 56CONF = cfg.CONF
diff --git a/ec2api/utils.py b/ec2api/utils.py
index c95c1ae..425ed1e 100644
--- a/ec2api/utils.py
+++ b/ec2api/utils.py
@@ -15,42 +15,16 @@
15 15
16"""Utilities and helper functions.""" 16"""Utilities and helper functions."""
17 17
18import contextlib
19import hashlib 18import hashlib
20import hmac 19import hmac
21import shutil
22import tempfile
23from xml.sax import saxutils 20from xml.sax import saxutils
24 21
25from oslo_config import cfg
26from oslo_log import log as logging 22from oslo_log import log as logging
27 23
28 24
29utils_opts = [
30 cfg.StrOpt('tempdir',
31 help='Explicitly specify the temporary working directory'),
32]
33CONF = cfg.CONF
34CONF.register_opts(utils_opts)
35
36LOG = logging.getLogger(__name__) 25LOG = logging.getLogger(__name__)
37 26
38 27
39@contextlib.contextmanager
40def tempdir(**kwargs):
41 argdict = kwargs.copy()
42 if 'dir' not in argdict:
43 argdict['dir'] = CONF.tempdir
44 tmpdir = tempfile.mkdtemp(**argdict)
45 try:
46 yield tmpdir
47 finally:
48 try:
49 shutil.rmtree(tmpdir)
50 except OSError as e:
51 LOG.error('Could not remove tmpdir: %s', str(e))
52
53
54def get_hash_str(base_str): 28def get_hash_str(base_str):
55 """returns string that represents hash of base_str (in hex format).""" 29 """returns string that represents hash of base_str (in hex format)."""
56 return hashlib.md5(base_str).hexdigest() 30 return hashlib.md5(base_str).hexdigest()