public void parseVNFCSAR(String vnfd_csar) throws Exception { InputStream csar = new FileInputStream(vnfd_csar); readFiles(csar); readMetaData(); VNFDTemplate VNFDTemplate = Utils.bytesToVNFDTemplate(this.template); VirtualNetworkFunctionDescriptor vnfd = toscaParser.parseVNFDTemplate(VNFDTemplate); }
public NetworkServiceDescriptor parseNSDCSAR(String nsd_csar) throws Exception { InputStream input = new FileInputStream(new File(nsd_csar)); readFiles(input); readMetaData(); NSDTemplate nsdTemplate = Utils.bytesToNSDTemplate(this.template); NetworkServiceDescriptor nsd = toscaParser.parseNSDTemplate(nsdTemplate); return nsd; }
public VirtualNetworkFunctionDescriptor onboardVNFD(byte[] bytes, String projectId) throws NotFoundException, PluginException, VimException, IOException, IncompatibleVNFPackage { File temp = File.createTempFile("CSAR", null); FileOutputStream fos = new FileOutputStream(temp); fos.write(bytes); InputStream input = new FileInputStream(temp); readFiles(input); VNFDTemplate vnfdt = Utils.bytesToVNFDTemplate(this.template); VirtualNetworkFunctionDescriptor vnfd = toscaParser.parseVNFDTemplate(vnfdt); saveVNFD(vnfd, projectId, scripts); input.close(); fos.close(); this.template.close(); this.metadata.close(); return vnfd; }
public NetworkServiceDescriptor onboardNSD(byte[] bytes, String projectId) throws NotFoundException, PluginException, VimException, IOException, IncompatibleVNFPackage { File temp = File.createTempFile("CSAR", null); FileOutputStream fos = new FileOutputStream(temp); fos.write(bytes); InputStream input = new FileInputStream(temp); ArrayList<String> ids = new ArrayList<>(); readFiles(input); NSDTemplate nsdTemplate = Utils.bytesToNSDTemplate(this.template); NetworkServiceDescriptor nsd = toscaParser.parseNSDTemplate(nsdTemplate); for (VirtualNetworkFunctionDescriptor vnfd : nsd.getVnfd()) { if (!folderNames.contains(vnfd.getType())) { throw new NotFoundException("No Scripts specified for the VNFD of type: " + vnfd.getType()); } Set<Script> vnfScripts = new HashSet<>(); for (Script script : scripts) { String[] splitted_name = script.getName().split("!_!"); log.debug(splitted_name[0]); log.debug(script.getName()); if (splitted_name.length == 2) { String folder_name = splitted_name[0]; if (folder_name.equals(vnfd.getType())) { Script s = new Script(); s.setName(splitted_name[1]); s.setPayload(script.getPayload()); vnfScripts.add(s); } } } ids.add(saveVNFD(vnfd, projectId, vnfScripts)); } nsd.getVnfd().clear(); for (String id : ids) { String vnfdId = ""; Iterable<VirtualNetworkFunctionDescriptor> vnfds = vnfdRepository.findByProjectId(projectId); for (VirtualNetworkFunctionDescriptor vnfd : vnfds) { if (vnfd.getVnfPackageLocation().equals(id)) { vnfdId = vnfd.getId(); } } VirtualNetworkFunctionDescriptor vnfd = new VirtualNetworkFunctionDescriptor(); vnfd.setId(vnfdId); nsd.getVnfd().add(vnfd); } input.close(); fos.close(); this.template.close(); this.metadata.close(); return nsd; }