@ApiOperation( value = "Retrieve a script from a VNF Package", notes = "The ids of the package and the script are provided in the URL") @RequestMapping( value = "{id}/scripts/{scriptId}", method = RequestMethod.GET, produces = MediaType.TEXT_PLAIN_VALUE) public String getScript( @PathVariable("id") String id, @PathVariable("scriptId") String scriptId, @RequestHeader(value = "project-id") String projectId) throws NotFoundException { VNFPackage vnfPackage = vnfPackageManagement.query(id, projectId); if (vnfPackage == null) throw new NotFoundException("No VNFPackage found with ID " + id); for (Script script : vnfPackage.getScripts()) { if (script.getId().equals(scriptId)) { return new String(script.getPayload()); } } throw new NotFoundException( "Script with id " + scriptId + " was not found into package with id " + id); }
if (vnfPackage.getScripts() != null && !vnfPackage.getScripts().isEmpty()) { log.debug( "VNFPackageManagement: Remove scripts got by scripts/ because the scripts-link is defined");
script.setName(entry.getName().substring(8)); script.setPayload(content); if (vnfPackage.getScripts() == null) vnfPackage.setScripts(new HashSet<>()); vnfPackage.getScripts().add(script); } else if (!entry.getName().startsWith("scripts/") && entry.getName().endsWith(".json")) { imageFile = content; && (vnfPackage.getScripts() != null && vnfPackage.getScripts().size() > 0)) { log.debug("Remove scripts got by scripts/ because the scripts-link is defined"); vnfPackage.setScripts(new HashSet<>());
@ApiOperation( value = "Update a script of a VNF Package", notes = "The updated script has to be passed in the Request Body") @RequestMapping( value = "{id}/scripts/{scriptId}", method = RequestMethod.PUT, produces = MediaType.TEXT_PLAIN_VALUE, consumes = MediaType.TEXT_PLAIN_VALUE) public String updateScript( @PathVariable("id") String vnfPackageId, @PathVariable("scriptId") String scriptId, @RequestBody String scriptNew, @RequestHeader(value = "project-id") String projectId) throws NotFoundException, BadFormatException, ExecutionException, InterruptedException { VNFPackage vnfPackage = vnfPackageManagement.query(vnfPackageId, projectId); if (vnfPackage == null) throw new NotFoundException("No VNFPackage found with ID " + vnfPackageId); for (Script script : vnfPackage.getScripts()) { if (script.getId().equals(scriptId)) { script.setPayload(scriptNew.getBytes()); script = vnfPackageManagement.updateScript(script, vnfPackageId); return new String(script.getPayload()); } } throw new NotFoundException( "Script with id " + scriptId + " was not found into package with id " + vnfPackageId); }
scripts = scalingMessage.getVnfPackage().getScriptsLink(); } else { scripts = scalingMessage.getVnfPackage().getScripts(); allocateResources.setKeyPairs(orVnfmInstantiateMessage.getKeys()); if (orVnfmInstantiateMessage.getVnfPackage() != null && orVnfmInstantiateMessage.getVnfPackage().getScripts() != null) allocateResources.setCustomUserData( getUserDataFromPackage(orVnfmInstantiateMessage.getVnfPackage().getScripts())); try { virtualNetworkFunctionRecord = executor.submit(allocateResources).get(); instantiate( virtualNetworkFunctionRecord, orVnfmInstantiateMessage.getVnfPackage().getScripts(), vimInstances);