Skip to content

Commit 3ab4720

Browse files
caberoscaberos
authored andcommitted
fix the merge conflicts
2 parents 24771a7 + cd9db74 commit 3ab4720

File tree

18 files changed

+531
-70
lines changed

18 files changed

+531
-70
lines changed

SoftLayer/CLI/block/options.py

Lines changed: 90 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -6,47 +6,104 @@
66
import SoftLayer
77
from SoftLayer.CLI.command import SLCommand
88
from SoftLayer.CLI import environment
9+
from SoftLayer.CLI import exceptions
910
from SoftLayer.CLI import formatting
1011

1112
PACKAGE_STORAGE = 759
1213

1314

1415
@click.command(cls=SLCommand)
16+
@click.argument('location', required=False)
17+
@click.option('--prices', '-p', is_flag=True,
18+
help='Use --prices to list the server item prices, and to list the Item Prices by location,'
19+
'add it to the --prices option using location short name, e.g. --prices dal13')
1520
@environment.pass_env
16-
def cli(env):
21+
def cli(env, prices, location=None):
1722
"""List all options for ordering a block storage"""
1823

1924
order_manager = SoftLayer.OrderingManager(env.client)
2025
items = order_manager.get_items(PACKAGE_STORAGE)
21-
datacenters = order_manager.get_regions(PACKAGE_STORAGE)
22-
23-
iops_table = formatting.Table(['Id', 'Description', 'KeyName'], title='IOPS')
24-
snapshot_table = formatting.Table(['Id', 'Description', 'KeyName'], title='Snapshot')
25-
storage_table = formatting.Table(['Id', 'Description', 'KeyName', 'Capacity Minimum'], title='Storage')
26-
datacenter_table = formatting.Table(['Id', 'Description', 'KeyName'], title='Datacenter')
27-
28-
storage_table.align['Description'] = 'l'
29-
storage_table.align['KeyName'] = 'l'
30-
storage_table.sortby = 'Id'
31-
for datacenter in datacenters:
32-
datacenter_table.add_row([datacenter['location']['locationId'],
33-
datacenter.get('description'),
34-
datacenter['keyname']])
35-
36-
for item in items:
37-
if item['itemCategory']['categoryCode'] == 'performance_storage_space':
38-
storage_table.add_row([item.get('id'), item.get('description'),
39-
item.get('keyName'), item.get('capacityMinimum') or '-'])
40-
41-
if item['itemCategory']['categoryCode'] == 'storage_tier_level':
42-
iops_table.add_row([item.get('id'), item.get('description'),
43-
item.get('keyName')])
44-
45-
if item['itemCategory']['categoryCode'] == 'storage_snapshot_space':
46-
snapshot_table.add_row([item.get('id'), item.get('description'),
47-
item.get('keyName')])
48-
49-
env.fout(datacenter_table)
50-
env.fout(iops_table)
51-
env.fout(storage_table)
52-
env.fout(snapshot_table)
26+
datacenters = order_manager.get_regions(PACKAGE_STORAGE, location)
27+
28+
tables = []
29+
network = SoftLayer.NetworkManager(env.client)
30+
pods = network.get_closed_pods()
31+
32+
if datacenters != []:
33+
datacenter_table = formatting.Table(['Id', 'Description', 'KeyName'], title='Datacenter')
34+
35+
for datacenter in datacenters:
36+
closure = []
37+
for pod in pods:
38+
if datacenter['location']['location']['name'] in str(pod['name']):
39+
closure.append(pod['name'])
40+
41+
notes = '-'
42+
if len(closure) > 0:
43+
notes = 'closed soon: %s' % (', '.join(closure))
44+
datacenter_table.add_row([datacenter['location']['locationId'],
45+
datacenter.get('description'),
46+
datacenter['keyname'], notes])
47+
tables.append(datacenter_table)
48+
else:
49+
raise exceptions.CLIAbort('Location does not exit.')
50+
51+
tables.append(_block_ios_get_table(items, prices))
52+
tables.append(_block_storage_table(items, prices))
53+
tables.append(_block_snapshot_get_table(items, prices))
54+
env.fout(tables)
55+
56+
57+
def _block_ios_get_table(items, prices):
58+
if prices:
59+
table = formatting.Table(['Id', 'Description', 'KeyName', 'Prices'], title='IOPS')
60+
for block_item in items:
61+
if block_item['itemCategory']['categoryCode'] == 'storage_tier_level':
62+
table.add_row([block_item.get('id'), block_item.get('description'),
63+
block_item.get('keyName'), block_item['prices'][0]['recurringFee']])
64+
else:
65+
table = formatting.Table(['Id', 'Description', 'KeyName'], title='IOPS')
66+
for block_item in items:
67+
if block_item['itemCategory']['categoryCode'] == 'storage_tier_level':
68+
table.add_row([block_item.get('id'), block_item.get('description'),
69+
block_item.get('keyName')])
70+
table.sortby = 'Id'
71+
table.align = 'l'
72+
return table
73+
74+
75+
def _block_storage_table(items, prices):
76+
if prices:
77+
table = formatting.Table(['Id', 'Description', 'KeyName', 'Capacity Minimum', 'Prices'], title='Storage')
78+
for block_item in items:
79+
if block_item['itemCategory']['categoryCode'] == 'performance_storage_space':
80+
table.add_row([block_item.get('id'), block_item.get('description'),
81+
block_item.get('keyName'), block_item.get('capacityMinimum') or '-',
82+
block_item['prices'][0]['recurringFee']])
83+
else:
84+
table = formatting.Table(['Id', 'Description', 'KeyName', 'Capacity Minimum'], title='Storage')
85+
for block_item in items:
86+
if block_item['itemCategory']['categoryCode'] == 'performance_storage_space':
87+
table.add_row([block_item.get('id'), block_item.get('description'),
88+
block_item.get('keyName'), block_item.get('capacityMinimum') or '-', ])
89+
table.sortby = 'Id'
90+
table.align = 'l'
91+
return table
92+
93+
94+
def _block_snapshot_get_table(items, prices):
95+
if prices:
96+
table = formatting.Table(['Id', 'Description', 'KeyName', 'Prices'], title='Snapshot')
97+
for block_item in items:
98+
if block_item['itemCategory']['categoryCode'] == 'storage_snapshot_space':
99+
table.add_row([block_item.get('id'), block_item.get('description'),
100+
block_item.get('keyName'), block_item['prices'][0]['recurringFee']])
101+
else:
102+
table = formatting.Table(['Id', 'Description', 'KeyName'], title='Snapshot')
103+
for block_item in items:
104+
if block_item['itemCategory']['categoryCode'] == 'storage_snapshot_space':
105+
table.add_row([block_item.get('id'), block_item.get('description'),
106+
block_item.get('keyName')])
107+
table.sortby = 'Id'
108+
table.align = 'l'
109+
return table

