Skip to content

Commit a9771e7

Browse files
caberoscaberos
authored andcommitted
fix the merge conflicts
2 parents fd579dd + 9a5f6c6 commit a9771e7

23 files changed

+406
-306
lines changed

CHANGELOG.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,18 @@
11
# Change Log
22

3+
4+
## [5.9.9] - 2021-12-07
5+
6+
https://github.com/softlayer/softlayer-python/compare/v5.9.8...v5.9.9
7+
8+
#### Improvements
9+
- Add loadbalancer timeout values #1576
10+
- Add pricing date to slcli order preset-list #1578
11+
12+
#### New Commands
13+
- `slcli vlan create-options` add new feature on vlan #1572
14+
- `slcli account bandwidth-pools` Bandwidth pool features #1579
15+
316
## [5.9.8] - 2021-12-07
417

518
https://github.com/softlayer/softlayer-python/compare/v5.9.7...v5.9.8
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
"""Displays information about the accounts bandwidth pools"""
2+
# :license: MIT, see LICENSE for more details.
3+
import click
4+
5+
from SoftLayer.CLI import environment
6+
from SoftLayer.CLI import formatting
7+
from SoftLayer.managers.account import AccountManager as AccountManager
8+
from SoftLayer import utils
9+
10+
11+
@click.command()
12+
@environment.pass_env
13+
def cli(env):
14+
"""Displays bandwidth pool information
15+
16+
Similiar to https://cloud.ibm.com/classic/network/bandwidth/vdr
17+
"""
18+
19+
manager = AccountManager(env.client)
20+
items = manager.get_bandwidth_pools()
21+
22+
table = formatting.Table([
23+
"Pool Name",
24+
"Region",
25+
"Servers",
26+
"Allocation",
27+
"Current Usage",
28+
"Projected Usage"
29+
], title="Bandwidth Pools")
30+
table.align = 'l'
31+
32+
for item in items:
33+
name = item.get('name')
34+
region = utils.lookup(item, 'locationGroup', 'name')
35+
servers = manager.get_bandwidth_pool_counts(identifier=item.get('id'))
36+
allocation = "{} GB".format(item.get('totalBandwidthAllocated', 0))
37+
current = "{} GB".format(utils.lookup(item, 'billingCyclePublicBandwidthUsage', 'amountOut'))
38+
projected = "{} GB".format(item.get('projectedPublicBandwidthUsage', 0))
39+
40+
table.add_row([name, region, servers, allocation, current, projected])
41+
env.fout(table)

SoftLayer/CLI/loadbal/detail.py

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -39,32 +39,44 @@ def lbaas_table(this_lb):
3939
listener_table, pools = get_listener_table(this_lb)
4040
table.add_row(['Protocols', listener_table])
4141

42-
member_table = get_member_table(this_lb, pools)
43-
table.add_row(['Members', member_table])
44-
45-
hp_table = get_hp_table(this_lb)
46-
table.add_row(['Health Checks', hp_table])
47-
48-
l7pool_table = get_l7pool_table(this_lb)
49-
table.add_row(['L7 Pools', l7pool_table])
50-
51-
ssl_table = get_ssl_table(this_lb)
52-
table.add_row(['Ciphers', ssl_table])
42+
if pools.get('members') is not None:
43+
member_table = get_member_table(this_lb, pools)
44+
table.add_row(['Members', member_table])
45+
else:
46+
table.add_row(['Members', "Not Found"])
47+
48+
if this_lb.get('healthMonitors') != []:
49+
hp_table = get_hp_table(this_lb)
50+
table.add_row(['Health Checks', hp_table])
51+
else:
52+
table.add_row(['Health Checks', "Not Found"])
53+
54+
if this_lb.get('l7Pools') != []:
55+
l7pool_table = get_l7pool_table(this_lb)
56+
table.add_row(['L7 Pools', l7pool_table])
57+
else:
58+
table.add_row(['L7 Pools', "Not Found"])
59+
60+
if this_lb.get('sslCiphers') != []:
61+
ssl_table = get_ssl_table(this_lb)
62+
table.add_row(['Ciphers', ssl_table])
63+
else:
64+
table.add_row(['Ciphers', "Not Found"])
5365

