Skip to content

Commit

Permalink
Remove value checks
Browse files Browse the repository at this point in the history
  • Loading branch information
phil-dileo committed Oct 13, 2015
1 parent 77bb81a commit 1e2e6af
Showing 1 changed file with 23 additions and 30 deletions.
53 changes: 23 additions & 30 deletions pyeapi/api/routemaps.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@
Routemaps Attributes:
name (string): The name given to the routemap clause
action (choices: permit/deny): How the clause will filter the route
action (string): How the clause will filter the route. Typically
permit or deny.
seqno (integer): The sequence number of this clause
description (string): A description for the routemap clause
set (list): The list of set statements present in this clause
Expand Down Expand Up @@ -125,18 +126,13 @@ def create(self, name, action, seqno):
Args:
name (string): The full name of the routemap.
action (choices: permit,deny): The action to take for this routemap
clause.
action (string): The action to take for this routemap clause.
seqno (integer): The sequence number for the routemap clause.
Returns:
True if the routemap could be created otherwise False (see Note)
"""
if action not in ['permit', 'deny']:
raise ValueError('action must be permit or deny')
if seqno < 1 or seqno > 16777215:
raise ValueError('seqno must be an integer between 1 and 16777215')
return self.configure('route-map %s %s %s' % (name, action, seqno))

def delete(self, name, action, seqno):
Expand All @@ -149,8 +145,7 @@ def delete(self, name, action, seqno):
Args:
name (string): The full name of the routemap.
action (choices: permit,deny): The action to take for this routemap
clause.
action (string): The action to take for this routemap clause.
seqno (integer): The sequence number for the routemap clause.
Returns:
Expand All @@ -172,8 +167,7 @@ def default(self, name, action, seqno):
Args:
name (string): The full name of the routemap.
action (choices: permit,deny): The action to take for this routemap
clause.
action (string): The action to take for this routemap clause.
seqno (integer): The sequence number for the routemap clause.
Returns:
Expand All @@ -184,18 +178,19 @@ def default(self, name, action, seqno):
% (name, action, seqno))

def set_match_statements(self, name, action, seqno, statements):
"""Configures the match statements that are found within the
routemap clause. Match statements found in the routemap that
are not specified in the \'statements\' list will be removed.
"""Configures the match statements within the routemap clause.
The final configuration of match statements will reflect the list
of statements passed into the statements attribute. This implies
match statements found in the routemap that are not specified in the
statements attribute will be removed.
Args:
name (string): The full name of the routemap.
action (choices: permit,deny): The action to take for this routemap
clause.
action (string): The action to take for this routemap clause.
seqno (integer): The sequence number for the routemap clause.
statements (list): A list of the match-related statements. Note
that the statements should omit the leading
\'match\'.
match.
Returns:
True if the operation succeeds otherwise False
Expand All @@ -220,17 +215,18 @@ def set_match_statements(self, name, action, seqno, statements):
return self.configure(commands) if commands else True

def set_set_statements(self, name, action, seqno, statements):
"""Configures the set statements that are found within the
routemap clause. Set statements found in the routemap that
are not specified in the \'statements\' list will be removed.
"""Configures the set statements within the routemap clause.
The final configuration of set statements will reflect the list
of statements passed into the statements attribute. This implies
set statements found in the routemap that are not specified in the
statements attribute will be removed.
Args:
name (string): The full name of the routemap.
action (choices: permit,deny): The action to take for this routemap
clause.
action (string): The action to take for this routemap clause.
seqno (integer): The sequence number for the routemap clause.
statements (list): A list of the set-related statements. Note that
the statements should omit the leading \'set\'.
the statements should omit the leading set.
Returns:
True if the operation succeeds otherwise False
Expand Down Expand Up @@ -259,8 +255,7 @@ def set_continue(self, name, action, seqno, value=None, default=False):
Args:
name (string): The full name of the routemap.
action (choices: permit,deny): The action to take for this routemap
clause.
action (string): The action to take for this routemap clause.
seqno (integer): The sequence number for the routemap clause.
value (integer): The value to configure for the routemap continue
default (bool): Specifies to default the routemap continue value
Expand All @@ -272,9 +267,8 @@ def set_continue(self, name, action, seqno, value=None, default=False):
if default:
commands.append('default continue')
elif value is not None:
if value < 1 or value > 16777215:
raise ValueError('seqno must be an integer between '
'1 and 16777215')
if value < 1:
raise ValueError('seqno must be a positive integer')
commands.append('continue %s' % value)
else:
commands.append('no continue')
Expand All @@ -286,8 +280,7 @@ def set_description(self, name, action, seqno, value=None, default=False):
Args:
name (string): The full name of the routemap.
action (choices: permit,deny): The action to take for this routemap
clause.
action (string): The action to take for this routemap clause.
seqno (integer): The sequence number for the routemap clause.
value (string): The value to configure for the routemap description
default (bool): Specifies to default the routemap continue value
Expand Down

0 comments on commit 1e2e6af

Please sign in to comment.