@ -1950,7 +1950,7 @@ def bgpConfig(
elif ( bgpArg1 == " log-neighbor-changes " ) :
elif ( bgpArg1 == " log-neighbor-changes " ) :
# debugOutput(bgpArg1)
# debugOutput(bgpArg1)
command = command + bgpArg1 f
command = command + bgpArg1
elif ( bgpArg1 == " maxas-limit " ) :
elif ( bgpArg1 == " maxas-limit " ) :
# debugOutput(bgpArg1)
# debugOutput(bgpArg1)
@ -3257,15 +3257,14 @@ def checkSanityofVariable(deviceType, variableId, variableValue):
def getRuleStringForVariable ( deviceType , ruleFile , variableId ) :
def getRuleStringForVariable ( deviceType , ruleFile , variableId ) :
retVal = " "
retVal = " "
try :
try :
# with open(ruleFile, 'r') as f:
with open ( ruleFile , ' r ' ) as f :
f = open ( errorFile , ' r ' )
for line in f :
for line in f :
# debugOutput(line)
# debugOutput(line)
if ( ' : ' in line ) :
if ( ' : ' in line ) :
data = line . split ( ' : ' )
data = line . split ( ' : ' )
# debugOutput(data[0])
# debugOutput(data[0])
if ( data [ 0 ] . strip ( ) == variableId ) :
if ( data [ 0 ] . strip ( ) == variableId ) :
retVal = line
retVal = line
except Exception :
except Exception :
ruleString = cnos_devicerules . getRuleString ( deviceType , variableId )
ruleString = cnos_devicerules . getRuleString ( deviceType , variableId )
retVal = ruleString . strip ( )
retVal = ruleString . strip ( )
@ -3342,7 +3341,7 @@ def validateValueAgainstRule(ruleString, variableValue):
return " Error-115 "
return " Error-115 "
elif ( variableType == " LONG " ) :
elif ( variableType == " LONG " ) :
result = check Long ( variableValue )
result = check Integer ( variableValue )
if ( result is True ) :
if ( result is True ) :
return " ok "
return " ok "
else :
else :
@ -3350,11 +3349,11 @@ def validateValueAgainstRule(ruleString, variableValue):
elif ( variableType == " LONG_VALUE " ) :
elif ( variableType == " LONG_VALUE " ) :
long_range = varRange . split ( ' - ' )
long_range = varRange . split ( ' - ' )
r = range ( long ( long_range [ 0 ] . strip ( ) ) , long ( long_range [ 1 ] . strip ( ) ) )
r = range ( int ( long_range [ 0 ] . strip ( ) ) , int ( long_range [ 1 ] . strip ( ) ) )
if ( check Long ( variableValue ) is not True ) :
if ( check Integer ( variableValue ) is not True ) :
# debugOutput(variableValue)
# debugOutput(variableValue)
return " Error-116 "
return " Error-116 "
result = long ( variableValue ) in r
result = int ( variableValue ) in r
if ( result is True ) :
if ( result is True ) :
return " ok "
return " ok "
else :
else :
@ -3362,10 +3361,10 @@ def validateValueAgainstRule(ruleString, variableValue):
elif ( variableType == " LONG_VALUE_RANGE " ) :
elif ( variableType == " LONG_VALUE_RANGE " ) :
long_range = varRange . split ( ' - ' )
long_range = varRange . split ( ' - ' )
r = range ( long ( long_range [ 0 ] . strip ( ) ) , long ( long_range [ 1 ] . strip ( ) ) )
r = range ( int ( long_range [ 0 ] . strip ( ) ) , int ( long_range [ 1 ] . strip ( ) ) )
val_range = variableValue . split ( ' - ' )
val_range = variableValue . split ( ' - ' )
if ( ( check Long ( val_range [ 0 ] ) is not True ) or
if ( ( check Integer ( val_range [ 0 ] ) is not True ) or
( check Long ( val_range [ 1 ] ) is not True ) ) :
( check Integer ( val_range [ 1 ] ) is not True ) ) :
return " Error-117 "
return " Error-117 "
result = ( val_range [ 0 ] in r ) and (
result = ( val_range [ 0 ] in r ) and (
val_range [ 1 ] in r ) and ( val_range [ 0 ] < val_range [ 1 ] )
val_range [ 1 ] in r ) and ( val_range [ 0 ] < val_range [ 1 ] )
@ -3375,7 +3374,7 @@ def validateValueAgainstRule(ruleString, variableValue):
return " Error-113 "
return " Error-113 "
elif ( variableType == " LONG_OPTIONS " ) :
elif ( variableType == " LONG_OPTIONS " ) :
long_options = varRange . split ( ' , ' )
long_options = varRange . split ( ' , ' )
if ( check Long ( variableValue ) is not True ) :
if ( check Integer ( variableValue ) is not True ) :
return " Error-116 "
return " Error-116 "
for opt in long_options :
for opt in long_options :
if ( opt . strip ( ) == variableValue ) :
if ( opt . strip ( ) == variableValue ) :
@ -3531,14 +3530,6 @@ def checkFloat(s):
# EOM
# EOM
def checkLong ( s ) :
try :
long ( s )
return True
except ValueError :
return False
def debugOutput ( command ) :
def debugOutput ( command ) :
f = open ( ' debugOuput.txt ' , ' a ' )
f = open ( ' debugOuput.txt ' , ' a ' )
f . write ( str ( command ) ) # python will convert \n to os.linesep
f . write ( str ( command ) ) # python will convert \n to os.linesep