Correct i18n message for api and db module
Part of bp make-string-localizable Change-Id: I68af562af9438a6cff0628a98ace8aeb291dfeaa
This commit is contained in:
parent
79b1465a1a
commit
48e850eeb9
@ -458,8 +458,8 @@ class ExtensionManager(object):
|
|||||||
else:
|
else:
|
||||||
attr_map[resource] = resource_attrs
|
attr_map[resource] = resource_attrs
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
LOG.exception("Error fetching extended attributes for "
|
LOG.exception(_("Error fetching extended attributes for "
|
||||||
"extension '%s'" % ext.get_name())
|
"extension '%s'"), ext.get_name())
|
||||||
|
|
||||||
def _check_extension(self, extension):
|
def _check_extension(self, extension):
|
||||||
"""Checks for required methods in extension objects."""
|
"""Checks for required methods in extension objects."""
|
||||||
@ -496,7 +496,7 @@ class ExtensionManager(object):
|
|||||||
if os.path.exists(path):
|
if os.path.exists(path):
|
||||||
self._load_all_extensions_from_path(path)
|
self._load_all_extensions_from_path(path)
|
||||||
else:
|
else:
|
||||||
LOG.error("Extension path \"%s\" doesn't exist!" % path)
|
LOG.error(_("Extension path '%s' doesn't exist!"), path)
|
||||||
|
|
||||||
def _load_all_extensions_from_path(self, path):
|
def _load_all_extensions_from_path(self, path):
|
||||||
for f in os.listdir(path):
|
for f in os.listdir(path):
|
||||||
@ -517,8 +517,9 @@ class ExtensionManager(object):
|
|||||||
new_ext = new_ext_class()
|
new_ext = new_ext_class()
|
||||||
self.add_extension(new_ext)
|
self.add_extension(new_ext)
|
||||||
except Exception as exception:
|
except Exception as exception:
|
||||||
LOG.warn("extension file %s wasnt loaded due to %s",
|
LOG.warn(_("extension file %(file)s wasn't loaded due to "
|
||||||
f, exception)
|
"%(e)s"),
|
||||||
|
{'file': f, 'e': exception})
|
||||||
|
|
||||||
def add_extension(self, ext):
|
def add_extension(self, ext):
|
||||||
# Do nothing if the extension doesn't check out
|
# Do nothing if the extension doesn't check out
|
||||||
@ -529,7 +530,7 @@ class ExtensionManager(object):
|
|||||||
LOG.info(_('Loaded extension: %s'), alias)
|
LOG.info(_('Loaded extension: %s'), alias)
|
||||||
|
|
||||||
if alias in self.extensions:
|
if alias in self.extensions:
|
||||||
raise exceptions.Error("Found duplicate extension: %s" %
|
raise exceptions.Error(_("Found duplicate extension: %s") %
|
||||||
alias)
|
alias)
|
||||||
self.extensions[alias] = ext
|
self.extensions[alias] = ext
|
||||||
|
|
||||||
@ -562,8 +563,8 @@ class PluginAwareExtensionManager(ExtensionManager):
|
|||||||
supports_extension = (alias in
|
supports_extension = (alias in
|
||||||
ENABLED_EXTS[plugin_provider]['ext_alias'])
|
ENABLED_EXTS[plugin_provider]['ext_alias'])
|
||||||
if not supports_extension:
|
if not supports_extension:
|
||||||
LOG.warn(_("extension %s not supported by any of loaded plugins" %
|
LOG.warn(_("extension %s not supported by any of loaded plugins"),
|
||||||
alias))
|
alias)
|
||||||
return supports_extension
|
return supports_extension
|
||||||
|
|
||||||
def _plugins_implement_interface(self, extension):
|
def _plugins_implement_interface(self, extension):
|
||||||
@ -573,8 +574,8 @@ class PluginAwareExtensionManager(ExtensionManager):
|
|||||||
for plugin in self.plugins.values():
|
for plugin in self.plugins.values():
|
||||||
if isinstance(plugin, extension.get_plugin_interface()):
|
if isinstance(plugin, extension.get_plugin_interface()):
|
||||||
return True
|
return True
|
||||||
LOG.warn(_("Loaded plugins do not implement extension %s interface"
|
LOG.warn(_("Loaded plugins do not implement extension %s interface"),
|
||||||
% extension.get_alias()))
|
extension.get_alias())
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
@ -237,8 +237,10 @@ class Controller(object):
|
|||||||
obj_deleter(request.context, obj['id'])
|
obj_deleter(request.context, obj['id'])
|
||||||
except Exception:
|
except Exception:
|
||||||
# broad catch as our only purpose is to log the exception
|
# broad catch as our only purpose is to log the exception
|
||||||
LOG.exception("Unable to undo add for %s %s",
|
LOG.exception(_("Unable to undo add for "
|
||||||
self._resource, obj['id'])
|
"%(resource)s %(id)s"),
|
||||||
|
{'resource': self._resource,
|
||||||
|
'id': obj['id']})
|
||||||
# TODO(salvatore-orlando): The object being processed when the
|
# TODO(salvatore-orlando): The object being processed when the
|
||||||
# plugin raised might have been created or not in the db.
|
# plugin raised might have been created or not in the db.
|
||||||
# We need a way for ensuring that if it has been created,
|
# We need a way for ensuring that if it has been created,
|
||||||
@ -307,7 +309,7 @@ class Controller(object):
|
|||||||
body[self._resource]['tenant_id'],
|
body[self._resource]['tenant_id'],
|
||||||
**kwargs)
|
**kwargs)
|
||||||
except exceptions.PolicyNotAuthorized:
|
except exceptions.PolicyNotAuthorized:
|
||||||
LOG.exception("Create operation not authorized")
|
LOG.exception(_("Create operation not authorized"))
|
||||||
raise webob.exc.HTTPForbidden()
|
raise webob.exc.HTTPForbidden()
|
||||||
|
|
||||||
def notify(create_result):
|
def notify(create_result):
|
||||||
@ -474,7 +476,7 @@ class Controller(object):
|
|||||||
raise webob.exc.HTTPBadRequest(msg)
|
raise webob.exc.HTTPBadRequest(msg)
|
||||||
|
|
||||||
if not attr_vals['allow_post'] and attr in res_dict:
|
if not attr_vals['allow_post'] and attr in res_dict:
|
||||||
msg = _("Attribute '%s' not allowed in POST" % attr)
|
msg = _("Attribute '%s' not allowed in POST") % attr
|
||||||
raise webob.exc.HTTPBadRequest(msg)
|
raise webob.exc.HTTPBadRequest(msg)
|
||||||
|
|
||||||
if attr_vals['allow_post']:
|
if attr_vals['allow_post']:
|
||||||
|
@ -50,8 +50,8 @@ class MySQLPingListener(object):
|
|||||||
dbapi_con.cursor().execute('select 1')
|
dbapi_con.cursor().execute('select 1')
|
||||||
except dbapi_con.OperationalError, ex:
|
except dbapi_con.OperationalError, ex:
|
||||||
if ex.args[0] in (2006, 2013, 2014, 2045, 2055):
|
if ex.args[0] in (2006, 2013, 2014, 2045, 2055):
|
||||||
LOG.warn('Got mysql server has gone away: %s', ex)
|
LOG.warn(_('Got mysql server has gone away: %s'), ex)
|
||||||
raise DisconnectionError("Database server went away")
|
raise DisconnectionError(_("Database server went away"))
|
||||||
else:
|
else:
|
||||||
raise
|
raise
|
||||||
|
|
||||||
@ -113,11 +113,12 @@ def retry_registration(remaining, reconnect_interval, base=BASE):
|
|||||||
while True:
|
while True:
|
||||||
if remaining != 'infinite':
|
if remaining != 'infinite':
|
||||||
if remaining == 0:
|
if remaining == 0:
|
||||||
LOG.error("Database connection lost, exit...")
|
LOG.error(_("Database connection lost, exit..."))
|
||||||
break
|
break
|
||||||
remaining -= 1
|
remaining -= 1
|
||||||
LOG.info("Unable to connect to database, %s attempts left. "
|
LOG.info(_("Unable to connect to database, %(remaining)s attempts "
|
||||||
"Retrying in %s seconds" % (remaining, reconnect_interval))
|
"left. Retrying in %(reconnect_interval)s seconds"),
|
||||||
|
locals())
|
||||||
time.sleep(reconnect_interval)
|
time.sleep(reconnect_interval)
|
||||||
if register_models(base):
|
if register_models(base):
|
||||||
break
|
break
|
||||||
@ -130,7 +131,7 @@ def register_models(base=BASE):
|
|||||||
try:
|
try:
|
||||||
base.metadata.create_all(_ENGINE)
|
base.metadata.create_all(_ENGINE)
|
||||||
except sql.exc.OperationalError as e:
|
except sql.exc.OperationalError as e:
|
||||||
LOG.info("Database registration exception: %s" % e)
|
LOG.info(_("Database registration exception: %s"), e)
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
@ -234,13 +234,15 @@ class QuantumDbPluginV2(quantum_plugin_base_v2.QuantumPluginBaseV2):
|
|||||||
mac_address = ':'.join(map(lambda x: "%02x" % x, mac))
|
mac_address = ':'.join(map(lambda x: "%02x" % x, mac))
|
||||||
if QuantumDbPluginV2._check_unique_mac(context, network_id,
|
if QuantumDbPluginV2._check_unique_mac(context, network_id,
|
||||||
mac_address):
|
mac_address):
|
||||||
LOG.debug("Generated mac for network %s is %s",
|
LOG.debug(_("Generated mac for network %(network_id)s "
|
||||||
network_id, mac_address)
|
"is %(mac_address)s"), locals())
|
||||||
return mac_address
|
return mac_address
|
||||||
else:
|
else:
|
||||||
LOG.debug("Generated mac %s exists. Remaining attempts %s.",
|
LOG.debug(_("Generated mac %(mac_address)s exists. Remaining "
|
||||||
mac_address, max_retries - (i + 1))
|
"attempts %(max_retries)s."),
|
||||||
LOG.error("Unable to generate mac address after %s attempts",
|
{'mac_address': mac_address,
|
||||||
|
'max_retries': max_retries - (i + 1)})
|
||||||
|
LOG.error(_("Unable to generate mac address after %s attempts"),
|
||||||
max_retries)
|
max_retries)
|
||||||
raise q_exc.MacAddressGenerationFailure(net_id=network_id)
|
raise q_exc.MacAddressGenerationFailure(net_id=network_id)
|
||||||
|
|
||||||
@ -269,8 +271,9 @@ class QuantumDbPluginV2(quantum_plugin_base_v2.QuantumPluginBaseV2):
|
|||||||
QuantumDbPluginV2._recycle_ip(
|
QuantumDbPluginV2._recycle_ip(
|
||||||
context, network_id, subnet_id, ip_address)
|
context, network_id, subnet_id, ip_address)
|
||||||
else:
|
else:
|
||||||
LOG.debug("Hold allocated IP %s (%s/%s/%s)", ip_address,
|
LOG.debug(_("Hold allocated IP %(ip_address)s "
|
||||||
network_id, subnet_id, port_id)
|
"(%(network_id)s/%(subnet_id)s/%(port_id)s)"),
|
||||||
|
locals())
|
||||||
allocated.port_id = None
|
allocated.port_id = None
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@ -315,7 +318,7 @@ class QuantumDbPluginV2(quantum_plugin_base_v2.QuantumPluginBaseV2):
|
|||||||
break
|
break
|
||||||
if not pool_id:
|
if not pool_id:
|
||||||
error_message = _("No allocation pool found for "
|
error_message = _("No allocation pool found for "
|
||||||
"ip address:%s" % ip_address)
|
"ip address:%s") % ip_address
|
||||||
raise q_exc.InvalidInput(error_message=error_message)
|
raise q_exc.InvalidInput(error_message=error_message)
|
||||||
# Two requests will be done on the database. The first will be to
|
# Two requests will be done on the database. The first will be to
|
||||||
# search if an entry starts with ip_address + 1 (r1). The second
|
# search if an entry starts with ip_address + 1 (r1). The second
|
||||||
@ -326,19 +329,19 @@ class QuantumDbPluginV2(quantum_plugin_base_v2.QuantumPluginBaseV2):
|
|||||||
range_qry = context.session.query(models_v2.IPAvailabilityRange)
|
range_qry = context.session.query(models_v2.IPAvailabilityRange)
|
||||||
ip_first = str(netaddr.IPAddress(ip_address) + 1)
|
ip_first = str(netaddr.IPAddress(ip_address) + 1)
|
||||||
ip_last = str(netaddr.IPAddress(ip_address) - 1)
|
ip_last = str(netaddr.IPAddress(ip_address) - 1)
|
||||||
LOG.debug("Recycle %s", ip_address)
|
LOG.debug(_("Recycle %s"), ip_address)
|
||||||
try:
|
try:
|
||||||
r1 = range_qry.filter_by(allocation_pool_id=pool_id,
|
r1 = range_qry.filter_by(allocation_pool_id=pool_id,
|
||||||
first_ip=ip_first).one()
|
first_ip=ip_first).one()
|
||||||
LOG.debug("Recycle: first match for %s-%s", r1['first_ip'],
|
LOG.debug(_("Recycle: first match for %(first_ip)s-%(last_ip)s"),
|
||||||
r1['last_ip'])
|
{'first_ip': r1['first_ip'], 'last_ip': r1['last_ip']})
|
||||||
except exc.NoResultFound:
|
except exc.NoResultFound:
|
||||||
r1 = []
|
r1 = []
|
||||||
try:
|
try:
|
||||||
r2 = range_qry.filter_by(allocation_pool_id=pool_id,
|
r2 = range_qry.filter_by(allocation_pool_id=pool_id,
|
||||||
last_ip=ip_last).one()
|
last_ip=ip_last).one()
|
||||||
LOG.debug("Recycle: last match for %s-%s", r2['first_ip'],
|
LOG.debug(_("Recycle: last match for %(first_ip)s-%(last_ip)s"),
|
||||||
r2['last_ip'])
|
{'first_ip': r2['first_ip'], 'last_ip': r2['last_ip']})
|
||||||
except exc.NoResultFound:
|
except exc.NoResultFound:
|
||||||
r2 = []
|
r2 = []
|
||||||
|
|
||||||
@ -349,20 +352,22 @@ class QuantumDbPluginV2(quantum_plugin_base_v2.QuantumPluginBaseV2):
|
|||||||
first_ip=r2['first_ip'],
|
first_ip=r2['first_ip'],
|
||||||
last_ip=r1['last_ip'])
|
last_ip=r1['last_ip'])
|
||||||
context.session.add(ip_range)
|
context.session.add(ip_range)
|
||||||
LOG.debug("Recycle: merged %s-%s and %s-%s", r2['first_ip'],
|
LOG.debug(_("Recycle: merged %(first_ip1)s-%(last_ip1)s and "
|
||||||
r2['last_ip'], r1['first_ip'], r1['last_ip'])
|
"%(first_ip2)s-%(last_ip2)s"),
|
||||||
|
{'first_ip1': r2['first_ip'], 'last_ip1': r2['last_ip'],
|
||||||
|
'first_ip2': r1['first_ip'], 'last_ip2': r1['last_ip']})
|
||||||
context.session.delete(r1)
|
context.session.delete(r1)
|
||||||
context.session.delete(r2)
|
context.session.delete(r2)
|
||||||
elif r1:
|
elif r1:
|
||||||
# Update the range with matched first IP
|
# Update the range with matched first IP
|
||||||
r1['first_ip'] = ip_address
|
r1['first_ip'] = ip_address
|
||||||
LOG.debug("Recycle: updated first %s-%s", r1['first_ip'],
|
LOG.debug(_("Recycle: updated first %(first_ip)s-%(last_ip)s"),
|
||||||
r1['last_ip'])
|
{'first_ip': r1['first_ip'], 'last_ip': r1['last_ip']})
|
||||||
elif r2:
|
elif r2:
|
||||||
# Update the range with matched last IP
|
# Update the range with matched last IP
|
||||||
r2['last_ip'] = ip_address
|
r2['last_ip'] = ip_address
|
||||||
LOG.debug("Recycle: updated last %s-%s", r2['first_ip'],
|
LOG.debug(_("Recycle: updated last %(first_ip)s-%(last_ip)s"),
|
||||||
r2['last_ip'])
|
{'first_ip': r2['first_ip'], 'last_ip': r2['last_ip']})
|
||||||
else:
|
else:
|
||||||
# Create a new range
|
# Create a new range
|
||||||
ip_range = models_v2.IPAvailabilityRange(
|
ip_range = models_v2.IPAvailabilityRange(
|
||||||
@ -370,7 +375,8 @@ class QuantumDbPluginV2(quantum_plugin_base_v2.QuantumPluginBaseV2):
|
|||||||
first_ip=ip_address,
|
first_ip=ip_address,
|
||||||
last_ip=ip_address)
|
last_ip=ip_address)
|
||||||
context.session.add(ip_range)
|
context.session.add(ip_range)
|
||||||
LOG.debug("Recycle: created new %s-%s", ip_address, ip_address)
|
LOG.debug(_("Recycle: created new %(first_ip)s-%(last_ip)s"),
|
||||||
|
{'first_ip': ip_address, 'last_ip': ip_address})
|
||||||
QuantumDbPluginV2._delete_ip_allocation(context, network_id, subnet_id,
|
QuantumDbPluginV2._delete_ip_allocation(context, network_id, subnet_id,
|
||||||
ip_address)
|
ip_address)
|
||||||
|
|
||||||
@ -392,15 +398,16 @@ class QuantumDbPluginV2(quantum_plugin_base_v2.QuantumPluginBaseV2):
|
|||||||
fixed_ip = query.one()
|
fixed_ip = query.one()
|
||||||
fixed_ip.expiration = expiration
|
fixed_ip.expiration = expiration
|
||||||
except exc.NoResultFound:
|
except exc.NoResultFound:
|
||||||
LOG.debug("No fixed IP found that matches the network %s and "
|
LOG.debug(_("No fixed IP found that matches the network "
|
||||||
"ip address %s.", network_id, ip_address)
|
"%(network_id)s and ip address %(ip_address)s."),
|
||||||
|
locals())
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _delete_ip_allocation(context, network_id, subnet_id, ip_address):
|
def _delete_ip_allocation(context, network_id, subnet_id, ip_address):
|
||||||
|
|
||||||
# Delete the IP address from the IPAllocate table
|
# Delete the IP address from the IPAllocate table
|
||||||
LOG.debug("Delete allocated IP %s (%s/%s)", ip_address,
|
LOG.debug(_("Delete allocated IP %(ip_address)s "
|
||||||
network_id, subnet_id)
|
"(%(network_id)s/%(subnet_id)s)"), locals())
|
||||||
alloc_qry = context.session.query(models_v2.IPAllocation)
|
alloc_qry = context.session.query(models_v2.IPAllocation)
|
||||||
allocated = alloc_qry.filter_by(network_id=network_id,
|
allocated = alloc_qry.filter_by(network_id=network_id,
|
||||||
ip_address=ip_address,
|
ip_address=ip_address,
|
||||||
@ -419,16 +426,20 @@ class QuantumDbPluginV2(quantum_plugin_base_v2.QuantumPluginBaseV2):
|
|||||||
for subnet in subnets:
|
for subnet in subnets:
|
||||||
range = range_qry.filter_by(subnet_id=subnet['id']).first()
|
range = range_qry.filter_by(subnet_id=subnet['id']).first()
|
||||||
if not range:
|
if not range:
|
||||||
LOG.debug("All IP's from subnet %s (%s) allocated",
|
LOG.debug(_("All IP's from subnet %(subnet_id)s (%(cidr)s) "
|
||||||
subnet['id'], subnet['cidr'])
|
"allocated"),
|
||||||
|
{'subnet_id': subnet['id'], 'cidr': subnet['cidr']})
|
||||||
continue
|
continue
|
||||||
ip_address = range['first_ip']
|
ip_address = range['first_ip']
|
||||||
LOG.debug("Allocated IP - %s from %s to %s", ip_address,
|
LOG.debug(_("Allocated IP - %(ip_address)s from %(first_ip)s "
|
||||||
range['first_ip'], range['last_ip'])
|
"to %(last_ip)s"),
|
||||||
|
{'ip_address': ip_address,
|
||||||
|
'first_ip': range['first_ip'],
|
||||||
|
'last_ip': range['last_ip']})
|
||||||
if range['first_ip'] == range['last_ip']:
|
if range['first_ip'] == range['last_ip']:
|
||||||
# No more free indices on subnet => delete
|
# No more free indices on subnet => delete
|
||||||
LOG.debug("No more free IP's in slice. Deleting allocation "
|
LOG.debug(_("No more free IP's in slice. Deleting allocation "
|
||||||
"pool.")
|
"pool."))
|
||||||
context.session.delete(range)
|
context.session.delete(range)
|
||||||
else:
|
else:
|
||||||
# increment the first free
|
# increment the first free
|
||||||
@ -552,9 +563,11 @@ class QuantumDbPluginV2(quantum_plugin_base_v2.QuantumPluginBaseV2):
|
|||||||
else:
|
else:
|
||||||
subnet = self._get_subnet(context, fixed['subnet_id'])
|
subnet = self._get_subnet(context, fixed['subnet_id'])
|
||||||
if subnet['network_id'] != network_id:
|
if subnet['network_id'] != network_id:
|
||||||
msg = _('Failed to create port on network %s, '
|
msg = (_("Failed to create port on network %(network_id)s"
|
||||||
'because fixed_ips included invalid subnet '
|
", because fixed_ips included invalid subnet "
|
||||||
'%s') % (network_id, fixed['subnet_id'])
|
"%(subnet_id)s") %
|
||||||
|
{'network_id': network_id,
|
||||||
|
'subnet_id': fixed['subnet_id']})
|
||||||
raise q_exc.InvalidInput(error_message=msg)
|
raise q_exc.InvalidInput(error_message=msg)
|
||||||
subnet_id = subnet['id']
|
subnet_id = subnet['id']
|
||||||
|
|
||||||
@ -618,7 +631,7 @@ class QuantumDbPluginV2(quantum_plugin_base_v2.QuantumPluginBaseV2):
|
|||||||
# Check if the IP's to add are OK
|
# Check if the IP's to add are OK
|
||||||
to_add = self._test_fixed_ips_for_port(context, network_id, new_ips)
|
to_add = self._test_fixed_ips_for_port(context, network_id, new_ips)
|
||||||
for ip in original_ips:
|
for ip in original_ips:
|
||||||
LOG.debug("Port update. Hold %s", ip)
|
LOG.debug(_("Port update. Hold %s"), ip)
|
||||||
QuantumDbPluginV2._hold_ip(context,
|
QuantumDbPluginV2._hold_ip(context,
|
||||||
network_id,
|
network_id,
|
||||||
ip['subnet_id'],
|
ip['subnet_id'],
|
||||||
@ -626,7 +639,7 @@ class QuantumDbPluginV2(quantum_plugin_base_v2.QuantumPluginBaseV2):
|
|||||||
ip['ip_address'])
|
ip['ip_address'])
|
||||||
|
|
||||||
if to_add:
|
if to_add:
|
||||||
LOG.debug("Port update. Adding %s", to_add)
|
LOG.debug(_("Port update. Adding %s"), to_add)
|
||||||
network = self._get_network(context, network_id)
|
network = self._get_network(context, network_id)
|
||||||
ips = self._allocate_fixed_ips(context, network, to_add)
|
ips = self._allocate_fixed_ips(context, network, to_add)
|
||||||
return ips
|
return ips
|
||||||
@ -682,12 +695,17 @@ class QuantumDbPluginV2(quantum_plugin_base_v2.QuantumPluginBaseV2):
|
|||||||
for subnet in subnet_list:
|
for subnet in subnet_list:
|
||||||
if (netaddr.IPSet([subnet.cidr]) & new_subnet_ipset):
|
if (netaddr.IPSet([subnet.cidr]) & new_subnet_ipset):
|
||||||
# don't give out details of the overlapping subnet
|
# don't give out details of the overlapping subnet
|
||||||
err_msg = _("Requested subnet with cidr: %s "
|
err_msg = (_("Requested subnet with cidr: %(cidr)s for "
|
||||||
"for network: %s overlaps with another subnet" %
|
"network: %(network_id)s overlaps with another "
|
||||||
(new_subnet_cidr, network.id))
|
"subnet") %
|
||||||
LOG.error("Validation for CIDR:%s failed - overlaps with "
|
{'cidr': new_subnet_cidr,
|
||||||
"subnet %s (CIDR:%s)",
|
'network_id': network.id})
|
||||||
new_subnet_cidr, subnet.id, subnet.cidr)
|
LOG.error(_("Validation for CIDR: %(new_cidr)s failed - "
|
||||||
|
"overlaps with subnet %(subnet_id)s "
|
||||||
|
"(CIDR: %(cidr)s)"),
|
||||||
|
{'new_cidr': new_subnet_cidr,
|
||||||
|
'subnet_id': subnet.id,
|
||||||
|
'cidr': subnet.cidr})
|
||||||
raise q_exc.InvalidInput(error_message=err_msg)
|
raise q_exc.InvalidInput(error_message=err_msg)
|
||||||
|
|
||||||
def _validate_allocation_pools(self, ip_pools, gateway_ip, subnet_cidr):
|
def _validate_allocation_pools(self, ip_pools, gateway_ip, subnet_cidr):
|
||||||
@ -705,31 +723,33 @@ class QuantumDbPluginV2(quantum_plugin_base_v2.QuantumPluginBaseV2):
|
|||||||
subnet_first_ip = netaddr.IPAddress(subnet.first + 1)
|
subnet_first_ip = netaddr.IPAddress(subnet.first + 1)
|
||||||
subnet_last_ip = netaddr.IPAddress(subnet.last - 1)
|
subnet_last_ip = netaddr.IPAddress(subnet.last - 1)
|
||||||
|
|
||||||
LOG.debug("Performing IP validity checks on allocation pools")
|
LOG.debug(_("Performing IP validity checks on allocation pools"))
|
||||||
ip_sets = []
|
ip_sets = []
|
||||||
for ip_pool in ip_pools:
|
for ip_pool in ip_pools:
|
||||||
try:
|
try:
|
||||||
start_ip = netaddr.IPAddress(ip_pool['start'])
|
start_ip = netaddr.IPAddress(ip_pool['start'])
|
||||||
end_ip = netaddr.IPAddress(ip_pool['end'])
|
end_ip = netaddr.IPAddress(ip_pool['end'])
|
||||||
except netaddr.AddrFormatError:
|
except netaddr.AddrFormatError:
|
||||||
LOG.error("Found invalid IP address in pool: %s - %s:",
|
LOG.error(_("Found invalid IP address in pool: "
|
||||||
ip_pool['start'],
|
"%(start)s - %(end)s:"),
|
||||||
ip_pool['end'])
|
{'start': ip_pool['start'],
|
||||||
|
'end': ip_pool['end']})
|
||||||
raise q_exc.InvalidAllocationPool(pool=ip_pool)
|
raise q_exc.InvalidAllocationPool(pool=ip_pool)
|
||||||
if (start_ip.version != subnet.version or
|
if (start_ip.version != subnet.version or
|
||||||
end_ip.version != subnet.version):
|
end_ip.version != subnet.version):
|
||||||
LOG.error("Specified IP addresses do not match "
|
LOG.error(_("Specified IP addresses do not match "
|
||||||
"the subnet IP version")
|
"the subnet IP version"))
|
||||||
raise q_exc.InvalidAllocationPool(pool=ip_pool)
|
raise q_exc.InvalidAllocationPool(pool=ip_pool)
|
||||||
if end_ip < start_ip:
|
if end_ip < start_ip:
|
||||||
LOG.error("Start IP (%s) is greater than end IP (%s)",
|
LOG.error(_("Start IP (%(start)s) is greater than end IP "
|
||||||
ip_pool['start'],
|
"(%(end)s)"),
|
||||||
ip_pool['end'])
|
{'start': ip_pool['start'], 'end': ip_pool['end']})
|
||||||
raise q_exc.InvalidAllocationPool(pool=ip_pool)
|
raise q_exc.InvalidAllocationPool(pool=ip_pool)
|
||||||
if start_ip < subnet_first_ip or end_ip > subnet_last_ip:
|
if start_ip < subnet_first_ip or end_ip > subnet_last_ip:
|
||||||
LOG.error("Found pool larger than subnet CIDR:%s - %s",
|
LOG.error(_("Found pool larger than subnet "
|
||||||
ip_pool['start'],
|
"CIDR:%(start)s - %(end)s"),
|
||||||
ip_pool['end'])
|
{'start': ip_pool['start'],
|
||||||
|
'end': ip_pool['end']})
|
||||||
raise q_exc.OutOfBoundsAllocationPool(
|
raise q_exc.OutOfBoundsAllocationPool(
|
||||||
pool=ip_pool,
|
pool=ip_pool,
|
||||||
subnet_cidr=subnet_cidr)
|
subnet_cidr=subnet_cidr)
|
||||||
@ -739,8 +759,8 @@ class QuantumDbPluginV2(quantum_plugin_base_v2.QuantumPluginBaseV2):
|
|||||||
ip_pool['start'],
|
ip_pool['start'],
|
||||||
ip_pool['end']).cidrs()))
|
ip_pool['end']).cidrs()))
|
||||||
|
|
||||||
LOG.debug("Checking for overlaps among allocation pools "
|
LOG.debug(_("Checking for overlaps among allocation pools "
|
||||||
"and gateway ip")
|
"and gateway ip"))
|
||||||
ip_ranges = ip_pools[:]
|
ip_ranges = ip_pools[:]
|
||||||
# Treat gw as IPset as well
|
# Treat gw as IPset as well
|
||||||
if gateway_ip:
|
if gateway_ip:
|
||||||
@ -753,8 +773,8 @@ class QuantumDbPluginV2(quantum_plugin_base_v2.QuantumPluginBaseV2):
|
|||||||
if ip_sets[l_cursor] & ip_sets[r_cursor]:
|
if ip_sets[l_cursor] & ip_sets[r_cursor]:
|
||||||
l_range = ip_ranges[l_cursor]
|
l_range = ip_ranges[l_cursor]
|
||||||
r_range = ip_ranges[r_cursor]
|
r_range = ip_ranges[r_cursor]
|
||||||
LOG.error("Found overlapping ranges: %s and %s",
|
LOG.error(_("Found overlapping ranges: %(l_range)s and "
|
||||||
l_range, r_range)
|
"%(r_range)s"), locals())
|
||||||
raise q_exc.OverlappingAllocationPools(
|
raise q_exc.OverlappingAllocationPools(
|
||||||
pool_1=l_range,
|
pool_1=l_range,
|
||||||
pool_2=r_range,
|
pool_2=r_range,
|
||||||
@ -891,8 +911,8 @@ class QuantumDbPluginV2(quantum_plugin_base_v2.QuantumPluginBaseV2):
|
|||||||
objects.append(obj_creator(context, item))
|
objects.append(obj_creator(context, item))
|
||||||
context.session.commit()
|
context.session.commit()
|
||||||
except Exception:
|
except Exception:
|
||||||
LOG.exception("An exception occured while creating "
|
LOG.exception(_("An exception occured while creating "
|
||||||
"the %s:%s", resource, item)
|
"the %(resource)s:%(item)s"), locals())
|
||||||
context.session.rollback()
|
context.session.rollback()
|
||||||
raise
|
raise
|
||||||
return objects
|
return objects
|
||||||
@ -1006,7 +1026,8 @@ class QuantumDbPluginV2(quantum_plugin_base_v2.QuantumPluginBaseV2):
|
|||||||
netaddr.IPAddress(dns)
|
netaddr.IPAddress(dns)
|
||||||
except Exception:
|
except Exception:
|
||||||
raise q_exc.InvalidInput(
|
raise q_exc.InvalidInput(
|
||||||
error_message=("error parsing dns address %s" % dns))
|
error_message=(_("error parsing dns address %s") %
|
||||||
|
dns))
|
||||||
self._validate_ip_version(ip_ver, dns, 'dns_nameserver')
|
self._validate_ip_version(ip_ver, dns, 'dns_nameserver')
|
||||||
|
|
||||||
if ('host_routes' in s and
|
if ('host_routes' in s and
|
||||||
@ -1212,8 +1233,9 @@ class QuantumDbPluginV2(quantum_plugin_base_v2.QuantumPluginBaseV2):
|
|||||||
for ip in ips:
|
for ip in ips:
|
||||||
ip_address = ip['ip_address']
|
ip_address = ip['ip_address']
|
||||||
subnet_id = ip['subnet_id']
|
subnet_id = ip['subnet_id']
|
||||||
LOG.debug("Allocated IP %s (%s/%s/%s)", ip_address,
|
LOG.debug(_("Allocated IP %(ip_address)s "
|
||||||
network_id, subnet_id, port_id)
|
"(%(network_id)s/%(subnet_id)s/%(port_id)s)"),
|
||||||
|
locals())
|
||||||
allocated = models_v2.IPAllocation(
|
allocated = models_v2.IPAllocation(
|
||||||
network_id=network_id,
|
network_id=network_id,
|
||||||
port_id=port_id,
|
port_id=port_id,
|
||||||
|
@ -599,11 +599,11 @@ class L3_NAT_db_mixin(l3.RouterPluginBase):
|
|||||||
# TODO(salvatore-orlando): Avoid broad catch
|
# TODO(salvatore-orlando): Avoid broad catch
|
||||||
# Maybe by introducing base class for L3 exceptions
|
# Maybe by introducing base class for L3 exceptions
|
||||||
except q_exc.BadRequest:
|
except q_exc.BadRequest:
|
||||||
LOG.exception("Unable to create Floating ip due to a "
|
LOG.exception(_("Unable to create Floating ip due to a "
|
||||||
"malformed request")
|
"malformed request"))
|
||||||
raise
|
raise
|
||||||
except Exception:
|
except Exception:
|
||||||
LOG.exception("Floating IP association failed")
|
LOG.exception(_("Floating IP association failed"))
|
||||||
raise
|
raise
|
||||||
|
|
||||||
return self._make_floatingip_dict(floatingip_db)
|
return self._make_floatingip_dict(floatingip_db)
|
||||||
|
Loading…
Reference in New Issue
Block a user