Support --version for heatclient
Closes-Bug: #1220524 Change-Id: Id78f7c7c78d31c0126b43f7a846f02f2542b0b7c
This commit is contained in:
parent
e2cbb45036
commit
5cb3fc07d5
|
@ -9,23 +9,8 @@
|
||||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
import inspect
|
|
||||||
import os
|
import pbr.version
|
||||||
|
|
||||||
|
|
||||||
def _get_heatclient_version():
|
__version__ = pbr.version.VersionInfo('python-heatclient').version_string()
|
||||||
"""Read version from versioninfo file."""
|
|
||||||
mod_abspath = inspect.getabsfile(inspect.currentframe())
|
|
||||||
heatclient_path = os.path.dirname(mod_abspath)
|
|
||||||
version_path = os.path.join(heatclient_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_heatclient_version()
|
|
||||||
|
|
|
@ -21,7 +21,8 @@ import sys
|
||||||
|
|
||||||
from keystoneclient.v2_0 import client as ksclient
|
from keystoneclient.v2_0 import client as ksclient
|
||||||
|
|
||||||
from heatclient import client as heatclient
|
import heatclient
|
||||||
|
from heatclient import client as heat_client
|
||||||
from heatclient.common import utils
|
from heatclient.common import utils
|
||||||
from heatclient import exc
|
from heatclient import exc
|
||||||
|
|
||||||
|
@ -45,6 +46,11 @@ class HeatShell(object):
|
||||||
action='store_true',
|
action='store_true',
|
||||||
help=argparse.SUPPRESS)
|
help=argparse.SUPPRESS)
|
||||||
|
|
||||||
|
parser.add_argument('--version',
|
||||||
|
action='version',
|
||||||
|
version=heatclient.__version__,
|
||||||
|
help="Shows the client version and exits")
|
||||||
|
|
||||||
parser.add_argument('-d', '--debug',
|
parser.add_argument('-d', '--debug',
|
||||||
default=bool(utils.env('HEATCLIENT_DEBUG')),
|
default=bool(utils.env('HEATCLIENT_DEBUG')),
|
||||||
action='store_true',
|
action='store_true',
|
||||||
|
@ -328,7 +334,7 @@ class HeatShell(object):
|
||||||
if not endpoint:
|
if not endpoint:
|
||||||
endpoint = self._get_endpoint(_ksclient, **kwargs)
|
endpoint = self._get_endpoint(_ksclient, **kwargs)
|
||||||
|
|
||||||
client = heatclient.Client(api_version, endpoint, **kwargs)
|
client = heat_client.Client(api_version, endpoint, **kwargs)
|
||||||
|
|
||||||
args.func(client, args)
|
args.func(client, args)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue