Skip to content

Commit 40891d1

Browse files
caberoscaberos
authored andcommitted
fix the merge conflicts
2 parents 835d1ee + ce5dabf commit 40891d1

30 files changed

+571
-63
lines changed

SoftLayer/CLI/account/licenses.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
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)

SoftLayer/CLI/block/count.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,6 @@ def cli(env, sortby, datacenter):
3737

3838
table = formatting.KeyValueTable(DEFAULT_COLUMNS)
3939
table.sortby = sortby
40-
for datacenter_name in datacenters:
41-
table.add_row([datacenter_name, datacenters[datacenter_name]])
40+
for key, value in datacenters.items():
41+
table.add_row([key, value])
4242
env.fout(table)

SoftLayer/CLI/core.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,17 +54,17 @@ def list_commands(self, ctx):
5454

5555
return sorted(env.list_commands(*self.path))
5656

57-
def get_command(self, ctx, name):
57+
def get_command(self, ctx, cmd_name):
5858
"""Get command for click."""
5959
env = ctx.ensure_object(environment.Environment)
6060
env.load()
6161

6262
# Do alias lookup (only available for root commands)
6363
if len(self.path) == 0:
64-
name = env.resolve_alias(name)
64+
cmd_name = env.resolve_alias(cmd_name)
6565

6666
new_path = list(self.path)
67-
new_path.append(name)
67+
new_path.append(cmd_name)
6868
module = env.get_command(*new_path)
6969
if isinstance(module, types.ModuleType):
7070
return CommandLoader(*new_path, help=module.__doc__ or '')

SoftLayer/CLI/file/count.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,6 @@ def cli(env, sortby, datacenter):
3636

3737
table = formatting.KeyValueTable(DEFAULT_COLUMNS)
3838
table.sortby = sortby
39-
for datacenter_name in datacenters:
40-
table.add_row([datacenter_name, datacenters[datacenter_name]])
39+
for key, value in datacenters.items():
40+
table.add_row([key, value])
4141
env.fout(table)

SoftLayer/CLI/formatting.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -248,11 +248,11 @@ def __str__(self):
248248
class CLIJSONEncoder(json.JSONEncoder):
249249
"""A JSON encoder which is able to use a .to_python() method on objects."""
250250

251-
def default(self, obj):
251+
def default(self, o):
252252
"""Encode object if it implements to_python()."""
253-
if hasattr(obj, 'to_python'):
254-
return obj.to_python()
255-
return super().default(obj)
253+
if hasattr(o, 'to_python'):
254+
return o.to_python()
255+
return super().default(o)
256256

257257

258258
class Table(object):

SoftLayer/CLI/licenses/cancel.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
"""Cancel a license."""
2+
# :licenses: MIT, see LICENSE for more details.
3+
4+
import click
5+
import SoftLayer
6+
7+
from SoftLayer.CLI import environment
8+
9+
10+
@click.command()
11+
@click.argument('key')
12+
@click.option('--immediate', is_flag=True, help='Immediate cancellation')
13+
@environment.pass_env
14+
def cli(env, key, immediate):
15+
"""Cancel a license."""
16+
17+
licenses = SoftLayer.LicensesManager(env.client)
18+
19+
env.fout(licenses.cancel_item(key, immediate))

SoftLayer/CLI/licenses/create.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
"""Order/create a vwmare licenses."""
2+
# :licenses: MIT, see LICENSE for more details.
3+
4+
import click
5+
6+
import SoftLayer
7+
8+
from SoftLayer.CLI import environment
9+
from SoftLayer.CLI import formatting
10+
11+
12+
@click.command()
13+
@click.option('--key', '-k', required=True, prompt=True,
14+
help="The VMware License Key. "
15+
"To get could use the product_package::getItems id=301 with name Software License Package"
16+
"E.g VMWARE_VSAN_ENTERPRISE_TIER_III_65_124_TB_6_X_2")
17+
@click.option('--datacenter', '-d', required=True, prompt=True, help="Datacenter shortname")
18+
@environment.pass_env
19+
def cli(env, key, datacenter):
20+
"""Order/Create License."""
21+
22+
item_package = [key]
23+
24+
licenses = SoftLayer.LicensesManager(env.client)
25+
26+
result = licenses.create(datacenter, item_package)
27+
28+
table = formatting.KeyValueTable(['name', 'value'])
29+
table.align['name'] = 'r'
30+
table.align['value'] = 'l'
31+
table.add_row(['id', result['orderId']])
32+
table.add_row(['created', result['orderDate']])
33+
34+
env.fout(table)

SoftLayer/CLI/loadbal/detail.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,8 @@ def lbaas_table(this_lb):
8383

8484
# https://sldn.softlayer.com/reference/datatypes/SoftLayer_Network_LBaaS_Member/
8585
member_col = ['UUID', 'Address', 'Weight', 'Modify', 'Active']
86-
for uuid in pools:
87-
member_col.append(pools[uuid])
86+
for uuid in pools.values():
87+
member_col.append(uuid)
8888
member_table = formatting.Table(member_col)
8989
for member in this_lb.get('members', []):
9090
row = [

SoftLayer/CLI/loadbal/pools.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,9 +114,9 @@ def edit(env, identifier, listener, **args):
114114
'sslcert': 'tlsCertificateId'
115115
}
116116

117-
for arg in args:
118-
if args[arg]:
119-
new_listener[arg_to_option[arg]] = args[arg]
117+
for key, value in args.items():
118+
if value:
119+
new_listener[arg_to_option[key]] = value
120120

121121
try:
122122
mgr.add_lb_listener(uuid, new_listener)

SoftLayer/CLI/routes.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
('account:invoices', 'SoftLayer.CLI.account.invoices:cli'),
1717
('account:events', 'SoftLayer.CLI.account.events:cli'),
1818
('account:event-detail', 'SoftLayer.CLI.account.event_detail:cli'),
19+
('account:licenses', 'SoftLayer.CLI.account.licenses:cli'),
1920
('account:summary', 'SoftLayer.CLI.account.summary:cli'),
2021
('account:billing-items', 'SoftLayer.CLI.account.billing_items:cli'),
2122
('account:item-detail', 'SoftLayer.CLI.account.item_detail:cli'),
@@ -220,6 +221,10 @@
220221
('nas:list', 'SoftLayer.CLI.nas.list:cli'),
221222
('nas:credentials', 'SoftLayer.CLI.nas.credentials:cli'),
222223

224+
('licenses', 'SoftLayer.CLI.licenses'),
225+
('licenses:create', 'SoftLayer.CLI.licenses.create:cli'),
226+
('licenses:cancel', 'SoftLayer.CLI.licenses.cancel:cli'),
227+
223228
('object-storage', 'SoftLayer.CLI.object_storage'),
224229

225230
('object-storage:accounts', 'SoftLayer.CLI.object_storage.list_accounts:cli'),

0 commit comments

Comments
 (0)