summaryrefslogtreecommitdiffstats
path: root/BRMSGateway/config.properties
blob: 45ce3f02ce4ee359eca90c850e4b3dbfecf20f72 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
###
# ============LICENSE_START=======================================================
# ONAP Policy Engine
# ================================================================================
# 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=========================================================
###

PDP_URL2 =  https://localhost:8082/pdp/ , testpdp, alpha456
PAP_URL = http://localhost:8070/pap/ , testpap, alpha123

#Notification Properties... type can be either websocket, ueb, or dmaap
NOTIFICATION_TYPE=websocket
NOTIFICATION_SERVERS=
NOTIFICATION_TOPIC=PDPD-CONFIGURATION
NOTIFICATION_DELAY=
UEB_API_KEY=
UEB_API_SECRET=
CLIENT_ID=
CLIENT_KEY=

# BRMS Properties. 
## defaultName is the default group name to which the rule gets pushed if no artifactID is specified. 
defaultName = default
## repositoryID 
repositoryID = releases
## reposiroryName
repositoryName = Releases
## repositoryURL
repositoryURL = http://nexus:8081/nexus/content/repositories/releases
## repositoryUsername & Password
repositoryUsername=admin
repositoryPassword=admin123
## policyKeyID the value of Policy Key whose value will be the group Name. 
policyKeyID = controller

## GroupNames can be comma separated values. 
groupNames = default, amsterdam
default.groupID = org.onap.policy-engine
default.artifactID = drlPDPGroup
amsterdam.groupID= org.onap.policy-engine.drools.amsterdam
amsterdam.artifactID= policy-amsterdam-rules

#Integrity Monitor values
#database driver for Integrity Monitor
javax.persistence.jdbc.driver=org.mariadb.jdbc.Driver
#database URL for Integrity Monitor
javax.persistence.jdbc.url=jdbc:mariadb://localhost:3306/onap_sdk
#database username for Integrity Monitor
javax.persistence.jdbc.user=policy_user
#database password for Integrity Monitor
javax.persistence.jdbc.password=password
#resource name
RESOURCE_NAME=site_1.brmsgw_1
#***Properties for IntegrityMonitor integration defined in IntegrityMonitorProperties.java***
site_name=site_1
node_type=brms_gateway
fp_monitor_interval=30
failed_counter_threshold=3
test_trans_interval=20
write_fpc_interval=5
max_fpc_update_interval=60
test_via_jmx=false
ping_interval=30000
#
#
#
brms.dependency.version=1.3.0-SNAPSHOT

ENVIRONMENT = DEVL
>
#!/bin/bash

usage() {
cat << EOF
Install (or upgrade) an umbrella Helm Chart, and its subcharts, as separate Helm Releases 

The umbrella Helm Chart is broken apart into a parent release and subchart releases.
Subcharts the are disabled (<chart>.enabled=false) will not be installed or upgraded.
All releases are grouped and deployed within the same namespace.


The deploy arguments must be a release and chart. The chart
argument can be either: a chart reference('stable/onap'), a path to a chart directory,
a packaged chart, or a fully qualified URL. For chart references, the latest
version will be specified unless the '--version' flag is set.

To override values in a chart, use either the '--values' flag and pass in a file
or use the '--set' flag and pass configuration from the command line, to force string
values, use '--set-string'.

You can specify the '--values'/'-f' flag multiple times. The priority will be given to the
last (right-most) file specified. For example, if both myvalues.yaml and override.yaml
contained a key called 'Test', the value set in override.yaml would take precedence:

	$ helm deploy demo ./onap --namespace onap -f openstack.yaml -f overrides.yaml

You can specify the '--set' flag multiple times. The priority will be given to the
last (right-most) set specified. For example, if both 'bar' and 'newbar' values are
set for a key called 'foo', the 'newbar' value would take precedence:

	$ helm deploy demo local/onap --namespace onap -f overrides.yaml --set log.enabled=false --set vid.enabled=false

Usage:
  helm deploy [RELEASE] [CHART] [flags]

Flags:
      --namespace string         namespace to install the release into. Defaults to the current kube config namespace.
      --set stringArray          set values on the command line (can specify multiple or separate values with commas: key1=val1,key2=val2)
      --set-string stringArray   set STRING values on the command line (can specify multiple or separate values with commas: key1=val1,key2=val2)
  -f, --values valueFiles        specify values in a YAML file or a URL(can specify multiple) (default [])
      --verbose                  enables full helm install/upgrade output during deploy
      --set-last-applied         set the last-applied-configuration annotation on all objects.This annotation is required to restore services using Ark/Veloro backup restore.
EOF
}

