From 6761c99daf469c5f3b1dd1169dc9586c2137e5a3 Mon Sep 17 00:00:00 2001 From: KIYOHIRO ADACHI Date: Thu, 20 Feb 2014 09:56:39 +0900 Subject: [PATCH] Remove unused methods o glance/common/utils.py: def add_features_to_http_headers(features, headers): This method was removed in the following commit. commit 76c3620c7effb15be577450c276db1e394c2de3e Author: Brian Waldon Date: Fri Sep 7 17:21:34 2012 -0700 Drop Glance Client In this case, it has been used only in the following test program. - glance/tests/unit/common/test_utils.py o glance/tests/functional/__init__.py: def reload_server(self, This method was removed in the following commit. commit 866cb846f5310e1ad36181e64e7d59ba54d9fd40 Author: John Bresnahan Date: Fri May 3 10:50:42 2013 -1000 Remove glance-control from the test suite The following methods are not used(w/o tests), however, it can not be deleted, added the comment. o glance/common/location_strategy/__init__.py: def verify_location_strategy(conf=None, strategies=_available_strategies): Change-Id: I50e3fdb6e929337b946e3534c8e7dbff77ac7998 --- glance/common/location_strategy/__init__.py | 2 ++ glance/common/utils.py | 15 -------- glance/tests/functional/__init__.py | 38 --------------------- glance/tests/unit/common/test_utils.py | 9 ----- 4 files changed, 2 insertions(+), 62 deletions(-) diff --git a/glance/common/location_strategy/__init__.py b/glance/common/location_strategy/__init__.py index e926d43676..55a7d55279 100644 --- a/glance/common/location_strategy/__init__.py +++ b/glance/common/location_strategy/__init__.py @@ -66,6 +66,8 @@ def _load_strategies(): _available_strategies = _load_strategies() +# TODO(kadachi): Not used but don't remove this until glance.store +# development/migration stage. def verify_location_strategy(conf=None, strategies=_available_strategies): """Validate user configured 'location_strategy' option value.""" if not conf: diff --git a/glance/common/utils.py b/glance/common/utils.py index 755d2c411e..e72e7435d4 100644 --- a/glance/common/utils.py +++ b/glance/common/utils.py @@ -209,21 +209,6 @@ def image_meta_to_http_headers(image_meta): return headers -def add_features_to_http_headers(features, headers): - """ - Adds additional headers representing glance features to be enabled. - - :param headers: Base set of headers - :param features: Map of enabled features - """ - if features: - for k, v in features.items(): - if k.lower() in FEATURE_BLACKLIST: - raise exception.UnsupportedHeaderFeature(feature=k) - if v is not None: - headers[k.lower()] = unicode(v) - - def get_image_meta_from_headers(response): """ Processes HTTP headers from a supplied response that diff --git a/glance/tests/functional/__init__.py b/glance/tests/functional/__init__.py index 51351471b8..5299509646 100644 --- a/glance/tests/functional/__init__.py +++ b/glance/tests/functional/__init__.py @@ -25,7 +25,6 @@ import atexit import datetime import logging import os -import re import shutil import signal import socket @@ -845,43 +844,6 @@ class FunctionalTest(test_utils.BaseTestCase): return msg if expect_launch else None - def reload_server(self, - server, - expect_launch, - expect_exit=True, - expected_exitcode=0, - **kwargs): - """ - Reload a running server - - Any kwargs passed to this method will override the configuration - value in the conf file used in starting the server. - - :param server: the server to launch - :param expect_launch: true iff the server is expected to - successfully start - :param expect_exit: true iff the launched process is expected - to exit in a timely fashion - :param expected_exitcode: expected exitcode from the launcher - """ - self.cleanup() - - # Start up the requested server - exitcode, out, err = server.reload(expect_exit=expect_exit, - expected_exitcode=expected_exitcode, - **kwargs) - if expect_exit: - self.assertEqual(expected_exitcode, exitcode, - "Failed to spin up the requested server. " - "Got: %s" % err) - - self.assertTrue(re.search("Restarting glance-[a-z]+ with", out)) - - self.launched_servers.append(server) - - launch_msg = self.wait_for_servers([server], expect_launch) - self.assertTrue(launch_msg is None, launch_msg) - def stop_server(self, server, name): """ Called to stop a single server in a normal fashion using the diff --git a/glance/tests/unit/common/test_utils.py b/glance/tests/unit/common/test_utils.py index e34c0b7f9c..10536c7483 100644 --- a/glance/tests/unit/common/test_utils.py +++ b/glance/tests/unit/common/test_utils.py @@ -135,15 +135,6 @@ class TestUtils(test_utils.BaseTestCase): self.assertRaises(webob.exc.HTTPBadRequest, utils.get_image_meta_from_headers, resp) - def test_add_features_to_http_headers(self): - features_test1 = {'x-image-meta-size': 'test'} - url = ("http://glance.example.com/v1/" - "images/71c675ab-d94f-49cd-a114-e12490b328d9") - headers = {"x-image-meta-uri": url} - self.assertRaises(exception.UnsupportedHeaderFeature, - utils.add_features_to_http_headers, - features_test1, headers) - def test_image_meta(self): image_meta = {'x-image-meta-size': 'test'} image_meta_properties = {'properties': {'test': "test"}}