aboutsummaryrefslogtreecommitdiffstats
AgeCommit message (Expand)AuthorFilesLines
2021-09-16Merge "[DCAEGEN2] Update PM-Mapper image to 1.7.1"Sylvain Desbureaux1-1/+1
2021-09-14Merge "[AAI] Service Mesh compatibility"Sylvain Desbureaux41-96/+282
2021-09-14[DCAEGEN2] Update PM-Mapper image to 1.7.1k.kedron1-1/+1
2021-09-14Merge "[CPS] Charts added for repo cps-cps-temporal"Sylvain Desbureaux24-1/+983
2021-09-14Merge "[DCAEGEN2] Update HV-VES version to 1.9.1"Sylvain Desbureaux2-2/+3
2021-09-14Merge "[DCAE] Update DFC to version 1.6.1"Sylvain Desbureaux2-3/+7
2021-09-14Merge "[HOLMES] Updated the Version of Docker Images"Sylvain Desbureaux2-2/+2
2021-09-14Merge "[DCAE] Update tcagen2 version to 1.3.1"Sylvain Desbureaux2-3/+3
2021-09-14Merge "[COMMON] Fix deploy.sh/undeploy.sh scripts"Sylvain Desbureaux2-4/+4
2021-09-13[AAI] Service Mesh compatibilityosk1146141-96/+282
2021-09-13[CPS] Charts added for repo cps-cps-temporalputhuparambil.aditya24-1/+983
2021-09-10[DCAE] Update DFC to version 1.6.1Remigiusz Janeczek2-3/+7
2021-09-10Merge "[CPS] Charts added for repo cps-ncmp-dmi-plugin"Sylvain Desbureaux15-2/+615
2021-09-09Merge "[CDS] Prometheus metrics for command-executor"Sylvain Desbureaux4-0/+53
2021-09-09Merge "[OOM] Update Linux SSL Truststore /etc/ssl"Sylvain Desbureaux2-0/+16
2021-09-09Merge "[CONTRIB] Introduce certificate update use case in CertService"Sylvain Desbureaux14-65/+227
2021-09-09Merge "[DCAE] Bootstrap and other components version update"Sylvain Desbureaux4-4/+4
2021-09-09[COMMON] Fix deploy.sh/undeploy.sh scriptsguillaume.lambert2-4/+4
2021-09-08[CPS] Charts added for repo cps-ncmp-dmi-pluginshivasubedi15-2/+615
2021-09-08Merge "[ESR] Remove ESR from OOM"Sylvain Desbureaux35-1146/+2
2021-09-08Merge "[COMMON] Fix bashisms in import-custom-cert"Krzysztof Opasiak1-5/+4
2021-09-08Merge "[COMMON] Fix ${p//pat/str} bashism"Krzysztof Opasiak1-2/+2
2021-09-08[DCAE] Update tcagen2 version to 1.3.1Remigiusz Janeczek2-3/+3
2021-09-08Merge "[CONSUL] Update chart with service account"Sylvain Desbureaux8-1/+126
2021-09-08[HOLMES] Updated the Version of Docker ImagesGuangrong Fu2-2/+2
2021-09-07[CDS] Prometheus metrics for command-executorkuldipr4-0/+53
2021-09-07[CONSUL] Update chart with service accountfarida azmy8-1/+126
2021-09-07[DCAE] Bootstrap and other components version updateVijay Venkatesh Kumar5-5/+5
2021-09-07[COMMON] Fix bashisms in import-custom-certguillaume.lambert1-5/+4
2021-09-07Merge "[COMMON] Fix brace expansion bashisms"Krzysztof Opasiak2-4/+4
2021-09-07[COMMON] Fix ${p//pat/str} bashismGuillaume Lambert1-2/+2
2021-09-07Merge "[COMMON] Fix ${foo:3[:1]} bashisms"Sylvain Desbureaux5-9/+9
2021-09-07Merge "[COMMON] Add prometheus service monitor template"Sylvain Desbureaux2-35/+169
2021-09-06[DCAEGEN2] Update HV-VES version to 1.9.1Joanna Jeremicz2-2/+3
2021-09-06[CONTRIB] Introduce certificate update use case in CertServicePiotr Marcinkiewicz14-65/+227
2021-09-06Merge "[AAI] Added Rolling Update Strategy to traversal"Sylvain Desbureaux2-0/+32
2021-09-06Merge "[AAI] Added Rolling Update Strategy to graphAdmin"Sylvain Desbureaux2-0/+32
2021-09-06Merge "[AAI] Added Rolling Update Strategy"Sylvain Desbureaux2-0/+32
2021-09-06Merge "[DCAEGEN2] Add Consul key delete job"Sylvain Desbureaux42-24/+368
2021-09-06[COMMON] Fix ${foo:3[:1]} bashismsGuillaume Lambert5-9/+9
2021-09-06Merge "[DCAEGEN2] Update VES version to 1.10.1"Sylvain Desbureaux2-2/+6
2021-09-06Merge "[DCAE] Update PRH version"Sylvain Desbureaux2-2/+5
2021-09-06Merge "[UUI] Update image of components of UUI"Sylvain Desbureaux1-1/+1
2021-09-06[COMMON] Add prometheus service monitor templateMarat Salakhutdinov2-35/+169
2021-09-06Merge "[DCAE] Make sure to update index.yaml after pushing all components"Sylvain Desbureaux1-1/+7
2021-09-05[OOM] Update Linux SSL Truststore /etc/sslAbdelmuhaimen Seaudi2-0/+16
2021-09-03[AAI] Added Rolling Update Strategy to graphAdminM.Hosnidokht2-0/+32
2021-09-03[AAI] Added Rolling Update Strategy to traversalM.Hosnidokht2-0/+32
2021-09-03[AAI] Added Rolling Update StrategyM.Hosnidokht2-0/+32
2021-09-03[DCAEGEN2] Add Consul key delete jobJack Lucas42-24/+368
data(Map<String, String> metadata) { this.metadata = metadata; } } static { try { FileUtils.forceMkdir(new File(getBasePath())); storeReady = true; } catch (IOException e) { log.error("Failed to create the data store results"); } } private static OnapCommandArtifactStore store = null; private OnapCommandArtifactStore() { this.dateFormatter.setTimeZone(TimeZone.getTimeZone("UTC")); } public static OnapCommandArtifactStore getStore() { if (store == null) { store = new OnapCommandArtifactStore(); } return store; } private static String getBasePath() { return OnapCommandConfig.getPropertyValue(OnapCommandConstants.OPEN_CLI_DATA_DIR) + File.separator + "artifacts"; } private static String getArtifactPath(String name, String category) { return getBasePath() + File.separator + name + SEPARATOR + category + ".json"; } private String getChecksum(String storePath) throws IOException, NoSuchAlgorithmException { byte[] b = Files.readAllBytes(Paths.get(storePath)); byte[] hash = MessageDigest.getInstance("MD5").digest(b); //NOSONAR return DatatypeConverter.printHexBinary(hash); } public Artifact createArtifact(Artifact artifact) throws OnapCommandArtifactContentNotExist, OnapCommandArtifactAlreadyExist, OnapCommandArtifactContentChecksumNotMatch { //NOSONAR if (!new File(artifact.getPath()).exists()) { throw new OnapCommandArtifactContentNotExist(artifact.getPath()); } String storePath = getArtifactPath(artifact.getName(), artifact.getCategoty()); File aFile = new File(storePath); if (aFile.exists()) { throw new OnapCommandArtifactAlreadyExist(artifact.getName(), artifact.getCategoty()); } try { String actual = this.getChecksum(artifact.getPath()); artifact.setChecksum(actual); artifact.setSize(new File(artifact.getPath()).length() / 1024); artifact.setCreateAt(dateFormatter.format(new Date())); artifact.setLastUpdatedAt(artifact.getCreateAt()); FileUtils.writeStringToFile(new File(storePath), gson.toJson(artifact), (Charset) null); } catch (Exception e) { // NOSONAR //It is expected that this never occurs log.error("Failed to store the artifact at {}", storePath); } return artifact; } public Artifact getArtifact(String name, String category) throws OnapCommandArtifactNotFound { String storePath = getArtifactPath(name, category); File aFile = new File(storePath); if (!aFile.exists()) { throw new OnapCommandArtifactNotFound(name, category); } try { return gson.fromJson(FileUtils.readFileToString(aFile, (Charset) null), Artifact.class); } catch (Exception e) { // NOSONAR //It is expected that this never occurs log.error("Failed to retrieve the artifact at {}", storePath); } return null; } public List<Artifact> listArtifact(String category, String namePattern) throws OnapCommandArtifactNotFound { //NOSONAR List<Artifact> artifacts = new ArrayList<>(); String searchPattern = ""; if (namePattern != null && !namePattern.isEmpty()) { searchPattern += namePattern; } else { searchPattern += "*"; } searchPattern += SEPARATOR; if (category != null && !category.isEmpty()) { searchPattern += category; } else { searchPattern += "*"; } searchPattern += ".json"; final String SP = searchPattern; //NOSONAR for (File file: new File(getBasePath()).listFiles()) { try (JsonReader jsonReader = new JsonReader(new FileReader(file))){ artifacts.add(gson.fromJson(jsonReader, Artifact.class)); } catch (Exception e) { // NOSONAR //It is expected that this never occurs String fileAbsPath = file.getAbsolutePath(); log.error("While seraching Failed to retrieve the artifact at {}", fileAbsPath); } } return artifacts; } public void deleteArtifact(String name, String category) throws OnapCommandArtifactNotFound { String storePath = getArtifactPath(name, category); File aFile = new File(storePath); if (!aFile.exists()) { throw new OnapCommandArtifactNotFound(name, category); } try { Files.delete(Paths.get(storePath)); } catch (IOException e) { log.error("Failed to delete the artifact {}", aFile.getAbsolutePath()); } } public Artifact setArtifact(Artifact artifact, Artifact existing) throws OnapCommandArtifactNotFound, OnapCommandArtifactContentNotExist, OnapCommandArtifactAlreadyExist, IOException, NoSuchAlgorithmException { if (artifact.getName() == null) { artifact.setName(existing.getName()); } if (artifact.getDescription() == null) { artifact.setDescription(existing.getDescription()); } if (artifact.getCategoty() == null) { artifact.setCategoty(existing.getCategoty()); } if (artifact.getPath()!= null) { if (!new File(artifact.getPath()).exists()) { throw new OnapCommandArtifactContentNotExist(artifact.getPath()); } String actual = this.getChecksum(artifact.getPath()); if (!existing.getChecksum().equals(actual)) { artifact.setChecksum(actual); artifact.setSize(new File(artifact.getPath()).length() / 1024); } } else { artifact.setPath(existing.getPath()); } artifact.setCreateAt(existing.getCreateAt()); artifact.setLastUpdatedAt(dateFormatter.format(new Date())); return artifact; } public Artifact updateArtifact(String name, String category, Artifact artifact) throws OnapCommandArtifactNotFound, OnapCommandArtifactContentNotExist, OnapCommandArtifactAlreadyExist { Artifact existing = this.getArtifact(name, category); String existingStorePath = getArtifactPath(name, category); String newStorePath = getArtifactPath(artifact.getName(), artifact.getCategoty()); if ( !existingStorePath.equalsIgnoreCase(newStorePath) && new File(newStorePath).exists()) { throw new OnapCommandArtifactAlreadyExist(artifact.getName(), artifact.getCategoty()); } try { artifact = setArtifact(artifact, existing); if (artifact.getMetadata().size() > 0) { //update to existing one for (Map.Entry<String, String> entry: artifact.getMetadata().entrySet()) { if (entry.getValue() == null || entry.getValue().isEmpty() || entry.getValue().equalsIgnoreCase("null")) { existing.getMetadata().remove(entry.getKey()); } else existing.getMetadata().put(entry.getKey(), entry.getValue()); } artifact.setMetadata(existing.getMetadata()); } FileUtils.writeStringToFile(new File(newStorePath), gson.toJson(artifact), (Charset) null); if (!newStorePath.equalsIgnoreCase(existingStorePath)) { this.deleteArtifact(name, category); } } catch (Exception e) { // NOSONAR //It is expected that this never occurs log.error("Failed to update the artifact at {}", existingStorePath); } return artifact; } }