workflow replication factor 15/75215/5
authoravigaffa <avi.gaffa@amdocs.com>
Thu, 3 Jan 2019 12:18:49 +0000 (14:18 +0200)
committerVitaly Emporopulo <Vitaliy.Emporopulo@amdocs.com>
Thu, 3 Jan 2019 13:35:56 +0000 (13:35 +0000)
Change sdc-workflow-designer-init docker to support keyspace configuration

Change-Id: I5e5350b00de1702d978d3c7179692c7b0cd04e9e
Issue-ID: SDC-2033
Signed-off-by: avigaffa <avi.gaffa@amdocs.com>
README.md
workflow-designer-init/src/main/docker/Dockerfile
workflow-designer-init/src/main/docker/create_keyspaces.cql [new file with mode: 0644]
workflow-designer-init/src/main/docker/create_tables.cql [moved from workflow-designer-init/src/main/docker/create_workflow_db.cql with 89% similarity]
workflow-designer-init/src/main/docker/start.sh

index ec28b82..ca48433 100644 (file)
--- a/README.md
+++ b/README.md
@@ -52,6 +52,17 @@ An easy way to spin up a Cassandra instance is using a Cassandra Docker image as
 
 **WARNING**: *This step must be executed only once.*
 
+Workflow Designer requires two Cassandra namespaces:
+
+- WORKFLOW
+- ZUSAMMEN_WORKFLOW
+
+By default, these keyspaces are configured to use a simple replication strategy (`'class' : 'SimpleStrategy'`)
+and the replication factor of one (`'replication_factor' : 1`). In order to override this configuration, override
+the *create_keyspaces.cql* file at the root of the initialization container using
+[Docker volume mapping](https://docs.docker.com/storage/volumes/). Include `IF NOT EXISTS` clause in the keyspace
+creation statements to prevent accidental data loss.
+
 `docker run -ti -e CS_HOST=<cassandra-host> -e CS_PORT=<cassandra-port> -e CS_AUTHENTICATE=true/false
 -e CS_USER=<cassandra-user> -e CS_PASSWORD=<cassandra-password> nexus3.onap.org:10001/onap/workflow-init:latest`
 
index 7cd101c..399f216 100644 (file)
@@ -2,8 +2,7 @@ FROM python:2.7-alpine3.8
 
 RUN pip install cqlsh==4.0.1
 
-COPY create_workflow_db.cql .
-COPY start.sh .
+COPY create_keyspaces.cql create_tables.cql start.sh ./
 
 RUN chmod 744 start.sh
 
diff --git a/workflow-designer-init/src/main/docker/create_keyspaces.cql b/workflow-designer-init/src/main/docker/create_keyspaces.cql
new file mode 100644 (file)
index 0000000..4740697
--- /dev/null
@@ -0,0 +1,12 @@
+CREATE KEYSPACE IF NOT EXISTS WORKFLOW
+WITH DURABLE_WRITES = TRUE
+AND REPLICATION = {
+       'class' : 'SimpleStrategy',
+       'replication_factor' : 1
+};
+
+CREATE KEYSPACE IF NOT EXISTS ZUSAMMEN_WORKFLOW
+WITH REPLICATION = {
+       'class' : 'SimpleStrategy',
+       'replication_factor' : 1
+};
@@ -1,10 +1,3 @@
-CREATE KEYSPACE IF NOT EXISTS WORKFLOW
-WITH DURABLE_WRITES = TRUE
-AND REPLICATION = {
-       'class' : 'SimpleStrategy',
-       'replication_factor' : 1
-};
-
 USE WORKFLOW;
 
 CREATE TABLE IF NOT EXISTS UNIQUE_VALUE (
@@ -13,12 +6,6 @@ CREATE TABLE IF NOT EXISTS UNIQUE_VALUE (
        PRIMARY KEY (( TYPE, VALUE ))
 );
 
-CREATE KEYSPACE IF NOT EXISTS ZUSAMMEN_WORKFLOW
-WITH REPLICATION = {
-       'class' : 'SimpleStrategy',
-       'replication_factor' : 1
-};
-
 USE ZUSAMMEN_WORKFLOW;
 
 CREATE TABLE IF NOT EXISTS ITEM (
@@ -122,4 +109,4 @@ CREATE TABLE IF NOT EXISTS VERSION_STAGE (
        PUBLISH_TIME TIMESTAMP,
        ACTION TEXT,
        PRIMARY KEY (( SPACE, ITEM_ID ), VERSION_ID)
-);
\ No newline at end of file
+);
index 919277f..8acb2cf 100644 (file)
@@ -25,9 +25,14 @@ if [[ -z "${CS_HOST}" ]]; then
        exit 1
 fi
 
-if [ $is_cs_unauthenticated -eq 1 ]; then
-    cqlsh -u ${CS_USER} -p ${CS_PASSWORD} -f /create_workflow_db.cql ${CS_HOST} ${CS_PORT}
-else
-    cqlsh -f /create_workflow_db.cql ${CS_HOST} ${CS_PORT}
-fi
+cql_from_file() {
+
+    if [ $is_cs_unauthenticated -eq 1 ]; then
+        cqlsh -u ${CS_USER} -p ${CS_PASSWORD} -f $1 ${CS_HOST} ${CS_PORT}
+    else
+        cqlsh -f $1 ${CS_HOST} ${CS_PORT}
+    fi
+}
 
+cql_from_file /create_keyspaces.cql
+cql_from_file /create_tables.cql