Repository URL to install this package:
Version:
4.0.105 ▾
|
python3-workloadmgrclient
/
usr
/
lib
/
python3
/
dist-packages
/
workloadmgrclient
/
v1
/
license.py
|
---|
import os
import six
from cliff import show
from workloadmgrclient import utils
from workloadmgrclient.v1 import WorkloadmgrCommand
class LicenseCommand(WorkloadmgrCommand):
resource = "workloads"
class ListLicense(LicenseCommand, show.ShowOne):
"""List the license. (Admin only)"""
def take_action(self, parsed_args):
client = self.get_client()
license_data = client.license_list() or {}
metadata = {}
for meta in license_data.get("metadata", []):
if meta["key"] == "filename":
metadata["filename"] = meta["value"]
license_data["metadata"] = metadata
return zip(*sorted(six.iteritems(license_data)))
class CheckLicense(LicenseCommand):
"""Check the license. (Admin only)"""
def take_action(self, parsed_args):
client = self.get_client()
message = client.license_check()
print(message)
class CreateLicense(LicenseCommand, show.ShowOne):
"""Creates a license. (Admin only)"""
@staticmethod
def _add_arguments(parser):
parser.add_argument(
"license_file",
metavar="<license_file>",
type=open,
help="Provide file path(relative or absolute) including file name of license file.",
)
def take_action(self, parsed_args):
client = self.get_client()
lic_text = utils.read_file(parsed_args.license_file)
file_name = os.path.split(parsed_args.license_file.name)[1]
license_data = {"lic_txt": lic_text, "file_name": file_name}
license = client.license_create(license_data)
return zip(*sorted(six.iteritems(license)))