aboutsummaryrefslogtreecommitdiffstats
path: root/adapters/mso-openstack-adapters/mvnw
blob: 5bf251c0774593ca4f5335acf0f7483eaa162e8f (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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
#!/bin/sh
# ----------------------------------------------------------------------------
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements.  See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership.  The ASF licenses this file
# to you 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.
# ----------------------------------------------------------------------------

# ----------------------------------------------------------------------------
# Maven2 Start Up Batch script
#
# Required ENV vars:
# ------------------
#   JAVA_HOME - location of a JDK home dir
#
# Optional ENV vars
# -----------------
#   M2_HOME - location of maven2's installed home dir
#   MAVEN_OPTS - parameters passed to the Java VM when running Maven
#     e.g. to debug Maven itself, use
#       set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
#   MAVEN_SKIP_RC - flag to disable loading of mavenrc files
# ----------------------------------------------------------------------------

if [ -z "$MAVEN_SKIP_RC" ] ; then

  if [ -f /etc/mavenrc ] ; then
    . /etc/mavenrc
  fi

  if [ -f "$HOME/.mavenrc" ] ; then
    . "$HOME/.mavenrc"
  fi

fi

# OS specific support.  $var _must_ be set to either true or false.
cygwin=false;
darwin=false;
mingw=false
case "`uname`" in
  CYGWIN*) cygwin=true ;;
  MINGW*) mingw=true;;
  Darwin*) darwin=true
    # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home
    # See https://developer.apple.com/library/mac/qa/qa1170/_index.html
    if [ -z "$JAVA_HOME" ]; then
      if [ -x "/usr/libexec/java_home" ]; then
        export JAVA_HOME="`/usr/libexec/java_home`"
      else
        export JAVA_HOME="/Library/Java/Home"
      fi
    fi
    ;;
esac

if [ -z "$JAVA_HOME" ] ; then
  if [ -r /etc/gentoo-release ] ; then
    JAVA_HOME=`java-config --jre-home`
  fi
fi

if [ -z "$M2_HOME" ] ; then
  ## resolve links - $0 may be a link to maven's home
  PRG="$0"

  # need this for relative symlinks
  while [ -h "$PRG" ] ; do
    ls=`ls -ld "$PRG"`
    link=`expr "$ls" : '.*-> \(.*\)$'`
    if expr "$link" : '/.*' > /dev/null; then
      PRG="$link"
    else
      PRG="`dirname "$PRG"`/$link"
    fi
  done

  saveddir=`pwd`

  M2_HOME=`dirname "$PRG"`/..

  # make it fully qualified
  M2_HOME=`cd "$M2_HOME" && pwd`

  cd "$saveddir"
  # echo Using m2 at $M2_HOME
fi

# For Cygwin, ensure paths are in UNIX format before anything is touched
if $cygwin ; then
  [ -n "$M2_HOME" ] &&
    M2_HOME=`cygpath --unix "$M2_HOME"`
  [ -n "$JAVA_HOME" ] &&
    JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
  [ -n "$CLASSPATH" ] &&
    CLASSPATH=`cygpath --path --unix "$CLASSPATH"`
fi

# For Migwn, ensure paths are in UNIX format before anything is touched
if $mingw ; then
  [ -n "$M2_HOME" ] &&
    M2_HOME="`(cd "$M2_HOME"; pwd)`"
  [ -n "$JAVA_HOME" ] &&
    JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`"
  # TODO classpath?
fi

if [ -z "$JAVA_HOME" ]; then
  javaExecutable="`which javac`"
  if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then
    # readlink(1) is not available as standard on Solaris 10.
    readLink=`which readlink`
    if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then
      if $darwin ; then
        javaHome="`dirname \"$javaExecutable\"`"
        javaExecutable="`cd \"$javaHome\" && pwd -P`/javac"
      else
        javaExecutable="`readlink -f \"$javaExecutable\"`"
      fi
      javaHome="`dirname \"$javaExecutable\"`"
      javaHome=`expr "$javaHome" : '\(.*\)/bin'`
      JAVA_HOME="$javaHome"
      export JAVA_HOME
    fi
  fi
fi

