config/sysinv/cgts-client/cgts-client/cgtsclient/v1/license_shell.py
Al Bailey d7330d0f44 Convert cgtsclient from setuptools to pbr. Add tox.
Primary reason for this change was to update the spec and setup files
from basic setuptools to use pbr
This allows the autogenerated  /usr/bin/system file to directly call the
main method without using pkg-resources.
This will provide a performance improvement of .5 seconds per CLI call,
once the other pkg_resources issues are resolved

Second reason for this change was to wire in the tox unit tests.  This
also includes pep8, pylint and coverage.
Currently pep8 does not perform the 80 char limit check
Currently pylint still reports some issues

This should not affect the RPM names being generated or otherwise affect
patching or upgrades.

Change-Id: I9f14c9216fdcc63930a4b2849102b58442706144
2018-06-28 22:07:37 -04:00

53 lines
1.4 KiB
Python

#!/usr/bin/env python
#
# Copyright (c) 2017 Wind River Systems, Inc.
#
# SPDX-License-Identifier: Apache-2.0
#
# vim: tabstop=4 shiftwidth=4 softtabstop=4
# All Rights Reserved.
#
from cgtsclient.common import utils
from cgtsclient import exc
@utils.arg('-a', '--all',
action='store_true',
help='List all licenses information')
def do_license_list(cc, args):
"""List all licenses"""
labels = ['name', 'status', 'expiry_date']
fields = ['name', 'status', 'expiry_date']
licenses = cc.license.list()
for license in licenses[:]:
if not args.all:
if license.status == 'Not-installed':
licenses.remove(license)
utils.print_list(licenses, fields, labels, sortby=0)
@utils.arg('license_file_path',
metavar='<license file path>',
default=None,
help="Path to license file to install.")
def do_license_install(cc, args):
"""Install license file."""
filename = args.license_file_path
try:
license_file = open(filename, 'rb')
except Exception:
raise exc.CommandError(
"Error: Could not open file %s for read." % filename)
response = cc.license.install_license(license_file)
success = response.get('success')
error = response.get('error')
if success:
print success + "\n"
if error:
print error + "\n"