change error code and message due to Amazon changes
Amazon changed error code some time ago. Change-Id: Ib5eb94f3a5bbdb27bc4ead5898376f274dd6e5c3
This commit is contained in:
parent
bb89039e9b
commit
8d1a61ce6c
@ -118,8 +118,7 @@ def create_network_interface(context, subnet_id,
|
|||||||
os_port = neutron.create_port(os_port_body)['port']
|
os_port = neutron.create_port(os_port_body)['port']
|
||||||
except (neutron_exception.IpAddressGenerationFailureClient,
|
except (neutron_exception.IpAddressGenerationFailureClient,
|
||||||
neutron_exception.OverQuotaClient):
|
neutron_exception.OverQuotaClient):
|
||||||
raise exception.NetworkInterfaceLimitExceeded(
|
raise exception.InsufficientFreeAddressesInSubnet()
|
||||||
subnet_id=subnet_id)
|
|
||||||
except (neutron_exception.IpAddressInUseClient,
|
except (neutron_exception.IpAddressInUseClient,
|
||||||
neutron_exception.BadRequest) as ex:
|
neutron_exception.BadRequest) as ex:
|
||||||
# NOTE(ft): AWS returns InvalidIPAddress.InUse for a primary IP
|
# NOTE(ft): AWS returns InvalidIPAddress.InUse for a primary IP
|
||||||
@ -279,8 +278,7 @@ def assign_private_ip_addresses(context, network_interface_id,
|
|||||||
neutron.update_port(os_port['id'],
|
neutron.update_port(os_port['id'],
|
||||||
{'port': {'fixed_ips': fixed_ips}})
|
{'port': {'fixed_ips': fixed_ips}})
|
||||||
except neutron_exception.IpAddressGenerationFailureClient:
|
except neutron_exception.IpAddressGenerationFailureClient:
|
||||||
raise exception.NetworkInterfaceLimitExceeded(
|
raise exception.InsufficientFreeAddressesInSubnet()
|
||||||
subnet_id=subnet['id'])
|
|
||||||
except neutron_exception.IpAddressInUseClient:
|
except neutron_exception.IpAddressInUseClient:
|
||||||
msg = _('Some of %(addresses)s is assigned, but move is not '
|
msg = _('Some of %(addresses)s is assigned, but move is not '
|
||||||
'allowed.') % {'addresses': private_ip_address}
|
'allowed.') % {'addresses': private_ip_address}
|
||||||
|
@ -462,9 +462,9 @@ class SubnetLimitExceeded(EC2OverlimitException):
|
|||||||
'can create')
|
'can create')
|
||||||
|
|
||||||
|
|
||||||
class NetworkInterfaceLimitExceeded(EC2OverlimitException):
|
class InsufficientFreeAddressesInSubnet(EC2OverlimitException):
|
||||||
msg_fmt = _('You have reached the limit of network interfaces for subnet'
|
msg_fmt = _('The specified subnet does not have enough free addresses to '
|
||||||
'%(subnet_id)s.')
|
'satisfy the request.')
|
||||||
|
|
||||||
|
|
||||||
class AddressLimitExceeded(EC2OverlimitException):
|
class AddressLimitExceeded(EC2OverlimitException):
|
||||||
|
@ -142,7 +142,8 @@ class NetworkInterfaceTest(base.EC2TestCase):
|
|||||||
SubnetId=self.subnet_id)
|
SubnetId=self.subnet_id)
|
||||||
except botocore.exceptions.ClientError as e:
|
except botocore.exceptions.ClientError as e:
|
||||||
error_code = e.response['Error']['Code']
|
error_code = e.response['Error']['Code']
|
||||||
self.assertEqual('NetworkInterfaceLimitExceeded', error_code)
|
self.assertEqual('InsufficientFreeAddressesInSubnet',
|
||||||
|
error_code, e.message)
|
||||||
break
|
break
|
||||||
ni_id = data['NetworkInterface']['NetworkInterfaceId']
|
ni_id = data['NetworkInterface']['NetworkInterfaceId']
|
||||||
res_clean = self.addResourceCleanUp(
|
res_clean = self.addResourceCleanUp(
|
||||||
|
@ -239,7 +239,7 @@ class NetworkInterfaceTestCase(base.ApiTestCase):
|
|||||||
self.neutron.create_port.side_effect = cls()
|
self.neutron.create_port.side_effect = cls()
|
||||||
do_check({'SubnetId': fakes.ID_EC2_SUBNET_1,
|
do_check({'SubnetId': fakes.ID_EC2_SUBNET_1,
|
||||||
'PrivateIpAddress': fakes.IP_NETWORK_INTERFACE_1},
|
'PrivateIpAddress': fakes.IP_NETWORK_INTERFACE_1},
|
||||||
'NetworkInterfaceLimitExceeded')
|
'InsufficientFreeAddressesInSubnet')
|
||||||
|
|
||||||
for cls in [neutron_exception.IpAddressInUseClient,
|
for cls in [neutron_exception.IpAddressInUseClient,
|
||||||
neutron_exception.BadRequest]:
|
neutron_exception.BadRequest]:
|
||||||
@ -656,7 +656,7 @@ class NetworkInterfaceTestCase(base.ApiTestCase):
|
|||||||
|
|
||||||
self.neutron.update_port.side_effect = (
|
self.neutron.update_port.side_effect = (
|
||||||
neutron_exception.IpAddressGenerationFailureClient())
|
neutron_exception.IpAddressGenerationFailureClient())
|
||||||
do_check('NetworkInterfaceLimitExceeded')
|
do_check('InsufficientFreeAddressesInSubnet')
|
||||||
|
|
||||||
self.neutron.update_port.side_effect = (
|
self.neutron.update_port.side_effect = (
|
||||||
neutron_exception.IpAddressInUseClient())
|
neutron_exception.IpAddressInUseClient())
|
||||||
|
Loading…
Reference in New Issue
Block a user