config/sysinv/cgts-client/cgts-client/cgtsclient/v1/license_shell.py
Bin Qian 54f164a193 Clean up licensing code
Remove "system license-list" command,
replace with "system license-show"
The new system license-show command shows the content of the
license file

Remove any validation and interpretation of license file.

Partial-Bug: 1845522
Change-Id: I9dfb765d300e86eae1c554703e8e3e4f088d87b7
Signed-off-by: Bin Qian <bin.qian@windriver.com>
2019-10-01 08:52:43 -04:00

47 lines
1.1 KiB
Python

#!/usr/bin/env python
#
# Copyright (c) 2017-2019 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
def do_license_show(cc, args):
"""Show license file content"""
response = cc.license.show()
error = response.get('error')
content = response.get('content')
if error != "":
print("Error: %s" % error + "\n")
else:
print(content + "\n")
@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")