imp: vim instance check/selection
@@ -1574,28 +1574,45 @@ public class NetworkServiceRecordManagement
private Set<String> checkIfVimAreSupportedByPackage(
VirtualNetworkFunctionDescriptor vnfd, Set<String> instanceNames) throws BadRequestException {
- Set<String> checkedVimInstanceNames = new HashSet<>();
+
+ if (instanceNames.size() == 0) {
+ log.debug(
+ "No VIM instances selected for the deployment of VNF "
+ + vnfd.getName()
+ + ". Adding all available VIM Instances...");
+ for (BaseVimInstance vimInstance :
+ vimInstanceRepository.findByProjectId(vnfd.getProjectId())) {
+ instanceNames.add(vimInstance.getName());
+ }
+ }
+
VNFPackage vnfPackage = vnfPackageRepository.findFirstById(vnfd.getVnfPackageLocation());
if (vnfPackage == null
|| vnfPackage.getVimTypes() == null
|| vnfPackage.getVimTypes().size() == 0) {
- log.warn("VNFPackage does not provide supported VIM. I will skip the check!");
- } else {
+ log.warn("VNFPackage does not provide supported VIM types. I will skip the check!");
+ return instanceNames;
+ }
+
+ log.debug("Performing VIM type check for VIM instances...");
+ Set<String> checkedVimInstanceNames = new HashSet<>();
for (String vimInstanceName : instanceNames) {
- BaseVimInstance vimInstance;
- for (BaseVimInstance vi : vimInstanceRepository.findByProjectId(vnfd.getProjectId())) {
- if (vimInstanceName.equals(vi.getName())) {
- vimInstance = vi;
+ for (BaseVimInstance vimInstance :
+ vimInstanceRepository.findByProjectId(vnfd.getProjectId())) {
+ if (vimInstanceName.equals(vimInstance.getName())) {
log.debug("Found vim instance " + vimInstance.getName());
log.debug(
"Checking if "
+ vimInstance.getType()
+ " is contained in "
+ vnfPackage.getVimTypes());
- if (vnfPackage.getVimTypes().contains(vimInstance.getType())) {
+ String type = vimInstance.getType();
+ if (type.contains(".")) {
+ type = type.split("\\.")[0];
+ }
+ if (vnfPackage.getVimTypes().contains(type)) {
checkedVimInstanceNames.add(vimInstance.getName());
} else {
- // throw new org.openbaton.exceptions.BadRequestException(
log.warn(
"The Vim Instance "
+ vimInstance.getName()
@@ -1605,25 +1622,6 @@ public class NetworkServiceRecordManagement
}
}
}
- }
- if (instanceNames.size() == 0) {
- for (BaseVimInstance vimInstance :
- vimInstanceRepository.findByProjectId(vnfd.getProjectId())) {
- if (vnfPackage == null
- || vnfPackage.getVimTypes() == null
- || vnfPackage.getVimTypes().isEmpty()) {
- checkedVimInstanceNames.add(vimInstance.getName());
- } else {
- String type = vimInstance.getType();
- if (type.contains(".")) {
- type = type.split("\\.")[0];
- }
- if (vnfPackage.getVimTypes().contains(type)) {
- checkedVimInstanceNames.add(vimInstance.getName());
- }
- }
- }
- }
if (checkedVimInstanceNames.size() == 0) {
throw new org.openbaton.exceptions.BadRequestException(
