Auto Auth Data

Issue-ID: AAF-420
Change-Id: Ide26f253aaf2a3c3741cb2a0317bc6ea89e357ed
Signed-off-by: Instrumental <jonathan.gathman@att.com>
diff --git a/auth/auth-cass/docker/dinstall.sh b/auth/auth-cass/docker/dinstall.sh
index d6fcb9f..3270196 100644
--- a/auth/auth-cass/docker/dinstall.sh
+++ b/auth/auth-cass/docker/dinstall.sh
@@ -43,7 +43,6 @@
   echo "Creating /opt/app/cass_init dir on aaf_cass"
   $DOCKER exec aaf_cass mkdir -p /opt/app/cass_init
   echo "cp the following files to /opt/app/cass_init dir on aaf_cass"
-  ls ../src/main/cql
   $DOCKER cp "../src/main/cql/." aaf_cass:/opt/app/cass_init
   echo "The following files are on /opt/app/cass_init dir on aaf_cass"
   $DOCKER exec aaf_cass ls /opt/app/cass_init
@@ -55,8 +54,6 @@
     echo " cd /opt/app/cass_init"  
     echo " cqlsh -f keyspace.cql"
     echo " cqlsh -f init.cql"
-    echo " cqlsh -f osaaf.cql"
-    echo " cqlsh -f temp_identity.cql"
     echo ""
     echo "The following will give you a temporary identity with which to start working, or emergency"
     echo " cqlsh -f temp_identity.cql"
@@ -64,8 +61,41 @@
     $DOCKER exec aaf_cass bash /usr/bin/cqlsh -f /opt/app/cass_init/keyspace.cql
     $DOCKER exec aaf_cass bash /usr/bin/cqlsh -e 'describe keyspaces'
     $DOCKER exec aaf_cass bash /usr/bin/cqlsh -f /opt/app/cass_init/init.cql
-    $DOCKER exec aaf_cass bash /usr/bin/cqlsh -f /opt/app/cass_init/osaaf.cql
-    $DOCKER exec aaf_cass bash /usr/bin/cqlsh -f /opt/app/cass_init/temp_identity.cql
+    cd ../../sample/cass_data
+    ID_FILE=../data/identities.dat 
+    if [ -e $ID_FILE ]; then
+      DATE=$(date "+%Y-%m-%d %H:%M:%S.000+0000" -d "+6 months")
+      echo $DATE
+      CRED="cred.dat"
+      # Enter for People
+      echo "Default Passwords for People"
+      for ID in $(grep '|a|' $ID_FILE | sed -e "s/|.*//"); do
+	 if [ "$ID" = "aaf" ]; then
+	    DOMAIN="aaf.osaaf.org";
+	 else
+            DOMAIN="$ID.onap.org";
+	 fi
+	 echo "$ID@$DOMAIN|2|${DATE}|0xd993c5617486296f1b99d04de31633332b8ba1a550038e23860f9dbf0b2fcf95|Initial ID|org.osaaf.people|53344|" >> $CRED
+      done
+    
+      for ID in $(grep '|e|' $ID_FILE | sed -e "s/|.*//"); do
+	 echo "$ID@people.osaaf.org|2|${DATE}|0xd993c5617486296f1b99d04de31633332b8ba1a550038e23860f9dbf0b2fcf95|Initial ID|org.osaaf.people|53344|" >> $CRED
+      done
+    
+      mv user_role.dat tmp
+      sed "s/\(^.*|\)\(.*|\)\(.*|\)\(.*\)/\1${DATE}|\3\4/" tmp > user_role.dat 
+
+      for DAT in ns perm role ns_attrib user_role cred; do 
+          $DOCKER container cp $DAT.dat aaf_cass:/tmp/$DAT.dat
+          $DOCKER exec aaf_cass bash /usr/bin/cqlsh -k authz -e "COPY authz.$DAT FROM '/tmp/$DAT.dat' WITH DELIMITER='|'"
+          $DOCKER exec -t aaf_cass rm /tmp/$DAT.dat
+      done
+      rm $CRED
+      mv tmp user_role.dat
+    else
+        echo DInstall requires access to 'identities.dat'
+    fi
+    cd -
   fi
 else 
   $DOCKER start aaf_cass
diff --git a/auth/docker/drun.sh b/auth/docker/drun.sh
index 04f5b32..2eb025e 100644
--- a/auth/docker/drun.sh
+++ b/auth/docker/drun.sh
@@ -5,8 +5,17 @@
 # Only need Cassandra Link Info when initializing the container.
 if [ ! -e ./cass.props ]; then
     cp cass.props.init cass.props
-    echo "Edit appropriate Cassandra Link Info into cass.props"
-    exit
+fi
+
+CASS_IS_SET="$(grep '<Cass IP>' cass.props)"
+if [ -n "$CASS_IS_SET" ]; then
+    CASS_IP="$(docker container inspect aaf_cass | grep \"IPAddress\": -m 1 | cut -d '"' -f 4)"
+    if [ -n "$CASS_IP" ]; then
+      sed -i -e "s/\(^.*:\).*/\1$CASS_IP/" cass.props
+    else
+      echo "Set CASSASNDRA IP in cass.props"
+      exit
+    fi
 fi
 
 . ./cass.props
diff --git a/auth/sample/data/identities.dat b/auth/sample/data/identities.dat
index 7bf14d5..cf3d671 100644
--- a/auth/sample/data/identities.dat
+++ b/auth/sample/data/identities.dat
@@ -18,22 +18,29 @@
 #  7 - responsible to (i.e Supervisor for People, or AppOwner, if it's an App ID)
 #
 
