Check version using pbr module

Use pbr module to check package version.

Change-Id: I7557dec9044c4d43bd05c57c733d15df5ec1e736
This commit is contained in:
Artur Basiak 2017-06-19 10:22:05 +02:00
parent 9ef72192a2
commit 4e6d7bee76
2 changed files with 22 additions and 1 deletions

View File

@ -8,6 +8,7 @@ import yaml
from monasca_agent.common.exceptions import PathNotFound
import monasca_agent.common.singleton as singleton
from monasca_agent import version
DEFAULT_CONFIG_FILE = '/etc/monasca/agent/agent.yaml'
DEFAULT_LOG_DIR = '/var/log/monasca/agent'
@ -108,7 +109,7 @@ class Config(object):
return new_config
def get_version(self):
return pkg_resources.require("monasca-agent")[0].version
return version.version_string
def _read_config(self):
"""Read in the config file."""

20
monasca_agent/version.py Normal file
View File

@ -0,0 +1,20 @@
# Copyright 2017 FUJITSU LIMITED
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from pbr import version
__all__ = ['version_info', 'version_string']
version_info = version.VersionInfo('monasca-agent')
version_string = version_info.version_string()