diff options
author | Dongcan Ye <hellochosen@gmail.com> | 2018-01-15 12:58:45 +0000 |
---|---|---|
committer | Dongcan Ye <hellochosen@gmail.com> | 2018-02-12 16:49:21 +0000 |
commit | e2e9b763a829ca9c7bb3df8622b3e22d3829b39b (patch) | |
tree | cf8004a2fcac982b7edd37c41135c38d37cfca59 /ironic/dhcp | |
parent | 4a74c3406115902078586d9440573d1c6fe19380 (diff) | |
download | ironic-e2e9b763a829ca9c7bb3df8622b3e22d3829b39b.tar.gz |
Add meaningful exception in Neutron port show
We had already defined an exception FailedToGetIPAddressOnPort
if not get fixed_ips, for the neutron port show we can add
some meaningful exception.
Change-Id: I242da01fdf703f7c52e51aa5236209edea37c856
Diffstat (limited to 'ironic/dhcp')
-rw-r--r-- | ironic/dhcp/neutron.py | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/ironic/dhcp/neutron.py b/ironic/dhcp/neutron.py index 27c4366d0..0ac34877f 100644 --- a/ironic/dhcp/neutron.py +++ b/ironic/dhcp/neutron.py @@ -135,16 +135,16 @@ class NeutronDHCPApi(base.BaseDHCP): :param port_uuid: Neutron port id. :param client: Neutron client instance. :returns: Neutron port ip address. - :raises: FailedToGetIPAddressOnPort + :raises: NetworkError :raises: InvalidIPv4Address + :raises: FailedToGetIPAddressOnPort """ ip_address = None try: neutron_port = client.show_port(port_uuid).get('port') except neutron_client_exc.NeutronClientException: - LOG.exception("Failed to Get IP address on Neutron port %s.", - port_uuid) - raise exception.FailedToGetIPAddressOnPort(port_id=port_uuid) + raise exception.NetworkError( + _('Could not retrieve neutron port: %s') % port_uuid) fixed_ips = neutron_port.get('fixed_ips') @@ -158,8 +158,9 @@ class NeutronDHCPApi(base.BaseDHCP): if netutils.is_valid_ipv4(ip_address): return ip_address else: - LOG.error("Neutron returned invalid IPv4 address %s.", - ip_address) + LOG.error("Neutron returned invalid IPv4 " + "address %(ip_address)s on port %(port_uuid)s.", + {'ip_address': ip_address, 'port_uuid': port_uuid}) raise exception.InvalidIPv4Address(ip_address=ip_address) else: LOG.error("No IP address assigned to Neutron port %s.", @@ -209,7 +210,8 @@ class NeutronDHCPApi(base.BaseDHCP): client) ip_addresses.append(vif_ip_address) except (exception.FailedToGetIPAddressOnPort, - exception.InvalidIPv4Address): + exception.InvalidIPv4Address, + exception.NetworkError): failures.append(obj.uuid) if failures: |