@Scheduled(initialDelay = 30000, fixedDelay = 20000) public void checkHeartBeat() { for (VnfmManagerEndpoint endpoint : vnfmEndpointRepository.findAll()) { if (endpoint.getEndpointType().ordinal() == EndpointType.RABBIT.ordinal()) { if (endpoint.isEnabled()) { try { if (!RabbitManager.getQueues( brokerIp.trim(), username, password, virtualHost, managementPort) .contains(endpoint.getEndpoint())) { if (endpoint.isActive()) { log.info("Set endpoint " + endpoint.getType() + " to unactive"); endpoint.setActive(false); vnfmEndpointRepository.save(endpoint); } } else { if (!endpoint.isActive()) { log.info("Set endpoint " + endpoint.getType() + " to active"); endpoint.setActive(true); vnfmEndpointRepository.save(endpoint); } } } catch (IOException ignored) { log.warn("Not able to list queues, probably " + brokerIp.trim() + " is not reachable."); } } } } } }
if (endpoint.isActive()) { log.info("Set endpoint " + endpoint.getType() + " to unactive"); endpoint.setActive(false); vnfmEndpointRepository.save(endpoint); if (!endpoint.isActive()) { log.info("Set endpoint " + endpoint.getType() + " to active"); endpoint.setActive(true); vnfmEndpointRepository.save(endpoint); if (endpoint.isActive()) { log.warn("Not able to check endpoint: " + endpoint.getEndpoint()); endpoint.setActive(false); vnfmEndpointRepository.save(endpoint);
@Override public void register(VnfmManagerEndpoint endpoint) throws AlreadyExistingException { log.debug("Persisting: " + endpoint); for (VnfmManagerEndpoint endpointExisting : vnfmEndpointRepository.findAll()) { // TODO: decide whether the type or the endpoint (or both) is the unique identifier. strategy // here is different than in unregister function if (endpointExisting.getEndpoint().equals(endpoint.getEndpoint()) && endpointExisting.getType().equals(endpoint.getType()) && endpointExisting.getEndpointType().equals(endpoint.getEndpointType())) throw new AlreadyExistingException( "VnfmManagerEndpoint " + endpoint + " already exists in the DB"); } endpoint.setActive(true); this.vnfmEndpointRepository.save(endpoint); }
@Before public void init() { MockitoAnnotations.initMocks(this); NetworkServiceDescriptor nsd_exp = createNetworkServiceDescriptor(); when(nsdRepository.save(any(NetworkServiceDescriptor.class))).thenReturn(nsd_exp); when(vnfPackageRepository.save(any(VNFPackage.class))).thenReturn(new VNFPackage()); when(vnfmManagerEndpointRepository.findAll()) .thenReturn( new ArrayList<VnfmManagerEndpoint>() { { VnfmManagerEndpoint vnfmManagerEndpoint = new VnfmManagerEndpoint(); vnfmManagerEndpoint.setEndpoint("test"); vnfmManagerEndpoint.setType("test"); vnfmManagerEndpoint.setActive(true); vnfmManagerEndpoint.setEnabled(true); add(vnfmManagerEndpoint); } }); }
vnfmManagerEndpoint.setEndpoint("test"); vnfmManagerEndpoint.setType("test"); vnfmManagerEndpoint.setActive(true); vnfmManagerEndpoint.setEnabled(true); add(vnfmManagerEndpoint);
vnfmManagerEndpoint.setEndpoint("test"); vnfmManagerEndpoint.setType("test"); vnfmManagerEndpoint.setActive(true); vnfmManagerEndpoint.setEnabled(true); add(vnfmManagerEndpoint);
vnfmManagerEndpoint.setEndpoint("test"); vnfmManagerEndpoint.setType("test"); vnfmManagerEndpoint.setActive(true); vnfmManagerEndpoint.setEnabled(true); add(vnfmManagerEndpoint);
vnfmManagerEndpoint.setEndpoint("test"); vnfmManagerEndpoint.setType("test"); vnfmManagerEndpoint.setActive(true); vnfmManagerEndpoint.setEnabled(true); add(vnfmManagerEndpoint);
/** * This method setups the VNFM and then subscribe it to the NFVO. We recommend to not change this * method or at least to override calling super() */ protected void setup() { loadProperties(); vnfmManagerEndpoint = new VnfmManagerEndpoint(); vnfmManagerEndpoint.setType(vnfmHelper.getVnfmType()); vnfmManagerEndpoint.setDescription(vnfmHelper.getVnfmDescription()); vnfmManagerEndpoint.setEnabled(vnfmHelper.isVnfmEnabled()); vnfmManagerEndpoint.setActive(true); vnfmManagerEndpoint.setEndpoint(vnfmHelper.getVnfmEndpoint()); vnfmManagerEndpoint.setEndpointType(vnfmHelper.getVnfmEndpointType()); }
@Test public void nsdManagementOnboardTest() throws NotFoundException, BadFormatException, NetworkServiceIntegrityException, CyclicDependenciesException, EntityInUseException, BadRequestException, IOException, AlreadyExistingException, PluginException, IncompatibleVNFPackage, VimException, InterruptedException, EntityUnreachableException { NetworkServiceDescriptor nsd_exp = createNetworkServiceDescriptor(); when(vnfmManagerEndpointRepository.findAll()) .thenReturn( new ArrayList<VnfmManagerEndpoint>() { { VnfmManagerEndpoint vnfmManagerEndpoint = new VnfmManagerEndpoint(); vnfmManagerEndpoint.setEndpoint("test"); vnfmManagerEndpoint.setType("test"); vnfmManagerEndpoint.setActive(true); vnfmManagerEndpoint.setEnabled(true); add(vnfmManagerEndpoint); } }); when(nsdRepository.save(nsd_exp)).thenReturn(nsd_exp); exception = ExpectedException.none(); nsdManagement.onboard(nsd_exp, projectId); assertEqualsNSD(nsd_exp); }