Re: [pysnmp-dev] Can't get ConstraintsUnion to fail
Brought to you by:
elie
From: Graham H. <gr...@ze...> - 2016-08-15 12:55:09
|
Ilya, Thanks for the quick work ! I've tried a variety of SYNTAX rules (e.g. "0|2..10", "2..11|13..20", "0|2..20") and they all now work as I expect. Cheers, Graham. P. S. Now using PySNMP 4.3.2 ... On 13 August 2016 at 18:24, Ilya Etingof <il...@gl...> wrote: > > Hi Graham, > > Thank you for your report! That seems to be a bug in pyasn1 which is just > fixed in master (e.g. pyasn1 0.1.10): > > https://github.com/etingof/pyasn1 > > Could you please try it out? The other thing is that I’d highly recommend > using the latest pysnmp release. > > On 11 Aug 2016, at 10:07, Graham Hudspith <gr...@ze...> wrote: > > 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/> |