cpal icon indicating copy to clipboard operation
cpal copied to clipboard

Modified getHostname, getFQDN and getCPU to utilize regEX

Open yandy-r opened this issue 10 years ago • 2 comments

Modified the three above methods to use regex, should be much more efficient than the 3000 lines of string and list splitting.

still works as expected

$ python core/main.py -i veos-03 -m arista -f getFacts
{   'connect_ip': 'veos-03',
    'cpu_utilization': u'2.2%',
    'free_system_memory': 57532,
    'hostname': u'veos-03',
    'platform': u'vEOS',
    'serial_number': '12345',
    'system_uptime': u' 3:45',
    'total_sytem_memory': 1000444,
    'var_name': 'dev',
    'vendor': 'arista',
    'version': u'4.12.1-1581426.vEOS4125.1 (engineering build)'}

yandy-r avatar Apr 10 '14 22:04 yandy-r

Been on vaca for a few days...hoping to get to some of this real soon.

jedelman8 avatar Apr 16 '14 12:04 jedelman8

Vacation? Da h*ll is that? ;) I kid of course. No worries man, but been meaning to port some code I've been working on, but dont' want to fill the queue.

Part of what I've been working on Parsing a Routing Table, of course the single run method in device()... and a some other goodies.

I also noted a bug in your getRoutes() method in onepk, you use c as a counter, but never increment it. The loop keeps over writing the same index.

c = 1
for r in route_list:
    routes['route'] = str(r.prefix.address) + '/' + str(r.prefix.prefix_length)
    routes['prefix'] = r.prefix.address
    routes['prefix_length'] = r.prefix.prefix_length
    routes['admin_distance'] = r.admin_distance
    routes['type'] = ''
    routes['metric'] = ''
    all_routes[c] = routes
    c += 1 # just add that

Look at the last line

Enjoy your vaca man, come back rested.

yandy-r avatar Apr 18 '14 03:04 yandy-r