generate_overrides() {
  SUBCHART_NAMES=($(cat $COMPUTED_OVERRIDES | grep -v '^\s\s'))

  for index in "${!SUBCHART_NAMES[@]}"; do
    START=${SUBCHART_NAMES[index]}
    END=${SUBCHART_NAMES[index+1]}
    if [[ $START == "global:" ]]; then
      echo "global:" > $GLOBAL_OVERRIDES
      cat $COMPUTED_OVERRIDES | sed '/common:/,/consul:/d' \
        | sed -n '/'"$START"'/,/'log:'/p' | sed '1d;$d' >> $GLOBAL_OVERRIDES
    else
      SUBCHART_DIR="$CACHE_SUBCHART_DIR/$(cut -d':' -f1 <<<"$START")"
      if [[ -d "$SUBCHART_DIR" ]]; then
        if [[ -z "$END" ]]; then
          cat $COMPUTED_OVERRIDES | sed -n '/^'"$START"'/,/'"$END"'/p' \
            | sed '1d;$d' | cut -c3- > $SUBCHART_DIR/subchart-overrides.yaml
        else
          cat $COMPUTED_OVERRIDES | sed -n '/^'"$START"'/,/^'"$END"'/p' \
            | sed '1d;$d' | cut -c3- > $SUBCHART_DIR/subchart-overrides.yaml
        fi
      fi
    fi
  done
}
resolve_deploy_flags() {
  flags=($1)
  n=${#flags[*]}
  for (( i = 0; i < n; i++ )); do
    PARAM=${flags[i]}
    if [[ $PARAM == "-f" || \
          $PARAM == "--values" || \
          $PARAM == "--set" || \
          $PARAM == "--set-string" || \
          $PARAM == "--version" ]]; then
       # skip param and its value
       i=$((i + 1))
    else
      DEPLOY_FLAGS="$DEPLOY_FLAGS $PARAM"
    fi
  done
  echo "$DEPLOY_FLAGS"
}

deploy() {
  # validate params
  if [[ -z "$1" || -z "$2" ]]; then
    usage
    exit 0
  fi

  RELEASE=$1
  CHART_URL=$2
  FLAGS=${@:3}
  CHART_REPO="$(cut -d'/' -f1 <<<"$CHART_URL")"
  CHART_NAME="$(cut -d'/' -f2 <<<"$CHART_URL")"
  CACHE_DIR=~/.helm/plugins/deploy/cache
  CHART_DIR=$CACHE_DIR/$CHART_NAME
  CACHE_SUBCHART_DIR=$CHART_DIR-subcharts
  LOG_DIR=$CHART_DIR/logs

  # determine if verbose output is enabled
  VERBOSE="false"
  if [[ $FLAGS = *"--verbose"* ]]; then
    FLAGS="$(echo $FLAGS| sed -n 's/--verbose//p')"
    VERBOSE="true"
  fi
  # determine if set-last-applied flag is enabled
  SET_LAST_APPLIED="false"
  if [[ $FLAGS = *"--set-last-applied"* ]]; then
    FLAGS="$(echo $FLAGS| sed -n 's/--set-last-applied//p')"
    SET_LAST_APPLIED="true"
  fi
  if [[ $FLAGS = *"--dry-run"* ]]; then
    VERBOSE="true"
    FLAGS="$FLAGS --debug"
  fi

  # should pass all flags instead
  NAMESPACE="$(echo $FLAGS | sed -n 's/.*\(namespace\).\s*/\1/p' | cut -c10- | cut -d' ' -f1)"

  VERSION="$(echo $FLAGS | sed -n 's/.*\(version\).\s*/\1/p' | cut -c8- | cut -d' ' -f1)"

  if [ ! -z $VERSION ]; then
     VERSION="--version $VERSION"
  fi

  # Remove all override values passed in as arguments. These will be used during dry run
  # to resolve computed override values. Remaining flags will be passed on during
  # actual upgrade/install of parent and subcharts.
  DEPLOY_FLAGS=$(resolve_deploy_flags "$FLAGS")

 # determine if upgrading individual subchart or entire parent + subcharts
  SUBCHART_RELEASE="$(cut -d'-' -f2 <<<"$RELEASE")"
  if [[ ! -d "$CACHE_SUBCHART_DIR/$SUBCHART_RELEASE" ]]; then
    SUBCHART_RELEASE=
  else
    # update specified subchart without parent
    RELEASE="$(cut -d'-' -f1 <<<"$RELEASE")"
  fi

  # clear previously cached charts
  rm -rf $CACHE_DIR

  # create log driectory
  mkdir -p $LOG_DIR

  # fetch umbrella chart (parent chart containing subcharts)
  if [[ -d "$CHART_URL" ]]; then
    mkdir -p $CHART_DIR
    cp -R $CHART_URL/* $CHART_DIR/

    charts=$CHART_DIR/charts/*
    for subchart in $charts ; do
      tar xzf ${subchart} -C $CHART_DIR/charts/
    done
    rm -rf $CHART_DIR/charts/*.tgz
  else
    echo "fetching $CHART_URL"
    helm fetch $CHART_URL --untar --untardir $CACHE_DIR $VERSION
  fi

  # move out subcharts to process separately
  mkdir -p $CACHE_SUBCHART_DIR
  mv $CHART_DIR/charts/* $CACHE_SUBCHART_DIR/
  # temp hack - parent chart needs common subchart
  mv $CACHE_SUBCHART_DIR/common $CHART_DIR/charts/

  # disable dependencies
  rm $CHART_DIR/requirements.lock
  mv $CHART_DIR/requirements.yaml $CHART_DIR/requirements.deploy

  # compute overrides for parent and all subcharts
  COMPUTED_OVERRIDES=$CACHE_DIR/$CHART_NAME/computed-overrides.yaml
  helm upgrade -i $RELEASE $CHART_DIR $FLAGS --dry-run --debug \
   | sed -n '/COMPUTED VALUES:/,/HOOKS:/p' | sed '1d;$d' > $COMPUTED_OVERRIDES

  # extract global overrides to apply to parent and all subcharts
  GLOBAL_OVERRIDES=$CHART_DIR/global-overrides.yaml
  generate_overrides $COMPUTED_OVERRIDES $GLOBAL_OVERRIDES

  # upgrade/install parent chart first
  if [[ -z "$SUBCHART_RELEASE" ]]; then
    LOG_FILE=$LOG_DIR/${RELEASE}.log
    :> $LOG_FILE

    helm upgrade -i $RELEASE $CHART_DIR $DEPLOY_FLAGS -f $COMPUTED_OVERRIDES \
     > $LOG_FILE.log 2>&1

    if [[ $VERBOSE == "true" ]]; then
      cat $LOG_FILE
    else
      echo "release \"$RELEASE\" deployed"
    fi
    # Add annotation last-applied-configuration if set-last-applied flag is set
    if [[ $SET_LAST_APPLIED == "true" ]]; then
      helm get manifest ${RELEASE} \
      | kubectl apply set-last-applied --create-annotation -n onap -f - \
      > $LOG_FILE.log 2>&1
    fi
  fi

  # upgrade/install each "enabled" subchart
  cd $CACHE_SUBCHART_DIR/
  for subchart in * ; do
    SUBCHART_OVERRIDES=$CACHE_SUBCHART_DIR/$subchart/subchart-overrides.yaml

    SUBCHART_ENABLED=0
    if [[ -f $SUBCHART_OVERRIDES ]]; then
      SUBCHART_ENABLED=$(cat $SUBCHART_OVERRIDES | grep -c "^enabled: true")
    fi

    if [[ $SUBCHART_ENABLED -eq 1 ]]; then
      if [[ -z "$SUBCHART_RELEASE" || $SUBCHART_RELEASE == "$subchart" ]]; then
        LOG_FILE=$LOG_DIR/"${RELEASE}-${subchart}".log
        :> $LOG_FILE

        helm upgrade -i "${RELEASE}-${subchart}" $CACHE_SUBCHART_DIR/$subchart \
         $DEPLOY_FLAGS -f $GLOBAL_OVERRIDES -f $SUBCHART_OVERRIDES \
         > $LOG_FILE 2>&1

        if [[ $VERBOSE == "true" ]]; then
          cat $LOG_FILE
        else
          echo "release \"${RELEASE}-${subchart}\" deployed"
        fi
	# Add annotation last-applied-configuration if set-last-applied flag is set
        if [[ $SET_LAST_APPLIED == "true" ]]; then
          helm get manifest "${RELEASE}-${subchart}" \
          | kubectl apply set-last-applied --create-annotation -n onap -f - \
	      > $LOG_FILE.log 2>&1
        fi
      fi
    else
      array=($(helm ls -q | grep "${RELEASE}-${subchart}"))
      n=${#array[*]}
      for (( i = n-1; i >= 0; i-- )); do
        helm del "${array[i]}" --purge
      done
    fi
  done

  # report on success/failures of installs/upgrades
  helm ls | grep FAILED | grep $RELEASE
}

case "${1:-"help"}" in
  "help")
    usage
    ;;
  "--help")
    usage
    ;;
  "-h")
    usage
    ;;
  *)
    deploy $1 $2 ${@:3}
    ;;
esac

exit 0