DaanHoogland commented on code in PR #11591:
URL: https://github.com/apache/cloudstack/pull/11591#discussion_r2527325924
##########
server/src/main/java/com/cloud/server/ManagementServerImpl.java:
##########
@@ -2429,20 +2446,20 @@ public Pair<List<? extends IpAddress>, Integer>
searchForIPAddresses(final ListP
final Long networkId = cmd.getNetworkId();
final Long vpcId = cmd.getVpcId();
- final String state = cmd.getState();
+ final List<IpAddress.State> states = getStatesForIpAddressSearch(cmd);
Boolean isAllocated = cmd.isAllocatedOnly();
if (isAllocated == null) {
- if (state != null &&
(state.equalsIgnoreCase(IpAddress.State.Free.name()) ||
state.equalsIgnoreCase(IpAddress.State.Reserved.name()))) {
+ if (states.contains(IpAddress.State.Free) ||
states.contains(IpAddress.State.Reserved)) {
isAllocated = Boolean.FALSE;
} else {
isAllocated = Boolean.TRUE; // default
}
} else {
- if (state != null &&
(state.equalsIgnoreCase(IpAddress.State.Free.name()) ||
state.equalsIgnoreCase(IpAddress.State.Reserved.name()))) {
+ if (states.contains(IpAddress.State.Free) ||
states.contains(IpAddress.State.Reserved)) {
Review Comment:
same here
##########
server/src/main/java/com/cloud/server/ManagementServerImpl.java:
##########
@@ -2521,10 +2538,8 @@ public Pair<List<? extends IpAddress>, Integer>
searchForIPAddresses(final ListP
Boolean isRecursive = cmd.isRecursive();
final List<Long> permittedAccounts = new ArrayList<>();
ListProjectResourcesCriteria listProjectResourcesCriteria = null;
- boolean isAllocatedOrReserved = false;
- if (isAllocated ||
IpAddress.State.Reserved.name().equalsIgnoreCase(state)) {
- isAllocatedOrReserved = true;
- }
+ boolean isAllocatedOrReserved = isAllocated ||
+ (states.size() == 1 &&
IpAddress.State.Reserved.equals(states.get(0)));
Review Comment:
```suggestion
(states.size() == 1 &&
states.contains(IpAddress.State.Reserved));
```
##########
server/src/main/java/com/cloud/server/ManagementServerImpl.java:
##########
@@ -2429,20 +2446,20 @@ public Pair<List<? extends IpAddress>, Integer>
searchForIPAddresses(final ListP
final Long networkId = cmd.getNetworkId();
final Long vpcId = cmd.getVpcId();
- final String state = cmd.getState();
+ final List<IpAddress.State> states = getStatesForIpAddressSearch(cmd);
Boolean isAllocated = cmd.isAllocatedOnly();
if (isAllocated == null) {
- if (state != null &&
(state.equalsIgnoreCase(IpAddress.State.Free.name()) ||
state.equalsIgnoreCase(IpAddress.State.Reserved.name()))) {
+ if (states.contains(IpAddress.State.Free) ||
states.contains(IpAddress.State.Reserved)) {
Review Comment:
we cannot have a null here, so no biggy but maybe reverse the checks and
even use `Arrays`?
##########
server/src/main/java/com/cloud/server/ManagementServerImpl.java:
##########
@@ -2429,20 +2446,20 @@ public Pair<List<? extends IpAddress>, Integer>
searchForIPAddresses(final ListP
final Long networkId = cmd.getNetworkId();
final Long vpcId = cmd.getVpcId();
- final String state = cmd.getState();
+ final List<IpAddress.State> states = getStatesForIpAddressSearch(cmd);
Boolean isAllocated = cmd.isAllocatedOnly();
if (isAllocated == null) {
- if (state != null &&
(state.equalsIgnoreCase(IpAddress.State.Free.name()) ||
state.equalsIgnoreCase(IpAddress.State.Reserved.name()))) {
+ if (states.contains(IpAddress.State.Free) ||
states.contains(IpAddress.State.Reserved)) {
isAllocated = Boolean.FALSE;
} else {
isAllocated = Boolean.TRUE; // default
}
} else {
- if (state != null &&
(state.equalsIgnoreCase(IpAddress.State.Free.name()) ||
state.equalsIgnoreCase(IpAddress.State.Reserved.name()))) {
+ if (states.contains(IpAddress.State.Free) ||
states.contains(IpAddress.State.Reserved)) {
if (isAllocated) {
throw new InvalidParameterValueException("Conflict:
allocatedonly is true but state is Free");
}
- } else if (state != null &&
state.equalsIgnoreCase(IpAddress.State.Allocated.name())) {
+ } else if (states.contains(IpAddress.State.Allocated)) {
Review Comment:
and here
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]