Fix two bugs: one in parsing the ACI and one in comparing two ACIs

The parsing bug was looking for the string 'version' expecting to find
the ACI version. This blew up with the attribute nsosversion. Use
the string 'version 3.0' instead.

The comparison bug appeared if neither ACI had a targetattr attribute.
It was trying to create a set out of a None which is illegal. If an
ACI doesn't have any targetattrs then return () instead.
This commit is contained in:
Rob Crittenden 2009-11-12 13:11:14 -05:00 committed by Jason Gerard DeRose
parent f14f5156d4
commit 1ea6def129

View File

@ -129,7 +129,7 @@ class ACI:
self.target[var]['expression'] = val
def _parse_acistr(self, acistr):
vstart = acistr.find('version')
vstart = acistr.find('version 3.0')
if vstart < 0:
raise SyntaxError, "malformed ACI, unable to find version %s" % acistr
acimatch = ACIPat.match(acistr[vstart-1:])
@ -231,7 +231,7 @@ class ACI:
if self.target.get('targetfilter',{}).get('operator') != b.target.get('targetfilter',{}).get('operator'):
return False
if set(self.target.get('targetattr',{}).get('expression')) != set(b.target.get('targetattr',{}).get('expression')):
if set(self.target.get('targetattr', {}).get('expression', ())) != set(b.target.get('targetattr',{}).get('expression', ())):
return False
if self.target.get('targetattr',{}).get('operator') != b.target.get('targetattr',{}).get('operator'):
return False