From 58c1be2b65f3e5ec6a87e2d53e3757314a815e9b Mon Sep 17 00:00:00 2001 From: Hongbin Lu Date: Fri, 19 Jan 2018 00:23:51 +0000 Subject: [PATCH] Define IpAddressAlreadyAllocated exception This exception will raise when creating a port with an IP allocated IP address. This exception needs to be defined in client so that nova can catch it and perform the error handling. Needed-By: I5bee9ae18764b6f285ecc5e8d7148a1019c74701 Change-Id: Ie1d4581d334e1ec491e56371c62978945ae24a44 Related-Bug: #1744103 --- neutronclient/common/exceptions.py | 4 ++++ neutronclient/tests/unit/test_cli20.py | 2 ++ ...ssAlreadyAllocatedClient-exception-e8600ca5ba1c7f45.yaml | 6 ++++++ 3 files changed, 12 insertions(+) create mode 100644 releasenotes/notes/Define-IpAddressAlreadyAllocatedClient-exception-e8600ca5ba1c7f45.yaml diff --git a/neutronclient/common/exceptions.py b/neutronclient/common/exceptions.py index 4298d423a..1040ee120 100644 --- a/neutronclient/common/exceptions.py +++ b/neutronclient/common/exceptions.py @@ -162,6 +162,10 @@ class IpAddressInUseClient(Conflict): pass +class IpAddressAlreadyAllocatedClient(Conflict): + pass + + class InvalidIpForNetworkClient(BadRequest): pass diff --git a/neutronclient/tests/unit/test_cli20.py b/neutronclient/tests/unit/test_cli20.py index 132e1e547..0837a6c3d 100644 --- a/neutronclient/tests/unit/test_cli20.py +++ b/neutronclient/tests/unit/test_cli20.py @@ -911,6 +911,8 @@ class CLITestV20ExceptionHandler(CLITestV20Base): ('OverQuota', exceptions.OverQuotaClient, 409), ('InvalidIpForNetwork', exceptions.InvalidIpForNetworkClient, 400), ('InvalidIpForSubnet', exceptions.InvalidIpForSubnetClient, 400), + ('IpAddressAlreadyAllocated', + exceptions.IpAddressAlreadyAllocatedClient, 400), ] error_msg = 'dummy exception message' diff --git a/releasenotes/notes/Define-IpAddressAlreadyAllocatedClient-exception-e8600ca5ba1c7f45.yaml b/releasenotes/notes/Define-IpAddressAlreadyAllocatedClient-exception-e8600ca5ba1c7f45.yaml new file mode 100644 index 000000000..4182585e0 --- /dev/null +++ b/releasenotes/notes/Define-IpAddressAlreadyAllocatedClient-exception-e8600ca5ba1c7f45.yaml @@ -0,0 +1,6 @@ +--- +other: + - | + Define a new exception type ``IpAddressAlreadyAllocatedClient``. + Users can catch this specific exception instead of the generic + ``NeutronClientException``.