workaraound, deleting vim is blocked if there are nsr using it not vnfr
@@ -33,6 +33,7 @@ import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.Future;
import org.openbaton.catalogue.mano.descriptor.VirtualDeploymentUnit;
import org.openbaton.catalogue.mano.descriptor.VirtualNetworkFunctionDescriptor;
+import org.openbaton.catalogue.mano.record.NetworkServiceRecord;
import org.openbaton.catalogue.mano.record.VirtualLinkRecord;
import org.openbaton.catalogue.mano.record.VirtualNetworkFunctionRecord;
import org.openbaton.catalogue.nfvo.images.BaseNfvImage;
@@ -44,6 +45,7 @@ import org.openbaton.exceptions.NotFoundException;
import org.openbaton.exceptions.PluginException;
import org.openbaton.exceptions.VimException;
import org.openbaton.nfvo.repositories.ImageRepository;
+import org.openbaton.nfvo.repositories.NetworkServiceRecordRepository;
import org.openbaton.nfvo.repositories.VNFDRepository;
import org.openbaton.nfvo.repositories.VNFRRepository;
import org.openbaton.nfvo.repositories.VimRepository;
@@ -91,6 +93,8 @@ public class VimManagement implements org.openbaton.nfvo.core.interfaces.VimMana
@Value("${nfvo.vim.cache.timout:10000}")
private long refreshCacheTimeout;
+ @Autowired private NetworkServiceRecordRepository nsrRepository;
+
@Override
@Async
public Future<BaseVimInstance> add(BaseVimInstance vimInstance, String projectId)
@@ -109,7 +113,9 @@ public class VimManagement implements org.openbaton.nfvo.core.interfaces.VimMana
throw new NotFoundException("Vim Instance with id " + id + " was not found");
}
if (checkForVimInVnfr) {
- for (VirtualNetworkFunctionRecord vnfr : vnfrRepository.findByProjectId(projectId)) {
+
+ for (NetworkServiceRecord nsr : nsrRepository.findByProjectId(projectId)) {
+ for (VirtualNetworkFunctionRecord vnfr : nsr.getVnfr()) {
for (VirtualDeploymentUnit vdu : vnfr.getVdu()) {
if (vdu.getVimInstanceName().contains(vimInstance.getName())) {
throw new BadRequestException(
@@ -118,6 +124,7 @@ public class VimManagement implements org.openbaton.nfvo.core.interfaces.VimMana
}
}
}
+ }
vimRepository.delete(vimInstance);
}
