Advertisement
Guest User

Untitled

a guest
Jan 19th, 2018
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.25 KB | None | 0 0
  1.     '''
  2.    #show switch
  3.    Switch/Stack Mac Address : e089.9d50.7000
  4.                                               H/W   Current
  5.    Switch#  Role   Mac Address     Priority Version  State
  6.    ----------------------------------------------------------
  7.    *1       Master e089.9d50.7000     15     1       Ready              
  8.     2       Member 1ce8.5d68.7b00     14     1       Ready              
  9.     3       Member 1ce8.5d68.3980     13     1       Ready              
  10.     4       Member 1ce8.5d8a.cc80     12     1       Ready              
  11.    '''
  12.     def get_switches(self):
  13.         p = re.compile(r"""              
  14.                        (\s|\*)
  15.                        (?P<switch>\d)
  16.                        \s+                          
  17.                        (?P<role>Member|Master)    
  18.                        \s+                      
  19.                        (?P<mac>[a-z0-9]{4}\.[a-z0-9]{4}\.[a-z0-9]{4})                
  20.                        \s+                          
  21.                        (?P<prior>\d{1,2})
  22.                        \s+
  23.                        (?P<version>\d+)
  24.                        \s+
  25.                        (?P<state>Ready|.*?)
  26.                        \s+
  27.                        """, re.VERBOSE)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement