Skip to content

Commit c1a6ecc

Browse files
committed
Merge branch 'softlayer:master' into ft/hw_upgrade_table
2 parents 9688980 + 4694601 commit c1a6ecc

22 files changed

+288
-104
lines changed

CHANGELOG.md

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

3+
4+
## [5.9.5] - 2021-05-25
5+
https://github.com/softlayer/softlayer-python/compare/v5.9.4...v5.9.5
6+
7+
#### Improvements
8+
- Changed a testing domain to one that really doesnt exist #1492
9+
- Fix Incomplete notes field for file and block #1484
10+
- Show component versions on hw detail #1470
11+
- Add the firewall information on slcli firewall detail #1475
12+
- Add an --orderBy parameters to call-api #1459
13+
- Add image detail transaction data #1479
14+
15+
16+
317
## [5.9.4] - 2021-04-27
418
https://github.com/softlayer/softlayer-python/compare/v5.9.3...v5.9.4
519

README.rst

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,12 @@ To install the slcli snap:
6060

6161
.. code-block:: bash
6262
63-
$ sudo snap install slcli
63+
$ sudo snap install slcli
64+
65+
(or to get the latest release)
66+
67+
$ sudo snap install slcli --edge
68+
6469
6570
6671

SoftLayer/CLI/block/list.py

Lines changed: 3 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@
55
import SoftLayer
66
from SoftLayer.CLI import columns as column_helper
77
from SoftLayer.CLI import environment
8-
from SoftLayer.CLI import formatting
9-
8+
from SoftLayer.CLI import storage_utils
109

1110
COLUMNS = [
1211
column_helper.Column('id', ('id',), mask="id"),
@@ -18,7 +17,7 @@
1817
'storage_type',
1918
lambda b: b['storageType']['keyName'].split('_').pop(0)
2019
if 'storageType' in b and 'keyName' in b['storageType']
21-
and isinstance(b['storageType']['keyName'], str)
20+
and isinstance(b['storageType']['keyName'], str)
2221
else '-',
2322
mask="storageType.keyName"),
2423
column_helper.Column('capacity_gb', ('capacityGb',), mask="capacityGb"),
@@ -52,8 +51,6 @@
5251
'notes'
5352
]
5453

55-
DEFAULT_NOTES_SIZE = 20
56-
5754

5855
@click.command()
5956
@click.option('--username', '-u', help='Volume username')
@@ -78,24 +75,5 @@ def cli(env, sortby, columns, datacenter, username, storage_type, order):
7875
order=order,
7976
mask=columns.mask())
8077

81-
table = formatting.Table(columns.columns)
82-
table.sortby = sortby
83-
84-
_reduce_notes(block_volumes)
85-
86-
for block_volume in block_volumes:
87-
table.add_row([value or formatting.blank()
88-
for value in columns.row(block_volume)])
89-
78+
table = storage_utils.build_output_table(env, block_volumes, columns, sortby)
9079
env.fout(table)
91-
92-
93-
def _reduce_notes(block_volumes):
94-
"""Reduces the size of the notes in a volume list.
95-
96-
:param block_volumes: An list of block volumes
97-
"""
98-
for block_volume in block_volumes:
99-
if len(block_volume.get('notes', '')) > DEFAULT_NOTES_SIZE:
100-
shortened_notes = block_volume['notes'][:DEFAULT_NOTES_SIZE]
101-
block_volume['notes'] = shortened_notes

SoftLayer/CLI/environment.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@ def fmt(self, output, fmt=None):
5252
fmt = self.format
5353
return formatting.format_output(output, fmt)
5454

55+
def format_output_is_json(self):
56+
"""Return True if format output is json or jsonraw"""
57+
return 'json' in self.format
58+
5559
def fout(self, output, newline=True):
5660
"""Format the input and output to the console (stdout)."""
5761
if output is not None:

SoftLayer/CLI/file/list.py

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import SoftLayer
66
from SoftLayer.CLI import columns as column_helper
77
from SoftLayer.CLI import environment
8-
from SoftLayer.CLI import formatting
8+
from SoftLayer.CLI import storage_utils
99

1010
COLUMNS = [
1111
column_helper.Column('id', ('id',), mask="id"),
@@ -76,24 +76,5 @@ def cli(env, sortby, columns, datacenter, username, storage_type, order):
7676
order=order,
7777
mask=columns.mask())
7878

79-
table = formatting.Table(columns.columns)
80-
table.sortby = sortby
81-
82-
_reduce_notes(file_volumes)
83-
84-
for file_volume in file_volumes:
85-
table.add_row([value or formatting.blank()
86-
for value in columns.row(file_volume)])
87-
79+
table = storage_utils.build_output_table(env, file_volumes, columns, sortby)
8880
env.fout(table)
89-
90-
91-
def _reduce_notes(file_volumes):
92-
"""Reduces the size of the notes in a volume list.
93-
94-
:param file_volumes: An list of file volumes
95-
"""
96-
for file_volume in file_volumes:
97-
if len(file_volume.get('notes', '')) > DEFAULT_NOTES_SIZE:
98-
shortened_notes = file_volume['notes'][:DEFAULT_NOTES_SIZE]
99-
file_volume['notes'] = shortened_notes

SoftLayer/CLI/hardware/detail.py

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,16 @@
99
from SoftLayer.CLI import helpers
1010
from SoftLayer import utils
1111

12+
# pylint: disable=R0915
13+
1214

