diff --git a/nodepool/cmd/nodepoolcmd.py b/nodepool/cmd/nodepoolcmd.py index 7154a1a75..461eb32ad 100644 --- a/nodepool/cmd/nodepoolcmd.py +++ b/nodepool/cmd/nodepoolcmd.py @@ -21,6 +21,7 @@ import time from nodepool import nodedb from nodepool import nodepool +from nodepool.version import version_info as npc_version_info from prettytable import PrettyTable @@ -33,7 +34,8 @@ class NodePoolCmd(object): parser.add_argument('-c', dest='config', default='/etc/nodepool/nodepool.yaml', help='path to config file') - parser.add_argument('--version', dest='version', action='store_true', + parser.add_argument('--version', action='version', + version=npc_version_info.version_string(), help='show version') parser.add_argument('--debug', dest='debug', action='store_true', help='show DEBUG level logging') @@ -316,11 +318,6 @@ class NodePoolCmd(object): self.pool.deleteImage(self.args.id) def main(self): - if self.args.version: - from nodepool.version import version_info as npc_version_info - print "Nodepool version: %s" % npc_version_info.version_string() - return(0) - self.pool = nodepool.NodePool(self.args.config) config = self.pool.loadConfig() self.pool.reconfigureDatabase(config) diff --git a/nodepool/version.py b/nodepool/version.py new file mode 100644 index 000000000..4ac2dadfb --- /dev/null +++ b/nodepool/version.py @@ -0,0 +1,17 @@ +# Copyright 2014 Hewlett-Packard Development Company, L.P. +# +# 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. + +import pbr.version + +version_info = pbr.version.VersionInfo('nodepool')