5466
return table
5567

5668

5769
def get_hp_table(this_lb):
5870
"""Generates a table from a list of LBaaS devices"""
5971
# https://sldn.softlayer.com/reference/datatypes/SoftLayer_Network_LBaaS_HealthMonitor/
60-
hp_table = formatting.Table(['UUID', 'Interval', 'Retries', 'Type', 'Timeout', 'Modify', 'Active'])
72+
hp_table = formatting.Table(['UUID', 'Interval', 'Retries', 'Type', 'ServerTimeout ', 'Modify', 'Active'])
6173
for health in this_lb.get('healthMonitors', []):
6274
hp_table.add_row([
6375
health.get('uuid'),
6476
health.get('interval'),
6577
health.get('maxRetries'),
6678
health.get('monitorType'),
67-
health.get('timeout'),
79+
health.get('serverTimeout'),
6880
utils.clean_time(health.get('modifyDate')),
6981
health.get('provisioningStatus')
7082
])

SoftLayer/CLI/order/preset_list.py

Lines changed: 37 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,9 @@
1616
@click.argument('package_keyname')
1717
@click.option('--keyword',
1818
help="A word (or string) used to filter preset names.")
19+
@click.option('--prices', '-p', is_flag=True, help='Use --prices to list the server item prices, e.g. --prices')
1920
@environment.pass_env
20-
def cli(env, package_keyname, keyword):
21+
def cli(env, package_keyname, keyword, prices):
2122
"""List package presets.
2223
2324
.. Note::
@@ -33,6 +34,8 @@ def cli(env, package_keyname, keyword):
3334
slcli order preset-list BARE_METAL_SERVER --keyword gpu
3435
3536
"""
37+
38+
tables = []
3639
table = formatting.Table(COLUMNS)
3740
manager = ordering.OrderingManager(env.client)
3841

@@ -41,10 +44,36 @@ def cli(env, package_keyname, keyword):
4144
_filter = {'activePresets': {'name': {'operation': '*= %s' % keyword}}}
4245
presets = manager.list_presets(package_keyname, filter=_filter)
4346

44-
for preset in presets:
45-
table.add_row([
46-
str(preset['name']).strip(),
47-
str(preset['keyName']).strip(),
48-
str(preset['description']).strip()
49-
])
50-
env.fout(table)
47+
if prices:
48+
table_prices = formatting.Table(['keyName', 'priceId', 'Hourly', 'Monthly', 'Restriction', 'Location'])
49+
for price in presets:
50+
locations = []
51+
if price['locations'] != []:
52+
for location in price['locations']:
53+
locations.append(location['name'])
54+
cr_max = get_item_price_data(price['prices'][0], 'capacityRestrictionMaximum')
55+
cr_min = get_item_price_data(price['prices'][0], 'capacityRestrictionMinimum')
56+
cr_type = get_item_price_data(price['prices'][0], 'capacityRestrictionType')
57+
table_prices.add_row([price['keyName'], price['id'],
58+
get_item_price_data(price['prices'][0], 'hourlyRecurringFee'),
59+
get_item_price_data(price['prices'][0], 'recurringFee'),
60+
"%s - %s %s" % (cr_min, cr_max, cr_type), str(locations)])
61+
tables.append(table_prices)
62+
63+
else:
64+
for preset in presets:
65+
table.add_row([
66+
str(preset['name']).strip(),
67+
str(preset['keyName']).strip(),
68+
str(preset['description']).strip()
69+
])
70+
tables.append(table)
71+
env.fout(tables)
72+
73+
74+
def get_item_price_data(price, item_attribute):
75+
"""Given an SoftLayer_Product_Item_Price, returns its default price data"""
76+
result = '-'
77+
if item_attribute in price:
78+
result = price[item_attribute]
79+
return result

SoftLayer/CLI/report/bandwidth.py

