summaryrefslogtreecommitdiffstats
path: root/policy-management/src/main/server-gen
diff options
context:
space:
mode:
authorPamela Dragosh <pdragosh@research.att.com>2017-02-14 19:45:48 -0500
committerPamela Dragosh <pdragosh@research.att.com>2017-02-14 19:46:03 -0500
commit0e16acf4d8579fd82349d6cd24e236275735a818 (patch)
tree2c397f9d025dacfb3318d75e8fef9a750f71f76b /policy-management/src/main/server-gen
parentec6b0922de2f7e9e68ba9586efc9ed2ad75768f8 (diff)
Initial OpenECOMP policy/drools-pdp commit
Change-Id: I0072ccab6f40ed32da39667f9f8523b6d6dad2e2 Signed-off-by: Pamela Dragosh <pdragosh@research.att.com>
Diffstat (limited to 'policy-management/src/main/server-gen')
-rw-r--r--policy-management/src/main/server-gen/bin/add-secured-participant.sh122
-rw-r--r--policy-management/src/main/server-gen/bin/create-api-key.sh76
-rw-r--r--policy-management/src/main/server-gen/bin/create-secured-topic.sh130
-rw-r--r--policy-management/src/main/server-gen/bin/options125
-rw-r--r--policy-management/src/main/server-gen/bin/pdpd-configuration.sh200
-rw-r--r--policy-management/src/main/server-gen/bin/policy-management-controller191
-rw-r--r--policy-management/src/main/server-gen/bin/rest-add-controller.sh37
-rw-r--r--policy-management/src/main/server-gen/bin/rest-delete-controller.sh43
8 files changed, 924 insertions, 0 deletions
diff --git a/policy-management/src/main/server-gen/bin/add-secured-participant.sh b/policy-management/src/main/server-gen/bin/add-secured-participant.sh
new file mode 100644
index 00000000..d6843fee
--- /dev/null
+++ b/policy-management/src/main/server-gen/bin/add-secured-participant.sh
@@ -0,0 +1,122 @@
+#! /bin/bash
+
+###
+# ============LICENSE_START=======================================================
+# policy-management
+# ================================================================================
+# 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=========================================================
+###
+
+function usage() {
+ echo -n "Usage: $(basename $0) "
+ echo -n "[(-d|--debug)] "
+ echo -n "(-h|--host) <bus-host> "
+ echo -n "[(-p|--port) <bus-port>] "
+ echo -n "(-k|--key) <api-key> "
+ echo -n "(-s|--secret) <api-secret> "
+ echo -n "(-P|--producer-key) <producer-key> "
+ echo -n "(-C|--consumer-key) <consumer-key> "
+ echo "(-t|--topic) <topic> "
+}
+
+BUS_PORT=3904
+
+# command line options parsing
+until [[ -z "$1" ]]; do
+ case $1 in
+ -d|--debug) set -x
+ ;;
+ -h|--host) shift
+ BUS_HOST=$1
+ ;;
+ -p|--port) shift
+ BUS_PORT=$1
+ ;;
+ -k|--key) shift
+ API_KEY=$1
+ ;;
+ -s|--secret) shift
+ API_SECRET=$1
+ ;;
+ -t|--topic) shift
+ TOPIC=$1
+ ;;
+ -P|--producer-key) shift
+ URL_CONTEXT="producers"
+ PRODUCER_KEY=$1
+ KEY=$1
+ ;;
+ -C|--consumer-key) shift
+ URL_CONTEXT="consumers"
+ CONSUMER_KEY=$1
+ KEY=$1
+ ;;
+ *) usage
+ exit 1
+ ;;
+ esac
+ shift
+done
+
+if [[ -z ${BUS_HOST} ]]; then
+ echo "An UEB/DMAAP server must be provided."
+ echo
+ usage
+ exit 1
+fi
+
+if [[ -z ${API_KEY} ]]; then
+ echo "The API Key must be provided."
+ usage
+ exit 2
+fi
+
+if [[ -z ${API_SECRET} ]]; then
+ echo "The API Secret must be provided."
+ usage
+ exit 3
+fi
+
+if [[ -z ${TOPIC} ]]; then
+ echo "The Topic Name must be provided."
+ usage
+ exit 3
+fi
+
+if [[ -z ${PRODUCER_KEY} && -z ${CONSUMER_KEY} ]]; then
+ echo "Either the Producer or Consumer options must be provided."
+ usage
+ exit 4
+fi
+
+if [[ -n ${PRODUCER_KEY} && -n ${CONSUMER_KEY} ]]; then
+ echo "Only and only one of the Producer or Consumer options must be provided."
+ usage
+ exit 5
+fi
+
+
+DATE=$(date)
+DATE_HASH=$(echo -n "${DATE}" | openssl sha1 -hmac "${API_SECRET}" -binary | openssl base64)
+
+unset http_proxy
+curl --silent -X PUT \
+ --header "Accept:" \
+ --header "X-CambriaDate: ${DATE}" \
+ --header "X-CambriaAuth: ${API_KEY}:${DATE_HASH}" \
+ --header "Content-Type: application/json" \
+ --data "{}" \
+ http://${BUS_HOST}:${BUS_PORT}/topics/${TOPIC}/${URL_CONTEXT}/${KEY}
diff --git a/policy-management/src/main/server-gen/bin/create-api-key.sh b/policy-management/src/main/server-gen/bin/create-api-key.sh
new file mode 100644
index 00000000..ea0ec7ad
--- /dev/null
+++ b/policy-management/src/main/server-gen/bin/create-api-key.sh
@@ -0,0 +1,76 @@
+#! /bin/bash
+
+###
+# ============LICENSE_START=======================================================
+# policy-management
+# ================================================================================
+# 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=========================================================
+###
+
+function usage() {
+ echo -n "Usage: $(basename $0) "
+ echo -n "[(-d|--debug)] "
+ echo -n "(-h|--host) <bus-host> "
+ echo -n "[(-p|--port) <bus-port>] "
+ echo "(-e|--email) <email>"
+}
+
+BUS_PORT=3904
+
+# command line options parsing
+until [[ -z "$1" ]]; do
+ case $1 in
+ -d|--debug) set -x
+ ;;
+ -h|--host) shift
+ BUS_HOST=$1
+ ;;
+ -p|--port) shift
+ BUS_PORT=$1
+ ;;
+ -e|--email) shift
+ EMAIL=$1
+ ;;
+ *) usage
+ exit 1
+ ;;
+ esac
+ shift
+done
+
+if [[ -z ${BUS_HOST} ]]; then
+ echo "An UEB/DMAAP server must be provided."
+ echo
+ usage
+ exit 1
+fi
+
+if [[ -z ${EMAIL} ]]; then
+ echo "An email address must be provided."
+ usage
+ exit 2
+fi
+
+REQUEST_API_KEY_BODY=$(< <(cat <<EOF
+{
+ "email": "${EMAIL}",
+ "description": "Generated by PDP-D $(hostname -f)"
+}
+EOF
+))
+
+unset http_proxy
+curl -s -X POST --data "${REQUEST_API_KEY_BODY}" --header "Content-Type: application/json" http://${BUS_HOST}:${BUS_PORT}/v1/apiKeys/create
diff --git a/policy-management/src/main/server-gen/bin/create-secured-topic.sh b/policy-management/src/main/server-gen/bin/create-secured-topic.sh
new file mode 100644
index 00000000..b0d4d6f2
--- /dev/null
+++ b/policy-management/src/main/server-gen/bin/create-secured-topic.sh
@@ -0,0 +1,130 @@
+#! /bin/bash
+
+###
+# ============LICENSE_START=======================================================
+# policy-management
+# ================================================================================
+# 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=========================================================
+###
+
+function usage() {
+ echo -n "Usage: $(basename $0) "
+ echo -n "[(-d|--debug)] "
+ echo -n "(-h|--host) <bus-host> "
+ echo -n "[(-p|--port) <bus-port>] "
+ echo -n "(-k|--key) <api-key> "
+ echo -n "(-s|--secret) <api-secret> "
+ echo -n "[(-P|--partition) <partition-count>] "
+ echo -n "[(-R|--replication) <replication-count>] "
+ echo "(-t|--topic) <topic> "
+ echo ""
+}
+
+BUS_PORT=3904
+PARTITION_COUNT=1
+REPLICATION_COUNT=1
+
+# command line options parsing
+until [[ -z "$1" ]]; do
+ case $1 in
+ -d|--debug) set -x
+ ;;
+ -h|--host) shift
+ BUS_HOST=$1
+ ;;
+ -p|--port) shift
+ BUS_PORT=$1
+ ;;
+ -k|--key) shift
+ API_KEY=$1
+ ;;
+ -s|--secret) shift
+ API_SECRET=$1
+ ;;
+ -t|--topic) shift
+ TOPIC=$1
+ ;;
+ -P|--partition-count) shift
+ PARTITION_COUNT=$1
+ ;;
+ -R|--replication-count) shift
+ REPLICATION_COUNT=$1
+ ;;
+ *) usage
+ exit 1
+ ;;
+ esac
+ shift
+done
+
+if [[ -z ${BUS_HOST} ]]; then
+ echo "An UEB/DMAAP server must be provided."
+ echo
+ usage
+ exit 1
+fi
+
+if [[ -z ${API_KEY} ]]; then
+ echo "The API Key must be provided."
+ usage
+ exit 2
+fi
+
+if [[ -z ${API_SECRET} ]]; then
+ echo "The API Secret must be provided."
+ usage
+ exit 3
+fi
+
+if [[ -z ${TOPIC} ]]; then
+ echo "The Topic Name must be provided."
+ usage
+ exit 3
+fi
+
+if [[ -z ${PARTITION_COUNT} ]]; then
+ echo "The Partition Count must be provided."
+ usage
+ exit 4
+fi
+
+if [[ -z ${REPLICATION_COUNT} ]]; then
+ echo "The Replication Count must be provided."
+ usage
+ exit 5
+fi
+
+REQUEST_API_KEY_BODY=$(< <(cat <<EOF
+{
+ "topicName": "${TOPIC}",
+ "topicDescription": "Generated by PDP-D $(hostname -f)",
+ "partitionCount": ${PARTITION_COUNT},
+ "replicationCount": ${REPLICATION_COUNT}
+}
+EOF
+))
+
+DATE=$(date)
+DATE_HASH=$(echo -n "${DATE}" | openssl sha1 -hmac "${API_SECRET}" -binary | openssl base64)
+
+unset http_proxy
+curl --silent -X POST \
+ --header "Accept:" \
+ --header "X-CambriaDate: ${DATE}" \
+ --header "X-CambriaAuth: ${API_KEY}:${DATE_HASH}" \
+ --header "Content-Type: application/json" \
+ --data "${REQUEST_API_KEY_BODY}" \
+ http://${BUS_HOST}:${BUS_PORT}/topics/create
diff --git a/policy-management/src/main/server-gen/bin/options b/policy-management/src/main/server-gen/bin/options
new file mode 100644
index 00000000..a9ae7125
--- /dev/null
+++ b/policy-management/src/main/server-gen/bin/options
@@ -0,0 +1,125 @@
+#! /bin/bash
+
+lib=${POLICY_HOME}/lib
+opt=${lib}/opt
+
+# change to the options directory
+cd ${opt}
+
+# default field lengths
+nameLength=20
+versionLength=15
+
+# update field lengths, if needed
+for jar in $(ls) ; do
+ # get file name without 'jar' suffix
+ tmp="${jar%\.jar}"
+
+ # get feature name by removing the version portion
+ name="${tmp%%-[0-9]*}"
+
+ # extract version portion of name
+ version="${tmp#${name}-}"
+
+ # grow the size of the name/version field, if needed
+ if (( "${#name}" > nameLength )) ; then
+ nameLength="${#name}"
+ fi
+ if (( "${#version}" > versionLength )) ; then
+ versionLength="${#version}"
+ fi
+done
+
+# dump out status information
+function status
+{
+ local tmp name version status
+ local format="%-${nameLength}s %-${versionLength}s %s\n"
+
+ printf "${format}" "name" "version" "status"
+ printf "${format}" "----" "-------" "------"
+ for jar in $(ls) ; do
+ # get file name without 'jar' suffix
+ tmp="${jar%\.jar}"
+
+ # get feature name by removing the version portion
+ name="${tmp%%-[0-9]*}"
+
+ # extract version portion of name
+ version="${tmp#${name}-}"
+
+ # determine status
+ status=disabled
+ if [[ -e "${lib}/${jar}" ]] ; then
+ status=enabled
+ fi
+ printf "${format}" "${name}" "${version}" "${status}"
+ done
+}
+
+case "$1" in
+ status)
+ {
+ # dump out status information
+ status
+ };;
+
+ enable)
+ {
+ # enable the specified options
+ shift
+ match=
+ for name in "$@" ; do
+ # look for matches - 'file' has the full path name
+ file=$(ls ${opt}/"${name}"-[0-9]* 2>/dev/null)
+ if [[ "$?" != 0 ]] ; then
+ # no matching file
+ echo "${name}: no such option"
+ else
+ # found a match (handle multiple matches, just in case)
+ match=true
+ ln -s -f ${file} "${lib}/"
+ fi
+ done
+ if [[ "${match}" ]] ; then
+ echo
+ status
+ fi
+ };;
+
+ disable)
+ {
+ # disable the specified options
+ shift
+ match=
+ for name in "$@" ; do
+ # look for matches -- 'file' has the last segment of the path name
+ file=$(ls "${name}"-[0-9]* 2>/dev/null)
+ if [[ "$?" != 0 ]] ; then
+ echo "${name}: no such option"
+ else
+ # found a match (handle multiple matches, just in case)
+ match=true
+ (cd ${lib} ; rm -f ${file})
+ fi
+ done
+ if [[ "${match}" ]] ; then
+ echo
+ status
+ fi
+ };;
+
+ *)
+ {
+ # print out usage information
+ cat >&2 <<-'EOF'
+ Usage: options status
+ Get enabled/disabled status on all options
+ options enable <option> ...
+ Enable the specified options
+ options disable <option> ...
+ Disable the specified options
+ EOF
+ };;
+esac
+exit
diff --git a/policy-management/src/main/server-gen/bin/pdpd-configuration.sh b/policy-management/src/main/server-gen/bin/pdpd-configuration.sh
new file mode 100644
index 00000000..8c553927
--- /dev/null
+++ b/policy-management/src/main/server-gen/bin/pdpd-configuration.sh
@@ -0,0 +1,200 @@
+#! /bin/bash
+
+###
+# ============LICENSE_START=======================================================
+# policy-management
+# ================================================================================
+# 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=========================================================
+###
+
+function usage() {
+ echo -n "Usage: $(basename $0) "
+ echo -n "[(-d|--debug)] "
+ echo -n "(-h|--host) <bus-host> "
+ echo -n "[(-p|--port) <bus-port>] "
+ echo -n "[(-k|--key) <api-key>] "
+ echo -n "[(-s|--secret) <api-secret>] "
+ echo -n "[(-r|--request-id) <request-id>] "
+ echo -n "(-c|--controller-name) <controller-name> "
+ echo -n "(-o|--operation) <create|update|lock|unlock> "
+ echo -n "[(-g|--group-id) <group-id> "
+ echo -n "(-a|--artifact-id) <artifact-id> "
+ echo -n "(-v|--version) <version>] "
+ echo -n "[(-t|--topic) <topic>] "
+ echo ""
+}
+
+BUS_PORT=3904
+ENTITY=controller
+REQUEST_ID="7f5474ca-16a9-42ac-abc0-d86f62296fbc"
+TOPIC="PDPD_CONFIGURATION"
+
+# command line options parsing
+until [[ -z "$1" ]]; do
+ case $1 in
+ -d|--debug) set -x
+ ;;
+ -h|--host) shift
+ BUS_HOST=$1
+ ;;
+ -p|--port) shift
+ BUS_PORT=$1
+ ;;
+ -r|--request-id) shift
+ REQUEST_ID=$1
+ ;;
+ -k|--key) shift
+ API_KEY=$1
+ ;;
+ -s|--secret) shift
+ API_SECRET=$1
+ ;;
+ -c|--controller-name) shift
+ CONTROLLER_NAME=$1
+ ;;
+ -o|--operation) shift
+ OPERATION=$1
+ ;;
+ -g|--group-id) shift
+ GROUP_ID=$1
+ ;;
+ -a|--artifact-id) shift
+ ARTIFACT_ID=$1
+ ;;
+ -v|--version) shift
+ VERSION=$1
+ ;;
+ -t|--topic) shift
+ TOPIC=$1
+ ;;
+ *) usage
+ exit 1
+ ;;
+ esac
+ shift
+done
+
+if [[ -z ${BUS_HOST} ]]; then
+ echo "An UEB/DMAAP server must be provided."
+ echo
+ usage
+ exit 1
+fi
+
+if [[ -z ${CONTROLLER_NAME} ]]; then
+ echo "The controller-name must be provided."
+ usage
+ exit 2
+fi
+
+if [[ -z ${OPERATION} ]]; then
+ echo "The operation must be provided: create|update|lock|unlock"
+ usage
+ exit 3
+fi
+
+if [[ ${OPERATION} == "create" ]] || [[ ${OPERATION} == "update" ]]; then
+ if [[ -z ${GROUP_ID} ]]; then
+ echo "The maven group id must be provided when operation is create|update"
+ usage
+ exit 4
+ fi
+
+ if [[ -z ${ARTIFACT_ID} ]]; then
+ echo "The maven artifact id must be provided when operation is create|update"
+ usage
+ exit 5
+ fi
+
+ if [[ -z ${VERSION} ]]; then
+ echo "The maven version must be provided when operation is create|update"
+ usage
+ exit 6
+ fi
+fi
+
+UPDATE_BODY=$(< <(cat <<EOF
+{
+ "requestID": "${REQUEST_ID}",
+ "entity": "controller",
+ "controllers": [{
+ "name": "${CONTROLLER_NAME}",
+ "drools": {
+ "groupId": "${GROUP_ID}",
+ "artifactId": "${ARTIFACT_ID}",
+ "version": "${VERSION}"
+ },
+ "operation": "${OPERATION}"
+ }]
+}
+
+EOF
+))
+
+LOCK_BODY=$(< <(cat <<EOF
+{
+ "requestID": "${REQUEST_ID}",
+ "entity": "controller",
+ "controllers": [{
+ "name": "${CONTROLLER_NAME}",
+ "operation": "${OPERATION}"
+ }]
+}
+
+EOF
+))
+
+unset http_proxy
+
+if [[ ${OPERATION} == "lock" ]] || [[ ${OPERATION} == "unlock" ]]; then
+ if [[ -n ${API_KEY} ]]; then
+ DATE=$(date)
+ DATE_HASH=$(echo -n "${DATE}" | openssl sha1 -hmac "${API_SECRET}" -binary | openssl base64)
+ curl --silent -X POST \
+ --header "Accept:" \
+ --header "X-CambriaDate: ${DATE}" \
+ --header "X-CambriaAuth: ${API_KEY}:${DATE_HASH}" \
+ --header "Content-Type: application/json" \
+ --data "${LOCK_BODY}" \
+ http://${BUS_HOST}:${BUS_PORT}/events/${TOPIC}
+ else
+ curl --silent -X POST \
+ --header "Accept:" \
+ --header "Content-Type: application/json" \
+ --data "${LOCK_BODY}" \
+ http://${BUS_HOST}:${BUS_PORT}/events/${TOPIC}
+ fi
+fi
+
+if [[ ${OPERATION} == "create" ]] || [[ ${OPERATION} == "update" ]]; then
+ if [[ -n ${API_KEY} ]]; then
+ DATE=$(date)
+ DATE_HASH=$(echo -n "${DATE}" | openssl sha1 -hmac "${API_SECRET}" -binary | openssl base64)
+ curl --silent -X POST \
+ --header "Accept:" \
+ --header "X-CambriaDate: ${DATE}" \
+ --header "X-CambriaAuth: ${API_KEY}:${DATE_HASH}" \
+ --header "Content-Type: application/json" \
+ --data "${UPDATE_BODY}" \
+ http://${BUS_HOST}:${BUS_PORT}/events/${TOPIC}
+ else
+ curl --silent -X POST \
+ --header "Accept:" \
+ --header "Content-Type: application/json" \
+ --data "${UPDATE_BODY}" \
+ http://${BUS_HOST}:${BUS_PORT}/events/${TOPIC}
+ fi
+fi
diff --git a/policy-management/src/main/server-gen/bin/policy-management-controller b/policy-management/src/main/server-gen/bin/policy-management-controller
new file mode 100644
index 00000000..4d28d941
--- /dev/null
+++ b/policy-management/src/main/server-gen/bin/policy-management-controller
@@ -0,0 +1,191 @@
+#!/bin/bash
+
+SNAME="Policy Management"
+PNAME=policy-management
+CLASS=org.openecomp.policy.drools.system.Main
+
+
+function start() {
+ um_start
+ if [[ ${RETVAL} != 0 ]]; then
+ update_monitor off
+ else
+ update_monitor on
+ fi
+}
+
+# unmonitored start, does not change monitor status (immutable)
+function um_start() {
+ status
+ if [ "$_RUNNING" = "1" ]; then
+ echo $_STATUS
+ RETVAL=0
+ return
+ fi
+ mkdir -p $_DIR/logs
+ if [ -e $_DIR/logs/$PNAME.out.1 ]; then mv $_DIR/logs/$PNAME.out.1 $_DIR/logs/$PNAME.out.2; fi
+ if [ -e $_DIR/logs/$PNAME.err.1 ]; then mv $_DIR/logs/$PNAME.err.1 $_DIR/logs/$PNAME.err.2; fi
+ if [ -e $_DIR/logs/$PNAME.out ]; then mv $_DIR/logs/$PNAME.out $_DIR/logs/$PNAME.out.1; fi
+ if [ -e $_DIR/logs/$PNAME.err ]; then mv $_DIR/logs/$PNAME.err $_DIR/logs/$PNAME.err.1; fi
+ CP=$(ls $_DIR/lib/*.jar | xargs -I X printf ":%s" X)
+
+ # If 'system.properties' exists, convert it into JVM arguments.
+ # Note that the following also handles property values with spaces.
+ IFS=$'\n'
+ systemProperties=($(
+ if [[ -f $_DIR/config/system.properties ]] ; then
+ sed -n -e 's/^[ \t]*\([^ \t#]*\)[ \t]*=[ \t]*\(.*\)$/-D\1=\2/p' \
+ $_DIR/config/system.properties
+ fi
+ ))
+
+ cd $_DIR
+ (
+ if [[ "${cfg}" != "" ]] ; then
+ # need to make sure that we don't pass the lock file descriptor
+ # to subprocesses
+ exec {cfg}>&-
+ fi
+ nohup $JAVA_HOME/bin/java -Dkie.maven.settings.custom=$_DIR/config/kie_settings.xml -Dlog4j.configuration=file:$_DIR/config/log4j.properties -cp $_DIR/config:$_DIR/lib:$CP "${systemProperties[@]}" "$@" $CLASS > >( while read line; do echo "$(date): ${line}"; done > $_DIR/logs/$PNAME.out) 2> >( while read line; do echo "$(date): ${line}"; done > $_DIR/logs/$PNAME.err) &
+
+ _PID=$!
+ echo $_PID > $_PIDFILE
+ )
+ sleep 5
+ status
+ echo $_STATUS
+ if [ "$_RUNNING" = "1" ]; then
+ RETVAL=0
+ else
+ echo "Failed to start"
+ remove_pid_file
+ RETVAL=1
+ fi
+}
+
+function stop() {
+ um_stop
+ update_monitor off
+}
+
+# unmonitored stop, does not change monitor status (immutable)
+function um_stop() {
+ status
+ if [ "$_RUNNING" = "0" ]; then
+ echo $_STATUS
+ remove_pid_file
+ else
+ if [[ -n ${ENGINE_MANAGEMENT_PASSWORD} ]]; then
+ http_proxy= curl --silent --user ${ENGINE_MANAGEMENT_USER}:${ENGINE_MANAGEMENT_PASSWORD} -X DELETE http://localhost:${ENGINE_MANAGEMENT_PORT}/policy/pdp/engine -o /dev/null
+ else
+ http_proxy= curl --silent -X DELETE http://localhost:${ENGINE_MANAGEMENT_PORT}/policy/pdp/engine -o /dev/null
+ fi
+ sleep 5
+ echo "Stopping $SNAME..."
+ _PID_TO_KILL=$_PID;
+ echo "$SNAME (pid=${_PID_TO_KILL}) is stopping..."
+ kill -TERM $_PID_TO_KILL 2> /dev/null
+ sleep 5
+ check_status_of_pid $_PID_TO_KILL
+ if [ "$_RUNNING" = "1" ]; then
+ kill -TERM $_PID_TO_KILL
+ fi
+ while [ "$_RUNNING" = "1" ]; do
+ sleep 2
+ check_status_of_pid $_PID_TO_KILL
+ done
+ remove_pid_file
+ echo "$SNAME has stopped."
+ fi
+ RETVAL=0
+}
+
+function status() {
+ if [ -f "${_PIDFILE}" ]; then
+ _PID=`cat "${_PIDFILE}"`
+ check_status_of_pid $_PID
+ else
+ _STATUS="$SNAME (no pidfile) is NOT running"
+ _RUNNING=0
+ fi
+ if [[ $_RUNNING = 1 ]]; then
+ RETVAL=0
+ else
+ RETVAL=1
+ fi
+}
+
+
+function check_status_of_pid ()
+{
+ if [ -n "$1" ] && kill -0 $1 2>/dev/null ; then
+ _STATUS="$SNAME (pid $1) is running"
+ _RUNNING=1
+ else
+ _STATUS="$SNAME (pid $1) is NOT running"
+ _RUNNING=0
+ fi
+}
+
+function remove_pid_file ()
+{
+ if [ -f "${_PIDFILE}" ]; then
+ rm "${_PIDFILE}"
+ fi
+}
+
+function update_monitor() {
+ STATUS=$1
+ if [[ -f ${POLICY_HOME}/etc/monitor/monitor.cfg ]]; then
+ /bin/sed -i.bak \
+ -e "s/^${CONTROLLER}=.*/${CONTROLLER}=${STATUS}/g" \
+ ${POLICY_HOME}/etc/monitor/monitor.cfg
+ fi
+}
+
+
+# main
+
+_DIR=${POLICY_HOME}
+CONTROLLER=policy-management-controller
+
+RETVAL=0
+
+_PIDFILE=${POLICY_HOME}/PID
+
+case "$1" in
+ status)
+ status
+ echo "$_STATUS"
+ ;;
+ start)
+ if flock ${cfg} ; then
+ start
+ fi {cfg}>>${POLICY_HOME}/etc/monitor/monitor.cfg.lock
+ ;;
+ umstart)
+ um_start
+ ;;
+ stop)
+ if flock ${cfg} ; then
+ stop
+ fi {cfg}>>${POLICY_HOME}/etc/monitor/monitor.cfg.lock
+ ;;
+ umstop)
+ um_stop
+ ;;
+ restart)
+ if flock ${cfg} ; then
+ stop
+ sleep 2
+ start
+ fi {cfg}>>${POLICY_HOME}/etc/monitor/monitor.cfg.lock
+ ;;
+ *)
+ echo "error: invalid option $@"
+ echo "Usage: $0 status|start|stop|restart"
+ RETVAL=1
+ ;;
+esac
+
+exit ${RETVAL}
diff --git a/policy-management/src/main/server-gen/bin/rest-add-controller.sh b/policy-management/src/main/server-gen/bin/rest-add-controller.sh
new file mode 100644
index 00000000..187b2916
--- /dev/null
+++ b/policy-management/src/main/server-gen/bin/rest-add-controller.sh
@@ -0,0 +1,37 @@
+#! /bin/bash
+
+###
+# ============LICENSE_START=======================================================
+# policy-management
+# ================================================================================
+# 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=========================================================
+###
+
+source $POLICY_HOME/etc/profile.d/env.sh
+
+json=$1-controller.rest.json
+
+if [ -f ${json} ]; then
+ if [[ -n ${ENGINE_MANAGEMENT_PASSWORD} ]]; then
+ curl --silent --user ${ENGINE_MANAGEMENT_USER}:${ENGINE_MANAGEMENT_PASSWORD} -X POST --data @${json} --header "Content-Type: application/json" \
+ http://localhost:${ENGINE_MANAGEMENT_PORT}/policy/pdp/engine/controllers
+ else
+ curl --silent -X POST --data @${json} --header "Content-Type: application/json" \
+ http://localhost:${ENGINE_MANAGEMENT_PORT}/policy/pdp/engine/controllers
+ fi
+else
+ echo "Usage: rest-add-controller.sh closed-loop-sample|reporter|sepc|vsegw|.. (or any other config file ending with *-controller.rest.json)"
+fi
diff --git a/policy-management/src/main/server-gen/bin/rest-delete-controller.sh b/policy-management/src/main/server-gen/bin/rest-delete-controller.sh
new file mode 100644
index 00000000..de1d601c
--- /dev/null
+++ b/policy-management/src/main/server-gen/bin/rest-delete-controller.sh
@@ -0,0 +1,43 @@
+#! /bin/bash
+
+###
+# ============LICENSE_START=======================================================
+# policy-management
+# ================================================================================
+# 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=========================================================
+###
+
+source $POLICY_HOME/etc/profile.d/env.sh
+
+if [[ -n $1 ]]; then
+ if [[ -n ${ENGINE_MANAGEMENT_PASSWORD} ]]; then
+ curl --silent --user ${ENGINE_MANAGEMENT_USER}:${ENGINE_MANAGEMENT_PASSWORD} -X DELETE --header "Content-Type: application/json" \
+ http://localhost:${ENGINE_MANAGEMENT_PORT}/policy/pdp/engine/controllers/${1}
+ else
+ curl --silent -X DELETE --header "Content-Type: application/json" \
+ http://localhost:${ENGINE_MANAGEMENT_PORT}/policy/pdp/engine/controllers/${1}
+ fi
+ echo
+ exit
+fi
+
+
+
+cat <<-'EOF'
+
+Usage: rest-delete-controller.sh closed-loop-sample|reporter|sepc|vsegw|.. (or any other controller idenfied by name)
+
+EOF