diff options
Diffstat (limited to 'ajsc-aai/src/main/scripts')
34 files changed, 3237 insertions, 0 deletions
diff --git a/ajsc-aai/src/main/scripts/PropertyChangeName.sh b/ajsc-aai/src/main/scripts/PropertyChangeName.sh new file mode 100644 index 0000000..86a2e40 --- /dev/null +++ b/ajsc-aai/src/main/scripts/PropertyChangeName.sh @@ -0,0 +1,87 @@ +#!/bin/ksh +# +# ============LICENSE_START======================================================= +# org.openecomp.aai +# ================================================================================ +# Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. +# ================================================================================ +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ============LICENSE_END========================================================= +# +# This script uses the dataSnapshot and SchemaGenerator (via GenTester) java classes to restore +# data to a database by doing three things: +# 1) clear out whatever data and schema are currently in the db +# 2) rebuild the schema (using the SchemaGenerator) +# 3) reload data from the passed-in datafile (which must found in the dataSnapShots directory and +# contain an xml view of the db data). +# +# +# This script is used to add a target property name with the same value in the database schema +# to a vertex which has an existing property. The existing property is not removed. +# +# Note also - This script just makes changes to the schema that is currently live. +# If you were to create a new schema in a brandy-new environment, it would look like +# whatever the oxm (as of July 2016) told it to look like. So, part of making a +# change to the db schema should Always first be to make the change in the oxm so that +# future environments will have the change. This script is just to change existing +# instances of the schema since schemaGenerator (as of July 2015) does not update things - it +# just does the initial creation. +# +# To use this script, you need to pass four parameters: +# propertyName -- the name of the property that has the value to be used in the targetProperty +# targetPropertyName -- the name of the targetProperty +# targetNodeType -- NA if all propertyName instances in the DB are impacted, otherwise limit the change to this nodeType +# skipCommit -- true or false. For testing, skips the commit when set to true. +# +# Ie. propertyNameChange service-id persona-model-id service-instance true +# + +echo +echo `date` " Starting $0" + + +userid=$( id | cut -f2 -d"(" | cut -f1 -d")" ) +if [ "${userid}" != "aaiadmin" ]; then + echo "You must be aaiadmin to run $0. The id used $userid." + exit 1 +fi + + +if [ "$#" -ne 4 ]; then + echo "Illegal number of parameters" + echo "usage: $0 propertyName targetPropertyName targetNodeType skipCommit" + exit 1 +fi + +. /etc/profile.d/aai.sh + +for JAR in `ls $PROJECT_HOME/extJars/*.jar` +do + CLASSPATH=$CLASSPATH:$JAR +done + +for JAR in `ls $PROJECT_HOME/lib/*.jar` +do + CLASSPATH=$CLASSPATH:$JAR +done + +$JAVA_HOME/bin/java -classpath $CLASSPATH -Dhttps.protocols=TLSv1.1,TLSv1.2 -DAJSC_HOME=$PROJECT_HOME -Daai.home=$PROJECT_HOME \ + org.openecomp.aai.dbgen.PropertyNameChange $1 $2 $3 $4 +if [ "$?" -ne "0" ]; then + echo "Problem executing propertyNameChange " + exit 1 +fi + + +echo `date` " Done $0" +exit 0 diff --git a/ajsc-aai/src/main/scripts/aaiadmin.crontab b/ajsc-aai/src/main/scripts/aaiadmin.crontab new file mode 100644 index 0000000..eb6ba78 --- /dev/null +++ b/ajsc-aai/src/main/scripts/aaiadmin.crontab @@ -0,0 +1,25 @@ +######################################################################### +# Archive and/or delete the AAI logs +# Arg1: The directory containing the log files +# Arg2: The number of days after which a log will be archived +# Arg3: The number of days after which an archived log will be deleted +########################################################################## +# application logs includes all subdirectories under PROJECT_HOME/LOGS that have *.log and *.log.<date> log files +10 00 * * * . /etc/profile.d/aai.sh; ${PROJECT_HOME}/scripts/logcleanup.sh ${PROJECT_HOME}/logs 7 15 >> ${PROJECT_HOME}/logs/misc/logcleanup.log.$(date +\%Y-\%m-\%d) 2>&1 +# tomee logs +11 00 * * * . /etc/profile.d/aai.sh; ${PROJECT_HOME}/scripts/tomeelogcleanup.sh ${PROJECT_HOME}/servers/aai/logs 7 15 >> ${PROJECT_HOME}/logs/misc/tomeelogcleanup.log.$(date +\%Y-\%m-\%d) 2>&1 +######################################################################### +# Archive and/or delete the AAI db related out files +########################################################################## +# db snapshot .out files +17 00 * * * . /etc/profile.d/aai.sh; ${PROJECT_HOME}/scripts/dotOutMiddle_cleanup.sh ${PROJECT_HOME}/logs/data/dataSnapshots 5 30 >> ${PROJECT_HOME}/logs/misc/dotOutMiddle_cleanup.log.$(date +\%Y-\%m-\%d) 2>&1 +# db grooming .out files +19 00 * * * . /etc/profile.d/aai.sh; ${PROJECT_HOME}/scripts/dotOutEnd_cleanup.sh ${PROJECT_HOME}/logs/data/dataGrooming 5 30 >> ${PROJECT_HOME}/logs/misc/dotOutEnd_cleanup.log.$(date +\%Y-\%m-\%d) 2>&1 +######################################################################## +# Run the DataGrooming script +######################################################################## +10 1,7,13,20 * * * . /etc/profile.d/aai.sh; ${PROJECT_HOME}/scripts/dataGrooming.sh -autoFix -dupeFixOn -dontFixOrphans >> ${PROJECT_HOME}/logs/misc/run_dataGrooming.log.$(date +\%Y-\%m-\%d) 2>&1 +######################################################################## +# Take snapshot of our data +######################################################################## +45 * * * * . /etc/profile.d/aai.sh; ${PROJECT_HOME}/scripts/dataSnapshot.sh JUST_TAKE_SNAPSHOT >> ${PROJECT_HOME}/logs/misc/run_dataSnapshot.log.$(date +\%Y-\%m-\%d) 2>&1 diff --git a/ajsc-aai/src/main/scripts/addResourceVersionProperty.sh b/ajsc-aai/src/main/scripts/addResourceVersionProperty.sh new file mode 100644 index 0000000..7c4af8e --- /dev/null +++ b/ajsc-aai/src/main/scripts/addResourceVersionProperty.sh @@ -0,0 +1,55 @@ +#!/bin/ksh + +### +# ============LICENSE_START======================================================= +# org.openecomp.aai +# ================================================================================ +# Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. +# ================================================================================ +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ============LICENSE_END========================================================= +### + +# +# The script invokes the AddResourceVersionProp java class as a one-time (per database instance) migration tool +# which adds the new property "resource-version" to every node in the db. +# + +echo +echo `date` " Starting $0" + +. /etc/profile.d/aai.sh + + +for JAR in `ls $PROJECT_HOME/extJars/*.jar` +do + CLASSPATH=$CLASSPATH:$JAR +done + +for JAR in `ls $PROJECT_HOME/lib/*.jar` +do + CLASSPATH=$CLASSPATH:$JAR +done + +userid=$( id | cut -f2 -d"(" | cut -f1 -d")" ) +if [ "${userid}" != "aaiadmin" ]; then + echo "You must be aaiadmin to run $0. The id used $userid." + exit 1 +fi + + +$JAVA_HOME/bin/java -classpath $CLASSPATH -Dhttps.protocols=TLSv1.1,TLSv1.2 -DAJSC_HOME=$PROJECT_HOME -Daai.home=$PROJECT_HOME \ + org.openecomp.aai.dbgen.AddResourceVersionProp + +echo `date` " Done $0" +exit 0 diff --git a/ajsc-aai/src/main/scripts/audit_schema.sh b/ajsc-aai/src/main/scripts/audit_schema.sh new file mode 100644 index 0000000..52b0545 --- /dev/null +++ b/ajsc-aai/src/main/scripts/audit_schema.sh @@ -0,0 +1,46 @@ +#!/bin/sh +# +# ============LICENSE_START======================================================= +# org.openecomp.aai +# ================================================================================ +# Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. +# ================================================================================ +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ============LICENSE_END========================================================= +# +userid=$( id | cut -f2 -d"(" | cut -f1 -d")" ) +if [ "${userid}" != "aaiadmin" ]; then + echo "You must be aaiadmin to run $0. The id used $userid." + exit 1 +fi + +if [ -f "/etc/profile.d/aai.sh" ]; then + source /etc/profile.d/aai.sh +else + echo "File not found: /etc/profile.d/aai.sh"; + exit +fi + +JAVA=$JAVA_HOME/bin/java + +for JAR in `ls $PROJECT_HOME/extJars/*.jar` +do + CLASSPATH=$CLASSPATH:$JAR +done + +for JAR in `ls $PROJECT_HOME/lib/*.jar` +do + CLASSPATH=$CLASSPATH:$JAR +done + +$JAVA -Dhttps.protocols=TLSv1.1,TLSv1.2 -DAJSC_HOME=$PROJECT_HOME -Daai.home=$PROJECT_HOME -cp $CLASSPATH org.openecomp.aai.db.schema.ScriptDriver $@ diff --git a/ajsc-aai/src/main/scripts/changePropertyCardinality.sh b/ajsc-aai/src/main/scripts/changePropertyCardinality.sh new file mode 100644 index 0000000..04fdfee --- /dev/null +++ b/ajsc-aai/src/main/scripts/changePropertyCardinality.sh @@ -0,0 +1,85 @@ +#!/bin/ksh +# +# ============LICENSE_START======================================================= +# org.openecomp.aai +# ================================================================================ +# Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. +# ================================================================================ +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ============LICENSE_END========================================================= +# +# +# This script is used to change the cardinality of an existing database property. +# It currently just allows you to change TO a SET cardinality with dataType = String. +# It does not currently let you preserve the data (since we're just doing this for one +# field which nobody uses yet). +# +# Note also - This script just makes changes to the schema that is currently live. +# If you were to create a new schema in a brandy-new environment, it would look like +# whatever oxm told it to look like. So, part of making a +# change to the db schema should Always first be to make the change in oxm so that +# future environments will have the change. This script is just to change existing +# instances of the schema since schemaGenerator (as of Jan 2016) does not update things - it +# just does the initial creation. +# +# Boy, this is getting to be a big comment section... +# +# To use this script, you need to pass four parameters: +# propertyName -- the name of the property that you need to change Cardinality on. +# targetDataType -- whether it's changing or not, you need to give it: For now -- we only allow "String" +# targetCardinality -- For now -- only accepts "SET". In the future we should support ("SET", "LIST" or "SINGLE") +# preserveDataFlag -- true or false. For now -- only supports "false" +# +# Ie. changePropertyCardinality.sh supplier-release-list String SET false +# + +echo +echo `date` " Starting $0" + + +userid=$( id | cut -f2 -d"(" | cut -f1 -d")" ) +if [ "${userid}" != "aaiadmin" ]; then + echo "You must be aaiadmin to run $0. The id used $userid." + exit 1 +fi + + +if [ "$#" -ne 4 ]; then + echo "Illegal number of parameters" + echo "usage: $0 propertyName targetDataType targetCardinality preserveDataFlag" + exit 1 +fi + +. /etc/profile.d/aai.sh + +for JAR in `ls $PROJECT_HOME/extJars/*.jar` +do + CLASSPATH=$CLASSPATH:$JAR +done + +for JAR in `ls $PROJECT_HOME/lib/*.jar` +do + CLASSPATH=$CLASSPATH:$JAR +done + + +$JAVA_HOME/bin/java -classpath $CLASSPATH -Dhttps.protocols=TLSv1.1,TLSv1.2 -DAJSC_HOME=$PROJECT_HOME -Daai.home=$PROJECT_HOME \ + org.openecomp.aai.dbgen.ChangePropertyCardinality $1 $2 $3 $4 +if [ "$?" -ne "0" ]; then + echo "Problem executing ChangePropertyCardinality " + exit 1 +fi + + +echo `date` " Done $0" +exit 0 diff --git a/ajsc-aai/src/main/scripts/createDBSchema.sh b/ajsc-aai/src/main/scripts/createDBSchema.sh new file mode 100644 index 0000000..4d7e410 --- /dev/null +++ b/ajsc-aai/src/main/scripts/createDBSchema.sh @@ -0,0 +1,58 @@ +#!/bin/ksh +# +# ============LICENSE_START======================================================= +# org.openecomp.aai +# ================================================================================ +# Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. +# ================================================================================ +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ============LICENSE_END========================================================= +# +# The script invokes GenTester java class to create the DB schema +# +# OPTIONS: +# GEN_DB_WITH_NO_SCHEMA - use if you want it to create an instance of +# the graph - but with no schema (this is useful when using the Hbase copyTable to +# copy our database to different environments). +# Ie. createDbSchema.sh GEN_DB_WITH_NO_SCHEMA +# +# CREATE_HBASE_LOG_TBL - use if you want the Hbase logging table +# to be checked for existence and created if not found. +# +# GEN_DB_WITH_NO_DEFAULT_CR - use if you do NOT want the default cloud +# region generated automatically. Note - this is moot if you're +# using GEN_DB_WITH_NO_SCHEMA +# +# + +echo +echo `date` " Starting $0" + +. /etc/profile.d/aai.sh + + +for JAR in `ls $PROJECT_HOME/extJars/*.jar` +do + CLASSPATH=$CLASSPATH:$JAR +done + +for JAR in `ls $PROJECT_HOME/lib/*.jar` +do + CLASSPATH=$CLASSPATH:$JAR +done + +$JAVA_HOME/bin/java -classpath $CLASSPATH -Dhttps.protocols=TLSv1.1,TLSv1.2 -DAJSC_HOME=$PROJECT_HOME -Daai.home=$PROJECT_HOME \ + org.openecomp.aai.dbgen.GenTester $1 + +echo `date` " Done $0" +exit 0 diff --git a/ajsc-aai/src/main/scripts/dataGrooming.sh b/ajsc-aai/src/main/scripts/dataGrooming.sh new file mode 100644 index 0000000..dfa4ea8 --- /dev/null +++ b/ajsc-aai/src/main/scripts/dataGrooming.sh @@ -0,0 +1,131 @@ +#!/bin/ksh +# +# ============LICENSE_START======================================================= +# org.openecomp.aai +# ================================================================================ +# Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. +# ================================================================================ +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ============LICENSE_END========================================================= +# +# The script invokes the dataGrooming java class to run some tests and generate a report and +# potentially do some auto-deleteing. +# +# Here are the allowed Parameters. Note - they are all optional and can be mixed and matched. +# +# -f oldFileName (see note below) +# -autoFix +# -sleepMinutes nn +# -edgesOnly +# -dontFixOrphans +# -maxFix +# -skipHostCheck +# -singleCommits +# -dupeCheckOff +# -dupeFixOn +# -ghost2CheckOff +# -ghost2FixOn +# +# NOTES: +# -f The name of a previous report can optionally be passed in with the "-f" option. +# Just the filename -- ie. "dataGrooming.sh -f dataGrooming.201504272106.out" +# The file will be assumed to be in the directory that it was created in. +# If a filename is passed, then the "deleteCandidate" vertex-id's and bad edges +# listed inside that report file will be deleted on this run if they are encountered as +# bad nodes/edges again. +# +# -autoFix If you don't use the "-f" option, you could choose to use "-autofix" which will +# automatically run the script twice: once to look for problems, then after +# sleeping for a few minutes, it will re-run with the inital-run's output as +# an input file. +# +# -maxFix When using autoFix, you might want to limit how many 'bad' records get fixed. +# This is a safeguard against accidently deleting too many records automatically. +# It has a default value set in AAIConstants: AAI_GROOMING_DEFAULT_MAX_FIX = 15; +# If there are more than maxFix candidates found -- then none will be deleted (ie. +# someone needs to look into it) +# +# -sleepMinutes When using autoFix, this defines how many minutes we sleep before the second run. +# It has a default value set in AAIConstants: AAI_GROOMING_DEFAULT_SLEEP_MINUTES = 7; +# The reason we sleep at all between runs is that our DB is "eventually consistant", so +# we want to give it time to resolve itself if possible. +# +# -edgesOnly Can be used any time you want to limit this tool so it only looks at edges. +# It runs much more quickly when it's just doing edges and sometimes all our +# problems are with bad edges so it can be nice to focus on edges only sometimes. +# +# -dontFixOrphans Since there can sometimes be a lot of orphan nodes, and they don't +# harm processing as much as phantom-nodes or bad-edges, it is useful to be +# able to ignore them when fixing things. +# +# -skipHostCheck By default, the grooming tool will check to see that it is running +# on the host that is the first one in the list found in: +# aaiconfig.properties aai.primary.filetransfer.serverlist +# This is so that when run from the cron, it only runs on one machine. +# This option lets you turn that checking off. +# +# -singleCommits By default, the grooming tool will do all of its processing and then do +# a commit of all the changes at once. This option (maybe could have been named better) +# is letting the user override the default behavior and do a commit for each +# individual 'remove" one by one as they are encountered by the grooming logic. +# NOTE - this only applies when using either the "-f" or "-autoFix" options since +# those are the only two that make changes to the database. +# +# -dupeCheckOff By default, we will check all of our nodes for duplicates. This parameter lets +# us turn this check off if we don't want to do it for some reason. +# +# -dupeFixOn When we're fixing data, by default we will NOT fix duplicates This parameter lets us turn +# that fixing ON when we are comfortable that it can pick the correct duplicate to preserve. +# +# -ghost2CheckOff By default, we will check for the "new" kind of ghost that we saw on +# Production in early February 2016. This parameter lets us turn this check off if we +# don't want to do it for some reason. +# +# -ghost2FixOn When we're fixing data, by default we will NOT try to fix the "new" ghost nodes. +# This parameter lets us turn that fixing ON if we want to try to fix them. +# + +echo +echo `date` " Starting $0" + + +userid=$( id | cut -f2 -d"(" | cut -f1 -d")" ) +if [ "${userid}" != "aaiadmin" ]; then + echo "You must be aaiadmin to run $0. The id used $userid." + exit 1 +fi + + +. /etc/profile.d/aai.sh + +for JAR in `ls $PROJECT_HOME/extJars/*.jar` +do + CLASSPATH=$CLASSPATH:$JAR +done + +for JAR in `ls $PROJECT_HOME/jetty/webapps/*/webapp/WEB-INF/lib/*.jar` +do + CLASSPATH=$CLASSPATH:$JAR +done + +for JAR in `ls $PROJECT_HOME/lib/*.jar` +do + CLASSPATH=$CLASSPATH:$JAR +done + + +$JAVA_HOME/bin/java -classpath $CLASSPATH -Dhttps.protocols=TLSv1.1,TLSv1.2 -DAJSC_HOME=$PROJECT_HOME -Daai.home=$PROJECT_HOME \ + org.openecomp.aai.dbgen.DataGrooming "$@" + +echo `date` " Done $0" +exit 0 diff --git a/ajsc-aai/src/main/scripts/dataRestoreFromSnapshot.sh b/ajsc-aai/src/main/scripts/dataRestoreFromSnapshot.sh new file mode 100644 index 0000000..7b045ef --- /dev/null +++ b/ajsc-aai/src/main/scripts/dataRestoreFromSnapshot.sh @@ -0,0 +1,85 @@ +#!/bin/ksh
+#
+# ============LICENSE_START======================================================= +# org.openecomp.aai +# ================================================================================ +# Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. +# ================================================================================ +# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License. +# ============LICENSE_END=========================================================
+#
+# This script uses the dataSnapshot and SchemaGenerator (via GenTester) java classes to restore
+# data to a database by doing three things:
+# 1) clear out whatever data and schema are currently in the db
+# 2) rebuild the schema (using the SchemaGenerator)
+# 3) reload data from the passed-in datafile (which must found in the dataSnapShots directory and
+# contain an xml view of the db data).
+#
+
+echo
+echo `date` " Starting $0"
+
+
+userid=$( id | cut -f2 -d"(" | cut -f1 -d")" )
+if [ "${userid}" != "aaiadmin" ]; then
+ echo "You must be aaiadmin to run $0. The id used $userid."
+ exit 1
+fi
+
+
+if [ "$#" -ne 1 ]; then
+ echo "Illegal number of parameters"
+ echo "usage: $0 previous_snapshot_filename"
+ exit 1
+fi
+
+. /etc/profile.d/aai.sh
+
+for JAR in `ls $PROJECT_HOME/extJars/*.jar`
+do
+ CLASSPATH=$CLASSPATH:$JAR
+done
+
+for JAR in `ls $PROJECT_HOME/lib/*.jar`
+do
+ CLASSPATH=$CLASSPATH:$JAR
+done
+
+#### Step 1) clear out the database
+$JAVA_HOME/bin/java -classpath $CLASSPATH -Dhttps.protocols=TLSv1.1,TLSv1.2 -DAJSC_HOME=$PROJECT_HOME -Daai.home=$PROJECT_HOME \
+ org.openecomp.aai.dbgen.DataSnapshot CLEAR_ENTIRE_DATABASE $1
+if [ "$?" -ne "0" ]; then
+ echo "Problem clearing out database."
+ exit 1
+fi
+
+#### Step 2) rebuild the db-schema
+$JAVA_HOME/bin/java -classpath $CLASSPATH -Dhttps.protocols=TLSv1.1,TLSv1.2 -DAJSC_HOME=$PROJECT_HOME -Daai.home=$PROJECT_HOME \
+ org.openecomp.aai.dbgen.GenTester GEN_DB_WITH_NO_DEFAULT_CR
+if [ "$?" -ne "0" ]; then
+ echo "Problem rebuilding the schema (SchemaGenerator)."
+ exit 1
+fi
+
+#### Step 3) reload the data from a snapshot file
+$JAVA_HOME/bin/java -classpath $CLASSPATH -Dhttps.protocols=TLSv1.1,TLSv1.2 -DAJSC_HOME=$PROJECT_HOME -Daai.home=$PROJECT_HOME \
+ org.openecomp.aai.dbgen.DataSnapshot RELOAD_DATA $1
+if [ "$?" -ne "0" ]; then
+ echo "Problem reloading data into the database."
+ exit 1
+fi
+
+
+
+echo `date` " Done $0"
+exit 0
diff --git a/ajsc-aai/src/main/scripts/dataSnapshot.sh b/ajsc-aai/src/main/scripts/dataSnapshot.sh new file mode 100644 index 0000000..054e7f5 --- /dev/null +++ b/ajsc-aai/src/main/scripts/dataSnapshot.sh @@ -0,0 +1,59 @@ +#!/bin/ksh +# +# ============LICENSE_START======================================================= +# org.openecomp.aai +# ================================================================================ +# Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. +# ================================================================================ +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ============LICENSE_END========================================================= +# +# This script uses the dataSnapshot and SchemaGenerator (via GenTester) java classes to restore +# data to a database by doing three things: +# 1) clear out whatever data and schema are currently in the db +# 2) rebuild the schema (using the SchemaGenerator) +# 3) reload data from the passed-in datafile (which must found in the dataSnapShots directory and +# contain an xml view of the db data). +# +# +# This script invokes the dataSnapshot java class passing an option to tell it to take +# a snapshot of the database and store it as a single-line XML file. +# + +echo +echo `date` " Starting $0" + + +userid=$( id | cut -f2 -d"(" | cut -f1 -d")" ) +if [ "${userid}" != "aaiadmin" ]; then + echo "You must be aaiadmin to run $0. The id used $userid." + exit 1 +fi + +. /etc/profile.d/aai.sh + +for JAR in `ls $PROJECT_HOME/extJars/*.jar` +do + CLASSPATH=$CLASSPATH:$JAR +done + +for JAR in `ls $PROJECT_HOME/lib/*.jar` +do + CLASSPATH=$CLASSPATH:$JAR +done + +$JAVA_HOME/bin/java -classpath $CLASSPATH -Dhttps.protocols=TLSv1.1,TLSv1.2 -DAJSC_HOME=$PROJECT_HOME -Daai.home=$PROJECT_HOME \ + org.openecomp.aai.dbgen.DataSnapshot JUST_TAKE_SNAPSHOT + +echo `date` " Done $0" +exit 0 diff --git a/ajsc-aai/src/main/scripts/deleteTool.sh b/ajsc-aai/src/main/scripts/deleteTool.sh new file mode 100644 index 0000000..32437e5 --- /dev/null +++ b/ajsc-aai/src/main/scripts/deleteTool.sh @@ -0,0 +1,61 @@ +#!/bin/ksh +# +# ============LICENSE_START======================================================= +# org.openecomp.aai +# ================================================================================ +# Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. +# ================================================================================ +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ============LICENSE_END========================================================= +# +# This script uses the dataSnapshot and SchemaGenerator (via GenTester) java classes to restore +# data to a database by doing three things: +# 1) clear out whatever data and schema are currently in the db +# 2) rebuild the schema (using the SchemaGenerator) +# 3) reload data from the passed-in datafile (which must found in the dataSnapShots directory and +# contain an xml view of the db data). +# + +# The script invokes Deletion java class to delete customer, subs, dvs-switch, service-capability or tenants +# + +echo +echo `date` " Starting $0" + +userid=$( id | cut -f2 -d"(" | cut -f1 -d")" ) +if [ "${userid}" != "aaiadmin" ]; then + echo "You must be aaiadmin to run $0. The id used $userid." + exit 1 +fi + +. /etc/profile.d/aai.sh + +for JAR in `ls $PROJECT_HOME/extJars/*.jar` +do + CLASSPATH=$CLASSPATH:$JAR +done + +for JAR in `ls $PROJECT_HOME/lib/*.jar` +do + CLASSPATH=$CLASSPATH:$JAR +done + +$JAVA_HOME/bin/java -classpath $CLASSPATH -Dhttps.protocols=TLSv1.1,TLSv1.2 -DAJSC_HOME=$PROJECT_HOME -Daai.home=$PROJECT_HOME org.openecomp.aai.util.DeleteResource "$@" +ret_code=$? +if [ $ret_code != 0 ]; then + echo `date` " Done $0" + exit $ret_code +fi + +echo `date` " Done $0" +exit 0 diff --git a/ajsc-aai/src/main/scripts/deobfuscatePW.sh b/ajsc-aai/src/main/scripts/deobfuscatePW.sh new file mode 100644 index 0000000..918c7d7 --- /dev/null +++ b/ajsc-aai/src/main/scripts/deobfuscatePW.sh @@ -0,0 +1,63 @@ +#!/bin/sh +# +# +# ============LICENSE_START======================================================= +# org.openecomp.aai +# ================================================================================ +# Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. +# ================================================================================ +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ============LICENSE_END========================================================= +# +# This script uses the dataSnapshot and SchemaGenerator (via GenTester) java classes to restore +# data to a database by doing three things: +# 1) clear out whatever data and schema are currently in the db +# 2) rebuild the schema (using the SchemaGenerator) +# 3) reload data from the passed-in datafile (which must found in the dataSnapShots directory and +# contain an xml view of the db data). +# + +# The script invokes the utils.JettyObfuscationConversionCommandLineUtil class to +# deobfuscate an obfuscated name from aaiconfig property file +# e.g. +# ./deobfuscatePW.sh odl.auth.password +# will return: +# admin +# + +echo +echo `date` " Starting $0" + +userid=$( id | cut -f2 -d"(" | cut -f1 -d")" ) +if [ "${userid}" != "aaiadmin" ]; then + echo "You must be aaiadmin to run $0. The id used $userid." + exit 1 +fi + +. /etc/profile.d/aai.sh + +for JAR in `ls $PROJECT_HOME/extJars/*.jar` +do + CLASSPATH=$CLASSPATH:$JAR +done + +for JAR in `ls $PROJECT_HOME/lib/*.jar` +do + CLASSPATH=$CLASSPATH:$JAR +done + +$JAVA_HOME/bin/java -classpath $CLASSPATH -Dhttps.protocols=TLSv1.1,TLSv1.2 -DAJSC_HOME=$PROJECT_HOME -Daai.home=$PROJECT_HOME \ + -Dcom.att.eelf.logging.file=default-logback.xml -Dcom.att.eelf.logging.path="$PROJECT_HOME/bundleconfig/etc/appprops/" \ + org.openecomp.aai.util.AAIConfigCommandLinePropGetter $1 + +echo `date` " Done $0" diff --git a/ajsc-aai/src/main/scripts/dotOutEnd_cleanup.sh b/ajsc-aai/src/main/scripts/dotOutEnd_cleanup.sh new file mode 100644 index 0000000..79ca663 --- /dev/null +++ b/ajsc-aai/src/main/scripts/dotOutEnd_cleanup.sh @@ -0,0 +1,81 @@ +#!/bin/ksh +# +# ============LICENSE_START======================================================= +# org.openecomp.aai +# ================================================================================ +# Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. +# ================================================================================ +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ============LICENSE_END========================================================= +# +# This script uses the dataSnapshot and SchemaGenerator (via GenTester) java classes to restore +# data to a database by doing three things: +# 1) clear out whatever data and schema are currently in the db +# 2) rebuild the schema (using the SchemaGenerator) +# 3) reload data from the passed-in datafile (which must found in the dataSnapShots directory and +# contain an xml view of the db data). +# +# +# The script archives/deletes files that end in .out (Ie. dataGrooming.201511111305.out) that sit in our log/data directory structure +# + +userid=$( id | cut -f2 -d"(" | cut -f1 -d")" ) +if [ "${userid}" != "aaiadmin" ]; then + echo "You must be aaiadmin to run $0. The id used $userid." + exit 1 +fi + +. /etc/profile.d/aai.sh +PROGNAME=$(basename $0) +LOGDIR=${PROJECT_HOME}/logs +ZIPDIR=ARCHIVE +AGEZIP=30 +AGEDELETE=60 +ZIPPER=/bin/gzip +DATE=$(date +%Y%m%d) + +# Get the program arguments +if [[ $# -lt 3 ]] +then + echo "${PROGNAME}: Arguments are missing. Found $#" + exit 1 +fi +LOGDIR="${1}" +AGEZIP=$2 +AGEDELETE=$3 +if [[ ! -d $LOGDIR ]] +then + echo "${PROGNAME}: Directory does not exist: ${LOGDIR}" + exit 1 +fi + +# Create the archive folder, if it does not exist. +if [[ ! -d ${LOGDIR}/${ZIPDIR} ]] +then + mkdir ${LOGDIR}/${ZIPDIR} + if [ $? -ne 0 ] + then + echo "${PROGNAME}: Failed to create directory: ${LOGDIR}/${ZIPDIR}" + exit 1 + fi + chmod 777 ${LOGDIR}/${ZIPDIR} +fi + +# Compress files that are older than AGEZIP days +find -L ${LOGDIR} -name *.gz -prune -o -mtime +${AGEZIP} -type f -name "*.out" -exec ${ZIPPER} -f {} \; +find -L ${LOGDIR} -name ${ZIPDIR} -prune -o -type f -name "*.out.gz" -print | while read i; do dirnm=`dirname ${i}`; drn=`basename ${dirnm}`; mkdir -p ${LOGDIR}/${ZIPDIR}/${drn}; echo ${i}; echo ${LOGDIR}/${ZIPDIR}/${drn}; mv ${i} ${LOGDIR}/${ZIPDIR}/${drn}; done + +# Delete archive files that are older than AGEDELETE days +find -L ${LOGDIR}/${ZIPDIR}/* -type f -name "*.gz" -mtime +${AGEDELETE} -exec rm -r {} \; + +exit 0 diff --git a/ajsc-aai/src/main/scripts/dotOutMiddle_cleanup.sh b/ajsc-aai/src/main/scripts/dotOutMiddle_cleanup.sh new file mode 100644 index 0000000..1cc6214 --- /dev/null +++ b/ajsc-aai/src/main/scripts/dotOutMiddle_cleanup.sh @@ -0,0 +1,81 @@ +#!/bin/ksh +# +# ============LICENSE_START======================================================= +# org.openecomp.aai +# ================================================================================ +# Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. +# ================================================================================ +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ============LICENSE_END========================================================= +# +# This script uses the dataSnapshot and SchemaGenerator (via GenTester) java classes to restore +# data to a database by doing three things: +# 1) clear out whatever data and schema are currently in the db +# 2) rebuild the schema (using the SchemaGenerator) +# 3) reload data from the passed-in datafile (which must found in the dataSnapShots directory and +# contain an xml view of the db data). +# +# +# The script archives/deletes files that have ".out." in middle of their name (Ie. "dataSnapshot.out.201511102245") that sit +# in our log/data directory structure +# +userid=$( id | cut -f2 -d"(" | cut -f1 -d")" ) +if [ "${userid}" != "aaiadmin" ]; then + echo "You must be aaiadmin to run $0. The id used $userid." + exit 1 +fi + +. /etc/profile.d/aai.sh +PROGNAME=$(basename $0) +LOGDIR=${PROJECT_HOME}/logs +ZIPDIR=ARCHIVE +AGEZIP=30 +AGEDELETE=60 +ZIPPER=/bin/gzip +DATE=$(date +%Y%m%d) + +# Get the program arguments +if [[ $# -lt 3 ]] +then + echo "${PROGNAME}: Arguments are missing. Found $#" + exit 1 +fi +LOGDIR="${1}" +AGEZIP=$2 +AGEDELETE=$3 +if [[ ! -d $LOGDIR ]] +then + echo "${PROGNAME}: Directory does not exist: ${LOGDIR}" + exit 1 +fi + +# Create the archive folder, if it does not exist. +if [[ ! -d ${LOGDIR}/${ZIPDIR} ]] +then + mkdir ${LOGDIR}/${ZIPDIR} + if [ $? -ne 0 ] + then + echo "${PROGNAME}: Failed to create directory: ${LOGDIR}/${ZIPDIR}" + exit 1 + fi + chmod 777 ${LOGDIR}/${ZIPDIR} +fi + +# Compress files that are older than AGEZIP days +find -L ${LOGDIR} -name *.gz -prune -o -mtime +${AGEZIP} -type f -name "*.out.*" -exec ${ZIPPER} -f {} \; +find -L ${LOGDIR} -name ${ZIPDIR} -prune -o -type f -name "*.out.*.gz" -print | while read i; do dirnm=`dirname ${i}`; drn=`basename ${dirnm}`; mkdir -p ${LOGDIR}/${ZIPDIR}/${drn}; echo ${i}; echo ${LOGDIR}/${ZIPDIR}/${drn}; mv ${i} ${LOGDIR}/${ZIPDIR}/${drn}; done + +# Delete archive files that are older than AGEDELETE days +find -L ${LOGDIR}/${ZIPDIR}/* -type f -name "*.gz" -mtime +${AGEDELETE} -exec rm -r {} \; + +exit 0 diff --git a/ajsc-aai/src/main/scripts/edgeTagger.sh b/ajsc-aai/src/main/scripts/edgeTagger.sh new file mode 100644 index 0000000..5a120a2 --- /dev/null +++ b/ajsc-aai/src/main/scripts/edgeTagger.sh @@ -0,0 +1,96 @@ +#!/bin/ksh + +### +# ============LICENSE_START======================================================= +# org.openecomp.aai +# ================================================================================ +# Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. +# ================================================================================ +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ============LICENSE_END========================================================= +### + +# +# This script is used to synch-up the data in the database with the "edge-tags" definitions found in the DbEdgeRules.java file. +# It is not needed during normal operation, but if a new tag (really a property) is defined for an edge or if an +# existing tag is changed, then this script should be run to migrate existing data so that it matches the new +# definition. Note: it is only dealing with the "tags" defined after position 2. For example, for our existing +# rules, we have have "isParent" defined in position 2, and then other tags in positions 3, 4 and 5 as +# mapped in DbEdgeRules.EdgeInfoMap: +# +# public static final Map<Integer, String> EdgeInfoMap; +# static { +# EdgeInfoMap = new HashMap<Integer, String>(); +# EdgeInfoMap.put(0, "edgeLabel"); +# EdgeInfoMap.put(1, "direction"); +# EdgeInfoMap.put(2, "isParent" ); +# EdgeInfoMap.put(3, "usesResource" ); +# EdgeInfoMap.put(4, "hasDelTarget" ); +# EdgeInfoMap.put(5, "SVC-INFRA" ); +# } +# +# -- The map above is used to interpret the data in the DbEdgeRules.EdgeRules map: +# +# public static final Multimap<String, String> EdgeRules = +# new ImmutableSetMultimap.Builder<String, String>() +# .putAll("availability-zone|complex","groupsResourcesIn,OUT,false,false,false,reverse") +# .putAll("availability-zone|service-capability","supportsServiceCapability,OUT,false,false,false,false") +# .putAll("complex|ctag-pool","hasCtagPool,OUT,true,false,false,false") +# .putAll("complex|l3-network","usesL3Network,OUT,false,false,false,true") +# etc... +# +# -- Valid values for the "tags" can be "true", "false" or "reverse". Read the T-space +# write-up for a detailed explanation of this... +# +# +# To use this script, You can either pass the parameter, "all" to update all the edge rules, or +# you can pass the KEY to a single edge rule that you would like to update. NOTE - the +# key is that first part of each edge rule that looks like, "nodeTypeA|nodeTypeB". +# +# Ie. ./edgeTagger.sh "all" +# or ./edgeTagger.sh "complex|ctag-pool" +# + +echo +echo `date` " Starting $0" + + +userid=$( id | cut -f2 -d"(" | cut -f1 -d")" ) +if [ "${userid}" != "aaiadmin" ]; then + echo "You must be aaiadmin to run $0. The id used $userid." + exit 1 +fi + +. /etc/profile.d/aai.sh + +for JAR in `ls $PROJECT_HOME/extJars/*.jar` +do + CLASSPATH=$CLASSPATH:$JAR +done + +for JAR in `ls $PROJECT_HOME/lib/*.jar` +do + CLASSPATH=$CLASSPATH:$JAR +done + +$JAVA_HOME/bin/java -classpath $CLASSPATH -Dhttps.protocols=TLSv1.1,TLSv1.2 -DAJSC_HOME=$PROJECT_HOME -Daai.home=$PROJECT_HOME \ + -Dcom.att.eelf.logging.file=default-logback.xml -Dcom.att.eelf.logging.path="$PROJECT_HOME/bundleconfig/etc/appprops/" \ + org.openecomp.aai.dbgen.UpdateEdgeTags $1 +if [ "$?" -ne "0" ]; then + echo "Problem executing UpdateEdgeTags " + exit 1 +fi + + +echo `date` " Done $0" +exit 0 diff --git a/ajsc-aai/src/main/scripts/fix_yang_classes.pl b/ajsc-aai/src/main/scripts/fix_yang_classes.pl new file mode 100644 index 0000000..4e579c9 --- /dev/null +++ b/ajsc-aai/src/main/scripts/fix_yang_classes.pl @@ -0,0 +1,64 @@ +#!/usr/bin/perl + +use strict; + +use Getopt::Std; + +my %opts = (); + +getopts("n:", \%opts); + +my $namespace = ''; +if (!$opts{'n'}) { + $namespace = "http://org.openecomp.aai.inventory"; +} else { + $namespace = $opts{'n'}; +} + +my $has_xml_root_element = 0; +my $has_a_class = 0; +my @file = (); + +my $added_rel = 0; + +while (<>) { + 1 while chomp; + # we're going to read it again + + my $line = $_; + $line =~ s/(protected boolean (inMaint|isClosedLoopDisabled|isBoundToVpn|dhcpEnabled))(\;)/$1 \= false\;/i; + + push @file, $line; + + #if ($_ =~ /^import/ && $added_rel == 0) { + # push @file, "import org.openecomp.aai.domain.yang.rel.*;"; + # $added_rel = 1; + #} + if ($_ =~ /^\@XmlRootElement/) { + $has_xml_root_element = 1; + } + if ($_ =~ /^public\sclass\s(\S+)\s{/) { + $has_a_class = 1; + } +} + +if ($has_xml_root_element == 0 && $has_a_class == 1) { + my $printed_include = 0; + foreach my $line (@file) { + if ($line =~ /^import/ && $printed_include == 0) { + print "import javax.xml.bind.annotation.XmlRootElement;\n"; + + $printed_include++; + } + if ($line =~ /^public\sclass\s(\S+)\s{/) { + my $className = $1; + my @parts = $line =~ /([A-Z](?:[A-Z0-9]*(?=$|[A-Z0-9][a-z])|[a-z0-9]*))/g; + print "\@XmlRootElement(name = \"" . lc join('-', @parts) . "\", namespace = \"$namespace\")\n"; + } + print "$line\n"; + } +} else { + foreach my $line (@file) { + print "$line\n"; + } +} diff --git a/ajsc-aai/src/main/scripts/forceDeleteTool.sh b/ajsc-aai/src/main/scripts/forceDeleteTool.sh new file mode 100644 index 0000000..8840c05 --- /dev/null +++ b/ajsc-aai/src/main/scripts/forceDeleteTool.sh @@ -0,0 +1,73 @@ +#!/bin/ksh +# +# ============LICENSE_START======================================================= +# org.openecomp.aai +# ================================================================================ +# Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. +# ================================================================================ +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ============LICENSE_END========================================================= +# +# This script uses the dataSnapshot and SchemaGenerator (via GenTester) java classes to restore +# data to a database by doing three things: +# 1) clear out whatever data and schema are currently in the db +# 2) rebuild the schema (using the SchemaGenerator) +# 3) reload data from the passed-in datafile (which must found in the dataSnapShots directory and +# contain an xml view of the db data). +# +# +# Usage: forceDeleteTool.sh action dataString +# +# The script invokes the ForceDelete java class to either collect data about +# nodes that may need to be deleted (when passed the COLLECT_DATA action parameter), +# or to do a delete given a particular vertexId when passed the "DELETE_NODE action parameter. +# +# Ie. +# forceDeleteTool COLLECT_DATA "hypervisor-type|esx,operational-state|operationalState" +# or +# forceDeleteTool DELETE_NODE 98789378 +# +# Note: when collecting data, the dataString looks like: "propertyName1|propertyVal1,propertyName2|propertyVal2" +# for however many property names, values you are using to identify this one node. +# When doing the delete - the dataString has to just be the vertexId of the node you want to delete +# + +echo +echo `date` " Starting $0" + +echo " NOTE - if you are deleting data, please run the dataSnapshot.sh script first or " +echo " at least make a note the details of the node that you are deleting. " + +userid=$( id | cut -f2 -d"(" | cut -f1 -d")" ) +if [ "${userid}" != "aaiadmin" ]; then + echo "You must be aaiadmin to run $0. The id used $userid." + exit 1 +fi + +. /etc/profile.d/aai.sh + +for JAR in `ls $PROJECT_HOME/extJars/*.jar` +do + CLASSPATH=$CLASSPATH:$JAR +done + +for JAR in `ls $PROJECT_HOME/lib/*.jar` +do + CLASSPATH=$CLASSPATH:$JAR +done + +$JAVA_HOME/bin/java -classpath $CLASSPATH -Dhttps.protocols=TLSv1.1,TLSv1.2 -DAJSC_HOME=$PROJECT_HOME -Daai.home=$PROJECT_HOME \ + org.openecomp.aai.dbgen.ForceDeleteTool $1 "$2" + +echo `date` " Done $0" +exit 0 diff --git a/ajsc-aai/src/main/scripts/generate.sh b/ajsc-aai/src/main/scripts/generate.sh new file mode 100644 index 0000000..9ed1c4b --- /dev/null +++ b/ajsc-aai/src/main/scripts/generate.sh @@ -0,0 +1,91 @@ +#!/bin/bash + +### +# ============LICENSE_START======================================================= +# org.openecomp.aai +# ================================================================================ +# Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. +# ================================================================================ +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ============LICENSE_END========================================================= +### + +REV=$1 +SKIP=$2 +LATEST_REV="v8" + +export AAIHOME=/media/Users/userid/Documents/MyGit + +export script_home=$AAIHOME/src/main/scripts + +export YANG_HOME=$AAIHOME/src/main/yang + +export REV_HOME=$YANG_HOME/$REV + +echo "REV_HOME: " $REV_HOME + +cd $REV_HOME + +if test "$SKIP" != "POJO" +then + if [ ! -d "$REV_HOME/xsd" ] + then + mkdir xsd + fi + + for i in *.yang + do x=`echo $i | cut -d"." -f 1` + echo $i " " $x; pyang -f xsd $i > xsd/$x.xsd + done + + echo "Calling $script_home/run_FixXSD.sh $REV $AAIHOME" +# $script_home/run_FixXSD.sh $REV $AAIHOME + + cd $REV_HOME/xsd + + $script_home/make_refs_in_xsd.pl fixedup.xsd > aai${REV}-corrected.xsd + + NAMESPACE="http://org.openecomp.aai.inventory/$REV" + echo "Calling xjc"; + if test "$REV" = "$LATEST_REV" + then + xjc -p org.openecomp.aai.domain.yang -b ../bindings.xml aai${REV}-corrected.xsd + cd org/openecomp/aai/domain/yang + else + xjc -p org.openecomp.aai.domain.yang.${REV} -b ../bindings.xml aai${REV}-corrected.xsd + cd org/openecomp/aai/domain/yang/${REV} + fi + + echo "$script_home/fix_yang_classes.pl -n $NAMESPACE $i > $i.new" + + for i in *.java + do $script_home/fix_yang_classes.pl -n $NAMESPACE $i > $i.new + mv $i $i.bak + mv $i.new $i + done + + echo + if test "$REV" = "$LATEST_REV" + then + rm -f $AAIHOME/src/main/java/org/openecomp/aai/domain/yang/*.java + cp *.java $AAIHOME/src/main/java/org/openecomp/aai/domain/yang + else + rm -f $AAIHOME/src/main/java/org/openecomp/aai/domain/yang/$REV/*.java + cp *.java $AAIHOME/src/main/java/org/openecomp/aai/domain/yang/$REV + fi +fi + +if test "$SKIP" != "GEN" +then + $script_home/run_Generator.sh $REV $AAIHOME +fi diff --git a/ajsc-aai/src/main/scripts/getTool.sh b/ajsc-aai/src/main/scripts/getTool.sh new file mode 100644 index 0000000..7d30344 --- /dev/null +++ b/ajsc-aai/src/main/scripts/getTool.sh @@ -0,0 +1,61 @@ +#!/bin/ksh +# +# ============LICENSE_START======================================================= +# org.openecomp.aai +# ================================================================================ +# Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. +# ================================================================================ +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ============LICENSE_END========================================================= +# +# This script uses the dataSnapshot and SchemaGenerator (via GenTester) java classes to restore +# data to a database by doing three things: +# 1) clear out whatever data and schema are currently in the db +# 2) rebuild the schema (using the SchemaGenerator) +# 3) reload data from the passed-in datafile (which must found in the dataSnapShots directory and +# contain an xml view of the db data). +# +# +# The script invokes GetResource java class to get all nodes +# + +echo +echo `date` " Starting $0" + +userid=$( id | cut -f2 -d"(" | cut -f1 -d")" ) +if [ "${userid}" != "aaiadmin" ]; then + echo "You must be aaiadmin to run $0. The id used $userid." + exit 1 +fi + +. /etc/profile.d/aai.sh + +for JAR in `ls $PROJECT_HOME/extJars/*.jar` +do + CLASSPATH=$CLASSPATH:$JAR +done + +for JAR in `ls $PROJECT_HOME/lib/*.jar` +do + CLASSPATH=$CLASSPATH:$JAR +done + +$JAVA_HOME/bin/java -classpath $CLASSPATH -Dhttps.protocols=TLSv1.1,TLSv1.2 -DAJSC_HOME=$PROJECT_HOME -Daai.home=$PROJECT_HOME org.openecomp.aai.util.GetResource "$@" +ret_code=$? +if [ $ret_code != 0 ]; then + echo `date` " Done $0" + exit $ret_code +fi + +echo `date` " Done $0" +exit 0 diff --git a/ajsc-aai/src/main/scripts/install/addManualData.sh b/ajsc-aai/src/main/scripts/install/addManualData.sh new file mode 100644 index 0000000..ec5de93 --- /dev/null +++ b/ajsc-aai/src/main/scripts/install/addManualData.sh @@ -0,0 +1,111 @@ +#!/bin/ksh +# +# ============LICENSE_START======================================================= +# org.openecomp.aai +# ================================================================================ +# Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. +# ================================================================================ +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ============LICENSE_END========================================================= +# +# this script now requires a release parameter. +# the tool finds and sorts *.txt files within the +# bundleconfig/etc/scriptdate/addmanualdata/$release directory containing +# one resource to be added to the graph. The directory contains a second +# file with the same name, but the extension is .json. This json file +# is passed to the PutTool as the payload. The parameters passed to the +# PutTool will have 412 failures ignored. After calling the PutTool, the +# GetTool is called to include the object put into the graph. +# this script is run at every installation, logging the manual data applied. + +# Returns 0 if the specified string contains the specified substring, +# otherwise returns 1. +contains() { + string="$1" + substring="$2" + if test "${string#*$substring}" != "$string" + then + return 0 # $substring is in $string + else + return 1 # $substring is not in $string + fi +} + +PROGNAME=$(basename $0) +OUTFILE=$PROJECT_HOME/logs/misc/${PROGNAME}.log.$(date +\%Y-\%m-\%d) +#OUTFILE=/c/temp/${PROGNAME}.log.$(date +\%Y-\%m-\%d) + +TS=$(date "+%Y-%m-%d %H:%M:%S") + +CHECK_USER="aaiadmin" +userid=$( id | cut -f2 -d"(" | cut -f1 -d")" ) +if [ "${userid}" != $CHECK_USER ]; then + echo "You must be $CHECK_USER to run $0. The id used $userid." + exit 1 +fi + +if [ "$#" -ne 1 ]; then + echo "Release parameter is required, e.g. 1610, 1702, etc" + echo "usage: $0 release" + exit 1 +fi + +error_exit () { + echo "${PROGNAME}: failed for ${1:-"Unknown error"} on cmd $2 in $3" 1>&2 + echo "${PROGNAME}: failed for ${1:-"Unknown error"} on cmd $2 in $3" >> $OUTFILE +# exit ${2:-"1"} +} + +rel="/"$1"/" +k=0 + +ls $PROJECT_HOME/bundleconfig/etc/scriptdata/addmanualdata/*/*.txt >/dev/null 2>&1 +if [ $? -ne 0 ] +then +echo "No manual data to add for release $1"; +exit 0; +fi + +for filepath in `ls $PROJECT_HOME/bundleconfig/etc/scriptdata/addmanualdata/*/*.txt|sort -f` +do +contains $filepath $rel +if [ $? -eq 0 ] +then +jsonfile=${filepath%???}json +j=0 +while IFS=\n read -r i +do +echo "##### Begin putTool for $i ##### from file $filepath" | tee -a $OUTFILE +resource=`echo $i | tr -d '\r'` +$PROJECT_HOME/scripts/putTool.sh $resource $jsonfile 1 0 na 1 >> $OUTFILE 2>&1 || error_exit "$resource" $j $filepath +echo "##### End putTool for $resource #####" | tee -a $OUTFILE +echo "Begin getTool for $resource" | tee -a $OUTFILE +$PROJECT_HOME/scripts/getTool.sh $resource >> $OUTFILE 2>&1 || error_exit "$i" $j $filepath +echo "End getTool for $resource" | tee -a $OUTFILE + +j=$(expr "$j" + 1) +k=$(expr "$k" + 1) +done < $filepath + +fi + +done +if [ $k -eq 0 ] +then +echo "No manual data to add for release $1"; +exit 0; +fi + +echo "See output and error file: $OUTFILE" + +exit 0 diff --git a/ajsc-aai/src/main/scripts/install/doSchemaMods.sh b/ajsc-aai/src/main/scripts/install/doSchemaMods.sh new file mode 100644 index 0000000..db9b995 --- /dev/null +++ b/ajsc-aai/src/main/scripts/install/doSchemaMods.sh @@ -0,0 +1,102 @@ +#!/bin/ksh +# +# ============LICENSE_START======================================================= +# org.openecomp.aai +# ================================================================================ +# Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. +# ================================================================================ +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ============LICENSE_END========================================================= +# +# this script now requires a release parameter. +# the tool finds and sorts *.txt files within the +# bundleconfig/etc/scriptdate/schemamods/$release directory containing +# one or more sets of schemaMod.sh parameters +# this script is run at every installation, logging the schemaMods applied. + +# Returns 0 if the specified string contains the specified substring, +# otherwise returns 1. +contains() { + string="$1" + substring="$2" + if test "${string#*$substring}" != "$string" + then + return 0 # $substring is in $string + else + return 1 # $substring is not in $string + fi +} + +PROGNAME=$(basename $0) +OUTFILE=$PROJECT_HOME/logs/misc/${PROGNAME}.log.$(date +\%Y-\%m-\%d) +#OUTFILE=/c/temp/${PROGNAME}.log.$(date +\%Y-\%m-\%d) + +TS=$(date "+%Y-%m-%d %H:%M:%S") + +CHECK_USER="aaiadmin" +userid=$( id | cut -f2 -d"(" | cut -f1 -d")" ) +if [ "${userid}" != $CHECK_USER ]; then + echo "You must be $CHECK_USER to run $0. The id used $userid." + exit 1 +fi + +if [ "$#" -ne 1 ]; then + echo "Release parameter is required, e.g. 1610, 1702, etc" + echo "usage: $0 release" + exit 1 +fi + +error_exit () { + echo "${PROGNAME}: failed for ${1:-"Unknown error"} on cmd $2 in $3" 1>&2 + echo "${PROGNAME}: failed for ${1:-"Unknown error"} on cmd $2 in $3" >> $OUTFILE +# exit ${2:-"1"} +} + +rel="/"$1"/" +k=0 + +ls $PROJECT_HOME/bundleconfig/etc/scriptdata/schemamods/*/*.txt >/dev/null 2>&1 +if [ $? -ne 0 ] +then +echo "No schemaMod to run for release $1"; +exit 0; +fi + + +for filepath in `ls $PROJECT_HOME/bundleconfig/etc/scriptdata/schemamods/*/*.txt|sort -f` +do +contains $filepath $rel +if [ $? -eq 0 ] +then +j=0 +while IFS=\n read -r i +do +echo "##### Begin Schema Mods for $i #####" | tee -a $OUTFILE +$PROJECT_HOME/scripts/schemaMod.sh $i >> $OUTFILE 2>&1 || error_exit "$i" $j $filepath +echo "##### End Schema Mods for $i #####" | tee -a $OUTFILE +j=$(expr "$j" + 1) +k=$(expr "$k" + 1) +done < $filepath + +fi +#echo "End schemamod for $filepath" | tee -a $OUTFILE +done +if [ $k -eq 0 ] +then +echo "No schemaMod to run for release $1"; +exit 0; +fi + +echo "See output and error file: $OUTFILE" + +exit 0 diff --git a/ajsc-aai/src/main/scripts/install/instutils.sh b/ajsc-aai/src/main/scripts/install/instutils.sh new file mode 100644 index 0000000..497ba09 --- /dev/null +++ b/ajsc-aai/src/main/scripts/install/instutils.sh @@ -0,0 +1,722 @@ +#!/bin/ksh +# +# ============LICENSE_START======================================================= +# org.openecomp.aai +# ================================================================================ +# Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. +# ================================================================================ +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ============LICENSE_END========================================================= +# +ECHO=${ECHO:-echo} + +q_flags="-qq -k$$" + +show_install=${PROJECT_HOME}/install/show_install + +############################################################################ +# checkgroup groupname gid +# checks if group is already in /etc/group and if it has the right gid +# if it's not there, it adds it +# gid can be DC if you don't care +############################################################################ +checkgroup () { + ecode=0 + OFILE=/tmp/group.$$ + getent group "$1" > $OFILE + if [ $? -eq 0 ] + then + CHECKGID=$( grep "^$1:" $OFILE | cut -f3 -d: 2>/dev/null ) + CHECKGROUPPRESENT=$( grep "^$1:" $OFILE | cut -f1 -d: 2>/dev/null ) + CHECKGROUP=$( grep ":$2:" $OFILE | cut -f1 -d: 2>/dev/null ) + fi + if [ "${CHECKGID}" = "" -a "${CHECKGROUP}" = "" ] + then + ${ECHO} "Adding $1 group ..." + if [ "$2" = "DC" ] + then + groupadd $1 + else + groupadd -g $2 $1 + fi + if [ "$?" != "0" ] + then + ${ECHO} "Cannot add group $1, continuing..." + ecode=1 + fi + else + if [ "${CHECKGROUPPRESENT}" = "$1" ] + then + if [ "$2" != "DC" ] + then + if [ "${CHECKGID}" != "$2" ] + then + ${ECHO} "ERROR: $1 group added but with wrong gid \"${CHECKGID}\"; should be $2" + ecode=1 + fi + if [ "${CHECKGROUP}" != "$1" ] + then + ${ECHO} "ERROR: wrong group \"${CHECKGROUP}\" for gid $2, group should be $1" + ecode=1 + fi + else + ${ECHO} "$1 group has already been added" + fi + fi + fi + rm -f $OFILE + return ${ecode} +} + +############################################################################ +# checkuser username uid homedir shell group +# checks if the username/uid/homedir/shell combo is already in /etc/passwd +# if not, it adds it +# if the login is there and the uid belongs to a different user, it errors +# if the login is there and the shell is not correct, it errors +# uid may be DC for don't care +############################################################################ +checkuser () { + ecode=0 + OFILE=/tmp/user.$$ + getent passwd $1 > $OFILE + if [ $? -eq 0 ] + then + CHECKUID=$( grep "^$1:" $OFILE | cut -f3 -d: 2>/dev/null ) + CHECKLOGIN=$( grep ":x:$2:" $OFILE | cut -f1 -d: 2>/dev/null ) + CHECKLOGINPRESENT=$( grep "^$1:" $OFILE | cut -f1 -d: 2>/dev/null ) + CHECKSHELL=$( grep "^$1:" $OFILE | cut -f7 -d: 2>/dev/null ) + CHECKHOME=$( grep "^$1:" $OFILE | cut -f6 -d: 2>/dev/null ) + fi + + if [ ! -d $3 ] + then + mkdir -p $3 + if [ "$?" != "0" ] + then + ${ECHO} "mkdir -p $3 failed" + ecode=1 + fi + chmod -R 755 $3 + fi + if [ "${CHECKUID}" = "" -a "${CHECKLOGIN}" = "" ] + then + ${ECHO} "Adding $1 login ..." + if [ "$2" = "DC" ] + then + useradd -g $5 -d $3 -s $4 -c "$1 LOGIN" -m $1 + else + useradd -u $2 -g $5 -d $3 -s $4 -c "$1 LOGIN" -m $1 + fi + if [ "$?" != "0" ] + then + ${ECHO} "Cannot add $1 login, continuing..." + ecode=1 + fi + elif [ "${CHECKLOGINPRESENT}" = "$1" -a "$2" = "DC" -a "${CHECKSHELL}" = "$4" -a "${CHECKHOME}" = "$3" ] + then + ${ECHO} "The '$1' login has already been added to system with UID ${CHECKUID}." + + elif [ "${CHECKUID}" = "$2" -a "${CHECKLOGIN}" = "$1" -a "${CHECKSHELL}" = "$4" -a "${CHECKHOME}" = "$3" ] + then + ${ECHO} "The '$1' login has already been added to system." + else + if [ "$2" != "DC" -a "${CHECKUID}" != "$2" ] + then + ${ECHO} "ERROR: $1 login added but with wrong uid \"${CHECKUID}\"; should be $2" + ecode=1 + fi + if [ "$2" != "DC" -a "${CHECKLOGIN}" != "$1" ] + then + ${ECHO} "ERROR: wrong login \"${CHECKLOGIN}\" for uid $2, login should be $1" + ecode=1 + fi + if [ "${CHECKHOME}" != "$3" ] + then + ${ECHO} "ERROR: wrong home directory \"${CHECKHOME}\" for login $1, should be $3" + ecode=1 + fi + if [ "${CHECKSHELL}" != "$4" ] + then + ${ECHO} "ERROR: $1 login not set up with $4" + ecode=1 + fi + fi + rm -f $OFILE + return ${ecode} +} + +############################################################################ +# checkhome username homedir action +# if the user doesn't exist, it errors +# checks if the username has homedir as its home directory +# if not and action is null, it modifies it +# if not and action is mod, it modifies it +# if not and action is error, it errors +############################################################################ +checkhome () { + ecode=0 + OFILE=/tmp/user.$$ + getent passwd $1 > $OFILE + if [ $? -eq 0 ] + then + CHECKUID=$( grep "^$1:" $OFILE | cut -f3 -d: 2>/dev/null ) + CHECKGID=$( grep "^$1:" $OFILE | cut -f4 -d: 2>/dev/null ) + CHECKHOME=$( grep "^$1:" $OFILE | cut -f6 -d: 2>/dev/null ) + + if [ "${CHECKHOME}" = "$2" ] + then + if [ ! -d $2 ] + then + mkdir -p $2 + if [ "$?" != "0" ] + then + ${ECHO} "mkdir -p $2 failed" + ecode=1 + fi + chown ${CHECKUID}:${CHECKGID} $2 + chmod -R 755 $2 + fi + else + # modify the user to set the new home dir and move any current home dir to there + usermod -d $2 -m $1 + if [ "$?" != "0" ] + then + ${ECHO} "usermod -d $2 -m $1 failed" + ecode=1 + fi + fi + else + ${ECHO} "user $1 doesn't exist" + ecode=1 + fi + + rm -f $OFILE + return ${ecode} +} + +################################################################## +#checkloginsforpwds checks /etc/shadow for logins without passwords +# the first argument is a list of logins to check +################################################################## +checkloginsforpwds () { + for i in $1 + do + CHECK_LOGIN=$( grep "^${i}:" /etc/shadow | grep "!!" ) + if [ "${CHECK_LOGIN}" != "" ] + then + NOPWD="${NOPWD} ${i}" + fi + done + + if [ "${NOPWD}" != "" ] + then + ${ECHO} "" + ${ECHO} "REMINDER: The following logins must have a passwords assigned to them.\n" + ${ECHO} "##############################################################" + ${ECHO} " ${NOPWD} " + ${ECHO} "##############################################################" + ${ECHO} "" + ${ECHO} " This must be done by executing the following command:" + ${ECHO} "" + ${ECHO} " $ passwd <login>" + ${ECHO} "" + ${ECHO} " After typing the \"passwd\" command you will be prompted for" + ${ECHO} " the password for the login." + ${ECHO} "" + fi +} + +################################################################## +# checkassignpasswords checks /etc/shadow for logins without passwords +# and then asks the user to assign one +# the first argument is a list of logins to check +################################################################## +checkassignpasswords () { + for i in $1 + do + CHECK_LOGIN=$( grep "^${i}:" /etc/shadow | grep LK ) + if [ "${CHECK_LOGIN}" != "" ] + then + ${ECHO} "Please assign a password for the '${i}' login" + passwd ${i} + ${ECHO} + fi + done +} + +############################################################################ +# copywithperms origfile destfile owner group perms [save suffix] +# copies origfile to destfile, giving destfile ownership and permssions +# from owner, group, and perms. If the sixth argument is "save", the +# original is saved in the same place with the seventh argument as the +# suffix. If the seventh arg is null, $$ is used +############################################################################ +copywithperms () { + SAVE=0 + ECODE=0 + if [ "$6" = "save" -a -f "$2" ] + then + if [ "$7" = "" ] + then + cp $2 $2.$$ + else + cp $2 $2.$7 + fi + fi + if [ -f $1 ] + then + cp $1 $2 + ECODE=$? + chown ${3}:${4} $2 + chmod $5 $2 + else + ${ECHO} "$1 is not a file. No copy done!" + fi + return ${ECODE} +} + +############################################################################ +# mkdirwithperms dirname owner group perms ifExist +# makes directory dirname , giving dirname ownership and permssions +# from owner, group, and perms. +# perms can be DC if you don't care +# ifExist can be rm, error, dontcreate +############################################################################ +mkdirwithperms () { + ECODE=0 + if [ -f $1 ] + then + ECODE=1 + ${ECHO} "$1 exists but is a file. No mkdir done!" + elif [ -d $1 ] + then + if [ "$5" = "rm" ] + then + rm -rf $1 + mkdir -p $1 + if [ "$?" != "0" ] + then + ${ECHO} "mkdir -p $1 failed" + ECODE=1 + fi + elif [ "$5" = "error" ] + then + ECODE=1 + ${ECHO} "$1 is a directory. No mkdir done!" + elif [ "$5" != "dontcreate" ] + then + mkdir -p $1 + if [ "$?" != "0" ] + then + ${ECHO} "mkdir -p $1 failed" + ECODE=1 + fi + fi + else + mkdir -p $1 + if [ "$?" != "0" ] + then + ${ECHO} "mkdir -p $1 failed" + ECODE=1 + fi + fi + if [ "${ECODE}" = "0" ] + then + chown ${2}:${3} $1 + if [ "$4" != "DC" ] + then + chmod $4 $1 + fi + fi + return ${ECODE} +} + + +############################################################################ +# chownwithperms owner group file mode +# changes the ownership and mode for the specified file +############################################################################ +chownwithperms () { + chown ${1}:${2} $3 + chmod $4 $3 +} + +verifywhosrunning () { + userid=$( id | cut -f2 -d"(" | cut -f1 -d")" ) + if [ "${userid}" != "$1" ] + then + ${ECHO} "You must be $1 to run $0" + exit 1 + fi +} + +replaceline() { + + name=$1 + value=$2 + file=$3 + + if [ -z "${file}" ] + then + ${ECHO} "replaceline: ERROR: insufficient arguments: $1 $2" >&2 + return 1 + fi + + if [ -n "$4" ] + then + ${ECHO} "replaceline: ERROR: too many arguments: $1 $2 $3 $4" >&2 + return 1 + fi + + if [ -f ${file} ] + then + grep -v "^${name}=" ${file} > ${file}.$$ + ${ECHO} "${name}=${value}" >> ${file}.$$ + mv -f ${file}.$$ ${file} + else + ${ECHO} "${name}=${value}" > ${file} + fi +} + +replaceline_with_quotes() { + + name=$1 + value=$2 + file=$3 + + if [ -z "${file}" ] + then + ${ECHO} "replaceline: ERROR: insufficient arguments: $1 $2" >&2 + return 1 + fi + + if [ -n "$4" ] + then + ${ECHO} "replaceline: ERROR: too many arguments: $1 $2 $3 $4" >&2 + return 1 + fi + + if [ -f ${file} ] + then + grep -v "^${name}=" ${file} > ${file}.$$ + ${ECHO} "${name}=\"${value}\"" >> ${file}.$$ + mv -f ${file}.$$ ${file} + else + ${ECHO} "${name}=\"${value}\"" > ${file} + fi +} + +# this deleteline will not actually delete the entry +# but only delete the value leaving the name= +# when siteconf.pl went from Boilerplate to Fillin, +# we changed this because Fillin can handle null values. + +deleteline() { + + name=$1 + file=$2 + + if [ -z "${file}" ] + then + ${ECHO} "deleteline: ERROR: insufficient arguments" >&2 + return 1 + fi + + if [ -f ${file} ] + then + cp ${file} ${file}.$$ + lno=$( grep -n "^${name}=" ${file} | cut -d: -f1 ) + if [ "${lno}" != "" ] + then + sed "${lno}d" ${file} > ${file}.$$ + fi + ${ECHO} "${name}=" >> ${file}.$$ + mv -f ${file}.$$ ${file} + else + ${ECHO} "${name}=" > ${file} + fi +} + +# dropline will drop the line from the file +# unlike the deleteline function above + +dropline() { + + name=$1 + file=$2 + + if [ -z "${file}" ] + then + ${ECHO} "dropline: ERROR: insufficient arguments" >&2 + return 1 + fi + + if [ -f ${file} ] + then + grep -v "^${name}=" ${file} > ${file}.$$ + mv -f ${file}.$$ ${file} + fi +} + +pause_install() { + + if [ "${Pause}" = "1" ] + then + if ${chkyn} -y "Continue with ${Itype}?" + then + return 0 + else + ${ECHO} "${PNAME}: quitting" >&2 + exit 1 + fi + fi +} + +get_ITYPE() { + ITYPE=$( ${chkyn} -fer ${q_flags} -h\? ${ITYPE:+-D"${ITYPE}"} -H \ +" If you are doing a fresh install, answer 'I' or answer 'U' for upgrade." \ +"Is this a fresh 'install' or 'upgrade' (I or U):${ITYPE:+ [${ITYPE}]}" \ + '^[IU]$' \ +'*** ERROR *** Entry must be I or U.' ) +} + + +### +# Change an /etc/group entry to allow a give user to change group into it. +# arg1 = comma-sep group list (e.g., sylantro,other) +# arg2 = user +### +addUserToGroup() +{ + if [ -z "$1" -o -z "$2" ] + then + ${ECHO} "addUserToGroup failed, need two args, group and user" + return 1 + else + usermod -G $1 $2 + fi + return 0 +} + +################### BACKUP AND RESTORE METHODS ######################## +################### VARIABLES ########################## +################### VARIABLES ########################## +################### VARIABLES ########################## +################### VARIABLES ########################## + +NO_FILE_INDICATOR="__NO_PREVIOUS_FILE__" +SAVE_SUFFIX=${Project}save + +################### SUBROUTINES ########################## +################### SUBROUTINES ########################## +################### SUBROUTINES ########################## +################### SUBROUTINES ########################## +################### SUBROUTINES ########################## + +############################################################################## +# Purpose: make a backup copy of a file in such a way that the backup +# won't be lost by re-running your script PLUS give you a predictable name +# for the most recent back up to use when you roll back. +# +# Input: +# - Arg1 = file to back up +# +# Requirement: +# - Remove $1.save before calling this function or else a copy won't be made. +# - Make sure to set the value of env value TODAY to use as a suffix. +# +# Description: +# Copy $1 to $1.${SAVE_SUFFIX}.${TODAY}, then link that to $1.save. +# +############################################################################## +make_backup_copy () +{ + if [ -z "${TODAY}" ] + then + ${ECHO} "make_backup_copy - TODAY variable is unset" >&2 + return 1 + fi + + if [ -f $1.${SAVE_SUFFIX}.${TODAY} -a -h $1.save ] + then + ${ECHO} "Note: backup already exists for $1" + else + # if existing file doesn't exist, set up for later delete by rollback + if [ ! -f $1 -a ! -h $1 ] + then + ${ECHO} ${NO_FILE_INDICATOR} > $1 + fi + cp -p $1 $1.${SAVE_SUFFIX}.${TODAY} + ln -s $1.${SAVE_SUFFIX}.${TODAY} $1.save + fi +} + +################################################################################ +# Purpose: Find the actual file that belongs to $1, which can be a symbolic +# link. +# +# Input: +# - Arg1 = path to file or link +# - Arg2 = true if you want _SRCFILE to be null if no actual file is +# found. If Arg2 is NOT true, then _SRCFILE is set to Arg1. +# +# Side Effect: +# Sets value of _SRCFILE variable +################################################################################ +find_source_file () +{ + if [ -z "$1" ] + then + ${ECHO} "find_source_file - needs at least one argument" >&2 + return 1 + fi + + ls -l $1 > /tmp/tls$$ + cat /tmp/tls$$ | sed 's/ */ /g' |cut -f11 > /tmp/cuts$$ + _SRCFILE=$( cat /tmp/cuts$$ ) + + if [ "$_SRCFILE" = "" ] + then + if [ "$2" != "true" ] + then + _SRCFILE=$1 + fi + fi + rm -f /tmp/tls$$ /tmp/cuts$$ +} + +####################################################################### +# Purpose: Expands template file using data in COPT variable. +# Diffs expanded template against existing file and installs if different. +# If arg5 = true, sets _config_changes=1 so you know that changes were installed +# +# Makes its own backup copy using make_backup_copy. +# Does install if different using install_if_different. +# +# Input: +# Arg1 = template path without .tmpl extension +# Arg2 = install path +# Arg3 = owner and group (e.g., root:other) +# Arg4 = permissions (e.g., 750) +# Arg5 = true/false, if expanded file is different than installed . +# Set _config_changes to 1 if Arg5 is true. Otherwise, don't touch +# _config_changes +# +# Requirement: set COPT to the value of the -c option to siteconf.pl +# +# Side Effect: sets _config_changes=1 if changes were installed +####################################################################### +install_from_template () +{ + if [ -z "${COPT}" ] + then + ${ECHO} "install_from_template - COPT is unset" >&2 + return 1 + fi + + TMPL=$( basename ${1} ) + OFILE=/tmp/${TMPL} + if [ -f ${1}.tmpl ] + then + + ${PROJECT_HOME}/bin/siteconf.pl -t ${1}.tmpl -c ${COPT} -o ${OFILE} + install_if_different ${OFILE} ${2} ${3} ${4} ${5} + + else + ${ECHO} "install_from_template: ERROR: Missing ${TMPL}.tmpl" >&2 + fi + rm -f ${OFILE} +} + + +####################################################################### +# Purpose: Copies source to destination if the two are different. +# If arg5 = true, sets _config_changes=1 so you know that changes were installed +# +# Makes its own backup copy using make_backup_copy. +# +# Input: +# Arg1 = source path +# Arg2 = install path +# Arg3 = owner and group (e.g., root:other) +# Arg4 = permissions (e.g., 750) +# Arg5 = true/false, if expanded file is different than installed . +# Set _config_changes to 1 if Arg5 is true. Otherwise, don't touch +# _config_changes +# +# Side Effect: sets _config_changes=1 if changes were installed +####################################################################### +install_if_different() +{ + # Take backup before changing. + # Only change if different. + if [ -f ${2} ] + then + diff ${1} ${2} > /dev/null + diffrc=$? + if [ "${diffrc}" != "0" ] + then + ${ECHO} "Installing ${2}" + make_backup_copy ${2} + mv -f ${1} ${2} + chown ${3} ${2} + chmod ${4} ${2} + if [ "${5}" = "true" ] + then + _config_changes=1 + fi + fi + else + # creates backup containing ${NO_FILE_INDICATOR} for rollback removal + make_backup_copy ${2} + mv -f ${1} ${2} + chown ${3} ${2} + chmod ${4} ${2} + if [ "${5}" = "true" ] + then + _config_changes=1 + fi + fi +} +################################################################### +# Purpose: rollback a file whose backup was made with make_backup_copy +# +# Input: +# Arg1 is path of installed file. Subroutine will look for ${1}.save +# Arg2 = true/false, if expanded file is different than installed, +# set _config_changes to 1 if Arg2 is true. Otherwise, don't touch +# _config_changes +# +# Side Effect: sets _config_changes=1 if changes were rolled back +################################################################### +rollback_from_save () +{ + if [ -f ${1}.save -o -h ${1}.save ] + then + find_source_file ${1}.save false + ${ECHO} "rollback_from_save: rolling back to $( basename ${_SRCFILE} )" + grep ${NO_FILE_INDICATOR} ${_SRCFILE} > /dev/null + if [ $? -eq 0 ] + then + rm -f ${_SRCFILE} ${1} + else + mv -f ${_SRCFILE} ${1} + fi + if [ "${2}" = "true" ] + then + _config_changes=1 + fi + rm -f ${1}.save + fi +} diff --git a/ajsc-aai/src/main/scripts/install/updateQueryData.sh b/ajsc-aai/src/main/scripts/install/updateQueryData.sh new file mode 100644 index 0000000..2968230 --- /dev/null +++ b/ajsc-aai/src/main/scripts/install/updateQueryData.sh @@ -0,0 +1,103 @@ +#!/bin/ksh +# +# ============LICENSE_START======================================================= +# org.openecomp.aai +# ================================================================================ +# Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. +# ================================================================================ +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ============LICENSE_END========================================================= +# +PROGNAME=$(basename $0) +OUTFILE=$PROJECT_HOME/logs/misc/${PROGNAME}.log.$(date +\%Y-\%m-\%d) +#OUTFILE=/c/temp/${PROGNAME}.log.$(date +\%Y-\%m-\%d) + +TS=$(date "+%Y-%m-%d %H:%M:%S") + +CHECK_USER="aaiadmin" +userid=$( id | cut -f2 -d"(" | cut -f1 -d")" ) +if [ "${userid}" != $CHECK_USER ]; then + echo "You must be $CHECK_USER to run $0. The id used $userid." + exit 1 +fi + +error_exit () { + echo "${PROGNAME}: failed for ${1:-"Unknown error"} on cmd $2" 1>&2 + echo "${PROGNAME}: failed for ${1:-"Unknown error"} on cmd $2" >> $OUTFILE +# exit ${2:-"1"} +} + +j=0 +for filepath in `ls $PROJECT_HOME/bundleconfig/etc/scriptdata/widget-model-json/*.json|sort -f` +#for filepath in `ls /c/sources/aai/aaigitnew/bundleconfig-local/etc/scriptdata/widget-model-json/*.json|sort -f` +do +j=$(expr "$j" + 1) +filename=$(basename $filepath) +echo "Begin putTool for widget $filename" | tee -a $OUTFILE +vers=`grep model-name-version-id $filepath|cut -d':' -f2|cut -d'"' -f2` +# last parameter will skip put if it exists +resource=service-design-and-creation/models/model/$vers +$PROJECT_HOME/scripts/putTool.sh $resource $filepath 1 0 na 1 >> $OUTFILE 2>&1 || error_exit "$resource $filepath" $j +#/c/sources/aai/aaigitnew/src/main/scripts/putTool.sh $resource $filepath 1 0 na 1 >> $OUTFILE 2>&1 || error_exit "$resource $filepath" $j +echo "End putTool for widget $filename" | tee -a $OUTFILE +done + +j=0 +for filepath in `ls $PROJECT_HOME/bundleconfig/etc/scriptdata/named-query-json/*.json|sort -f` +#for filepath in `ls /c/sources/aai/aaigitnew/bundleconfig-local/etc/scriptdata/named-query-json/*.json|sort -f` +do +j=$(expr "$j" + 1) +filename=$(basename $filepath) +echo "Begin putTool for named-query $filename" | tee -a $OUTFILE +vers=`grep named-query-uuid $filepath|cut -d':' -f2|cut -d'"' -f2` +# last parameter will skip put if it exists +resource=service-design-and-creation/named-queries/named-query/$vers +$PROJECT_HOME/scripts/putTool.sh $resource $filepath 1 0 na 1 >> $OUTFILE 2>&1 || error_exit "$resource $filepath" $j +#/c/sources/aai/aaigitnew/src/main/scripts/putTool.sh $resource $filepath 1 0 na 1 >> $OUTFILE 2>&1 || error_exit "$resource $filepath" $j +echo "End putTool for named-query $filename" | tee -a $OUTFILE +done + +j=0 +for filepath in `ls $PROJECT_HOME/bundleconfig/etc/scriptdata/resource-model-json/*.json|sort -f` +#for filepath in `ls /c/sources/aai/aaigitnew/bundleconfig-local/etc/scriptdata/resource-model-json/*.json|sort -f` +do +j=$(expr "$j" + 1) +filename=$(basename $filepath) +echo "Begin putTool for resource model $filename" | tee -a $OUTFILE +vers=`grep model-name-version-id $filepath|cut -d':' -f2|cut -d'"' -f2` +# last parameter will skip put if it exists +resource=service-design-and-creation/models/model/$vers +$PROJECT_HOME/scripts/putTool.sh $resource $filepath 1 0 na 1 >> $OUTFILE 2>&1 || error_exit "$resource $filepath" $j +#/c/sources/aai/aaigitnew/src/main/scripts/putTool.sh $resource $filepath 1 0 na 1 >> $OUTFILE 2>&1 || error_exit "$resource $filepath" $j +echo "End putTool for resource model $filename" | tee -a $OUTFILE +done + +j=0 +for filepath in `ls $PROJECT_HOME/bundleconfig/etc/scriptdata/service-model-json/*.json|sort -f` +#for filepath in `ls /c/sources/aai/aaigitnew/bundleconfig-local/etc/scriptdata/service-model-json/*.json|sort -f` +do +j=$(expr "$j" + 1) +filename=$(basename $filepath) +echo "Begin putTool for service model $filename" | tee -a $OUTFILE +vers=`grep model-name-version-id $filepath|cut -d':' -f2|cut -d'"' -f2` +# last parameter will skip put if it exists +resource=service-design-and-creation/models/model/$vers +$PROJECT_HOME/scripts/putTool.sh $resource $filepath 1 0 na 1 >> $OUTFILE 2>&1 || error_exit "$resource $filepath" $j +#/c/sources/aai/aaigitnew/src/main/scripts/putTool.sh $resource $filepath 1 0 na 1 >> $OUTFILE 2>&1 || error_exit "$resource $filepath" $j +echo "End putTool for service model $filename" | tee -a $OUTFILE +done + +echo "$PROGNAME completed ${TS}" | tee -a $OUTFILE +echo "See output and error file: $OUTFILE" + +exit 0 diff --git a/ajsc-aai/src/main/scripts/logcleanup.sh b/ajsc-aai/src/main/scripts/logcleanup.sh new file mode 100644 index 0000000..36f8124 --- /dev/null +++ b/ajsc-aai/src/main/scripts/logcleanup.sh @@ -0,0 +1,80 @@ +#!/bin/ksh +# +# ============LICENSE_START======================================================= +# org.openecomp.aai +# ================================================================================ +# Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. +# ================================================================================ +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ============LICENSE_END========================================================= +# +# This script uses the dataSnapshot and SchemaGenerator (via GenTester) java classes to restore +# data to a database by doing three things: +# 1) clear out whatever data and schema are currently in the db +# 2) rebuild the schema (using the SchemaGenerator) +# 3) reload data from the passed-in datafile (which must found in the dataSnapShots directory and +# contain an xml view of the db data). +# +# +# The script archives/deletes log files +# +userid=$( id | cut -f2 -d"(" | cut -f1 -d")" ) +if [ "${userid}" != "aaiadmin" ]; then + echo "You must be aaiadmin to run $0. The id used $userid." + exit 1 +fi + +. /etc/profile.d/aai.sh +PROGNAME=$(basename $0) +LOGDIR=${PROJECT_HOME}/logs +ZIPDIR=ARCHIVE +AGEZIP=30 +AGEDELETE=60 +ZIPPER=/bin/gzip +DATE=$(date +%Y%m%d) + +# Get the program arguments +if [[ $# -lt 3 ]] +then + echo "${PROGNAME}: Arguments are missing. Found $#" + exit 1 +fi +LOGDIR="${1}" +AGEZIP=$2 +AGEDELETE=$3 +if [[ ! -d $LOGDIR ]] +then + echo "${PROGNAME}: Directory does not exist: ${LOGDIR}" + exit 1 +fi + +# Create the archive folder, if it does not exist. +if [[ ! -d ${LOGDIR}/${ZIPDIR} ]] +then + mkdir ${LOGDIR}/${ZIPDIR} + if [ $? -ne 0 ] + then + echo "${PROGNAME}: Failed to create directory: ${LOGDIR}/${ZIPDIR}" + exit 1 + fi + chmod 777 ${LOGDIR}/${ZIPDIR} +fi + +# Compress files that are older than AGEZIP days +find -L ${LOGDIR} -name *.gz -prune -o -mtime +${AGEZIP} -type f -name "*.log.*" -exec ${ZIPPER} -f {} \; +find -L ${LOGDIR} -name ${ZIPDIR} -prune -o -type f -name "*.log.*.gz" -print | while read i; do dirnm=`dirname ${i}`; drn=`basename ${dirnm}`; mkdir -p ${LOGDIR}/${ZIPDIR}/${drn}; echo ${i}; echo ${LOGDIR}/${ZIPDIR}/${drn}; mv ${i} ${LOGDIR}/${ZIPDIR}/${drn}; done + +# Delete archive files that are older than AGEDELETE days +find -L ${LOGDIR}/${ZIPDIR}/* -type f -name "*.gz" -mtime +${AGEDELETE} -exec rm -r {} \; + +exit 0 diff --git a/ajsc-aai/src/main/scripts/notifyTool.sh b/ajsc-aai/src/main/scripts/notifyTool.sh new file mode 100644 index 0000000..37be83d --- /dev/null +++ b/ajsc-aai/src/main/scripts/notifyTool.sh @@ -0,0 +1,61 @@ +#!/bin/ksh +# +# ============LICENSE_START======================================================= +# org.openecomp.aai +# ================================================================================ +# Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. +# ================================================================================ +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ============LICENSE_END========================================================= +# +# This script uses the dataSnapshot and SchemaGenerator (via GenTester) java classes to restore +# data to a database by doing three things: +# 1) clear out whatever data and schema are currently in the db +# 2) rebuild the schema (using the SchemaGenerator) +# 3) reload data from the passed-in datafile (which must found in the dataSnapShots directory and +# contain an xml view of the db data). +# +# +# The script invokes PutActionsNotify java class to PUT a actions/notify request for a given JSON payload. +# + +echo +echo `date` " Starting $0" + +userid=$( id | cut -f2 -d"(" | cut -f1 -d")" ) +if [ "${userid}" != "aaiadmin" ]; then + echo "You must be aaiadmin to run $0. The id used $userid." + exit 1 +fi + +. /etc/profile.d/aai.sh + +for JAR in `ls $PROJECT_HOME/extJars/*.jar` +do + CLASSPATH=$CLASSPATH:$JAR +done + +for JAR in `ls $PROJECT_HOME/lib/*.jar` +do + CLASSPATH=$CLASSPATH:$JAR +done + +$JAVA_HOME/bin/java -classpath $CLASSPATH -Dhttps.protocols=TLSv1.1,TLSv1.2 -DAJSC_HOME=$PROJECT_HOME -Daai.home=$PROJECT_HOME org.openecomp.aai.util.PutActionsNotify "$@" +ret_code=$? +if [ $ret_code != 0 ]; then + echo `date` " Done $0" + exit $ret_code +fi + +echo `date` " Done $0" +exit 0 diff --git a/ajsc-aai/src/main/scripts/postTool.sh b/ajsc-aai/src/main/scripts/postTool.sh new file mode 100644 index 0000000..e02895f --- /dev/null +++ b/ajsc-aai/src/main/scripts/postTool.sh @@ -0,0 +1,61 @@ +#!/bin/ksh +# +# ============LICENSE_START======================================================= +# org.openecomp.aai +# ================================================================================ +# Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. +# ================================================================================ +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ============LICENSE_END========================================================= +# +# This script uses the dataSnapshot and SchemaGenerator (via GenTester) java classes to restore +# data to a database by doing three things: +# 1) clear out whatever data and schema are currently in the db +# 2) rebuild the schema (using the SchemaGenerator) +# 3) reload data from the passed-in datafile (which must found in the dataSnapShots directory and +# contain an xml view of the db data). +# +# +# The script invokes PostResource java class to POST on a resource +# + +echo +echo `date` " Starting $0" + +userid=$( id | cut -f2 -d"(" | cut -f1 -d")" ) +if [ "${userid}" != "aaiadmin" ]; then + echo "You must be aaiadmin to run $0. The id used $userid." + exit 1 +fi + +. /etc/profile.d/aai.sh + +for JAR in `ls $PROJECT_HOME/extJars/*.jar` +do + CLASSPATH=$CLASSPATH:$JAR +done + +for JAR in `ls $PROJECT_HOME/lib/*.jar` +do + CLASSPATH=$CLASSPATH:$JAR +done + +$JAVA_HOME/bin/java -classpath $CLASSPATH -Dhttps.protocols=TLSv1.1,TLSv1.2 -DAJSC_HOME=$PROJECT_HOME -Daai.home=$PROJECT_HOME org.openecomp.aai.util.PostResource "$@" +ret_code=$? +if [ $ret_code != 0 ]; then + echo `date` " Done $0" + exit $ret_code +fi + +echo `date` " Done $0" +exit 0 diff --git a/ajsc-aai/src/main/scripts/putTool.sh b/ajsc-aai/src/main/scripts/putTool.sh new file mode 100644 index 0000000..369496e --- /dev/null +++ b/ajsc-aai/src/main/scripts/putTool.sh @@ -0,0 +1,61 @@ +#!/bin/ksh +# +# ============LICENSE_START======================================================= +# org.openecomp.aai +# ================================================================================ +# Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. +# ================================================================================ +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ============LICENSE_END========================================================= +# +# This script uses the dataSnapshot and SchemaGenerator (via GenTester) java classes to restore +# data to a database by doing three things: +# 1) clear out whatever data and schema are currently in the db +# 2) rebuild the schema (using the SchemaGenerator) +# 3) reload data from the passed-in datafile (which must found in the dataSnapShots directory and +# contain an xml view of the db data). +# +# +# The script invokes PutResource java class to PUT on a resource +# + +echo +echo `date` " Starting $0" + +userid=$( id | cut -f2 -d"(" | cut -f1 -d")" ) +if [ "${userid}" != "aaiadmin" ]; then + echo "You must be aaiadmin to run $0. The id used $userid." + exit 1 +fi + +. /etc/profile.d/aai.sh + +for JAR in `ls $PROJECT_HOME/extJars/*.jar` +do + CLASSPATH=$CLASSPATH:$JAR +done + +for JAR in `ls $PROJECT_HOME/lib/*.jar` +do + CLASSPATH=$CLASSPATH:$JAR +done + +$JAVA_HOME/bin/java -classpath $CLASSPATH -Dhttps.protocols=TLSv1.1,TLSv1.2 -DAJSC_HOME=$PROJECT_HOME -Daai.home=$PROJECT_HOME org.openecomp.aai.util.PutResource "$@" +ret_code=$? +if [ $ret_code != 0 ]; then + echo `date` " Done $0" + exit $ret_code +fi + +echo `date` " Done $0" +exit 0 diff --git a/ajsc-aai/src/main/scripts/rshipTool.sh b/ajsc-aai/src/main/scripts/rshipTool.sh new file mode 100644 index 0000000..bf6d585 --- /dev/null +++ b/ajsc-aai/src/main/scripts/rshipTool.sh @@ -0,0 +1,75 @@ +#!/bin/ksh +# +# ============LICENSE_START======================================================= +# org.openecomp.aai +# ================================================================================ +# Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. +# ================================================================================ +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ============LICENSE_END========================================================= +# +# This script uses the dataSnapshot and SchemaGenerator (via GenTester) java classes to restore +# data to a database by doing three things: +# 1) clear out whatever data and schema are currently in the db +# 2) rebuild the schema (using the SchemaGenerator) +# 3) reload data from the passed-in datafile (which must found in the dataSnapShots directory and +# contain an xml view of the db data). +# +# +# The script invokes RelationshipputDel java class to PUT/DELETE a relationship +# +# sample json file for an oam-network node to put a relationship to a complex +#{ +# "related-to": "complex", +# "relationship-data": [ { +# "relationship-key": "complex.physical-location-id", +# "relationship-value": "CHCGILCL73W" +# }] +#} +# + +echo +echo `date` " Starting $0" + +userid=$( id | cut -f2 -d"(" | cut -f1 -d")" ) +if [ "${userid}" != "aaiadmin" ]; then + echo "You must be aaiadmin to run $0. The id used $userid." + exit 1 +fi + +. /etc/profile.d/aai.sh + +for JAR in `ls $PROJECT_HOME/extJars/*.jar` +do + CLASSPATH=$CLASSPATH:$JAR +done + +for JAR in `ls $PROJECT_HOME/jetty/webapps/*/webapp/WEB-INF/lib/*.jar` +do + CLASSPATH=$CLASSPATH:$JAR +done + +for JAR in `ls $PROJECT_HOME/lib/*.jar` +do + CLASSPATH=$CLASSPATH:$JAR +done + +$JAVA_HOME/bin/java -classpath $CLASSPATH -Dhttps.protocols=TLSv1.1,TLSv1.2 -DAJSC_HOME=$PROJECT_HOME -Daai.home=$PROJECT_HOME org.openecomp.aai.util.RelationshipPutDel "$@" +ret_code=$? +if [ $ret_code != 0 ]; then + echo `date` " Done $0" + exit $ret_code +fi + +echo `date` " Done $0" +exit 0 diff --git a/ajsc-aai/src/main/scripts/run_ChangeAuthMethod.sh b/ajsc-aai/src/main/scripts/run_ChangeAuthMethod.sh new file mode 100644 index 0000000..7899db1 --- /dev/null +++ b/ajsc-aai/src/main/scripts/run_ChangeAuthMethod.sh @@ -0,0 +1,107 @@ +#!/bin/ksh +# +# ============LICENSE_START======================================================= +# org.openecomp.aai +# ================================================================================ +# Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. +# ================================================================================ +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ============LICENSE_END========================================================= +# +# This script uses the dataSnapshot and SchemaGenerator (via GenTester) java classes to restore +# data to a database by doing three things: +# 1) clear out whatever data and schema are currently in the db +# 2) rebuild the schema (using the SchemaGenerator) +# 3) reload data from the passed-in datafile (which must found in the dataSnapShots directory and +# contain an xml view of the db data). +# +# +# The script to update runner-web.xml to change authentication from basic to 2-way SSL and vice-versa +# + +usage () { + echo "=========input error===========" + echo " Usage: $0 <action>" + echo "usage examples: $0 disable-basic-auth" + echo " $0 enable-basic-auth" + exit 1 +} + +prop_file=$PROJECT_HOME/etc/runner-web.xml +prop_name='login-config' + +update_prop_disable_basic_auth() { + +# echo "Updating security-constraint and login-config elements in file $prop_file" + + sec_string=`egrep -i "<security-constraint>" $prop_file | grep "<\!--"` + if [ "$?" -eq "1" ]; then + sed -i "s/<security-constraint>/<\!-- <security-constraint>/g" $prop_file + fi + + config_string=`egrep -i "<\/login-config>" $prop_file | grep "\-->"` + if [ "$?" -eq "1" ]; then + sed -i "s/<\/login-config>/<\/login-config> -->/g" $prop_file + fi +} + +update_prop_enable_basic_auth() { + +# echo "Updating security-constraint and login-config elements in file $prop_file" + + sec_string=`egrep -i "<security-constraint>" $prop_file | grep "<\!--"` + if [ "$?" -eq "0" ]; then + sed -i "s/<\!-- <security-constraint>/<security-constraint>/g" $prop_file + fi + + config_string=`egrep -i "<\/login-config>" $prop_file | grep "\-->"` + if [ "$?" -eq "0" ]; then + sed -i "s/<\/login-config> -->/<\/login-config>/g" $prop_file + fi +} + +echo `date` "Running $0... Action:$1" +userid=$( id | cut -f2 -d"(" | cut -f1 -d")" ) +if [ "${userid}" != "aaiadmin" ]; then + echo "You must be aaiadmin to run $0. The id used $userid." + exit 1 +fi + +if [ "$#" -ne 1 ]; then + usage +fi + +if [ "$1" = "disable-basic-auth" ]; then + echo "Updating Authentication Type..." + update_prop_disable_basic_auth true + echo `date` " Done $0" + exit 0 +fi + +if [ "$1" = "enable-basic-auth" ]; then + echo "Updating Authentication Type..." + update_prop_enable_basic_auth true + echo `date` " Done $0" + exit 0 +fi +. /etc/profile.d/aai.sh + +CLASSPATH=$CLASSPATH:$PROJECT_HOME/extJars/* + +for JAR in `ls $PROJECT_HOME/lib/*.jar` +do + CLASSPATH=$CLASSPATH:$JAR +done + +exit 0 + diff --git a/ajsc-aai/src/main/scripts/run_DbTestProcessBuilder.sh b/ajsc-aai/src/main/scripts/run_DbTestProcessBuilder.sh new file mode 100644 index 0000000..8ba3960 --- /dev/null +++ b/ajsc-aai/src/main/scripts/run_DbTestProcessBuilder.sh @@ -0,0 +1,49 @@ +#!/bin/ksh + +### +# ============LICENSE_START======================================================= +# org.openecomp.aai +# ================================================================================ +# Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. +# ================================================================================ +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ============LICENSE_END========================================================= +### + +# +# The script invokes DbTestProcessBuilder class to run test methods from property file path passed as an argument +# + +echo `date` " Starting $0" +userid=$( id | cut -f2 -d"(" | cut -f1 -d")" ) +if [ "${userid}" != "aaiadmin" ]; then + echo "You must be aaiadmin to run $0. The id used $userid." + exit 1 +fi + +. /etc/profile.d/aai.sh + +for JAR in `ls $PROJECT_HOME/extJars/*.jar` +do + CLASSPATH=$CLASSPATH:$JAR +done + +for JAR in `ls $PROJECT_HOME/lib/*.jar` +do + CLASSPATH=$CLASSPATH:$JAR +done + +$JAVA_HOME/bin/java -classpath $CLASSPATH -Dhttps.protocols=TLSv1.1,TLSv1.2 -DAJSC_HOME=$PROJECT_HOME -Daai.home=$PROJECT_HOME org.openecomp.aai.util.DbTestProcessBuilder "$@" + +echo `date` " Done $0" +exit 0 diff --git a/ajsc-aai/src/main/scripts/run_FixXSD.sh b/ajsc-aai/src/main/scripts/run_FixXSD.sh new file mode 100644 index 0000000..3c61c55 --- /dev/null +++ b/ajsc-aai/src/main/scripts/run_FixXSD.sh @@ -0,0 +1,67 @@ +#!/bin/ksh + +### +# ============LICENSE_START======================================================= +# org.openecomp.aai +# ================================================================================ +# Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. +# ================================================================================ +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ============LICENSE_END========================================================= +### + +# +# The script invokes GetResource java class to get all nodes +# + +echo +echo `date` " Starting $0" + +REV=$1 +AAIHOME=$2 +echo "AAIHOME: $AAIHOME" + +if test "$REV" = "" +then + REV=v6 +fi + +. /etc/profile.d/aai.sh + +if test "$AAIHOME" = "" +then + AAIHOME=$PROJECT_HOME +fi + + +for JAR in `ls $AAIHOME/target/*.jar` +do + CLASSPATH=$CLASSPATH:$JAR +done + +for JAR in `ls $PROJECT_HOME/lib/*.jar` +do + CLASSPATH=$CLASSPATH:$JAR +done + +export REV=$REV +echo "FixXSD $REV $AAIHOME" +$JAVA_HOME/bin/java -classpath $CLASSPATH -DAJSC_HOME=$AAIHOME org.openecomp.aai.util.FixXSDNew $REV +ret_code=$? +if [ $ret_code != 0 ]; then + echo `date` " Done $0" + exit $ret_code +fi + +echo `date` " Done $0" +exit 0 diff --git a/ajsc-aai/src/main/scripts/schemaMod.sh b/ajsc-aai/src/main/scripts/schemaMod.sh new file mode 100644 index 0000000..f7acc2f --- /dev/null +++ b/ajsc-aai/src/main/scripts/schemaMod.sh @@ -0,0 +1,94 @@ +#!/bin/ksh +# +# ============LICENSE_START======================================================= +# org.openecomp.aai +# ================================================================================ +# Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. +# ================================================================================ +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ============LICENSE_END========================================================= +# +# This script uses the dataSnapshot and SchemaGenerator (via GenTester) java classes to restore +# data to a database by doing three things: +# 1) clear out whatever data and schema are currently in the db +# 2) rebuild the schema (using the SchemaGenerator) +# 3) reload data from the passed-in datafile (which must found in the dataSnapShots directory and +# contain an xml view of the db data). +# +# +# This script is used to correct mistakes made in the database schema. +# It currently just allows you to change either the dataType and/or indexType on properties used by nodes. +# +# NOTE - Titan is not elegant in 0.5.3 about making changes to the schema. Bad properties never +# actually leave the database, they just get renamed and stop getting used. So it is +# really worthwhile to get indexes and dataTypes correct the first time around. +# Note also - This script just makes changes to the schema that is currently live. +# If you were to create a new schema in a brandy-new environment, it would look like +# whatever oxm told it to look like. So, part of making a +# change to the db schema should Always first be to make the change in oxm so that +# future environments will have the change. This script is just to change existing +# instances of the schema since schemaGenerator (as of June 2015) does not update things - it +# just does the initial creation. +# +# Boy, this is getting to be a big comment section... +# +# To use this script, you need to pass four parameters: +# propertyName -- the name of the property that you need to change either the index or dataType on +# targetDataType -- whether it's changing or not, you need to give it: String, Integer, Boolean or Long +# targetIndexInfo -- whether it's changing or not, you need to give it: index, noIndex or uniqueIndex +# preserveDataFlag -- true or false. The only reason I can think of why you'd ever want to +# set this to false would be maybe if you were changing to an incompatible dataType so didn't +# want it to try to use the old data (and fail). But 99% of the time this will just be 'true'. +# +# Ie. schemaMod flavor-id String index true +# + +echo +echo `date` " Starting $0" + + +userid=$( id | cut -f2 -d"(" | cut -f1 -d")" ) +if [ "${userid}" != "aaiadmin" ]; then + echo "You must be aaiadmin to run $0. The id used $userid." + exit 1 +fi + + +if [ "$#" -ne 4 ]; then + echo "Illegal number of parameters" + echo "usage: $0 propertyName targetDataType targetIndexInfo preserveDataFlag" + exit 1 +fi + +. /etc/profile.d/aai.sh + +for JAR in `ls $PROJECT_HOME/extJars/*.jar` +do + CLASSPATH=$CLASSPATH:$JAR +done + +for JAR in `ls $PROJECT_HOME/lib/*.jar` +do + CLASSPATH=$CLASSPATH:$JAR +done + +$JAVA_HOME/bin/java -classpath $CLASSPATH -Dhttps.protocols=TLSv1.1,TLSv1.2 -DAJSC_HOME=$PROJECT_HOME -Daai.home=$PROJECT_HOME \ + org.openecomp.aai.dbgen.SchemaMod $1 $2 $3 $4 +if [ "$?" -ne "0" ]; then + echo "Problem executing schemaMod " + exit 1 +fi + + +echo `date` " Done $0" +exit 0 diff --git a/ajsc-aai/src/main/scripts/uniquePropertyCheck.sh b/ajsc-aai/src/main/scripts/uniquePropertyCheck.sh new file mode 100644 index 0000000..20bd2e3 --- /dev/null +++ b/ajsc-aai/src/main/scripts/uniquePropertyCheck.sh @@ -0,0 +1,64 @@ +#!/bin/ksh +# +# ============LICENSE_START======================================================= +# org.openecomp.aai +# ================================================================================ +# Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. +# ================================================================================ +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ============LICENSE_END========================================================= +# +# This script uses the dataSnapshot and SchemaGenerator (via GenTester) java classes to restore +# data to a database by doing three things: +# 1) clear out whatever data and schema are currently in the db +# 2) rebuild the schema (using the SchemaGenerator) +# 3) reload data from the passed-in datafile (which must found in the dataSnapShots directory and +# contain an xml view of the db data). +# +# +# The script invokes UniqueProperty java class to see if the passed property is unique in the db and if +# not, to display where duplicate values are found. +# +# For example: uniquePropertyCheck.sh subscriber-name +# + +echo +echo `date` " Starting $0" + +userid=$( id | cut -f2 -d"(" | cut -f1 -d")" ) +if [ "${userid}" != "aaiadmin" ]; then + echo "You must be aaiadmin to run $0. The id used $userid." + exit 1 +fi + +. /etc/profile.d/aai.sh + +for JAR in `ls $PROJECT_HOME/extJars/*.jar` +do + CLASSPATH=$CLASSPATH:$JAR +done + +for JAR in `ls $PROJECT_HOME/lib/*.jar` +do + CLASSPATH=$CLASSPATH:$JAR +done + +$JAVA_HOME/bin/java -classpath $CLASSPATH -Dhttps.protocols=TLSv1.1,TLSv1.2 -DAJSC_HOME=$PROJECT_HOME -Daai.home=$PROJECT_HOME org.openecomp.aai.util.UniquePropertyCheck "$@" +ret_code=$? +if [ $ret_code != 0 ]; then + echo `date` " Done $0" + exit $ret_code +fi + +echo `date` " Done $0" +exit 0 diff --git a/ajsc-aai/src/main/scripts/updateTool.sh b/ajsc-aai/src/main/scripts/updateTool.sh new file mode 100644 index 0000000..77faac8 --- /dev/null +++ b/ajsc-aai/src/main/scripts/updateTool.sh @@ -0,0 +1,61 @@ +#!/bin/ksh +# +# ============LICENSE_START======================================================= +# org.openecomp.aai +# ================================================================================ +# Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. +# ================================================================================ +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ============LICENSE_END========================================================= +# +# This script uses the dataSnapshot and SchemaGenerator (via GenTester) java classes to restore +# data to a database by doing three things: +# 1) clear out whatever data and schema are currently in the db +# 2) rebuild the schema (using the SchemaGenerator) +# 3) reload data from the passed-in datafile (which must found in the dataSnapShots directory and +# contain an xml view of the db data). +# +# +# The script invokes GetResource java class to get all nodes +# + +echo +echo `date` " Starting $0" + +userid=$( id | cut -f2 -d"(" | cut -f1 -d")" ) +if [ "${userid}" != "aaiadmin" ]; then + echo "You must be aaiadmin to run $0. The id used $userid." + exit 1 +fi + +. /etc/profile.d/aai.sh + +for JAR in `ls $PROJECT_HOME/extJars/*.jar` +do + CLASSPATH=$CLASSPATH:$JAR +done + +for JAR in `ls $PROJECT_HOME/lib/*.jar` +do + CLASSPATH=$CLASSPATH:$JAR +done + +$JAVA_HOME/bin/java -classpath $CLASSPATH -Dhttps.protocols=TLSv1.1,TLSv1.2 -DAJSC_HOME=$PROJECT_HOME -Daai.home=$PROJECT_HOME org.openecomp.aai.util.UpdateResource "$@" +ret_code=$? +if [ $ret_code != 0 ]; then + echo `date` " Done $0" + exit $ret_code +fi + +echo `date` " Done $0" +exit 0 diff --git a/ajsc-aai/src/main/scripts/yangToJava.sh b/ajsc-aai/src/main/scripts/yangToJava.sh new file mode 100644 index 0000000..ac10e7d --- /dev/null +++ b/ajsc-aai/src/main/scripts/yangToJava.sh @@ -0,0 +1,117 @@ +#!/bin/bash + +### +# ============LICENSE_START======================================================= +# org.openecomp.aai +# ================================================================================ +# Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. +# ================================================================================ +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ============LICENSE_END========================================================= +### + +#check system vars +: ${AAI_HOME:?"AAI_HOME must be set. This is typically your git root/aai-webapp/all/src"} +: ${SCRIPT_HOME:?"SCRIPT_HOME must be set. This is typically your git root/packages/scripts"} +: ${YANG_OUTPUT:?"YANG_OUTPUT must be set. This should be a temporary directory outside of your git root."} +: ${REV:?"REV must be set. The format is vX where X is the version you'd like to create."} + +usage() { + echo "-b [use defaults for all prompts] --help [display help]" +} +SKIP=false +while getopts ":b-" opt; do + case $opt in + b) + echo "skipping prompts" + SKIP=true + ;; + \?) + echo "Invalid option: -$OPTARG" >&2 + usage + exit 1 + ;; + -) + case "${OPTARG}" in + help) + usage + exit 1 + ;; + *) + usage + exit 1 + ;; + esac;; + *) + usage + exit 1 + ;; + esac +done + + +YANGDIR=$AAI_HOME/main/yang/$REV +cd $YANGDIR + +if [ ! -d "$YANG_OUTPUT/xsd" ]; then + mkdir $YANG_OUTPUT/xsd +fi + +for i in *.yang ; do x=`echo $i | cut -d"." -f 1`; echo $i " " $x; pyang -f xsd $i > $YANG_OUTPUT/xsd/$x.xsd; done + +cd $AAI_HOME/main/java/ +javac org/openecomp/aai/util/FixXSDNew.java +java org.openecomp.aai.util.FixXSDNew + +rm org/openecomp/aai/util/FixXSDNew.class +cd $YANG_OUTPUT/xsd + +$SCRIPT_HOME/make_refs_in_xsd.pl fixedup.xsd > aai$REV-corrected.xsd + +echo "compiling class files..." +xjc -p org.openecomp.aai.domain.yang -b $AAI_HOME/main/yang/$REV/bindings.xml aai$REV-corrected.xsd + +echo "done!" +cd $YANG_OUTPUT/xsd/org/openecomp/aai/domain/yang/ + +if [ ! $SKIP = true ]; then + read -p "Remove relationship classes? (N/y)" choice +else + choice="N" +fi +case "$choice" in + y|Y ) echo "removing..." + rm -v Relationship* + ;; + * ) echo "skipping removal" + ;; +esac + +echo "fixing yang classes via perl script..." +for i in *.java; do $SCRIPT_HOME/fix_yang_classes.pl -n "http://org.openecomp.aai.inventory/$REV" $i > $i.new; mv $i $i.bak; mv $i.new $i; done + +if [ ! $SKIP = true ]; then + read -p "Copy generated classes into git home? (Y/n)" choice +else + choice="Y" +fi +case "$choice" in + n|N ) echo "classes are at $YANG_OUTPUT";; + * ) echo "moving files..." + cp -fv *.java $AAI_HOME/main/java/org/openecomp/aai/domain/yang + ;; +esac + +echo "generation complete" +exit 1 + |