|
18 | 18 |
|
19 | 19 | import java.net.URI; |
20 | 20 | import java.util.ArrayList; |
| 21 | +import java.util.Arrays; |
| 22 | +import java.util.HashSet; |
21 | 23 | import java.util.List; |
22 | 24 | import java.util.Map; |
23 | 25 | import java.util.Random; |
| 26 | +import java.util.Set; |
24 | 27 |
|
25 | 28 | import javax.annotation.PostConstruct; |
26 | 29 | import javax.inject.Inject; |
@@ -107,6 +110,9 @@ public class NetworkDaoImpl extends GenericDaoBase<NetworkVO, Long>implements Ne |
107 | 110 | Random _rand = new Random(System.currentTimeMillis()); |
108 | 111 | long _prefix = 0x2; |
109 | 112 |
|
| 113 | + private static final Set<String> VLAN_OR_VXLAN = new HashSet<>(Arrays.asList(BroadcastDomainType.Vlan.toString().toLowerCase(), |
| 114 | + BroadcastDomainType.Vxlan.toString().toLowerCase())); |
| 115 | + |
110 | 116 | public NetworkDaoImpl() { |
111 | 117 | } |
112 | 118 |
|
@@ -780,8 +786,9 @@ protected Network.PVlanType getNetworkPvlanType(long networkId, List<Integer> ex |
780 | 786 | @Override |
781 | 787 | public List<NetworkVO> listByPhysicalNetworkPvlan(long physicalNetworkId, String broadcastUri) { |
782 | 788 | final URI searchUri = BroadcastDomainType.fromString(broadcastUri); |
783 | | - if (!searchUri.getScheme().equalsIgnoreCase("vlan")) { |
784 | | - throw new CloudRuntimeException("VLAN requested but URI is not in the expected format: " + searchUri.toString()); |
| 789 | + if (!VLAN_OR_VXLAN.contains(searchUri.getScheme().toLowerCase())) { |
| 790 | + throw new CloudRuntimeException( |
| 791 | + String.format("Requested URI '%s' is not in the expected format. Expected URI Scheme as 'vlan://VID' or 'vxlan://VID'.", searchUri.toString())); |
785 | 792 | } |
786 | 793 | final String searchRange = BroadcastDomainType.getValue(searchUri); |
787 | 794 | final List<Integer> searchVlans = UriUtils.expandVlanUri(searchRange); |
|
0 commit comments