1315
@click.command()
1416
@click.argument('identifier')
1517
@click.option('--passwords', is_flag=True, help='Show passwords (check over your shoulder!)')
1618
@click.option('--price', is_flag=True, help='Show associated prices')
19+
@click.option('--components', is_flag=True, default=False, help='Show associated hardware components')
1720
@environment.pass_env
18-
def cli(env, identifier, passwords, price):
21+
def cli(env, identifier, passwords, price, components):
1922
"""Get details for a hardware device."""
2023

2124
hardware = SoftLayer.HardwareManager(env.client)
@@ -66,7 +69,7 @@ def cli(env, identifier, passwords, price):
6669
utils.clean_time(utils.lookup(result, 'lastTransaction', 'modifyDate')))
6770

6871
table.add_row(['last_transaction', last_transaction])
69-
table.add_row(['billing', 'Hourly' if result['hourlyBillingFlag'] else'Monthly'])
72+
table.add_row(['billing', 'Hourly' if result['hourlyBillingFlag'] else 'Monthly'])
7073

7174
vlan_table = formatting.Table(['type', 'number', 'id'])
7275
for vlan in result['networkVlans']:
@@ -107,6 +110,24 @@ def cli(env, identifier, passwords, price):
107110
pass_table.add_row([item['username'], item['password']])
108111
table.add_row(['remote users', pass_table])
109112

113+
if components:
114+
components = hardware.get_components(identifier)
115+
components_table = formatting.Table(['name', 'Firmware version', 'Firmware build date', 'Type'])
116+
components_table.align['date'] = 'l'
117+
component_ids = []
118+
for hw_component in components:
119+
if hw_component['id'] not in component_ids:
120+
firmware = hw_component['hardwareComponentModel']['firmwares'][0]
121+
components_table.add_row([utils.lookup(hw_component, 'hardwareComponentModel', 'longDescription'),
122+
utils.lookup(firmware, 'version'),
123+
utils.clean_time(utils.lookup(firmware, 'createDate')),
124+
utils.lookup(hw_component, 'hardwareComponentModel',
125+
'hardwareGenericComponentModel', 'hardwareComponentType',
126+
'keyName')])
127+
component_ids.append(hw_component['id'])
128+
129+
table.add_row(['components', components_table])
130+
110131
table.add_row(['tags', formatting.tags(result['tagReferences'])])
111132

112133
env.fout(table)

SoftLayer/CLI/storage_utils.py

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,43 @@
22
# :license: MIT, see LICENSE for more details.
33

44
from SoftLayer.CLI import columns as column_helper
5+
from SoftLayer.CLI import formatting
6+
7+
DEFAULT_NOTES_SIZE = 20
8+
9+
10+
def reduce_notes(volumes, env):
11+
"""Reduces all long notes found in the volumes list just if the format output is different from a JSON format.
12+
13+
:param list volumes: An list of storage volumes
14+
:param env :A environment console.
15+
"""
16+
if env.format_output_is_json():
17+
return
18+
19+
for volume in volumes:
20+
if len(volume.get('notes', '')) > DEFAULT_NOTES_SIZE:
21+
shortened_notes = volume['notes'][:DEFAULT_NOTES_SIZE]
22+
volume['notes'] = shortened_notes
23+
24+
25+
def build_output_table(env, volumes, columns, sortby):
26+
"""Builds a formatting table for a list of volumes.
27+
28+
:param env :A Environment console.
29+
:param list volumes: An list of storage volumes
30+
:param columns :A ColumnFormatter for column names
31+
:param str sortby :A string to sort by.
32+
"""
33+
table = formatting.Table(columns.columns)
34+
if sortby in table.columns:
35+
table.sortby = sortby
36+
37+
reduce_notes(volumes, env)
38+
for volume in volumes:
39+
table.add_row([value or formatting.blank()
40+
for value in columns.row(volume)])
41+
return table
542

643

744
def _format_name(obj):
@@ -96,7 +133,6 @@ def _format_name(obj):
96133
"""),
97134
]
98135

99-
100136
DEFAULT_COLUMNS = [
101137
'id',
102138
'name',

SoftLayer/CLI/virt/create.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ def _parse_create_args(client, args):
177177
help="Forces the VS to only have access the private network")
178178
@click.option('--like', is_eager=True, callback=_update_with_like_args,
179179
help="Use the configuration from an existing VS")
180-
@click.option('--network', '-n', help="Network port speed in Mbps")
180+
@click.option('--network', '-n', help="Network port speed in Mbps", type=click.INT)
181181
@helpers.multi_option('--tag', '-g', help="Tags to add to the instance")
182182
@click.option('--template', '-t', is_eager=True,
183183
callback=template.TemplateCallback(list_args=['disk', 'key', 'tag']),

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.4'
8+
VERSION = 'v5.9.5'
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_Hardware_Server.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -377,3 +377,21 @@
377377
}
378378
}
379379
]
380+
381+
getComponents = [{
382+
"hardwareComponentModelId": 147,
383+
"hardwareId": 1234,
384+
"id": 369,
385+
"modifyDate": "2017-11-10T16:59:38-06:00",
386+
"serviceProviderId": 1,
387+
"hardwareComponentModel": {
388+
"name": "IMM2 - Onboard",
389+
"firmwares": [
390+
{
391+
"createDate": "2020-09-24T13:46:29-06:00",
392+
"version": "5.60"
393+
},
394+
{
395+
"createDate": "2019-10-14T16:51:12-06:00",
396+
"version": "5.10"
397+
}]}}]

0 commit comments

Comments
 (0)