|
| 1 | +"""Get monitoring for a hardware device.""" |
| 2 | +# :license: MIT, see LICENSE for more details. |
| 3 | + |
| 4 | +import click |
| 5 | + |
| 6 | +import SoftLayer |
| 7 | +from SoftLayer.CLI import environment |
| 8 | +from SoftLayer.CLI import formatting |
| 9 | + |
| 10 | + |
| 11 | +@click.command() |
| 12 | +@click.argument('identifier') |
| 13 | +@environment.pass_env |
| 14 | +def cli(env, identifier): |
| 15 | + """Get details for a hardware monitors device.""" |
| 16 | + |
| 17 | + hardware = SoftLayer.HardwareManager(env.client) |
| 18 | + |
| 19 | + table = formatting.KeyValueTable(['name', 'value']) |
| 20 | + table.align['name'] = 'r' |
| 21 | + table.align['value'] = 'l' |
| 22 | + |
| 23 | + monitoring = hardware.get_hardware(identifier) |
| 24 | + |
| 25 | + table.add_row(['Domain', monitoring.get('fullyQualifiedDomainName')]) |
| 26 | + table.add_row(['Public Ip', monitoring.get('primaryIpAddress')]) |
| 27 | + table.add_row(['Private Ip', monitoring.get('primaryBackendIpAddress')]) |
| 28 | + table.add_row(['Location', monitoring['datacenter']['longName']]) |
| 29 | + |
| 30 | + monitoring_table = formatting.Table(['Id', 'IpAddress', 'Status', 'Type', 'Notify']) |
| 31 | + for monitor in monitoring['networkMonitors']: |
| 32 | + monitoring_table.add_row([monitor.get('id'), monitor.get('ipAddress'), monitor.get('status'), |
| 33 | + monitor['queryType']['name'], monitor['responseAction']['actionDescription']]) |
| 34 | + |
| 35 | + table.add_row(['Devices monitors', monitoring_table]) |
| 36 | + |
| 37 | + env.fout(table) |
0 commit comments