mirror of
https://github.com/apache/cloudstack.git
synced 2025-11-02 20:02:29 +01:00
kvm: Check for VLAN or VXLAN in NetworkDaoImpl.listByPhysicalNetworkPvlan (#5074)
This PR fixes #5071; where it was reported an issue when creating a network with VXLAN.
This commit is contained in:
parent
937def533a
commit
3ee563905d
@ -18,9 +18,12 @@ package com.cloud.network.dao;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.inject.Inject;
|
||||
@ -107,6 +110,9 @@ public class NetworkDaoImpl extends GenericDaoBase<NetworkVO, Long>implements Ne
|
||||
Random _rand = new Random(System.currentTimeMillis());
|
||||
long _prefix = 0x2;
|
||||
|
||||
private static final Set<String> VLAN_OR_VXLAN = new HashSet<>(Arrays.asList(BroadcastDomainType.Vlan.toString().toLowerCase(),
|
||||
BroadcastDomainType.Vxlan.toString().toLowerCase()));
|
||||
|
||||
public NetworkDaoImpl() {
|
||||
}
|
||||
|
||||
@ -780,8 +786,9 @@ public class NetworkDaoImpl extends GenericDaoBase<NetworkVO, Long>implements Ne
|
||||
@Override
|
||||
public List<NetworkVO> listByPhysicalNetworkPvlan(long physicalNetworkId, String broadcastUri) {
|
||||
final URI searchUri = BroadcastDomainType.fromString(broadcastUri);
|
||||
if (!searchUri.getScheme().equalsIgnoreCase("vlan")) {
|
||||
throw new CloudRuntimeException("VLAN requested but URI is not in the expected format: " + searchUri.toString());
|
||||
if (!VLAN_OR_VXLAN.contains(searchUri.getScheme().toLowerCase())) {
|
||||
throw new CloudRuntimeException(
|
||||
String.format("Requested URI '%s' is not in the expected format. Expected URI Scheme as 'vlan://VID' or 'vxlan://VID'.", searchUri.toString()));
|
||||
}
|
||||
final String searchRange = BroadcastDomainType.getValue(searchUri);
|
||||
final List<Integer> searchVlans = UriUtils.expandVlanUri(searchRange);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user