jedelman8 / cpal

The Common Programmable Abstraction Layer
22 stars 10 forks source link

updated getHostname, added getCPU #14

Closed yandy-r closed 10 years ago

yandy-r commented 10 years ago

updated getHostname() to use JSON instead of text, much easier to parse.

$ python main.py -i 10.17.31.51 -m arista -n 'SW1' -f getHostname
eos-sw01

added getCPU method, returns entire line of cpu.

$ python main.py -i 10.17.31.51 -m arista -n 'SW1' -f getCPU
Cpu(s): 11.2%us,  1.4%sy,  0.0%ni, 87.2%id,  0.2%wa,  0.0%hi,  0.0%si,  0.0%st

This can be changed to return only:

Cpu(s): 11.2%us

or just

11.2%us

First one is much more verbose, but let me know and I can commit the change before merging.

added getFacts to device(), to streamline the calling of getFacts a bit and allow to be called with the -f switch, added some pretty code to createDevice() to allow printing of complex data like dictionaries for testing.

$ python main.py -i 10.17.31.51 -m arista -n 'SW1' -f getFacts
!
python main.py -i 10.17.31.51 -m arista -n 'SW1' -f getFacts
{   'connect_ip': '10.17.31.51',
    'cpu_utilization': u'Cpu(s): 11.0%us,  1.4%sy,  0.0%ni, 87.4%id,  0.1%wa,  0.0%hi,  0.0%si,  0.0%st',
    'free_system_memory': 1284928,
    'hostname': u'eos-sw01',
    'platform': u'DCS-7050T-64-R',
    'serial_number': u'JPE13020644',
    'system_uptime': u' 2:45',
    'total_sytem_memory': 3990500,
    'var_name': 'dev',
    'vendor': 'arista'}
jedelman8 commented 10 years ago

Okay, very nice. All looks good to me. Thanks for making the output pretty...def wanted to do that. Looks like you read my mind though! :+1: