Committed by
Gerrit Code Review
[ONOS-3641] Update the bug which is finded by fuel installer: the
floating ip can not be deleted successfully. Change-Id: I14609b374843f8bd88873941e4dbd3312850e34a
Showing
2 changed files
with
21 additions
and
35 deletions
| ... | @@ -176,23 +176,11 @@ public class FloatingIpManager implements FloatingIpService { | ... | @@ -176,23 +176,11 @@ public class FloatingIpManager implements FloatingIpService { |
| 176 | boolean result = true; | 176 | boolean result = true; |
| 177 | for (FloatingIp floatingIp : floatingIps) { | 177 | for (FloatingIp floatingIp : floatingIps) { |
| 178 | verifyFloatingIpData(floatingIp); | 178 | verifyFloatingIpData(floatingIp); |
| 179 | - if (floatingIp.portId() != null) { | 179 | + floatingIpStore.put(floatingIp.id(), floatingIp); |
| 180 | - floatingIpStore.put(floatingIp.id(), floatingIp); | 180 | + if (!floatingIpStore.containsKey(floatingIp.id())) { |
| 181 | - if (!floatingIpStore.containsKey(floatingIp.id())) { | 181 | + log.debug("The floating Ip is created failed whose identifier is {}", |
| 182 | - log.debug("The floating Ip is created failed whose identifier is {}", | 182 | + floatingIp.id().toString()); |
| 183 | - floatingIp.id().toString()); | 183 | + result = false; |
| 184 | - result = false; | ||
| 185 | - } | ||
| 186 | - } else { | ||
| 187 | - FloatingIp oldFloatingIp = floatingIpStore.get(floatingIp.id()); | ||
| 188 | - if (oldFloatingIp != null) { | ||
| 189 | - floatingIpStore.remove(floatingIp.id(), oldFloatingIp); | ||
| 190 | - if (floatingIpStore.containsKey(floatingIp.id())) { | ||
| 191 | - log.debug("The floating Ip is created failed whose identifier is {}", | ||
| 192 | - floatingIp.id().toString()); | ||
| 193 | - result = false; | ||
| 194 | - } | ||
| 195 | - } | ||
| 196 | } | 184 | } |
| 197 | } | 185 | } |
| 198 | return result; | 186 | return result; |
| ... | @@ -204,23 +192,11 @@ public class FloatingIpManager implements FloatingIpService { | ... | @@ -204,23 +192,11 @@ public class FloatingIpManager implements FloatingIpService { |
| 204 | boolean result = true; | 192 | boolean result = true; |
| 205 | for (FloatingIp floatingIp : floatingIps) { | 193 | for (FloatingIp floatingIp : floatingIps) { |
| 206 | verifyFloatingIpData(floatingIp); | 194 | verifyFloatingIpData(floatingIp); |
| 207 | - if (floatingIp.portId() != null) { | 195 | + floatingIpStore.put(floatingIp.id(), floatingIp); |
| 208 | - floatingIpStore.put(floatingIp.id(), floatingIp); | 196 | + if (!floatingIpStore.containsKey(floatingIp.id())) { |
| 209 | - if (!floatingIpStore.containsKey(floatingIp.id())) { | 197 | + log.debug("The floating Ip is updated failed whose identifier is {}", |
| 210 | - log.debug("The floating Ip is updated failed whose identifier is {}", | 198 | + floatingIp.id().toString()); |
| 211 | - floatingIp.id().toString()); | 199 | + result = false; |
| 212 | - result = false; | ||
| 213 | - } | ||
| 214 | - } else { | ||
| 215 | - FloatingIp oldFloatingIp = floatingIpStore.get(floatingIp.id()); | ||
| 216 | - if (oldFloatingIp != null) { | ||
| 217 | - floatingIpStore.remove(floatingIp.id(), oldFloatingIp); | ||
| 218 | - if (floatingIpStore.containsKey(floatingIp.id())) { | ||
| 219 | - log.debug("The floating Ip is updated failed whose identifier is {}", | ||
| 220 | - floatingIp.id().toString()); | ||
| 221 | - result = false; | ||
| 222 | - } | ||
| 223 | - } | ||
| 224 | } | 200 | } |
| 225 | } | 201 | } |
| 226 | return result; | 202 | return result; |
| ... | @@ -238,6 +214,11 @@ public class FloatingIpManager implements FloatingIpService { | ... | @@ -238,6 +214,11 @@ public class FloatingIpManager implements FloatingIpService { |
| 238 | "FloatingIP ID doesn't exist"); | 214 | "FloatingIP ID doesn't exist"); |
| 239 | } | 215 | } |
| 240 | FloatingIp floatingIp = floatingIpStore.get(floatingIpId); | 216 | FloatingIp floatingIp = floatingIpStore.get(floatingIpId); |
| 217 | + if (floatingIp.portId() != null) { | ||
| 218 | + log.debug("The floating Ip is uesd by the port whose identifier is {}", | ||
| 219 | + floatingIp.portId().toString()); | ||
| 220 | + return false; | ||
| 221 | + } | ||
| 241 | floatingIpStore.remove(floatingIpId, floatingIp); | 222 | floatingIpStore.remove(floatingIpId, floatingIp); |
| 242 | if (floatingIpStore.containsKey(floatingIpId)) { | 223 | if (floatingIpStore.containsKey(floatingIpId)) { |
| 243 | log.debug("The floating Ip is deleted failed whose identifier is {}", | 224 | log.debug("The floating Ip is deleted failed whose identifier is {}", | ... | ... |
| ... | @@ -70,6 +70,7 @@ public class FloatingIpWebResource extends AbstractWebResource { | ... | @@ -70,6 +70,7 @@ public class FloatingIpWebResource extends AbstractWebResource { |
| 70 | .getLogger(FloatingIpWebResource.class); | 70 | .getLogger(FloatingIpWebResource.class); |
| 71 | public static final String CREATE_FAIL = "Floating IP is failed to create!"; | 71 | public static final String CREATE_FAIL = "Floating IP is failed to create!"; |
| 72 | public static final String UPDATE_FAIL = "Floating IP is failed to update!"; | 72 | public static final String UPDATE_FAIL = "Floating IP is failed to update!"; |
| 73 | + public static final String DELETE_FAIL = "Floating IP is failed to delete!"; | ||
| 73 | public static final String GET_FAIL = "Floating IP is failed to get!"; | 74 | public static final String GET_FAIL = "Floating IP is failed to get!"; |
| 74 | public static final String NOT_EXIST = "Floating IP does not exist!"; | 75 | public static final String NOT_EXIST = "Floating IP does not exist!"; |
| 75 | public static final String DELETE_SUCCESS = "Floating IP delete success!"; | 76 | public static final String DELETE_SUCCESS = "Floating IP delete success!"; |
| ... | @@ -157,7 +158,11 @@ public class FloatingIpWebResource extends AbstractWebResource { | ... | @@ -157,7 +158,11 @@ public class FloatingIpWebResource extends AbstractWebResource { |
| 157 | try { | 158 | try { |
| 158 | FloatingIpId floatingIpId = FloatingIpId.of(id); | 159 | FloatingIpId floatingIpId = FloatingIpId.of(id); |
| 159 | Set<FloatingIpId> floatingIpIds = Sets.newHashSet(floatingIpId); | 160 | Set<FloatingIpId> floatingIpIds = Sets.newHashSet(floatingIpId); |
| 160 | - get(FloatingIpService.class).removeFloatingIps(floatingIpIds); | 161 | + Boolean result = nullIsNotFound(get(FloatingIpService.class) |
| 162 | + .removeFloatingIps(floatingIpIds), DELETE_FAIL); | ||
| 163 | + if (!result) { | ||
| 164 | + return Response.status(CONFLICT).entity(DELETE_FAIL).build(); | ||
| 165 | + } | ||
| 161 | return Response.status(NO_CONTENT).entity(DELETE_SUCCESS).build(); | 166 | return Response.status(NO_CONTENT).entity(DELETE_SUCCESS).build(); |
| 162 | } catch (Exception e) { | 167 | } catch (Exception e) { |
| 163 | return Response.status(NOT_FOUND).entity(e.getMessage()).build(); | 168 | return Response.status(NOT_FOUND).entity(e.getMessage()).build(); | ... | ... |
-
Please register or login to post a comment