Lines changed: 28 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -47,23 +47,25 @@ def _get_pooled_bandwidth(env, start, end):
4747
label='Calculating for bandwidth pools',
4848
file=sys.stderr) as pools:
4949
for pool in pools:
50-
if not pool.get('metricTrackingObjectId'):
51-
continue
52-
53-
yield {
54-
'id': pool['id'],
50+
pool_detail = {
51+
'id': pool.get('id'),
5552
'type': 'pool',
56-
'name': pool['name'],
57-
'data': env.client.call(
53+
'name': pool.get('name'),
54+
'data': []
55+
}
56+
if pool.get('metricTrackingObjectId'):
57+
bw_data = env.client.call(
5858
'Metric_Tracking_Object',
5959
'getSummaryData',
6060
start.strftime('%Y-%m-%d %H:%M:%S %Z'),
6161
end.strftime('%Y-%m-%d %H:%M:%S %Z'),
6262
types,
6363
300,
64-
id=pool['metricTrackingObjectId'],
65-
),
66-
}
64+
id=pool.get('metricTrackingObjectId'),
65+
)
66+
pool_detail['data'] = bw_data
67+
68+
yield pool_detail
6769

6870

6971
def _get_hardware_bandwidth(env, start, end):
@@ -172,28 +174,20 @@ def _get_virtual_bandwidth(env, start, end):
172174

173175

