Merge remote-tracking branch 'apache/4.17' into main

This commit is contained in:
Abhishek Kumar 2022-08-26 14:22:14 +05:30
commit c526244359
7 changed files with 38 additions and 27 deletions

View File

@ -370,6 +370,20 @@ public class NetworkServiceImpl extends ManagerBase implements NetworkService, C
private Map<String, String> _configs;
private void verifyDedicatedGuestVlansWithExistingDatacenterVlans(PhysicalNetwork physicalNetwork, Account vlanOwner, int startVlan, int endVlan) {
for (int i = startVlan; i <= endVlan; i++) {
List<DataCenterVnetVO> dataCenterVnet = _dcVnetDao.findVnet(physicalNetwork.getDataCenterId(), physicalNetwork.getId(), Integer.toString(i));
if (CollectionUtils.isEmpty(dataCenterVnet)) {
throw new InvalidParameterValueException(String.format("Guest vlan %d from this range %d-%d is not present in the system for physical network ID: %s", i, startVlan, endVlan, physicalNetwork.getUuid()));
}
// Verify guest vlans in the range don't belong to a network of a different account
if (dataCenterVnet.get(0).getAccountId() != null && dataCenterVnet.get(0).getAccountId() != vlanOwner.getAccountId()) {
throw new InvalidParameterValueException("Guest vlan from this range " + dataCenterVnet.get(0).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 ");
}
}
}
/* Get a list of IPs, classify them by service */
protected Map<PublicIp, Set<Service>> getIpToServices(List<PublicIp> publicIps, boolean rulesRevoked, boolean includingFirewall) {
Map<PublicIp, Set<Service>> ipToServices = new HashMap<PublicIp, Set<Service>>();
@ -4073,18 +4087,7 @@ public class NetworkServiceImpl extends ManagerBase implements NetworkService, C
}
}
// 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 ");
}
}
}
}
verifyDedicatedGuestVlansWithExistingDatacenterVlans(physicalNetwork, vlanOwner, startVlan, endVlan);
List<AccountGuestVlanMapVO> guestVlanMaps = _accountGuestVlanMapDao.listAccountGuestVlanMapsByPhysicalNetwork(physicalNetworkId);
// Verify if vlan range is already dedicated

View File

@ -29,9 +29,10 @@ import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import com.cloud.user.User;
import junit.framework.Assert;
import org.apache.cloudstack.api.command.admin.network.DedicateGuestVlanRangeCmd;
import org.apache.cloudstack.api.command.admin.network.ListDedicatedGuestVlanRangesCmd;
import org.apache.cloudstack.api.command.admin.network.ReleaseDedicatedGuestVlanRangeCmd;
import org.apache.cloudstack.context.CallContext;
import org.apache.log4j.Logger;
import org.junit.After;
import org.junit.Before;
@ -39,11 +40,6 @@ import org.junit.Test;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.apache.cloudstack.api.command.admin.network.DedicateGuestVlanRangeCmd;
import org.apache.cloudstack.api.command.admin.network.ListDedicatedGuestVlanRangesCmd;
import org.apache.cloudstack.api.command.admin.network.ReleaseDedicatedGuestVlanRangeCmd;
import org.apache.cloudstack.context.CallContext;
import com.cloud.dc.DataCenterVnetVO;
import com.cloud.dc.dao.DataCenterVnetDao;
import com.cloud.network.dao.AccountGuestVlanMapDao;
@ -54,10 +50,13 @@ import com.cloud.projects.ProjectManager;
import com.cloud.user.Account;
import com.cloud.user.AccountManager;
import com.cloud.user.AccountVO;
import com.cloud.user.User;
import com.cloud.user.UserVO;
import com.cloud.user.dao.AccountDao;
import com.cloud.utils.db.TransactionLegacy;
import junit.framework.Assert;
public class DedicateGuestVlanRangesTest {
private static final Logger s_logger = Logger.getLogger(DedicateGuestVlanRangesTest.class);
@ -275,7 +274,7 @@ public class DedicateGuestVlanRangesTest {
DataCenterVnetVO dataCenter = new DataCenterVnetVO("2-5", 1L, 1L);
dataCenter.setAccountId(1L);
dataCenterList.add(dataCenter);
when(networkService._dcVnetDao.listAllocatedVnetsInRange(anyLong(), anyLong(), anyInt(), anyInt())).thenReturn(dataCenterList);
when(networkService._dcVnetDao.findVnet(anyLong(), anyLong(), anyString())).thenReturn(dataCenterList);
try {
networkService.dedicateGuestVlanRange(dedicateGuestVlanRangesCmd);
@ -298,7 +297,8 @@ public class DedicateGuestVlanRangesTest {
when(networkService._physicalNetworkDao.findById(anyLong())).thenReturn(physicalNetwork);
when(networkService._dcVnetDao.listAllocatedVnetsInRange(anyLong(), anyLong(), anyInt(), anyInt())).thenReturn(null);
DataCenterVnetVO dataCenterVnetVO = new DataCenterVnetVO("2-5", 1L, 1L);
when(networkService._dcVnetDao.findVnet(anyLong(), anyLong(), anyString())).thenReturn(List.of(dataCenterVnetVO));
List<AccountGuestVlanMapVO> guestVlanMaps = new ArrayList<AccountGuestVlanMapVO>();
AccountGuestVlanMapVO accountGuestVlanMap = new AccountGuestVlanMapVO(1L, 1L);

View File

@ -33,7 +33,7 @@
<span>{{ $t('label.projects') }}</span>
</template>
<span class="custom-suffix-icon">
<ProjectOutlined v-if="!loading" />
<ProjectOutlined v-if="!loading" class="ant-select-suffix" />
<LoadingOutlined v-else />
</span>
</a-tooltip>

View File

@ -36,7 +36,7 @@
<span>{{ $t('label.domain') }}</span>
</template>
<span class="custom-suffix-icon">
<BlockOutlined v-if="!loading" />
<BlockOutlined v-if="!loading" class="ant-select-suffix" />
<LoadingOutlined v-else />
</span>
</a-tooltip>

View File

@ -18,3 +18,11 @@
.ant-form .ant-form-item {
margin-bottom: 6px;
}
.ant-select-arrow .ant-select-suffix svg {
transition: transform .3s, -webkit-transform .3s;
}
.ant-select-open .ant-select-arrow .ant-select-suffix svg {
transform: rotateZ(-180deg);
}

View File

@ -64,7 +64,7 @@
:filterOption="(input, option) => {
return option.label.toLowerCase().indexOf(input.toLowerCase()) >= 0
}" >
<template #suffixIcon><filter-outlined /></template>
<template #suffixIcon><filter-outlined class="ant-select-suffix" /></template>
<a-select-option
v-if="['Admin', 'DomainAdmin'].includes($store.getters.userInfo.roletype) && ['vm', 'iso', 'template'].includes($route.name)"
key="all"

View File

@ -95,11 +95,11 @@
:placeholder="apiParams.networkdomain.description"
autoFocus />
</a-form-item>
<a-form-item name="maclearning" ref="maclearning" v-if="resource.redundantrouter">
<a-form-item name="updateinsequence" ref="updateinsequence" v-if="resource.redundantrouter">
<template #label>
<tooltip-label :title="$t('label.updateinsequence')" :tooltip="apiParams.updateinsequence.description"/>
</template>
<a-switch v-model:checked="form.maclearning" />
<a-switch v-model:checked="form.updateinsequence" />
</a-form-item>
<a-form-item name="displaynetwork" ref="displaynetwork" v-if="isAdmin()">
<template #label>