]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
IPAM: make max fixed IP validations DRY
authorGary Kotton <gkotton@vmware.com>
Mon, 9 Nov 2015 09:02:10 +0000 (01:02 -0800)
committerGary Kotton <gkotton@vmware.com>
Mon, 9 Nov 2015 09:02:10 +0000 (01:02 -0800)
Reuse code to make the validations DRY. In addition to this
fixed a typo.

Change-Id: I69cc904d30aae0e2d189a72c9dddaaab63a923ca

neutron/db/ipam_backend_mixin.py

index 13650b1d2d38c01841ce3171ff1da8049649f41d..3f69e582b4d067e3f87063f91faee2fb08de70b9 100644 (file)
@@ -299,7 +299,7 @@ class IpamBackendMixin(db_base_plugin_common.DbBasePluginCommon):
 
     def _validate_max_ips_per_port(self, fixed_ip_list):
         if len(fixed_ip_list) > cfg.CONF.max_fixed_ips_per_port:
-            msg = _('Exceeded maximim amount of fixed ips per port')
+            msg = _('Exceeded maximum amount of fixed ips per port')
             raise n_exc.InvalidInput(error_message=msg)
 
     def _get_subnet_for_fixed_ip(self, context, fixed, network_id):
@@ -367,9 +367,7 @@ class IpamBackendMixin(db_base_plugin_common.DbBasePluginCommon):
                                   new_ips, device_owner):
         """Calculate changes in IPs for the port."""
         # the new_ips contain all of the fixed_ips that are to be updated
-        if len(new_ips) > cfg.CONF.max_fixed_ips_per_port:
-            msg = _('Exceeded maximum amount of fixed ips per port')
-            raise n_exc.InvalidInput(error_message=msg)
+        self._validate_max_ips_per_port(new_ips)
 
         add_ips = []
         remove_ips = []