|
9 | 9 | from SoftLayer.CLI import helpers |
10 | 10 | from SoftLayer import utils |
11 | 11 |
|
| 12 | +# pylint: disable=R0915 |
| 13 | + |
12 | 14 |
|
13 | 15 | @click.command() |
14 | 16 | @click.argument('identifier') |
15 | 17 | @click.option('--passwords', is_flag=True, help='Show passwords (check over your shoulder!)') |
16 | 18 | @click.option('--price', is_flag=True, help='Show associated prices') |
| 19 | +@click.option('--components', is_flag=True, default=False, help='Show associated hardware components') |
17 | 20 | @environment.pass_env |
18 | | -def cli(env, identifier, passwords, price): |
| 21 | +def cli(env, identifier, passwords, price, components): |
19 | 22 | """Get details for a hardware device.""" |
20 | 23 |
|
21 | 24 | hardware = SoftLayer.HardwareManager(env.client) |
@@ -66,7 +69,7 @@ def cli(env, identifier, passwords, price): |
66 | 69 | utils.clean_time(utils.lookup(result, 'lastTransaction', 'modifyDate'))) |
67 | 70 |
|
68 | 71 | 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']) |
70 | 73 |
|
71 | 74 | vlan_table = formatting.Table(['type', 'number', 'id']) |
72 | 75 | for vlan in result['networkVlans']: |
@@ -107,6 +110,24 @@ def cli(env, identifier, passwords, price): |
107 | 110 | pass_table.add_row([item['username'], item['password']]) |
108 | 111 | table.add_row(['remote users', pass_table]) |
109 | 112 |
|
| 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 | + |
110 | 131 | table.add_row(['tags', formatting.tags(result['tagReferences'])]) |
111 | 132 |
|
112 | 133 | env.fout(table) |
|
0 commit comments