On 2 July 2014 14:40, Gavin Panella <email address hidden> wrote:
> Review: Approve
>
> Looks good, but see my comments in the diff.
Thanks for the review!
> Diff comments:
>
>> === modified file 'src/maasserver/models/nodegroupinterface.py'
>> --- src/maasserver/models/nodegroupinterface.py 2014-06-30 14:46:10 +0000
>> +++ src/maasserver/models/nodegroupinterface.py 2014-07-02 13:30:15 +0000
>> @@ -218,18 +218,49 @@
>> # form; validation breaks if we pass an IPAddress.
>> self.broadcast_ip = unicode(network.broadcast)
>>
>> + def clean_ip_range_bounds(self):
>> + """Ensure that the static and dynamic ranges have sane bounds."""
>> + if (self.management != NODEGROUPINTERFACE_MANAGEMENT.UNMANAGED and
>
> This same condition appears already in 4 other places. What do you think of adding an `is_managed` property?
I think I noticed the same thing but was lazy. Gut Idee.
>> + (self.static_ip_range_low and self.static_ip_range_high)):
>
> Should do the `is not None` thing here, to avoid evaluating static_ip_range_{low,high} in a boolean context, which might not coincide with what you intend.
No; (static_)ip_range_(low|high) can be an empty string, too.
On 2 July 2014 14:40, Gavin Panella <email address hidden> wrote:
> Review: Approve
>
> Looks good, but see my comments in the diff.
Thanks for the review!
> Diff comments: /models/ nodegroupinterf ace.py' models/ nodegroupinterf ace.py 2014-06-30 14:46:10 +0000 models/ nodegroupinterf ace.py 2014-07-02 13:30:15 +0000 network. broadcast) range_bounds( self): ACE_MANAGEMENT. UNMANAGED and
>
>> === modified file 'src/maasserver
>> --- src/maasserver/
>> +++ src/maasserver/
>> @@ -218,18 +218,49 @@
>> # form; validation breaks if we pass an IPAddress.
>> self.broadcast_ip = unicode(
>>
>> + def clean_ip_
>> + """Ensure that the static and dynamic ranges have sane bounds."""
>> + if (self.management != NODEGROUPINTERF
>
> This same condition appears already in 4 other places. What do you think of adding an `is_managed` property?
I think I noticed the same thing but was lazy. Gut Idee.
>> + (self.static_ ip_range_ low and self.static_ ip_range_ high)): ip_range_ {low,high} in a boolean context, which might not coincide with what you intend.
>
> Should do the `is not None` thing here, to avoid evaluating static_
No; (static_ )ip_range_ (low|high) can be an empty string, too.
>> + errors = {} self.ip_ range_low) self.ip_ range_high) self.static_ ip_range_ low) ip_range_ high = IPAddress( self.static_ ip_range_ high)
>> + ip_range_low = IPAddress(
>> + ip_range_high = IPAddress(
>> + static_ip_range_low = IPAddress(
>> + static_
>> +
>> + message_base = (
>> + "Lower bound %s is higher than upper bound %s")
>
> Any reason we don't reorder them automatically?
Yes. If I write:
ip_range_low = 10.1.0.100
ip_range_high = 10.1.0.15
How are we to know that I didn't mean to write low = 10.1.0.10?
>> + try: static_ ip_range_ low, static_ ip_range_ high) ip_range_ low, self.static_ ip_range_ high)) 'static_ ip_range_ low'] = [message] 'static_ ip_range_ high'] = [message] ip_range_ low, ip_range_high) range_high) ) 'ip_range_ low'] = [message] 'ip_range_ high'] = [message] (errors) ranges( self): ACE_MANAGEMENT. UNMANAGED and ip_range_ low and self.static_ ip_range_ high)): self.ip_ range_low) self.ip_ range_high) self.static_ ip_range_ low) ip_range_ high = IPAddress( self.static_ ip_range_ high) ip_range_ low, ip_range_ high) ip_range_ low, static_ ip_range_ high) network_ not_too_ big() ips_in_ network( ) network_ config_ if_managed( ) ip_range_ bounds( ) ip_ranges( ) /models/ tests/test_ nodegroupinterf ace.py' models/ tests/test_ nodegroupinterf ace.py 2014-07-02 07:05:24 +0000 models/ tests/test_ nodegroupinterf ace.py 2014-07-02 13:30:15 +0000 ip_range_ high': [message], l(errors, exception. message_ dict) ip_range_ bounds_ checks_ for_reversed_ range_bounds( self): "10.1.0. 0/16") network) ip_range_ low = '10.1.0.2' ip_range_ high = '10.1.0.1' static_ ip_range_ low = '10.1.0.10' static_ ip_range_ high = '10.1.0.9' full_clean) ip_range_ low, interface. ip_range_ high)], ip_range_ low, interface. ip_range_ high)], ip_range_ low': [ static_ ip_range_ low, static_ ip_range_ high)], ip_range_ high': [ static_ ip_range_ low, static_ ip_range_ high)], l(errors, exception. message_ dict) /code.launchpad .net/~gmb/ maas/bug- 1336617/ +merge/ 225325
>> + IPRange(
>> + except AddrFormatError:
>> + message = (
>> + message_base % (
>> + self.static_
>> + errors[
>> + errors[
>> + try:
>> + IPRange(
>> + except AddrFormatError:
>> + message = (
>> + message_base % (self.ip_range_low, self.ip_
>> + errors[
>> + errors[
>> +
>> + if errors:
>> + raise ValidationError
>> +
>> def clean_ip_
>> """Ensure that the static and dynamic ranges don't overlap."""
>> if (self.management != NODEGROUPINTERF
>> (self.static_
>> + errors = {}
>> ip_range_low = IPAddress(
>> ip_range_high = IPAddress(
>> static_ip_range_low = IPAddress(
>> static_
>>
>> static_range = IPRange(
>> - static_
>> - static_
>> + static_
>> dynamic_range = IPRange(
>> ip_range_low, ip_range_high)
>>
>> @@ -260,4 +291,5 @@
>> self.clean_
>> self.clean_
>> self.clean_
>> + self.clean_
>> self.clean_
>>
>> === modified file 'src/maasserver
>> --- src/maasserver/
>> +++ src/maasserver/
>> @@ -273,3 +273,29 @@
>> 'static_
>> }
>> self.assertEqua
>> +
>> + def test_clean_
>> + network = IPNetwork(
>> + interface = make_interface(
>> + interface.
>> + interface.
>> + interface.
>> + interface.
>> + exception = self.assertRaises(
>> + ValidationError, interface.
>> + message = "Lower bound %s is higher than upper bound %s"
>> + errors = {
>> + 'ip_range_low': [
>> + message % (interface.
>> + 'ip_range_high': [
>> + message % (interface.
>> + 'static_
>> + message % (
>> + interface.
>> + interface.
>> + 'static_
>> + message % (
>> + interface.
>> + interface.
>> + }
>> + self.assertEqua
>>
>
>
> --
> https:/
> You are the owner of lp:~gmb/maas/bug-1336617.