Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
self.list_name = self.re_match_typed(
regex, group=1, result_type=str, default='')
self.group = self.re_match_typed(
regex, group=2, result_type=str, default='')
methods_str = self.re_match_typed(
regex, group=3, result_type=str, default='')
self.methods = methods_str.strip().split('\s')
@classmethod
def is_object_for(cls, line="", re=re):
if re.search(r'^aaa\sauthentication\senable', line):
return True
return False
class NXOSAaaCommandsAuthorizationLine(BaseCfgLine):
def __init__(self, *args, **kwargs):
super(NXOSAaaCommandsAuthorizationLine, self).__init__(*args, **kwargs)
self.feature = 'aaa authorization commands'
regex = r'^aaa\sauthorization\scommands\s(\d+)\s(\S+)\sgroup\s(\S+)(.+?)$'
self.level = self.re_match_typed(
regex, group=1, result_type=int, default=0)
self.list_name = self.re_match_typed(
regex, group=2, result_type=str, default='')
self.group = self.re_match_typed(
regex, group=3, result_type=str, default='')
methods_str = self.re_match_typed(
regex, group=4, result_type=str, default='')
self.methods = methods_str.strip().split('\s')
@classmethod
def server_private(self, re=re):
retval = set([])
rgx_priv = re.compile('^\s+server-private\s+(\S+)\s')
for cobj in self.children:
mm = rgx_priv.search(cobj.text)
if not (mm is None):
retval.add(mm.group(1)) # This is the server's ip
return retval
##
##------------- NXOS AAA Lines
##
class NXOSAaaLoginAuthenticationLine(BaseCfgLine):
def __init__(self, *args, **kwargs):
super(NXOSAaaLoginAuthenticationLine, self).__init__(*args, **kwargs)
self.feature = 'aaa authentication login'
regex = r'^aaa\sauthentication\slogin\s(\S+)\sgroup\s(\S+)(.+?)$'
self.list_name = self.re_match_typed(
regex, group=1, result_type=str, default='')
self.group = self.re_match_typed(
regex, group=2, result_type=str, default='')
methods_str = self.re_match_typed(
regex, group=3, result_type=str, default='')
self.methods = methods_str.strip().split('\s')
@classmethod
def is_object_for(cls, line="", re=re):
if re.search(r'^aaa\sauthentication\slogin', line):
self.list_name = self.re_match_typed(
regex, group=1, result_type=str, default='')
self.group = self.re_match_typed(
regex, group=2, result_type=str, default='')
methods_str = self.re_match_typed(
regex, group=3, result_type=str, default='')
self.methods = methods_str.strip().split('\s')
@classmethod
def is_object_for(cls, line="", re=re):
if re.search(r'^aaa\sauthentication\senable', line):
return True
return False
class IOSAaaCommandsAuthorizationLine(BaseCfgLine):
def __init__(self, *args, **kwargs):
super(IOSAaaCommandsAuthorizationLine, self).__init__(*args, **kwargs)
self.feature = 'aaa authorization commands'
regex = r'^aaa\sauthorization\scommands\s(\d+)\s(\S+)\sgroup\s(\S+)(.+?)$'
self.level = self.re_match_typed(
regex, group=1, result_type=int, default=0)
self.list_name = self.re_match_typed(
regex, group=2, result_type=str, default='')
self.group = self.re_match_typed(
regex, group=3, result_type=str, default='')
methods_str = self.re_match_typed(
regex, group=4, result_type=str, default='')
self.methods = methods_str.strip().split('\s')
@classmethod
self.list_name = self.re_match_typed(
regex, group=2, result_type=str, default='')
self.group = self.re_match_typed(
regex, group=3, result_type=str, default='')
methods_str = self.re_match_typed(
regex, group=4, result_type=str, default='')
self.methods = methods_str.strip().split('\s')
@classmethod
def is_object_for(cls, line="", re=re):
if re.search(r'^aaa\sauthorization\scommands', line):
return True
return False
class NXOSAaaCommandsAccountingLine(BaseCfgLine):
def __init__(self, *args, **kwargs):
super(NXOSAaaCommandsAccountingLine, self).__init__(*args, **kwargs)
self.feature = 'aaa accounting commands'
regex = r'^aaa\saccounting\scommands\s(\d+)\s(\S+)\s(none|stop\-only|start\-stop)\sgroup\s(\S+)$'
self.level = self.re_match_typed(
regex, group=1, result_type=int, default=0)
self.list_name = self.re_match_typed(
regex, group=2, result_type=str, default='')
self.record_type = self.re_match_typed(
regex, group=3, result_type=str, default='')
self.group = self.re_match_typed(
regex, group=4, result_type=str, default='')
@classmethod
def is_object_for(cls, line="", re=re):
def parse_exectimeout(self):
retval = self.re_match_iter_typed(
r'^\s*exec-timeout\s+(\d+\s*\d*)\s*$',
group=1,
result_type=str,
default='')
tmp = map(int, retval.strip().split())
return tmp
##
##------------- Base NXOS Route line object
##
class BaseNXOSRouteLine(BaseCfgLine):
def __init__(self, *args, **kwargs):
super(BaseNXOSRouteLine, self).__init__(*args, **kwargs)
def __repr__(self):
return "<%s # %s '%s' info: '%s'>" % (
self.classname, self.linenum, self.network_object, self.routeinfo)
@property
def routeinfo(self):
### Route information for the repr string
if self.tracking_object_name:
return self.nexthop_str + " AD: " + str(
self.admin_distance) + " Track: " + self.tracking_object_name
else:
return self.nexthop_str + " AD: " + str(self.admin_distance)
if self.re_search('^spanning-tree\sportfast\sbpduguard\sdefault'):
return True
return False
@property
def has_stp_mode_rapidpvst(self):
if self.re_search('^spanning-tree\smode\srapid-pvst'):
return True
return False
##
##------------- Junos Hostname Line
##
class JunosHostnameLine(BaseCfgLine):
def __init__(self, *args, **kwargs):
super(JunosHostnameLine, self).__init__(*args, **kwargs)
self.feature = 'hostname'
def __repr__(self):
return "<%s # %s '%s'>" % (self.classname, self.linenum,
self.hostname)
@classmethod
def is_object_for(cls, line="", re=re):
if re.search('^hostname', line):
return True
return False
@property
def hostname(self):
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
If you need to contact the author, you can do so by emailing:
mike [~at~] pennington [/dot\] net
"""
##
##------------- ASA Configuration line object
##
class ASACfgLine(BaseCfgLine):
"""An object for a parsed ASA-style configuration line.
:class:`~models_asa.ASACfgLine` objects contain references to other
parent and child :class:`~models_asa.ASACfgLine` objects.
.. note::
Originally, :class:`~models_asa.ASACfgLine` objects were only
intended for advanced ciscoconfparse users. As of ciscoconfparse
version 0.9.10, *all users* are strongly encouraged to prefer the
methods directly on :class:`~models_asa.ASACfgLine` objects.
Ultimately, if you write scripts which call methods on
:class:`~models_asa.ASACfgLine` objects, your scripts will be much
more efficient than if you stick strictly to the classic
:class:`~ciscoconfparse.CiscoConfParse` methods.
Args:
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
If you need to contact the author, you can do so by emailing:
mike [~at~] pennington [/dot\] net
"""
##
##------------- Junos Configuration line object
##
class JunosCfgLine(BaseCfgLine):
"""An object for a parsed Junos-style configuration line.
:class:`~models_junos.JunosCfgLine` objects contain references to other
parent and child :class:`~models_junos.JunosCfgLine` objects.
.. note::
Originally, :class:`~models_junos.JunosCfgLine` objects were only
intended for advanced ciscoconfparse users. As of ciscoconfparse
version 0.9.10, *all users* are strongly encouraged to prefer the
methods directly on :class:`~models_junos.JunosCfgLine` objects.
Ultimately, if you write scripts which call methods on
:class:`~models_junos.JunosCfgLine` objects, your scripts will be much
more efficient than if you stick strictly to the classic
:class:`~ciscoconfparse.CiscoConfParse` methods.
Args:
if re.search('^hostname', line):
return True
return False
@property
def hostname(self):
retval = self.re_match_typed(r'^hostname\s+(\S+)',
result_type=str, default='')
return retval
##
##------------- Base Junos Route line object
##
class BaseJunosRouteLine(BaseCfgLine):
def __init__(self, *args, **kwargs):
super(BaseJunosRouteLine, self).__init__(*args, **kwargs)
def __repr__(self):
return "<%s # %s '%s' info: '%s'>" % (self.classname, self.linenum, self.network_object, self.routeinfo)
@property
def routeinfo(self):
### Route information for the repr string
if self.tracking_object_name:
return self.nexthop_str+" AD: "+str(self.admin_distance)+" Track: "+self.tracking_object_name
else:
return self.nexthop_str+" AD: "+str(self.admin_distance)
@classmethod
def is_object_for(cls, line="", re=re):
regex, group=1, result_type=int, default=0)
self.list_name = self.re_match_typed(
regex, group=2, result_type=str, default='')
self.record_type = self.re_match_typed(
regex, group=3, result_type=str, default='')
self.group = self.re_match_typed(
regex, group=4, result_type=str, default='')
@classmethod
def is_object_for(cls, line="", re=re):
if re.search(r'^aaa\saccounting\scommands', line):
return True
return False
class NXOSAaaExecAccountingLine(BaseCfgLine):
def __init__(self, *args, **kwargs):
super(NXOSAaaExecAccountingLine, self).__init__(*args, **kwargs)
self.feature = 'aaa accounting exec'
regex = r'^aaa\saccounting\sexec\s(\S+)\s(none|stop\-only|start\-stop)\sgroup\s(\S+)$'
self.list_name = self.re_match_typed(
regex, group=1, result_type=str, default='')
self.record_type = self.re_match_typed(
regex, group=2, result_type=str, default='')
self.group = self.re_match_typed(
regex, group=3, result_type=str, default='')
@classmethod
def is_object_for(cls, line="", re=re):
if re.search(r'^aaa\saccounting\sexec', line):
return True