Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modified getHostname, getFQDN and getCPU to utilize regEX #27

Open
wants to merge 17 commits into
base: master
Choose a base branch
from
Open

Modified getHostname, getFQDN and getCPU to utilize regEX #27

wants to merge 17 commits into from

Conversation

yandy-r
Copy link
Contributor

@yandy-r yandy-r commented Apr 10, 2014

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 Ramirez added 16 commits April 6, 2014 09:31
Merging from main repo
adding extension back in
removing deleted files
merging latest changes
* origin/master:
  added: getFQDN (as per Yandy's recent modifications) changed: getHostname to only output the hostname, not FQDN added: setLogin (as created by Yandy) added: getInterfaces to iControl (at last) including output of each's MAC, MTU and status added: getInterfaceNumber to iControl & main (number of physical interfaces) added: getVLANNumber (number of L2 interfaces)  to iControl & main added: getIPNumber to iControl & main added: getTunnelNumber (IPsec)  to iControl & main
  added: getFQDN (as per Yandy's recent modifications) changed: getHostname to only output the hostname, not FQDN added: setLogin (as created by Yandy) added: getInterfaces to iControl (at last) including output of each's MAC, MTU and status added: getInterfaceNumber to iControl & main (number of physical interfaces) added: getVLANNumber (number of L2 interfaces)  to iControl & main added: getIPNumber to iControl & main added: getTunnelNumber (IPsec)  to iControl & main
@jedelman8
Copy link
Owner

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

@yandy-r
Copy link
Contributor Author

yandy-r commented Apr 18, 2014

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants