From 1b041ee7d8f057ea01b46abe38192836a5acb902 Mon Sep 17 00:00:00 2001 From: DK101010 <57522802+DK101010@users.noreply.github.com> Date: Fri, 20 Aug 2021 14:51:05 +0200 Subject: [PATCH] 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 * Update server/src/main/java/org/apache/cloudstack/vm/UnmanagedVMsManagerImpl.java Co-authored-by: Abhishek Kumar Co-authored-by: DK101010 Co-authored-by: dahn Co-authored-by: Abhishek Kumar --- .../org/apache/cloudstack/vm/UnmanagedVMsManagerImpl.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/server/src/main/java/org/apache/cloudstack/vm/UnmanagedVMsManagerImpl.java b/server/src/main/java/org/apache/cloudstack/vm/UnmanagedVMsManagerImpl.java index 6562370c7da..bf9ed7fd65c 100644 --- a/server/src/main/java/org/apache/cloudstack/vm/UnmanagedVMsManagerImpl.java +++ b/server/src/main/java/org/apache/cloudstack/vm/UnmanagedVMsManagerImpl.java @@ -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())); } }