[pysnmp-dev] Can't get ConstraintsUnion to fail
Brought to you by:
elie
From: Graham H. <gr...@ze...> - 2016-08-11 08:36:34
|
Hi I'm playing with a MIB where I want to experiment with the range of values allowed for a particular param. This is with PySNMP 4.2.5, PyASN1 0.1.9 on Ubuntu 16.04.1 with Python 2.7. The current syntax for the param is: SYNTAX Integer32(2..10) and, indeed, if the agent sends a value outside that range (say, 12), an exception is thrown. Great. The problem is that if I alter that syntax to: SYNTAX Integer32(0|2..10) and re-run the bulkCmd(), the operation now succeeds even though the agent is still sending an illegal value (12). When I examine the output from compiling the MIB file, I can see that the old code: someParam = MibTableColumn((1, 2, 3, 4), Integer32().subtype(subtypeSpec=ValueRangeConstraint(2, 10))).setMaxAccess("readonly") has become what seems sensible: someParam = MibTableColumn((1, 2, 3, 4), Integer32().subtype(subtypeSpec=ConstraintsUnion(ValueRangeConstraint(0,0),ValueRangeConstraint(2,10),))).setMaxAccess("readonly") However, when I breakpoint through the code, I can see that it gets into: pyasn1/type/constraint.py(192)_testValue(): -> v(value, idx) (Pdb) print self ConstraintsUnion(ConstraintsUnion(ValueRangeConstraint(0, 0), ValueRangeConstraint(2, 10)), ConstraintsIntersection(ConstraintsIntersection(), ValueRangeConstraint(-2147483648, 2147483647))) and this looks wrong to me. I can see that the "inner" ConstraintsUnion will fail, but won't the ConstraintsIntersection succeed, meaning that the "outer" ConstraintsUnion will also succeed ? My apologies if this is too terse a description, I can provide more detail if you require. Regards, Graham -- *Graham Hudspith Zeetta Networks Limited*Software Engineer Engine Shed, Station Approach, gr...@ze... Temple Meads, Bristol, BS1 6QH United Kingdom zeetta.com <http://www.zeetta.com/> |