Skip to content

Commit

Permalink
move method to utils class and make it static
Browse files Browse the repository at this point in the history
  • Loading branch information
marcellom committed Jan 28, 2019
1 parent 9b3e2d9 commit a25d9f0
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 44 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@ public static void handlePrivateInfo(BaseVimInstance vim) {
}
}

public static String getVimNameWithoutAvailabilityZone(String vimName) {
if (vimName.contains(":")) return vimName.split(":")[0];
return vimName;
}

public static void updatePrivateInfo(BaseVimInstance vimNew, BaseVimInstance vimOld) {
if (vimNew
.getClass()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

package org.openbaton.nfvo.core.api;

import static org.openbaton.nfvo.common.utils.viminstance.VimInstanceUtils.getVimNameWithoutAvailabilityZone;

import java.io.IOException;
import java.util.ArrayList;
import java.util.Date;
Expand Down Expand Up @@ -310,7 +312,7 @@ private NetworkServiceRecord scaleOutNsr(
// vduVimInstances now contains all possible vim instance names for a specific vdu
for (String vimInstanceName : instanceNames) {

String name = nsdUtils.getVimNameWithoutAvailabilityZone(vimInstanceName);
String name = getVimNameWithoutAvailabilityZone(vimInstanceName);
BaseVimInstance vimInstance =
vimInstanceRepository.findByProjectIdAndName(vdu.getProjectId(), name);

Expand Down Expand Up @@ -541,7 +543,7 @@ public void addVNFCInstance(
List<String> finalVimInstanceNames = new ArrayList<>();
vimInstanceNames.forEach(
n -> {
finalVimInstanceNames.add(nsdUtils.getVimNameWithoutAvailabilityZone(n));
finalVimInstanceNames.add(getVimNameWithoutAvailabilityZone(n));
});
if (vimInstanceRepository
.findByProjectId(projectId)
Expand Down Expand Up @@ -1220,7 +1222,7 @@ private NetworkServiceRecord deployNSR(
// vduVimInstances now contains all possible vim instance names for a specific vdu
for (String vimInstanceName : instanceNames) {

String name = nsdUtils.getVimNameWithoutAvailabilityZone(vimInstanceName);
String name = getVimNameWithoutAvailabilityZone(vimInstanceName);
BaseVimInstance vimInstance =
vimInstanceRepository.findByProjectIdAndName(vdu.getProjectId(), name);

Expand Down Expand Up @@ -1593,9 +1595,7 @@ private Set<String> checkIfVimAreSupportedByPackage(
for (BaseVimInstance vimInstance :
vimInstanceRepository.findByProjectId(vnfd.getProjectId())) {

if (nsdUtils
.getVimNameWithoutAvailabilityZone(vimInstanceName)
.equals(vimInstance.getName())) {
if (getVimNameWithoutAvailabilityZone(vimInstanceName).equals(vimInstance.getName())) {
log.debug("Found vim instance " + vimInstance.getName());
log.debug(
"Checking if "
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

package org.openbaton.nfvo.core.utils;

import static org.openbaton.nfvo.common.utils.viminstance.VimInstanceUtils.getVimNameWithoutAvailabilityZone;

import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.URL;
Expand Down Expand Up @@ -577,11 +579,6 @@ private BaseVimInstance checkIntegrityVimInstance(
return vimInstance;
}

public String getVimNameWithoutAvailabilityZone(String vimName) {
if (vimName.contains(":")) return vimName.split(":")[0];
return vimName;
}

private void checkIntegrityVDU(VirtualNetworkFunctionDescriptor virtualNetworkFunctionDescriptor)
throws NetworkServiceIntegrityException {
int i = 1;
Expand Down Expand Up @@ -720,33 +717,6 @@ private boolean checkIntegrityCidr(
return false;
}

// for (VNFComponent vnfComponent : virtualDeploymentUnit.getVnfc()) {
// for (VNFDConnectionPoint connectionPoint : vnfComponent.getConnection_point())
// {
// if (!internalVirtualLink.contains(
// connectionPoint.getVirtual_link_reference())) {
// throw new NetworkServiceIntegrityException(
// "Regarding the VirtualNetworkFunctionDescriptor "
// + virtualNetworkFunctionDescriptor.getName()
// + ": in one of the VirtualDeploymentUnit, the "
// + "virtualLinkReference "
// + connectionPoint.getVirtual_link_reference()
// + " of a VNFComponent is not contained in the "
// + "InternalVirtualLink "
// + internalVirtualLink);
// }
// }
// }
// if (!virtualLinkDescriptors.containsAll(internalVirtualLink)) {
// throw new NetworkServiceIntegrityException(
// "Regarding the VirtualNetworkFunctionDescriptor "
// + virtualNetworkFunctionDescriptor.getName()
// + ": the InternalVirtualLinks "
// + internalVirtualLink
// + " are not contained in the VirtualLinkDescriptors "
// + virtualLinkDescriptors);
// }

private void checkIntegrityLifecycleEvents(
VirtualNetworkFunctionDescriptor virtualNetworkFunctionDescriptor)
throws NetworkServiceIntegrityException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -277,8 +277,6 @@ public void nsrManagementOnboardTest1()
add(vnfmManagerEndpoint);
}
});
when(nsdUtils.getVimNameWithoutAvailabilityZone(anyString()))
.thenReturn(createVimInstance().getName());
nsrManagement.onboard(nsd_exp, projectId, null, null, null, null);
}

Expand Down Expand Up @@ -343,8 +341,6 @@ public void nsrManagementOnboardTest2()
add(createVimInstance());
}
});
when(nsdUtils.getVimNameWithoutAvailabilityZone(anyString()))
.thenReturn(createVimInstance().getName());
/** Real Method */
nsrManagement.onboard(networkServiceDescriptor.getId(), projectId, null, null, null, null);
}
Expand Down Expand Up @@ -409,8 +405,6 @@ public void nsrManagementOnboardTest3()
add(vnfmManagerEndpoint);
}
});
when(nsdUtils.getVimNameWithoutAvailabilityZone(anyString()))
.thenReturn(createVimInstance().getName());
nsrManagement.onboard(networkServiceDescriptor.getId(), projectId, null, null, null, null);
}

Expand Down

0 comments on commit a25d9f0

Please sign in to comment.