adapt condition to use the correct letter for pvlan types (#5194)

* adapt condition to use the correct letter for pvlan types

* changed to var and add lower case

* Update server/src/main/java/org/apache/cloudstack/vm/UnmanagedVMsManagerImpl.java

Co-authored-by: dahn <daan.hoogland@gmail.com>

* Update server/src/main/java/org/apache/cloudstack/vm/UnmanagedVMsManagerImpl.java

Co-authored-by: Abhishek Kumar <abhishek.mrt22@gmail.com>

Co-authored-by: DK101010 <dirk.klahre@itelligence.de>
Co-authored-by: dahn <daan.hoogland@gmail.com>
Co-authored-by: Abhishek Kumar <abhishek.mrt22@gmail.com>
This commit is contained in:
DK101010 2021-08-20 14:51:05 +02:00 committed by GitHub
parent 57a55bd777
commit 1b041ee7d8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 2 deletions

View File

@ -608,10 +608,11 @@ public class UnmanagedVMsManagerImpl implements UnmanagedVMsManager {
!networkBroadcastUri.equals(String.format("vlan://%d", nic.getVlan())))) {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, String.format("VLAN of network(ID: %s) %s is found different from the VLAN of nic(ID: %s) vlan://%d during VM import", network.getUuid(), networkBroadcastUri, nic.getNicId(), nic.getVlan()));
}
String pvLanType = nic.getPvlanType() == null ? "" : nic.getPvlanType().toLowerCase().substring(0, 1);
if (nic.getVlan() != null && nic.getVlan() != 0 && nic.getPvlan() != null && nic.getPvlan() != 0 &&
(Strings.isNullOrEmpty(network.getBroadcastUri().toString()) ||
!networkBroadcastUri.equals(String.format("pvlan://%d-i%d", nic.getVlan(), nic.getPvlan())))) {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, String.format("PVLAN of network(ID: %s) %s is found different from the VLAN of nic(ID: %s) pvlan://%d-i%d during VM import", network.getUuid(), networkBroadcastUri, nic.getNicId(), nic.getVlan(), nic.getPvlan()));
!networkBroadcastUri.equals(String.format("pvlan://%d-%s%d", nic.getVlan(), pvLanType, nic.getPvlan())))) {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, String.format("PVLAN of network(ID: %s) %s is found different from the VLAN of nic(ID: %s) pvlan://%d-%s%d during VM import", network.getUuid(), networkBroadcastUri, nic.getNicId(), nic.getVlan(), pvLanType, nic.getPvlan()));
}
}