Adding --version option
Change-Id: I7d37af1ddee186af22457baea9af71a955720053
This commit is contained in:
parent
8ccd9059d6
commit
b54330bfd2
@ -11,3 +11,23 @@
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
import inspect
|
||||
import os
|
||||
|
||||
|
||||
def _get_novaclient_version():
|
||||
"""Read version from versioninfo file."""
|
||||
mod_abspath = inspect.getabsfile(inspect.currentframe())
|
||||
novaclient_path = os.path.dirname(mod_abspath)
|
||||
version_path = os.path.join(novaclient_path, 'versioninfo')
|
||||
|
||||
if os.path.exists(version_path):
|
||||
version = open(version_path).read().strip()
|
||||
else:
|
||||
version = "Unknown, couldn't find versioninfo file at %s"\
|
||||
% version_path
|
||||
|
||||
return version
|
||||
|
||||
|
||||
__version__ = _get_novaclient_version()
|
||||
|
@ -28,6 +28,7 @@ import pkgutil
|
||||
import sys
|
||||
import logging
|
||||
|
||||
import novaclient
|
||||
from novaclient import client
|
||||
from novaclient import exceptions as exc
|
||||
import novaclient.extension
|
||||
@ -81,6 +82,10 @@ class OpenStackComputeShell(object):
|
||||
help=argparse.SUPPRESS,
|
||||
)
|
||||
|
||||
parser.add_argument('--version',
|
||||
action='version',
|
||||
version=novaclient.__version__)
|
||||
|
||||
parser.add_argument('--debug',
|
||||
default=False,
|
||||
action='store_true',
|
||||
|
3
setup.py
3
setup.py
@ -47,5 +47,6 @@ setuptools.setup(
|
||||
],
|
||||
entry_points={
|
||||
"console_scripts": ["nova = novaclient.shell:main"]
|
||||
}
|
||||
},
|
||||
data_files=[('novaclient', ['novaclient/versioninfo'])]
|
||||
)
|
||||
|
Loading…
x
Reference in New Issue
Block a user