raise n_exc.InvalidInput(error_message=msg)
return fixed_ip_set
- def _allocate_fixed_ips(self, context, network, fixed_ips):
+ def _allocate_fixed_ips(self, context, fixed_ips):
"""Allocate IP addresses according to the configured fixed_ips."""
ips = []
for fixed in fixed_ips:
if to_add:
LOG.debug(_("Port update. Adding %s"), to_add)
- network = self._get_network(context, network_id)
- ips = self._allocate_fixed_ips(context, network, to_add)
+ ips = self._allocate_fixed_ips(context, to_add)
return ips, prev_ips
- def _allocate_ips_for_port(self, context, network, port):
+ def _allocate_ips_for_port(self, context, port):
"""Allocate IP addresses for the port.
If port['fixed_ips'] is set to 'ATTR_NOT_SPECIFIED', allocate IP
configured_ips = self._test_fixed_ips_for_port(context,
p["network_id"],
p['fixed_ips'])
- ips = self._allocate_fixed_ips(context, network, configured_ips)
+ ips = self._allocate_fixed_ips(context, configured_ips)
else:
filter = {'network_id': [p['network_id']]}
subnets = self.get_subnets(context, filters=filter)
tenant_id)
with context.session.begin(subtransactions=True):
- network = self._get_network(context, network_id)
+ # Ensure that the network exists.
+ self._get_network(context, network_id)
# Ensure that a MAC address is defined and it is unique on the
# network
mac=p['mac_address'])
# Returns the IP's for the port
- ips = self._allocate_ips_for_port(context, network, port)
+ ips = self._allocate_ips_for_port(context, port)
if 'status' not in p:
status = constants.PORT_STATUS_ACTIVE