|
| 1 | +"""Show all licenses.""" |
| 2 | +# :license: MIT, see LICENSE for more details. |
| 3 | +import click |
| 4 | + |
| 5 | +from SoftLayer import utils |
| 6 | + |
| 7 | +from SoftLayer.CLI import environment |
| 8 | +from SoftLayer.CLI import formatting |
| 9 | +from SoftLayer.managers import account |
| 10 | + |
| 11 | + |
| 12 | +@click.command() |
| 13 | +@environment.pass_env |
| 14 | +def cli(env): |
| 15 | + """Show all licenses.""" |
| 16 | + |
| 17 | + manager = account.AccountManager(env.client) |
| 18 | + |
| 19 | + control_panel = manager.get_active_virtual_licenses() |
| 20 | + vmwares = manager.get_active_account_licenses() |
| 21 | + |
| 22 | + table_panel = formatting.KeyValueTable(['id', 'ip_address', 'manufacturer', 'software', |
| 23 | + 'key', 'subnet', 'subnet notes'], title="Control Panel Licenses") |
| 24 | + |
| 25 | + table_vmware = formatting.KeyValueTable(['name', 'license_key', 'cpus', 'description', |
| 26 | + 'manufacturer', 'requiredUser'], title="VMware Licenses") |
| 27 | + for panel in control_panel: |
| 28 | + table_panel.add_row([panel.get('id'), panel.get('ipAddress'), |
| 29 | + utils.lookup(panel, 'softwareDescription', 'manufacturer'), |
| 30 | + utils.trim_to(utils.lookup(panel, 'softwareDescription', 'longDescription'), 40), |
| 31 | + panel.get('key'), utils.lookup(panel, 'subnet', 'broadcastAddress'), |
| 32 | + utils.lookup(panel, 'subnet', 'note')]) |
| 33 | + |
| 34 | + env.fout(table_panel) |
| 35 | + for vmware in vmwares: |
| 36 | + table_vmware.add_row([utils.lookup(vmware, 'softwareDescription', 'name'), |
| 37 | + vmware.get('key'), vmware.get('capacity'), |
| 38 | + utils.lookup(vmware, 'billingItem', 'description'), |
| 39 | + utils.lookup(vmware, 'softwareDescription', 'manufacturer'), |
| 40 | + utils.lookup(vmware, 'softwareDescription', 'requiredUser')]) |
| 41 | + |
| 42 | + env.fout(table_vmware) |
0 commit comments