Deprecate version module
This allows us to get rid of pbr as a runtime dependency also, albeit with a 6 month/1 release delay. Change-Id: Id2222bc2f93d94023aba30e431479be0945a8a92 Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
This commit is contained in:
1 parent
9c7d9417f9
commit
ea4f4094a3
2 files changed
+15
-7
No files matched your search
@@ -17,6 +17,7 @@
|
||||
Routines for configuring Neutron
|
||||
"""
|
||||
|
||||
import importlib.metadata
|
||||
import sys
|
||||
|
||||
from keystoneauth1 import loading as ks_loading
|
||||
@@ -33,7 +34,6 @@ from oslo_service import wsgi
|
||||
from neutron._i18n import _
|
||||
from neutron.conf import common as common_config
|
||||
from neutron import policy
|
||||
from neutron import version
|
||||
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
@@ -95,8 +95,9 @@ def register_common_config_options():
|
||||
|
||||
|
||||
def init(args, default_config_files=None, **kwargs):
|
||||
version = importlib.metadata.version('neutron')
|
||||
cfg.CONF(args=args, project='neutron',
|
||||
version='%%(prog)s %s' % version.version_info.release_string(),
|
||||
version=f'%(prog)s {version}',
|
||||
default_config_files=default_config_files,
|
||||
**kwargs)
|
||||
|
||||
@@ -112,6 +113,7 @@ def init(args, default_config_files=None, **kwargs):
|
||||
def setup_logging():
|
||||
"""Sets up the logging options for a log with supplied name."""
|
||||
product_name = "neutron"
|
||||
version = importlib.metadata.version('neutron')
|
||||
# We use the oslo.log default log levels and add only the extra levels
|
||||
# that Neutron needs.
|
||||
logging.set_defaults(default_log_levels=logging.get_default_log_levels() +
|
||||
@@ -119,17 +121,15 @@ def setup_logging():
|
||||
logging.setup(cfg.CONF, product_name, fix_eventlet=False)
|
||||
LOG.info("Logging enabled!")
|
||||
LOG.info("%(prog)s version %(version)s",
|
||||
{'prog': sys.argv[0],
|
||||
'version': version.version_info.release_string()})
|
||||
{'prog': sys.argv[0], 'version': version})
|
||||
LOG.debug("command line: %s", " ".join(sys.argv))
|
||||
|
||||
|
||||
def setup_gmr():
|
||||
"""Sets up Guru Meditation Report(GMR) generation."""
|
||||
gmr_opts.set_defaults(cfg.CONF)
|
||||
_version_string = version.version_info.release_string()
|
||||
gmr.TextGuruMeditation.setup_autorun(version=_version_string,
|
||||
conf=cfg.CONF)
|
||||
version = importlib.metadata.version('neutron')
|
||||
gmr.TextGuruMeditation.setup_autorun(version=version, conf=cfg.CONF)
|
||||
|
||||
|
||||
def reset_service():
|
||||
|
||||
@@ -12,6 +12,14 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import warnings
|
||||
|
||||
import pbr.version
|
||||
|
||||
warnings.warn(
|
||||
f'The {__name__} module is deprecated. Prefer use of importlib.metadata '
|
||||
f'to inspect version information for packages.',
|
||||
DeprecationWarning,
|
||||
)
|
||||
|
||||
version_info = pbr.version.VersionInfo('neutron')
|
||||
Reference in new issue
Block a user