@Override public Iterable<VnfmManagerEndpoint> listVnfm() { return this.vnfmEndpointRepository.findAll(); }
public Iterable<VnfmManagerEndpoint> query() { return vnfmManagerEndpointRepository.findAll(); }
@Override public VnfmManagerEndpoint getVnfm(String endpoint) throws NotFoundException { log.trace("Looking for vnfmEndpoint endpoint: " + endpoint); for (VnfmManagerEndpoint vnfmManagerEndpoint : this.vnfmEndpointRepository.findAll()) { log.trace("" + vnfmManagerEndpoint); if (vnfmManagerEndpoint.getType().equals(endpoint)) { return vnfmManagerEndpoint; } } throw new NotFoundException("VnfManager of endpoint " + endpoint + " is not registered"); }
private void listVnfms() { String line = String.format("%20s%20s%20s", "Vnfm type", "active", "enable"); System.out.println(line); for (VnfmManagerEndpoint endpoint : vnfmEndpointRepository.findAll()) { System.out.println( String.format( "%20s%20s%20s", endpoint.getType(), endpoint.isActive(), endpoint.isEnabled())); } }
@Override public void removeManagerEndpoint(String endpoint_json) { VnfmManagerEndpoint endpoint = gson.fromJson(endpoint_json, VnfmManagerEndpoint.class); log.debug("Unregistering: " + endpoint); // TODO double check that the equals is done on all parameters.. for (VnfmManagerEndpoint vnfmManagerEndpoint : vnfmEndpointRepository.findAll()) if (vnfmManagerEndpoint.getEndpoint().equals(endpoint.getEndpoint())) { this.unregister(vnfmManagerEndpoint); break; } }
@Override public void unregister(VnfmManagerEndpoint endpoint) { Iterable<VnfmManagerEndpoint> vnfmManagerEndpoints = vnfmEndpointRepository.findAll(); for (VnfmManagerEndpoint vnfmManagerEndpoint : vnfmManagerEndpoints) { // TODO: decide whether the type or the endpoint (or both) is the unique identifier if (endpoint.getType().equals(vnfmManagerEndpoint.getType())) { log.info("Unregistered vnfm: " + endpoint.getType()); this.vnfmEndpointRepository.delete(vnfmManagerEndpoint.getId()); return; } } log.error("no VNFM found for endpoint: " + 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); }
@Test @Ignore public void nsdManagementOnboardExceptionTest() 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>()); exception.expect(NotFoundException.class); nsdManagement.onboard(nsd_exp, projectId); }
Iterable<VnfmManagerEndpoint> endpoints = vnfmManagerEndpointRepository.findAll();
@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."); } } } } } }
@Scheduled(initialDelay = 15000, fixedDelay = 20000) public void checkHeartBeat() { for (VnfmManagerEndpoint endpoint : vnfmEndpointRepository.findAll()) { if (endpoint.getEndpointType().ordinal() == EndpointType.REST.ordinal()) { if (endpoint.isEnabled()) {
@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); } }); }
Iterable<VnfmManagerEndpoint> endpoints = vnfmManagerEndpointRepository.findAll(); nsdUtils.checkEndpoint(networkServiceDescriptor, endpoints);
Iterable<VnfmManagerEndpoint> endpoints = vnfmManagerEndpointRepository.findAll(); nsdUtils.checkEndpoint(vnfd.getEndpoint(), endpoints);
.thenReturn(res); when(vnfmManagerEndpointRepository.findAll()) .thenReturn( new ArrayList<VnfmManagerEndpoint>() {
when(vnfmManagerEndpointRepository.findAll()) .thenReturn( new ArrayList<VnfmManagerEndpoint>() {
when(vnfmManagerEndpointRepository.findAll()) .thenReturn( new ArrayList<VnfmManagerEndpoint>() {
virtualNetworkFunctionDescriptor.getLifecycle_event().add(event); final BaseVimInstance vimInstance = createVimInstance(); when(vnfmManagerEndpointRepository.findAll()) .thenReturn( new ArrayList<VnfmManagerEndpoint>() {
@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); }