SoftLayer/CLI/file/options.py

Lines changed: 92 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -6,47 +6,105 @@
66
import SoftLayer
77
from SoftLayer.CLI.command import SLCommand
88
from SoftLayer.CLI import environment
9+
from SoftLayer.CLI import exceptions
910
from SoftLayer.CLI import formatting
1011

1112
PACKAGE_STORAGE = 759
1213

1314

1415
@click.command(cls=SLCommand)
16+
@click.argument('location', required=False)
17+
@click.option('--prices', '-p', is_flag=True,
18+
help='Use --prices to list the server item prices, and to list the Item Prices by location,'
19+
'add it to the --prices option using location short name, e.g. --prices dal13')
1520
@environment.pass_env
16-
def cli(env):
17-
"""List all options for ordering a file storage"""
21+
def cli(env, prices, location=None):
22+
"""List all options for ordering a block storage"""
1823

1924
order_manager = SoftLayer.OrderingManager(env.client)
2025
items = order_manager.get_items(PACKAGE_STORAGE)
21-
datacenters = order_manager.get_regions(PACKAGE_STORAGE)
22-
23-
iops_table = formatting.Table(['Id', 'Description', 'KeyName'], title='IOPS')
24-
snapshot_table = formatting.Table(['Id', 'Description', 'KeyName'], title='Snapshot')
25-
file_storage_table = formatting.Table(['Id', 'Description', 'KeyName', 'Capacity Minimum'], title='Storage')
26-
datacenter_table = formatting.Table(['Id', 'Description', 'KeyName'], title='Datacenter')
27-
28-
file_storage_table.align['Description'] = 'l'
29-
file_storage_table.align['KeyName'] = 'l'
30-
file_storage_table.sortby = 'Id'
31-
for datacenter in datacenters:
32-
datacenter_table.add_row([datacenter['location']['locationId'],
33-
datacenter.get('description'),
34-
datacenter['keyname']])
35-
36-
for item in items:
37-
if item['itemCategory']['categoryCode'] == 'performance_storage_space':
38-
file_storage_table.add_row([item.get('id'), item.get('description'),
39-
item.get('keyName'), item.get('capacityMinimum') or '-'])
40-
41-
if item['itemCategory']['categoryCode'] == 'storage_tier_level':
42-
iops_table.add_row([item.get('id'), item.get('description'),
43-
item.get('keyName')])
44-
45-
if item['itemCategory']['categoryCode'] == 'storage_snapshot_space':
46-
snapshot_table.add_row([item.get('id'), item.get('description'),
47-
item.get('keyName')])
48-
49-
env.fout(datacenter_table)
50-
env.fout(iops_table)
51-
env.fout(file_storage_table)
52-
env.fout(snapshot_table)
26+
datacenters = order_manager.get_regions(PACKAGE_STORAGE, location)
27+
28+
tables = []
29+
network = SoftLayer.NetworkManager(env.client)
30+
31+
pods = network.get_closed_pods()
32+
33+
if datacenters != []:
34+
datacenter_table = formatting.Table(['Id', 'Description', 'KeyName'], title='Datacenter')
35+
36+
for datacenter in datacenters:
37+
closure = []
38+
for pod in pods:
39+
if datacenter['location']['location']['name'] in str(pod['name']):
40+
closure.append(pod['name'])
41+
42+
notes = '-'
43+
if len(closure) > 0:
44+
notes = 'closed soon: %s' % (', '.join(closure))
45+
datacenter_table.add_row([datacenter['location']['locationId'],
46+
datacenter.get('description'),
47+
datacenter['keyname'], notes])
48+
tables.append(datacenter_table)
49+
else:
50+
raise exceptions.CLIAbort('Location does not exit.')
51+
52+
tables.append(_file_ios_get_table(items, prices))
53+
tables.append(_file_storage_table(items, prices))
54+
tables.append(_file_snapshot_get_table(items, prices))
55+
env.fout(tables)
56+
57+
58+
def _file_ios_get_table(items, prices):
59+
if prices:
60+
table = formatting.Table(['Id', 'Description', 'KeyName', 'Prices'], title='IOPS')
61+
for item in items:
62+
if item['itemCategory']['categoryCode'] == 'storage_tier_level':
63+
table.add_row([item.get('id'), item.get('description'),
64+
item.get('keyName'), item['prices'][0]['recurringFee']])
65+
else:
66+
table = formatting.Table(['Id', 'Description', 'KeyName'], title='IOPS')
67+
for item in items:
68+
if item['itemCategory']['categoryCode'] == 'storage_tier_level':
69+
table.add_row([item.get('id'), item.get('description'),
70+
item.get('keyName')])
71+
table.sortby = 'Id'
72+
table.align = 'l'
73+
return table
74+
75+
76+
def _file_storage_table(items, prices):
77+
if prices:
78+
table = formatting.Table(['Id', 'Description', 'KeyName', 'Capacity Minimum', 'Prices'], title='Storage')
79+
for item in items:
80+
if item['itemCategory']['categoryCode'] == 'performance_storage_space':
81+
table.add_row([item.get('id'), item.get('description'),
82+
item.get('keyName'), item.get('capacityMinimum') or '-',
83+
item['prices'][0]['recurringFee']])
84+
else:
85+
table = formatting.Table(['Id', 'Description', 'KeyName', 'Capacity Minimum'], title='Storage')
86+
for item in items:
87+
if item['itemCategory']['categoryCode'] == 'performance_storage_space':
88+
table.add_row([item.get('id'), item.get('description'),
89+
item.get('keyName'), item.get('capacityMinimum') or '-', ])
90+
table.sortby = 'Id'
91+
table.align = 'l'
92+
return table
93+
94+
95+
def _file_snapshot_get_table(items, prices):
96+
if prices:
97+
table = formatting.Table(['Id', 'Description', 'KeyName', 'Prices'], title='Snapshot')
98+
for item in items:
99+
if item['itemCategory']['categoryCode'] == 'storage_snapshot_space':
100+
table.add_row([item.get('id'), item.get('description'),
101+
item.get('keyName'), item['prices'][0]['recurringFee']])
102+
else:
103+
table = formatting.Table(['Id', 'Description', 'KeyName'], title='Snapshot')
104+
for item in items:
105+
if item['itemCategory']['categoryCode'] == 'storage_snapshot_space':
106+
table.add_row([item.get('id'), item.get('description'),
107+
item.get('keyName')])
108+
table.sortby = 'Id'
109+
table.align = 'l'
110+
return table