if [ -z "$JAVACMD" ] ; then
  if [ -n "$JAVA_HOME"  ] ; then
    if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
      # IBM's JDK on AIX uses strange locations for the executables
      JAVACMD="$JAVA_HOME/jre/sh/java"
    else
      JAVACMD="$JAVA_HOME/bin/java"
    fi
  else
    JAVACMD="`which java`"
  fi
fi

if [ ! -x "$JAVACMD" ] ; then
  echo "Error: JAVA_HOME is not defined correctly." >&2
  echo "  We cannot execute $JAVACMD" >&2
  exit 1
fi

if [ -z "$JAVA_HOME" ] ; then
  echo "Warning: JAVA_HOME environment variable is not set."
fi

CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher

# traverses directory structure from process work directory to filesystem root
# first directory with .mvn subdirectory is considered project base directory
find_maven_basedir() {

  if [ -z "$1" ]
  then
    echo "Path not specified to find_maven_basedir"
    return 1
  fi

  basedir="$1"
  wdir="$1"
  while [ "$wdir" != '/' ] ; do
    if [ -d "$wdir"/.mvn ] ; then
      basedir=$wdir
      break
    fi
    # workaround for JBEAP-8937 (on Solaris 10/Sparc)
    if [ -d "${wdir}" ]; then
      wdir=`cd "$wdir/.."; pwd`
    fi
    # end of workaround
  done
  echo "${basedir}"
}

# concatenates all lines of a file
concat_lines() {
  if [ -f "$1" ]; then
    echo "$(tr -s '\n' ' ' < "$1")"
  fi
}

BASE_DIR=`find_maven_basedir "$(pwd)"`
if [ -z "$BASE_DIR" ]; then
  exit 1;
fi

export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"}
echo $MAVEN_PROJECTBASEDIR
MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS"

# For Cygwin, switch paths to Windows format before running java
if $cygwin; then
  [ -n "$M2_HOME" ] &&
    M2_HOME=`cygpath --path --windows "$M2_HOME"`
  [ -n "$JAVA_HOME" ] &&
    JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"`
  [ -n "$CLASSPATH" ] &&
    CLASSPATH=`cygpath --path --windows "$CLASSPATH"`
  [ -n "$MAVEN_PROJECTBASEDIR" ] &&
    MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"`
fi

WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain

exec "$JAVACMD" \
  $MAVEN_OPTS \
  -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \
  "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \
  ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@"
