/** * Stores the PhysicalNetworkFunctionDescriptor * * @param pDescriptor : The PhysicalNetworkFunctionDescriptor to be stored * @param idNsd : The NSD id * @return PhysicalNetworkFunctionDescriptor: The PhysicalNetworkFunctionDescriptor stored @ */ @ApiOperation(value = "", notes = "", hidden = true) @RequestMapping( value = "{id}/pnfdescriptors/", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE) @ResponseStatus(HttpStatus.CREATED) public PhysicalNetworkFunctionDescriptor postPhysicalNetworkFunctionDescriptor( @RequestBody @Valid PhysicalNetworkFunctionDescriptor pDescriptor, @PathVariable("id") String idNsd, @RequestHeader(value = "project-id") String projectId) throws NotFoundException { return networkServiceDescriptorManagement.addPnfDescriptor(pDescriptor, idNsd, projectId); }
/** * Stores the Security into NSD * * @param security : The Security to be stored * @param id : The id of NSD * @return Security: The Security stored @ */ @ApiOperation(value = "", notes = "", hidden = true) @RequestMapping( value = "{id}/security/", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE) @ResponseStatus(HttpStatus.CREATED) public Security postSecurity( @RequestBody @Valid Security security, @PathVariable("id") String id, @RequestHeader(value = "project-id") String projectId) throws NotFoundException { return networkServiceDescriptorManagement.addSecurity(id, security, projectId); }
@ApiOperation( value = "Add a VNFD to the NSD", notes = "Takes a Virtual Network Function Descriptor in the Request Body and adds it to the vnfd list of the Network Service Descriptor with id specified in the URL") @RequestMapping( value = "{id}/vnfdescriptors/", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE) @ResponseStatus(HttpStatus.CREATED) public VirtualNetworkFunctionDescriptor postVNFD( @RequestBody @Valid VirtualNetworkFunctionDescriptor vnfDescriptor, @PathVariable("id") String idNsd, @RequestHeader(value = "project-id") String projectId) throws NotFoundException { return networkServiceDescriptorManagement.addVnfd(vnfDescriptor, idNsd, projectId); }
/** * This operation returns the Network Service Descriptor (NSD) selected by id * * @param id of Network Service Descriptor * @return NetworkServiceDescriptor: the Network Service Descriptor selected @ */ @ApiOperation( value = "Get Network Service Descriptor by id", notes = "Returns the Network Service Descriptor with the id in the URL") @RequestMapping(value = "{id}", method = RequestMethod.GET) public NetworkServiceDescriptor findById( @PathVariable("id") String id, @RequestHeader(value = "project-id") String projectId) throws NotFoundException { NetworkServiceDescriptor nsd = networkServiceDescriptorManagement.query(id, projectId); if (nsd == null) throw new NotFoundException("Did not find a Network Service Descriptor with ID " + id); return nsd; }
@Test public void NSDFindAll() { Iterable<NetworkServiceDescriptor> list = nsdManagement.query(); when(nsdManagement.queryByProjectId(anyString())).thenReturn(list); assertEquals(list, restNetworkService.findAll("project-id")); }
/** * This operation allows submitting and validating a Network Service Descriptor (NSD), including * any related VNFFGD and VLD. * * @param networkServiceDescriptor : the Network Service Descriptor to be created * @return networkServiceDescriptor: the Network Service Descriptor filled with id and values from * core */ @RequestMapping( method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE) @ResponseStatus(HttpStatus.CREATED) @ApiOperation( value = "Adding a Network Service Descriptor", notes = "POST request with Network Service Descriptor as JSON content of the request body") public NetworkServiceDescriptor create( @RequestBody @Valid NetworkServiceDescriptor networkServiceDescriptor, @RequestHeader(value = "project-id") String projectId) throws NotFoundException, BadFormatException, NetworkServiceIntegrityException, CyclicDependenciesException, EntityInUseException, BadRequestException, IOException, AlreadyExistingException, PluginException, IncompatibleVNFPackage, VimException, InterruptedException, EntityUnreachableException { NetworkServiceDescriptor nsd; log.trace("Just Received: " + networkServiceDescriptor); nsd = networkServiceDescriptorManagement.onboard(networkServiceDescriptor, projectId); return nsd; }
/** * This operation is used to remove a disabled Network Service Descriptor * * @param id of Network Service Descriptor */ @ApiOperation( value = "Removing a Network Service Descriptor", notes = "DELETE request where the id in the url belongs to the NSD to delete") @RequestMapping(value = "{id}", method = RequestMethod.DELETE) @ResponseStatus(HttpStatus.NO_CONTENT) public void delete( @PathVariable("id") String id, @RequestHeader(value = "project-id") String projectId) throws WrongStatusException, EntityInUseException, BadRequestException, NotFoundException { networkServiceDescriptorManagement.delete(id, projectId); }
@ApiOperation( value = "Gets a single VNF from the NSD", notes = "Returns the VNFD with the id specified in the URL and that is part of the specified NSD") @RequestMapping( value = "{idNsd}/vnfdescriptors/{idVfnd}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) @ResponseStatus(HttpStatus.OK) public VirtualNetworkFunctionDescriptor getVirtualNetworkFunctionDescriptor( @PathVariable("idNsd") String idNsd, @PathVariable("idVfnd") String idVfnd, @RequestHeader(value = "project-id") String projectId) throws NotFoundException { return networkServiceDescriptorManagement.getVirtualNetworkFunctionDescriptor( idNsd, idVfnd, projectId); }
/** * Returns the PhysicalNetworkFunctionDescriptor * * @param idNsd : The NSD id * @param idPnf : The PhysicalNetworkFunctionDescriptor id * @return PhysicalNetworkFunctionDescriptor: The PhysicalNetworkFunctionDescriptor selected @ */ @ApiOperation(value = "", notes = "", hidden = true) @RequestMapping( value = "{idNds}/pnfdescriptors/{idPnf}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) @ResponseStatus(HttpStatus.OK) public PhysicalNetworkFunctionDescriptor getPhysicalNetworkFunctionDescriptor( @PathVariable("idNds") String idNsd, @PathVariable("idPnf") String idPnf, @RequestHeader(value = "project-id") String projectId) throws NotFoundException { return networkServiceDescriptorManagement.getPhysicalNetworkFunctionDescriptor( idNsd, idPnf, projectId); }
@ApiOperation( value = "Returns the list of VNF Dependency for a VNF from the NSD", notes = "Returns all the VNF Dependencies only for a specific VNF specified in the NSD") @RequestMapping( value = "{idNsd}/vnfdependencies/{idVnfd}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) @ResponseStatus(HttpStatus.OK) public VNFDependency getVNFDependency( @PathVariable("idNsd") String idNsd, @PathVariable("idVnfd") String idVnfd, @RequestHeader(value = "project-id") String projectId) throws NotFoundException { return networkServiceDescriptorManagement.getVnfDependency(idNsd, idVnfd, projectId); }
/** * This operation returns the list of Network Service Descriptor (NSD) * * @return List<NetworkServiceDescriptor>: the list of Network Service Descriptor stored */ @ApiOperation( value = "Get all NSDs from a project", notes = "Returns all Network Service Descriptors onboarded in the project with the specified id") @RequestMapping(method = RequestMethod.GET) public List<NetworkServiceDescriptor> findAll( @RequestHeader(value = "project-id") String projectId) { return (List<NetworkServiceDescriptor>) networkServiceDescriptorManagement.queryByProjectId(projectId); }
/** * Returns the Security into a NSD with id * * @param id : The id of NSD * @return Security: The Security of PhysicalNetworkFunctionDescriptor into NSD @ */ @ApiOperation(value = "", notes = "", hidden = true) @RequestMapping( value = "{id}/security", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) @ResponseStatus(HttpStatus.OK) public Security getSecurity( @PathVariable("id") String id, @RequestHeader(value = "project-id") String projectId) throws NotFoundException { NetworkServiceDescriptor nsd = networkServiceDescriptorManagement.query(id, projectId); if (nsd == null) throw new NotFoundException("Did not find a Network Service Descriptor with ID " + id); return nsd.getNsd_security(); }
@RequestMapping(method = RequestMethod.POST) @ResponseStatus(HttpStatus.ACCEPTED) private NetworkServiceDescriptor postTosca( @RequestBody String nsd_yaml, @RequestHeader(value = "project-id") String projectId) throws NetworkServiceIntegrityException, BadFormatException, NotFoundException, CyclicDependenciesException, EntityInUseException, org.openbaton.tosca.exceptions.NotFoundException, BadRequestException, IOException, AlreadyExistingException, PluginException, IncompatibleVNFPackage, VimException, InterruptedException, EntityUnreachableException { NSDTemplate nsdTemplate = Utils.stringToNSDTemplate(nsd_yaml); NetworkServiceDescriptor nsd = toscaParser.parseNSDTemplate(nsdTemplate); return networkServiceDescriptorManagement.onboard(nsd, projectId); } }
/** * Removes a list Network Service Descriptor from the NSDs Repository * * @param ids: the list of the ids * @throws NotFoundException * @throws InterruptedException * @throws ExecutionException * @throws WrongStatusException * @throws VimException */ @RequestMapping( value = "/multipledelete", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE) @ApiOperation( value = "Removing multiple Network Service Descriptors", notes = "Delete Request takes a list of Network Service Descriptor ids") @ResponseStatus(HttpStatus.NO_CONTENT) public void multipleDelete( @RequestBody @Valid List<String> ids, @RequestHeader(value = "project-id") String projectId) throws WrongStatusException, NotFoundException, EntityInUseException, BadRequestException { for (String id : ids) networkServiceDescriptorManagement.delete(id, projectId); }
@Test @SuppressWarnings({"unsafe", "unchecked"}) public void VNFDNotFoundException() throws NotFoundException { exception.expect(NotFoundException.class); when(nsdManagement.getVirtualNetworkFunctionDescriptor(anyString(), anyString(), anyString())) .thenThrow(NotFoundException.class); restNetworkService.getVirtualNetworkFunctionDescriptor( networkServiceDescriptor.getId(), "-1", "pi"); }
@Test @SuppressWarnings({"unsafe", "unchecked"}) public void PNFDNotFoundException() throws NotFoundException { exception.expect(NotFoundException.class); when(nsdManagement.getPhysicalNetworkFunctionDescriptor(anyString(), anyString(), anyString())) .thenThrow(NotFoundException.class); PhysicalNetworkFunctionDescriptor physicalNetworkFunctionDescriptor = restNetworkService.getPhysicalNetworkFunctionDescriptor( networkServiceDescriptor.getId(), "-1", "pi"); }
@Test @SuppressWarnings({"unsafe", "unchecked"}) public void VNFDependencyNotFoundException() throws NotFoundException { exception.expect(NotFoundException.class); when(nsdManagement.getVnfDependency(anyString(), anyString(), anyString())) .thenThrow(NotFoundException.class); restNetworkService.getVNFDependency(networkServiceDescriptor.getId(), "-1", "pi"); }
/** * Returns the list of PhysicalNetworkFunctionDescriptor into a NSD with id * * @param id : The id of NSD * @return List<PhysicalNetworkFunctionDescriptor>: The List of PhysicalNetworkFunctionDescriptor * into NSD @ */ @ApiOperation(value = "", notes = "", hidden = true) @RequestMapping( value = "{id}/pnfdescriptors", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) @ResponseStatus(HttpStatus.OK) public Set<PhysicalNetworkFunctionDescriptor> getPhysicalNetworkFunctionDescriptors( @PathVariable("id") String id, @RequestHeader(value = "project-id") String projectId) throws NotFoundException { NetworkServiceDescriptor nsd = networkServiceDescriptorManagement.query(id, projectId); if (nsd == null) throw new NotFoundException("Did not find a Network Service Descriptor with ID " + id); return nsd.getPnfd(); }
@RequestMapping(value = "/api/v1/csar-nsd", method = RequestMethod.POST) @ResponseBody @ApiOperation( value = "Add a CSAR Network Service", notes = "The request parameter 'file' specifies an archive which is needed to onboard a Network Service as CSAR. " + "On how to create such an archive refer to: http://openbaton.github.io/documentation/tosca-CSAR-onboarding/") public NetworkServiceDescriptor onboardNSD( @RequestParam("file") MultipartFile file, @RequestHeader(value = "project-id") String projectId) throws Exception, BadFormatException { log.debug("Onboarding"); if (!file.isEmpty()) { byte[] bytes = file.getBytes(); NetworkServiceDescriptor nsd = csarParser.onboardNSD(bytes, projectId); return networkServiceDescriptorManagement.onboard(nsd, projectId); } else throw new BadRequestException("File is empty!"); }
private void deleteDescriptor(String line) throws WrongStatusException, EntityInUseException, BadRequestException, NotFoundException { String id = extractIdFromLine(line); if (id.equals("")) return; nsdManagement.delete(id, nsdRepository.findFirstById(id).getProjectId()); }