-iowna|Ima D. Owner|Ima|Owner|314-123-2000|ima.d.owner@osaaf.com|e|
-mmanager|Mark D. Manager|Mark|Manager|314-123-1234|mark.d.manager@osaaf.com|e|iowna
-bdevl|Robert D. Developer|Bob|Developer|314-123-1235|bob.d.develper@osaaf.com|e|mmanager
-mmarket|Mary D. Marketer|Mary|Marketer|314-123-1236|mary.d.marketer@osaaf.com|e|mmanager
-ccontra|Clarice D. Contractor|Clarice|Contractor|314-123-1237|clarice.d.contractor@osaaf.com|c|mmanager
-iretired|Ira Lee M. Retired|Ira|Retired|314-123-1238|clarice.d.contractor@osaaf.com|n|mmanager
-osaaf|ID of AAF|osaaf|AAF Application|||a|bdevl
+iowna|Ima D. Owner|Ima|Owner|314-123-2000|ima.d.owner@people.osaaf.com|e|
+mmanager|Mark D. Manager|Mark|Manager|314-123-1234|mark.d.manager@people.osaaf.com|e|iowna
+bdevl|Robert D. Developer|Bob|Developer|314-123-1235|bob.d.developer@people.osaaf.com|e|mmanager
+mmarket|Mary D. Marketer|Mary|Marketer|314-123-1236|mary.d.marketer@people.osaaf.com|e|mmanager
+ccontra|Clarice D. Contractor|Clarice|Contractor|314-123-1237|clarice.d.contractor@people.osaaf.com|c|mmanager
+iretired|Ira Lee M. Retired|Ira|Retired|314-123-1238|clarice.d.contractor@people.osaaf.com|n|mmanager
+
 # ONAP default Users
+demo|PORTAL DEMO|PORTAL|DEMO|||e|aaf_admin
+jh0003|PORTAL ADMIN|PORTAL|ADMIN|||e|aaf_admin
+cs0008|PORTAL DESIGNER|PORTAL|DESIGNER|||e|aaf_admin
+jm0007|PORTAL TESTER|PORTAL|TESTER|||e|aaf_admin
+op0001|PORTAL OPS|PORTAL|OPS|||e|aaf_admin
+gv0001|PORTAL GOVERNOR|PORTAL|GOVERNOR|||e|aaf_admin
+
+# AAF Defined Users
 aaf_admin|AAF Administrator|Mr AAF|AAF Admin|||e|mmanager
 deploy|Deployer|Deployer|Depoyer|||e|aaf_admin
-demo|PORTAL DEMO|PORTAL|DEMO|||e|aaf
-jh0003|PORTAL ADMIN|PORTAL|ADMIN|||e|aaf
-cs0008|PORTAL DESIGNER|PORTAL|DESIGNER|||e|aaf
-jm0007|PORTAL TESTER|PORTAL|TESTER|||e|aaf
-op0001|PORTAL OPS|PORTAL|OPS|||e|aaf
-gv0001|PORTAL GOVERNOR|PORTAL|GOVERNOR|||e|aaf
+
+# Requested Users
+djtimoney|Dan Timoney|Dan|Timoney|||e|mmanager
+portal_admin|Portal Admin|Portal|Admin|||e|mmanager
+
 # ONAP App IDs
 aaf|AAF Application|AAF|Application|||a|aaf_admin
 aaf-sms|AAF SMS Application|AAF SMS|Application|||a|aaf_admin
@@ -41,7 +48,18 @@
 aai|ONAP AAI Application|AAI|ONAP Application|||a|aaf_admin
 appc|ONAP APPC Application|APPC|ONAP Application|||a|aaf_admin
 dcae|ONAP DCAE Application|CLAMP|ONAP Application|||a|aaf_admin
-dmaap-bc|ONAP DMaap BC Application|DMaap BC|ONAP Application|||a|aaf_admin
-dmaap-mr|ONAP DMaap MR Application|DMaap MR|ONAP Application|||a|aaf_admin
 oof|ONAP OOF Application|OOF|ONAP Application|||a|aaf_admin
+so|ONAP SO Application|SO|ONAP Application|||a|aaf_admin
+sdc|ONAP SDC Application|SDC|ONAP Application|||a|aaf_admin
 sdnc|ONAP SDNC Application|SDNC|ONAP Application|||a|aaf_admin
+vid|ONAP VID Application|VID|ONAP Application|||a|aaf_admin
+policy|ONAP Policy Application|POLICY|ONAP Application|||a|aaf_admin
+portal|ONAP Portal Application|PORTAL|ONAP Application|||a|aaf_admin
+
+# DMAAP Identities
+dmaap-bc|ONAP DMaap BC Application|DMaap BC|ONAP Application|||a|aaf_admin
+dmaap_bc_topic_mgr|ONAP DMaap BC Topic Manager|DMaap BC Topic Manager|DMaap BC|||a|aaf_admin
+dmaap_bc_mm_prov|ONAP DMaap BC Provisioning Manager|DMaap BC Provision Manager|DMaap BC|||a|aaf_admin
+dmaap-mr|ONAP DMaap MR Application|DMaap MR|ONAP Application|||a|aaf_admin
+dmaap-dr-prov|ONAP DMaap DR Prov|Prov|DMaap MR|||a|aaf_admin
+dmaap-dr-node|ONAP DMaap DR Node|Node|DMaap MR|||a|aaf_admin