l-Scalar-Plain">20 # retry to getConfig from policy-engine on policy-update notification policy_retry_count : 5 policy_retry_sleep : 5 # mode of operation for the policy-handler # either active or passive # in passive mode the policy-hanlder will not listen to # and will not bring the policy-updates from policy-engine mode_of_operation : "active" # config of automatic catch_up for resiliency catch_up : # interval in seconds on how often to call automatic catch_up # example: 1200 is 20*60 seconds that is 20 minutes interval : 1200 # config of periodic reconfigure-rediscover for adaptability reconfigure: # interval in seconds on how often to call automatic reconfigure # example: 600 is 10*60 seconds that is 10 minutes interval : 600 # PDP (policy-engine) config # These are the url of and the auth for the external system, namely the policy-engine (PDP). # We obtain that info manually from PDP folks at the moment. # In long run we should figure out a way of bringing that info into consul record # related to policy-engine itself. policy_engine : url : "{{ YOUR_POLICY_ENGINE_URL }}" # path to decision on the new PDP API as of 2019 path_decision : "/decision/v1" headers : Accept : "application/json" "Content-Type" : "application/json" ClientAuth : "Basic {{ YOUR_POLICY_ENGINE_CLIENT_AUTH }}" Authorization : "Basic {{ YOUR_POLICY_ENGINE_AUTHORIZATION }}" Environment : "{{ YOUR_POLICY_ENGINE_ENVIRONMENT }}" target_entity : "policy_engine" # optional tls_ca_mode specifies where to find the cacert.pem for tls # can be one of these: # "cert_directory" - use the cacert.pem stored locally in cert_directory. # this is the default if cacert.pem file is found # # "os_ca_bundle" - use the public ca_bundle provided by linux system. # this is the default if cacert.pem file not found # # "do_not_verify" - special hack to turn off the verification by cacert and hostname tls_ca_mode : "cert_directory" # optional timeout_in_secs specifies the timeout for the http requests timeout_in_secs: 60 # deploy_handler config # changed from string "deployment_handler" in 2.3.1 to structure in 2.4.0 deploy_handler : # name of deployment-handler service used by policy-handler for logging target_entity : "deployment_handler" # url of the deployment-handler service for policy-handler to direct the policy-updates to # - expecting dns to resolve the name deployment_handler to ip address url : "http://deployment_handler:8188" # limit the size of a single data segment for policy-update messages # from policy-handler to deployment-handler in megabytes max_msg_length_mb : 5 query : # optionally specify the tenant name for the cloudify under deployment-handler # if not specified the "default_tenant" is used by the deployment-handler cfy_tenant_name : "default_tenant" # optional tls_ca_mode specifies where to find the cacert.pem or skip tls verification # can be one of these: # "cert_directory" - use the cacert.pem stored locally in cert_directory. # this is the default if cacert.pem file is found # # "os_ca_bundle" - use the public ca_bundle provided by linux system. # this is the default if cacert.pem file not found # # "do_not_verify" - special hack to turn off the verification by cacert and hostname tls_ca_mode : "cert_directory" # optional timeout_in_secs specifies the timeout for the http requests timeout_in_secs: 60 # optional service_activator config # is used to report the active-passive mode_of_operation of the DCAE-C cluster service_activator : # name of service_activator service used by policy-handler for logging target_entity : "service_activator" # url of the service_activator service for policy-handler to detect the mode-of-operation url : "http://service_activator:123" # path-endpoint to posting the registration to get the mode_of_operation path_register : "/register" # optional tls_ca_mode specifies where to find the cacert.pem or skip tls verification # can be one of these: # "cert_directory" - use the cacert.pem stored locally in cert_directory. # this is the default if cacert.pem file is found # # "os_ca_bundle" - use the public ca_bundle provided by linux system. # this is the default if cacert.pem file not found # # "do_not_verify" - special hack to turn off the verification by cacert and hostname tls_ca_mode : "cert_directory" # optional timeout_in_secs specifies the timeout for the http requests timeout_in_secs : 20 # /register request message to post to the service_activator # put anything that service_activator expects for the registration of the policy-handler post_register : # discoverable component name component_name : "policy_handler" # endpoint on policy-handler that will receive the POST on reconfigure event reconfigure_path : "/reconfigure" # protocol for the /reconfigure event http_protocol : "http" ``` ---------- ## run in folder `policy_handler`: `./run_policy.sh` ---------- ## customization per company ### ```etc_customize/``` folder - company is expected to place any company specific files required to be in the docker image in the folder ```etc_customize/``` - change the ```etc_customize/customize.sh``` script to perform company specific actions during docker image build - ```etc_customize/customize.sh``` script is expected to be overridden by company to customize docker image build ### ```policyhandler/customize/``` folder contains ```CustomizerBase``` and ```Customizer``` classes - ```CustomizerBase``` defines the interface and the default=ONAP behavior - ```CustomizerBase``` is owned by ONAP and should not be changed by the company - ```Customizer``` inherits ```CustomizerBase``` - policy-handler instantiates ```Customizer``` to get the customized behavior - ```Customizer``` is owned by the company and should be changed by the company - ONAP is not going to change ```Customizer``` - the methods of ```Customizer``` are expected to be overridden by the company to change the behavior of the policy-handler - samples are provided for methods in ```Customizer``` class as the commented out lines - Company is allowed to add more files to customize/ folder if that is required for better structuring of their code as soon as it is invoked by the methods of ```Customizer``` here is an example of ```customizer.py``` ```python """contains the Customizer class with method overrides per company specification""" from .customizer_base import CustomizerBase class Customizer(CustomizerBase): """ the Customizer class inherits CustomizerBase that is owned by ONAP :Customizer: class is owned by the company that needs to customize the policy-handler :override: any method defined in the CustomizerBase class to customize the behavior of the policy-handler """ def __init__(self): """class that contains the customization""" super().__init__() def get_service_url(self, audit, service_name, service): """ returns the service url when called from DiscoveryClient this is just a sample code - replace it with the real customization """ service_url = super().get_service_url(audit, service_name, service) audit.info("TODO: customization for service_url on {0}".format(service_name)) return service_url ``` ----------