174176
@click.command(short_help="Bandwidth report for every pool/server")
175-
@click.option(
176-
'--start',
177-
callback=_validate_datetime,
178-
default=(datetime.datetime.now() - datetime.timedelta(days=30)
179-
).strftime('%Y-%m-%d'),
180-
help="datetime in the format 'YYYY-MM-DD' or 'YYYY-MM-DD HH:MM:SS'")
181-
@click.option(
182-
'--end',
183-
callback=_validate_datetime,
184-
default=datetime.datetime.now().strftime('%Y-%m-%d'),
185-
help="datetime in the format 'YYYY-MM-DD' or 'YYYY-MM-DD HH:MM:SS'")
186-
@click.option('--sortby', help='Column to sort by',
187-
default='hostname',
188-
show_default=True)
189-
@click.option('--virtual', is_flag=True,
190-
help='Show the all bandwidth summary for each virtual server',
191-
default=False)
192-
@click.option('--server', is_flag=True,
193-
help='show the all bandwidth summary for each hardware server',
194-
default=False)
177+
@click.option('--start', callback=_validate_datetime,
178+
default=(datetime.datetime.now() - datetime.timedelta(days=30)).strftime('%Y-%m-%d'),
179+
help="datetime in the format 'YYYY-MM-DD' or 'YYYY-MM-DD HH:MM:SS'")
180+
@click.option('--end', callback=_validate_datetime, default=datetime.datetime.now().strftime('%Y-%m-%d'),
181+
help="datetime in the format 'YYYY-MM-DD' or 'YYYY-MM-DD HH:MM:SS'")
182+
@click.option('--sortby', help='Column to sort by', default='hostname', show_default=True)
183+
@click.option('--virtual', is_flag=True, default=False,
184+
help='Show only the bandwidth summary for each virtual server')
185+
@click.option('--server', is_flag=True, default=False,
186+
help='Show only the bandwidth summary for each hardware server')
187+
@click.option('--pool', is_flag=True, default=False,
188+
help='Show only the bandwidth pool summary.')
195189
@environment.pass_env
196-
def cli(env, start, end, sortby, virtual, server):
190+
def cli(env, start, end, sortby, virtual, server, pool):
197191
"""Bandwidth report for every pool/server.
198192
199193
This reports on the total data transfered for each virtual sever, hardware
@@ -243,6 +237,9 @@ def _input_to_table(item):
243237
for item in itertools.chain(_get_pooled_bandwidth(env, start, end),
244238
_get_hardware_bandwidth(env, start, end)):
245239
_input_to_table(item)
240+
elif pool:
241+
for item in _get_pooled_bandwidth(env, start, end):
242+
_input_to_table(item)
246243
else:
247244
for item in itertools.chain(_get_pooled_bandwidth(env, start, end),
248245
_get_hardware_bandwidth(env, start, end),

SoftLayer/CLI/routes.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
('account:item-detail', 'SoftLayer.CLI.account.item_detail:cli'),
2424
('account:cancel-item', 'SoftLayer.CLI.account.cancel_item:cli'),
2525
('account:orders', 'SoftLayer.CLI.account.orders:cli'),
26+
('account:bandwidth-pools', 'SoftLayer.CLI.account.bandwidth_pools:cli'),
2627

2728
('virtual', 'SoftLayer.CLI.virt'),
2829
('virtual:bandwidth', 'SoftLayer.CLI.virt.bandwidth:cli'),
@@ -355,6 +356,7 @@
355356

356357
('vlan', 'SoftLayer.CLI.vlan'),
357358
('vlan:create', 'SoftLayer.CLI.vlan.create:cli'),
359+
('vlan:create-options', 'SoftLayer.CLI.vlan.create_options:cli'),
358360
('vlan:detail', 'SoftLayer.CLI.vlan.detail:cli'),
359361
('vlan:edit', 'SoftLayer.CLI.vlan.edit:cli'),
360362
('vlan:list', 'SoftLayer.CLI.vlan.list:cli'),
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
"""Vlan order options."""
2+
# :license: MIT, see LICENSE for more details.
3+
# pylint: disable=too-many-statements
4+
import click
5+
6+
import SoftLayer
7+
from SoftLayer.CLI import environment
8+
from SoftLayer.CLI import formatting
9+
10+
11+
@click.command(short_help="Get options to use for creating Vlan servers.")
12+
@environment.pass_env
13+
def cli(env):
14+
"""List all the options for creating VLAN"""
15+
16+
mgr = SoftLayer.NetworkManager(env.client)
17+
datacenters = mgr.get_list_datacenter()
18+
19+
table = formatting.Table(['Options', 'Value'], title="Datacenters")
20+
router_table = formatting.Table(['Datacenter', 'Router/Pod'])
21+
dc_table = formatting.Table(['Datacenters'])
22+
table.add_row(['VLAN type', 'Private, Public'])
23+
24+
for datacenter in datacenters:
25+
dc_table.add_row([datacenter['name']])
26+
routers = mgr.get_routers(datacenter['id'])
27+
for router in routers:
28+
router_table.add_row([datacenter['name'], router['hostname']])
29+
30+
table.add_row(['Datacenters', dc_table])
31+
table.add_row(['Routers', router_table])
32+
33+
env.fout(table)

SoftLayer/consts.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
66
:license: MIT, see LICENSE for more details.
77
"""
8-
VERSION = 'v5.9.8'
8+
VERSION = 'v5.9.9'
99
API_PUBLIC_ENDPOINT = 'https://api.softlayer.com/xmlrpc/v3.1/'
1010
API_PRIVATE_ENDPOINT = 'https://api.service.softlayer.com/xmlrpc/v3.1/'
1111
API_PUBLIC_ENDPOINT_REST = 'https://api.softlayer.com/rest/v3.1/'

SoftLayer/fixtures/SoftLayer_Account.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1207,3 +1207,21 @@
12071207
"version": 4
12081208
}
12091209
}]
1210+
1211+
getBandwidthAllotments = [{
1212+
'billingCyclePublicBandwidthUsage': {
1213+
'amountIn': '6.94517',
1214+
'amountOut': '6.8859'
1215+
},
1216+
'id': 309961,
1217+
'locationGroup': {
1218+
'description': 'All Datacenters in Mexico',
1219+
'id': 262,
1220+
'locationGroupTypeId': 1,
1221+
'name': 'MEX',
1222+
'securityLevelId': None
1223+
},
1224+
'name': 'MexRegion',
1225+
'projectedPublicBandwidthUsage': 9.88,
1226+
'totalBandwidthAllocated': 3361
1227+
}]

SoftLayer/fixtures/SoftLayer_Location_Datacenter.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,5 @@
1010
"name": "dal09"
1111
}
1212
]
13+
14+
getHardwareRouters = []

0 commit comments

Comments
 (0)