aboutsummaryrefslogtreecommitdiffstats
path: root/heat/vFW_CNF_CDS/templates/cba/Scripts/kotlin
diff options
context:
space:
mode:
authorLukasz Rajewski <lukasz.rajewski@orange.com>2020-02-23 18:24:00 +0100
committerMarco Platania <platania@research.att.com>2020-02-28 13:55:08 +0000
commitb9f077ae5da15ba45728f6902b82bcdbbb31f2cf (patch)
tree428df886a176ef43673f62f2d3c3d80c8b698080 /heat/vFW_CNF_CDS/templates/cba/Scripts/kotlin
parent83e1a98bc9656ecaa6b99446a73513e9d3419937 (diff)
K8S Profile modification by CDS
This change implements the modification of K8s profile by CDS. The script creates the content of tar.gz file with profile base on the included profile tempalte and template artifcts of the profile. This version only builds the profile file. Change-Id: If3aafdb660b6e63ebb33892f5e8593bd0b6be392 Issue-ID: INT-1458 Signed-off-by: Lukasz Rajewski <lukasz.rajewski@orange.com>
Diffstat (limited to 'heat/vFW_CNF_CDS/templates/cba/Scripts/kotlin')
-rw-r--r--heat/vFW_CNF_CDS/templates/cba/Scripts/kotlin/KotlinK8sProfileUpload.kt28
1 files changed, 22 insertions, 6 deletions
diff --git a/heat/vFW_CNF_CDS/templates/cba/Scripts/kotlin/KotlinK8sProfileUpload.kt b/heat/vFW_CNF_CDS/templates/cba/Scripts/kotlin/KotlinK8sProfileUpload.kt
index 30a7b72e..22e4b33a 100644
--- a/heat/vFW_CNF_CDS/templates/cba/Scripts/kotlin/KotlinK8sProfileUpload.kt
+++ b/heat/vFW_CNF_CDS/templates/cba/Scripts/kotlin/KotlinK8sProfileUpload.kt
@@ -26,6 +26,8 @@ import org.onap.ccsdk.cds.blueprintsprocessor.rest.service.BlueprintWebClientSer
import org.onap.ccsdk.cds.blueprintsprocessor.rest.service.RestLoggerService
import org.onap.ccsdk.cds.blueprintsprocessor.services.execution.AbstractScriptComponentFunction
import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils
+import org.onap.ccsdk.cds.controllerblueprints.core.utils.BluePrintArchiveUtils
+import org.onap.ccsdk.cds.controllerblueprints.core.utils.ArchiveType
import org.apache.commons.io.IOUtils
import org.apache.commons.io.FilenameUtils
import org.apache.http.client.entity.EntityBuilder
@@ -51,11 +53,6 @@ import java.nio.charset.Charset
import java.util.Base64
import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintProcessorException
-import java.io.BufferedInputStream
-import java.io.FileInputStream
-import java.io.FileOutputStream
-import java.util.zip.GZIPInputStream
-
open class K8sProfileUpload : AbstractScriptComponentFunction() {
private val log = LoggerFactory.getLogger(K8sProfileUpload::class.java)!!
@@ -105,7 +102,7 @@ open class K8sProfileUpload : AbstractScriptComponentFunction() {
if (api.hasProfile(k8sRbProfileName)) {
log.info("Profile Already Existing - skipping upload")
} else {
- val profileFilePath = prepareProfileFile(k8sRbProfileName)
+ val profileFilePath: Path = prepareProfileFile(k8sRbProfileName)
var profile = K8sProfile()
profile.profileName = k8sRbProfileName
@@ -132,6 +129,25 @@ open class K8sProfileUpload : AbstractScriptComponentFunction() {
if (!profileFile.exists())
throw BluePrintProcessorException("K8s Profile template file ${profileFilePath} does not exists")
+ val tempMainPath: File = createTempDir("k8s-profile-", "")
+ val tempProfilePath: File = createTempDir("${k8sRbProfileName}-", "", tempMainPath)
+ log.info("Decompressing profile to ${tempProfilePath.toString()}")
+
+ val decompressedProfile: File = BluePrintArchiveUtils.deCompress(profileFilePath.toFile(),
+ "${tempProfilePath.toString()}", ArchiveType.TarGz)
+
+ log.info("${profileFilePath.toString()} decompression completed")
+
+ //Here we can add extra files inside the archive
+ profileFilePath = Paths.get(tempMainPath.toString().plus(File.separator).plus("${k8sRbProfileName}.tar.gz"))
+
+ if (!BluePrintArchiveUtils.compress(decompressedProfile, profileFilePath.toFile(),
+ ArchiveType.TarGz)) {
+ throw BluePrintProcessorException("Profile compression has failed")
+ }
+
+ log.info("${profileFilePath.toString()} compression completed")
+
return profileFilePath
}