SoftLayer/CLI/routes.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,7 @@
212212
('ipsec:translation-remove', 'SoftLayer.CLI.vpn.ipsec.translation.remove:cli'),
213213
('ipsec:translation-update', 'SoftLayer.CLI.vpn.ipsec.translation.update:cli'),
214214
('ipsec:update', 'SoftLayer.CLI.vpn.ipsec.update:cli'),
215+
('ipsec:order', 'SoftLayer.CLI.vpn.ipsec.order:cli'),
215216

216217
('loadbal', 'SoftLayer.CLI.loadbal'),
217218
('loadbal:detail', 'SoftLayer.CLI.loadbal.detail:cli'),
@@ -362,6 +363,7 @@
362363
('user:edit-details', 'SoftLayer.CLI.user.edit_details:cli'),
363364
('user:create', 'SoftLayer.CLI.user.create:cli'),
364365
('user:delete', 'SoftLayer.CLI.user.delete:cli'),
366+
('user:device-access', 'SoftLayer.CLI.user.device_access:cli'),
365367
('user:vpn-manual', 'SoftLayer.CLI.user.vpn_manual:cli'),
366368
('user:vpn-subnet', 'SoftLayer.CLI.user.vpn_subnet:cli'),
367369
('user:remove-access', 'SoftLayer.CLI.user.remove_access:cli'),
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
"""List User Device access."""
2+
import click
3+
4+
import SoftLayer
5+
from SoftLayer.CLI import environment
6+
from SoftLayer.CLI import formatting
7+
8+
9+
@click.command(cls=SoftLayer.CLI.command.SLCommand, )
10+
@click.argument('identifier')
11+
@environment.pass_env
12+
def cli(env, identifier):
13+
"""User Device access."""
14+
15+
mgr = SoftLayer.UserManager(env.client)
16+
all_permissions = mgr.get_user_permissions(identifier)
17+
18+
# verify the table in table
19+
table = formatting.Table(['Name', 'Value'])
20+
permission_table = formatting.Table(['KeyName', 'Name'])
21+
for permission in all_permissions:
22+
if 'ALL_' in permission['key']:
23+
permission_table.add_row([permission.get('keyName'), permission.get('name')])
24+
25+
hardwares = mgr.get_user_hardware(identifier)
26+
dedicatedhosts = mgr.get_user_dedicated_host(identifier)
27+
virtual_guests = mgr.get_user_virtuals(identifier)
28+
hardware_table = formatting.KeyValueTable(['Id', 'Device Name', 'Device type', 'Public Ip', 'Private Ip', 'notes'])
29+
virtual_table = formatting.KeyValueTable(['Id', 'Device Name', 'Device type', 'Public Ip', 'Private Ip', 'notes'])
30+
dedicated_table = formatting.KeyValueTable(['Id', 'Device Name', 'Device type', 'notes'])
31+
32+
hardware_table.align['Device Name'] = 'l'
33+
dedicated_table.align['Device Name'] = 'l'
34+
virtual_table.align['Device Name'] = 'l'
35+
for hardware in hardwares:
36+
hardware_table.add_row([hardware.get('id'),
37+
hardware.get('fullyQualifiedDomainName'),
38+
'Bare Metal',
39+
hardware.get('primaryIpAddress'),
40+
hardware.get('primaryBackendIpAddress'),
41+
hardware.get('notes') or '-'])
42+
for host in dedicatedhosts:
43+
dedicated_table.add_row([host.get('id'),
44+
host.get('name'),
45+
'Dedicated Host',
46+
host.get('notes') or '-'])
47+
for virtual in virtual_guests:
48+
virtual_table.add_row([virtual.get('id'),
49+
virtual.get('fullyQualifiedDomainName'),
50+
'virtual Guests',
51+
virtual.get('primaryIpAddress'),
52+
virtual.get('primaryBackendIpAddress'),
53+
virtual.get('notes') or '-'])
54+
55+
table.add_row(['Permission', permission_table])
56+
table.add_row(['Hardware', hardware_table])
57+
table.add_row(['Dedicated Host', dedicated_table])
58+
table.add_row(['Virtual Guest', virtual_table])
59+
60+
env.fout(table)

SoftLayer/CLI/vlan/create.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,16 @@
1919
help="Billing rate")
2020
@environment.pass_env
2121
def cli(env, name, datacenter, pod, network, billing):
22-
"""Order/create a VLAN instance."""
22+
"""Order/create a VLAN instance.
23+
24+
Example:
25+
slcli vlan create --name myvlan --datacenter dal13
26+
or
27+
slcli vlan create --name myvlan --pod dal10.pod01
28+
"""
29+
30+
if not (datacenter or pod):
31+
raise exceptions.CLIAbort("--datacenter or --pod is required to create a VLAN")
2332

2433
item_package = ['PUBLIC_NETWORK_VLAN']
2534
complex_type = 'SoftLayer_Container_Product_Order_Network_Vlan'

0 commit comments

Comments
 (0)