weizhouapache commented on code in PR #6655:
URL: https://github.com/apache/cloudstack/pull/6655#discussion_r949022463
##########
server/src/main/java/com/cloud/network/NetworkServiceImpl.java:
##########
@@ -4068,16 +4068,15 @@ public GuestVlanRange
dedicateGuestVlanRange(DedicateGuestVlanRangeCmd cmd) {
}
}
- // Verify guest vlans in the range don't belong to a network of a
different account
for (int i = startVlan; i <= endVlan; i++) {
- List<DataCenterVnetVO> allocatedVlans =
_dcVnetDao.listAllocatedVnetsInRange(physicalNetwork.getDataCenterId(),
physicalNetwork.getId(), startVlan, endVlan);
- if (allocatedVlans != null && !allocatedVlans.isEmpty()) {
- for (DataCenterVnetVO allocatedVlan : allocatedVlans) {
- if (allocatedVlan.getAccountId() !=
vlanOwner.getAccountId()) {
- throw new InvalidParameterValueException("Guest vlan
from this range " + allocatedVlan.getVnet() + " is allocated to a different
account."
- + " Can only dedicate a range which has no
allocated vlans or has vlans allocated to the same account ");
- }
- }
+ List<DataCenterVnetVO> dataCenterVnet =
_dcVnetDao.findVnet(physicalNetwork.getDataCenterId(), physicalNetworkId,
Integer.toString(i));
+ if (CollectionUtils.isEmpty(dataCenterVnet)) {
+ throw new InvalidParameterValueException(String.format("Guest
vlan %d from this range %s is present in the system for physical network ID:
%s", i, vlan, physicalNetwork.getUuid()));
+ }
+ // Verify guest vlans in the range don't belong to a network of a
different account
+ if (dataCenterVnet.get(0).getAccountId() !=
vlanOwner.getAccountId()) {
Review Comment:
findVnet returns vlans including the allocated and unallocated.
if vnet is not allocated, the accountId is null, can it be dedicated ?
##########
server/src/main/java/com/cloud/network/NetworkServiceImpl.java:
##########
@@ -4068,16 +4068,15 @@ public GuestVlanRange
dedicateGuestVlanRange(DedicateGuestVlanRangeCmd cmd) {
}
}
- // Verify guest vlans in the range don't belong to a network of a
different account
for (int i = startVlan; i <= endVlan; i++) {
- List<DataCenterVnetVO> allocatedVlans =
_dcVnetDao.listAllocatedVnetsInRange(physicalNetwork.getDataCenterId(),
physicalNetwork.getId(), startVlan, endVlan);
- if (allocatedVlans != null && !allocatedVlans.isEmpty()) {
- for (DataCenterVnetVO allocatedVlan : allocatedVlans) {
- if (allocatedVlan.getAccountId() !=
vlanOwner.getAccountId()) {
- throw new InvalidParameterValueException("Guest vlan
from this range " + allocatedVlan.getVnet() + " is allocated to a different
account."
- + " Can only dedicate a range which has no
allocated vlans or has vlans allocated to the same account ");
- }
- }
+ List<DataCenterVnetVO> dataCenterVnet =
_dcVnetDao.findVnet(physicalNetwork.getDataCenterId(), physicalNetworkId,
Integer.toString(i));
+ if (CollectionUtils.isEmpty(dataCenterVnet)) {
+ throw new InvalidParameterValueException(String.format("Guest
vlan %d from this range %s is present in the system for physical network ID:
%s", i, vlan, physicalNetwork.getUuid()));
Review Comment:
is present or is not present ?
--
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]