From be7e0d14765b8fb1520c457ab99ddedf0f7ab65e Mon Sep 17 00:00:00 2001 From: Instrumental Date: Thu, 4 Apr 2019 21:42:19 -0500 Subject: Refine Helm Client Charts Issue-ID: AAF-802 Change-Id: Ie00cd2919eeecef00aac1dae139c7ef80092589a Signed-off-by: Instrumental --- .../org/onap/aaf/auth/batch/reports/Analyze.java | 20 +++---- .../main/java/org/onap/aaf/auth/common/Define.java | 12 +++- .../auth/locate/validation/LocateValidator.java | 2 +- .../locate/validation/JU_LocateValidatorTest.java | 2 +- auth/docker/aaf.sh | 2 +- auth/docker/agent.sh | 1 + auth/docker/dbuild.sh | 6 +- auth/docker/drun.sh | 2 +- auth/helm/aaf-hello/templates/aaf-hello.yaml | 47 +++++++++------ auth/helm/aaf-hello/values.yaml | 22 +++---- auth/helm/aaf/templates/aaf-cm.yaml | 2 +- auth/helm/aaf/templates/aaf-fs.yaml | 2 +- auth/helm/aaf/templates/aaf-gui.yaml | 2 +- auth/helm/aaf/templates/aaf-locate.yaml | 2 +- auth/helm/aaf/templates/aaf-oauth.yaml | 2 +- auth/helm/aaf/templates/aaf-service.yaml | 2 +- auth/helm/aaf/values.yaml | 2 +- auth/sample/bin/client.sh | 68 +++++++++++++++++----- auth/sample/etc/org.osaaf.aaf.oauth.props | 4 +- auth/sample/local/initialConfig.props | 2 +- .../org/onap/aaf/cadi/aaf/TestConnectivity.java | 13 ++++- .../java/org/onap/aaf/cadi/configure/Agent.java | 1 - .../org/onap/aaf/cadi/configure/PropHolder.java | 9 +-- .../cadi/register/test/JU_RegistrationCreator.java | 2 +- .../main/java/org/onap/aaf/cadi/config/Config.java | 2 +- .../aaf/cadi/config/RegistrationPropHolder.java | 28 ++++----- .../config/test/JU_RegistrationPropHolder.java | 10 ++-- 27 files changed, 158 insertions(+), 111 deletions(-) diff --git a/auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/reports/Analyze.java b/auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/reports/Analyze.java index a49fc943..a8ec8268 100644 --- a/auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/reports/Analyze.java +++ b/auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/reports/Analyze.java @@ -210,10 +210,10 @@ public class Analyze extends Batch { // for users and approvers still valid String user = appr.getUser(); - if(org.isRevoked(trans, appr.getApprover())) { + if(org.isRevoked(noAvg, appr.getApprover())) { deleteCW.comment("Approver ID is revoked"); Approval.row(deleteCW, appr); - } else if(user!=null && !user.isEmpty() && org.isRevoked(trans, user)) { + } else if(user!=null && !user.isEmpty() && org.isRevoked(noAvg, user)) { deleteCW.comment("USER ID is revoked"); Approval.row(deleteCW, appr); } else { @@ -491,10 +491,6 @@ public class Analyze extends Batch { if(linst!=null) { Instance lastBath = null; for(Instance inst : linst) { - // if(inst.attn>0) { - // writeAnalysis(trans, cred, inst); - // // Special Behavior: only eval the LAST Instance - // } else // All Creds go through Life Cycle if(deleteDate!=null && inst.expires.before(deleteDate)) { writeAnalysis(noAvg, cred, inst); // will go to Delete @@ -551,14 +547,14 @@ public class Analyze extends Batch { return existing; } - private Range writeAnalysis(AuthzTrans trans, UserRole ur) { + private Range writeAnalysis(AuthzTrans noAvg, UserRole ur) { Range r = expireRange.getRange("ur", ur.expires()); if(r!=null) { Date lnd = ln.lastNotified(LastNotified.newKey(ur)); // Note: lnd is NEVER null Identity i; try { - i = org.getIdentity(trans, ur.user()); + i = org.getIdentity(noAvg, ur.user()); } catch (OrganizationException e) { i=null; } @@ -572,7 +568,7 @@ public class Analyze extends Batch { return r; } - private void writeAnalysis(AuthzTrans trans, Cred cred, Instance inst) { + private void writeAnalysis(AuthzTrans noAvg, Cred cred, Instance inst) { if(cred!=null && inst!=null) { Range r = expireRange.getRange("cred", inst.expires); if(r!=null) { @@ -580,7 +576,7 @@ public class Analyze extends Batch { // Note: lnd is NEVER null Identity i; try { - i = org.getIdentity(trans, cred.id); + i = org.getIdentity(noAvg, cred.id); } catch (OrganizationException e) { i=null; } @@ -594,14 +590,14 @@ public class Analyze extends Batch { } } - private void writeAnalysis(AuthzTrans trans, X509 x509, X509Certificate x509Cert) throws IOException { + private void writeAnalysis(AuthzTrans noAvg, X509 x509, X509Certificate x509Cert) throws IOException { Range r = expireRange.getRange("x509", x509Cert.getNotAfter()); if(r!=null) { Date lnd = ln.lastNotified(LastNotified.newKey(x509,x509Cert)); // Note: lnd is NEVER null Identity i; try { - i = org.getIdentity(trans, x509.id); + i = org.getIdentity(noAvg, x509.id); } catch (OrganizationException e) { i=null; } diff --git a/auth/auth-core/src/main/java/org/onap/aaf/auth/common/Define.java b/auth/auth-core/src/main/java/org/onap/aaf/auth/common/Define.java index 7bc1fdc6..e9c36017 100644 --- a/auth/auth-core/src/main/java/org/onap/aaf/auth/common/Define.java +++ b/auth/auth-core/src/main/java/org/onap/aaf/auth/common/Define.java @@ -35,6 +35,7 @@ public class Define { private final static String MSG = ".set(Access access) must be called before use"; public static final CharSequence ROOT_NS_TAG = "AAF_NS"; // use for certain Replacements in Location + private static final int ROOT_NS_TAG_LEN=ROOT_NS_TAG.length(); private static final String ROOT_NS_TAG_DOT = ROOT_NS_TAG +"."; public static String ROOT_NS() { @@ -74,10 +75,15 @@ public class Define { } public static String varReplace(final String potential) { - if (potential.startsWith(ROOT_NS_TAG_DOT)) { - return ROOT_NS + potential.substring(6); + int idx = potential.indexOf(ROOT_NS_TAG_DOT); + if(idx<0) { + return potential; + } else if(idx==0) { + return ROOT_NS + potential.substring(ROOT_NS_TAG_LEN); + } else if('.'==potential.charAt(idx)) { + return potential.replace(ROOT_NS_TAG, ROOT_NS); } else { - return potential; + return potential; } } diff --git a/auth/auth-locate/src/main/java/org/onap/aaf/auth/locate/validation/LocateValidator.java b/auth/auth-locate/src/main/java/org/onap/aaf/auth/locate/validation/LocateValidator.java index 4f3884d2..747211e1 100644 --- a/auth/auth-locate/src/main/java/org/onap/aaf/auth/locate/validation/LocateValidator.java +++ b/auth/auth-locate/src/main/java/org/onap/aaf/auth/locate/validation/LocateValidator.java @@ -47,7 +47,7 @@ public class LocateValidator extends Validator { if (e.getName()!=null) { int idx = e.getName().indexOf('.'); if (idx<=0) { - msg("Endpoint Name must prefixed by Namespace"); + msg("Endpoint Name (" + e.getName() + ") must prefixed by Namespace"); } } nullOrBlank("Endpoint Hostname", e.getHostname()); diff --git a/auth/auth-locate/src/test/java/org/onap/aaf/auth/locate/validation/JU_LocateValidatorTest.java b/auth/auth-locate/src/test/java/org/onap/aaf/auth/locate/validation/JU_LocateValidatorTest.java index 0339f318..44ed3403 100644 --- a/auth/auth-locate/src/test/java/org/onap/aaf/auth/locate/validation/JU_LocateValidatorTest.java +++ b/auth/auth-locate/src/test/java/org/onap/aaf/auth/locate/validation/JU_LocateValidatorTest.java @@ -76,7 +76,7 @@ public class JU_LocateValidatorTest { validator.endpoint(endpoint); - assertEquals("Endpoint Name must prefixed by Namespace\n", validator.errs()); + assertEquals("Endpoint Name (Endpoint1) must prefixed by Namespace\n", validator.errs()); } @Test diff --git a/auth/docker/aaf.sh b/auth/docker/aaf.sh index 02d258f8..656ce56c 100644 --- a/auth/docker/aaf.sh +++ b/auth/docker/aaf.sh @@ -38,7 +38,7 @@ function run_it() { --env aaf_locator_container_ns=${NAMESPACE} \ --env aaf_locator_fqdn=${HOSTNAME} \ --env aaf_locate_url=https://aaf-locate:8095 \ - --env aaf_locator_public_hostname=${HOSTNAME} \ + --env aaf_locator_public_fqdn=${HOSTNAME} \ --env AAF_ENV=${AAF_ENV} \ --env LATITUDE=${LATITUDE} \ --env LONGITUDE=${LONGITUDE} \ diff --git a/auth/docker/agent.sh b/auth/docker/agent.sh index 931249b0..eb1888c1 100644 --- a/auth/docker/agent.sh +++ b/auth/docker/agent.sh @@ -120,6 +120,7 @@ function run_it() { --env LATITUDE=${LATITUDE} \ --env LONGITUDE=${LONGITUDE} \ --env aaf_locator_container_ns=${CONTAINER_NS} \ + --env aaf_locator_container=docker \ --name aaf-agent-$USER \ "$PREFIX"onap/aaf/aaf_agent:$VERSION \ bash -c "bash /opt/app/aaf_config/bin/agent.sh $PARAMS" diff --git a/auth/docker/dbuild.sh b/auth/docker/dbuild.sh index 1b4e5eee..fab4b15a 100755 --- a/auth/docker/dbuild.sh +++ b/auth/docker/dbuild.sh @@ -28,8 +28,6 @@ fi . ./d.props -AAF_COMPONENTS=ALL - # process input. originally, an optional positional parameter is used to designate a component. # A flagged parameter has been added to optionally indicate docker pull registry. Ideally, options # would be flagged but we're avoiding ripple effect of changing original usage @@ -124,9 +122,7 @@ cd - ####### # Do all the Containers related to AAF Services ####### -if [ $AAF_COMPONENTS == "ALL" ]; then - AAF_COMPONENTS=$(cat components) -fi +AAF_COMPONENTS=$(cat components) cp ../sample/bin/pod_wait.sh ../aaf_${VERSION}/bin for AAF_COMPONENT in ${AAF_COMPONENTS}; do diff --git a/auth/docker/drun.sh b/auth/docker/drun.sh index 994bb556..648c497a 100644 --- a/auth/docker/drun.sh +++ b/auth/docker/drun.sh @@ -105,7 +105,7 @@ for AAF_COMPONENT in ${AAF_COMPONENTS}; do --env aaf_locator_container=docker \ --env aaf_locator_container_ns=${NAMESPACE} \ --env aaf_locator_fqdn=${HOSTNAME} \ - --env aaf_locator_public_hostname=${HOSTNAME} \ + --env aaf_locator_public_fqdn=${HOSTNAME} \ --env LATITUDE=${LATITUDE} \ --env LONGITUDE=${LONGITUDE} \ --env CASSANDRA_CLUSTER=${CASSANDRA_CLUSTER} \ diff --git a/auth/helm/aaf-hello/templates/aaf-hello.yaml b/auth/helm/aaf-hello/templates/aaf-hello.yaml index c114e5eb..787f32d5 100644 --- a/auth/helm/aaf-hello/templates/aaf-hello.yaml +++ b/auth/helm/aaf-hello/templates/aaf-hello.yaml @@ -31,8 +31,8 @@ spec: ports: - name: aaf-hello protocol: TCP - port: 8130 - nodePort: 30086 + port: {{.Values.cadi.port}} + nodePort: {{ .Values.cadi.public_port}} --- apiVersion: apps/v1 kind: Deployment @@ -52,37 +52,49 @@ spec: spec: volumes: # Use this Pod Sharing dir to declare various States of starting - - name: hello-config-vol + - name: aaf-hello-vol emptyDir: {} initContainers: - - name: hello-config-container + - name: aaf-hello-config image: {{ .Values.image.repository }}onap/aaf/aaf_agent:{{ .Values.image.version }} imagePullPolicy: IfNotPresent volumeMounts: - mountPath: "/opt/app/osaaf/local" - name: hello-config-vol - command: ["bash","-c","cd /opt/app/osaaf/local && /opt/app/aaf_config/bin/agent.sh place aaf@aaf.osaaf.org aaf"] + name: aaf-hello-vol + command: ["bash","-c","cd /opt/app/osaaf/local && /opt/app/aaf_config/bin/agent.sh place aaf@aaf.osaaf.org aaf-hello "] env: - name: "AAF_ENV" - value: "DEV" + value: "{{ .Values.cadi.aaf_env }}" - name: "AAF_FQDN" - value: "aaf-locate.onap" + value: "aaf-locate.{{ .Release.Namespace }}" - name: "APP_FQDN" - value: "aaf" + value: "{{ .Values.cadi.fqdn }}" - name: "APP_FQI" - value: "aaf@aaf.osaaf.org" - - name: LATITUDE + value: "{{ .Values.cadi.fqi }}" + - name: "LATITUDE" value: "{{ .Values.cadi.cadi_latitude }}" - - name: LONGITUDE + - name: "LONGITUDE" value: "{{ .Values.cadi.cadi_longitude }}" - - name: "CONTAINER_NS" - valueFrom: - fieldRef: - fieldPath: metadata.namespace - name: "DEPLOY_FQI" value: "deployer@people.osaaf.org" - name: "DEPLOY_PASSWORD" value: "demo123456!" + - name: "aaf_locator_container" + value: "helm" + - name: "aaf_locator_port" + value: "{{ .Values.cadi.port }}" + - name: "aaf_locator_fqdn.helm" + value: "{{ .Values.cadi.fqdn }}.{{.Release.Namespace}}" + - name: "aaf_locator_public_hostname" + value: "{{ .Values.cadi.public_fqdn }}" + - name: "aaf_locator_public_port" + value: "{{ .Values.cadi.public_port }}" + - name: "aaf_locator_container_ns" + value: "{{ .Release.Namespace }}" + - name: "aaf_locator_name" + value: "{{.Values.cadi.app_ns}}.hello" + - name: "aaf_locator_name.helm" + value: "{{ .Release.Namespace}}.{{.Values.cadi.app_ns}}.hello" ### ### AAF-HELLO @@ -94,9 +106,8 @@ spec: command: ["/bin/bash","-c","cd /opt/app/aaf && exec bin/hello"] volumeMounts: - mountPath: "/opt/app/osaaf/local" - name: hello-config-vol + name: aaf-hello-vol ports: - name: aaf-hello protocol: TCP containerPort: 8130 - diff --git a/auth/helm/aaf-hello/values.yaml b/auth/helm/aaf-hello/values.yaml index d5fa7476..a4fd23c4 100644 --- a/auth/helm/aaf-hello/values.yaml +++ b/auth/helm/aaf-hello/values.yaml @@ -23,32 +23,24 @@ # Declare variables to be passed into your templates. global: - persistence: - enabled: true common: namespace: "onap" replicas: hello: 1 -ingress: - enabled: false - cadi: - hostname: "aaf.onap" + fqdn: "aaf-hello" + port: 8130 + public_fqdn: "aaf.osaaf.org" + public_port: 30086 + fqi: "aaf@aaf.osaaf.org" + app_ns: "org.osaaf.aaf" cadi_latitude: "38.0" cadi_longitude: "-72.0" aaf_env: "DEV" -persistence: - # Note: Minikube will persist to /data on your host machine - mountPath: "/data/aaf" - hello: - volumeReclaimPolicy: Retain - accessMode: ReadWriteOnce - size: 1Gi - mountSubPath: "config" - storageClass: "manual" +persistence: {} image: # When using locally built Docker Container, set Repository to "" diff --git a/auth/helm/aaf/templates/aaf-cm.yaml b/auth/helm/aaf/templates/aaf-cm.yaml index f8bca522..cd43f7ae 100644 --- a/auth/helm/aaf/templates/aaf-cm.yaml +++ b/auth/helm/aaf/templates/aaf-cm.yaml @@ -81,7 +81,7 @@ spec: fieldPath: metadata.namespace - name: aaf_locate_url value: "https://aaf-locate.onap:8095" - - name: aaf_locator_public_hostname + - name: aaf_locator_public_fqdn value: "aaf.osaaf.org" - name: CASSANDRA_CLUSTER value: "aaf-cass" diff --git a/auth/helm/aaf/templates/aaf-fs.yaml b/auth/helm/aaf/templates/aaf-fs.yaml index d53e9201..5d75bb98 100644 --- a/auth/helm/aaf/templates/aaf-fs.yaml +++ b/auth/helm/aaf/templates/aaf-fs.yaml @@ -115,6 +115,6 @@ spec: fieldPath: metadata.namespace - name: aaf_locate_url value: "https://aaf-locate.onap:8095" - - name: aaf_locator_public_hostname + - name: aaf_locator_public_fqdn value: "aaf.osaaf.org" diff --git a/auth/helm/aaf/templates/aaf-gui.yaml b/auth/helm/aaf/templates/aaf-gui.yaml index dcff5e7b..dcc1f7f0 100644 --- a/auth/helm/aaf/templates/aaf-gui.yaml +++ b/auth/helm/aaf/templates/aaf-gui.yaml @@ -82,7 +82,7 @@ spec: fieldPath: metadata.namespace - name: aaf_locate_url value: "https://aaf-locate.onap:8095" - - name: aaf_locator_public_hostname + - name: aaf_locator_public_fqdn value: "aaf.osaaf.org" - name: CASSANDRA_CLUSTER value: "aaf-cass" diff --git a/auth/helm/aaf/templates/aaf-locate.yaml b/auth/helm/aaf/templates/aaf-locate.yaml index b09c80b8..8506d329 100644 --- a/auth/helm/aaf/templates/aaf-locate.yaml +++ b/auth/helm/aaf/templates/aaf-locate.yaml @@ -81,7 +81,7 @@ spec: fieldPath: metadata.namespace - name: aaf_locate_url value: "https://aaf-locate.onap:8095" - - name: aaf_locator_public_hostname + - name: aaf_locator_public_fqdn value: "aaf.osaaf.org" - name: CASSANDRA_CLUSTER value: "aaf-cass" diff --git a/auth/helm/aaf/templates/aaf-oauth.yaml b/auth/helm/aaf/templates/aaf-oauth.yaml index 1a382c06..722cc633 100644 --- a/auth/helm/aaf/templates/aaf-oauth.yaml +++ b/auth/helm/aaf/templates/aaf-oauth.yaml @@ -81,7 +81,7 @@ spec: fieldPath: metadata.namespace - name: aaf_locate_url value: "https://aaf-locate.onap:8095" - - name: aaf_locator_public_hostname + - name: aaf_locator_public_fqdn value: "aaf.osaaf.org" - name: CASSANDRA_CLUSTER value: "aaf-cass" diff --git a/auth/helm/aaf/templates/aaf-service.yaml b/auth/helm/aaf/templates/aaf-service.yaml index e6d6d09b..4a8f0b31 100644 --- a/auth/helm/aaf/templates/aaf-service.yaml +++ b/auth/helm/aaf/templates/aaf-service.yaml @@ -81,7 +81,7 @@ spec: fieldPath: metadata.namespace - name: aaf_locate_url value: "https://aaf-locate.onap:8095" - - name: aaf_locator_public_hostname + - name: aaf_locator_public_fqdn value: "aaf.osaaf.org" - name: CASSANDRA_CLUSTER value: "aaf-cass" diff --git a/auth/helm/aaf/values.yaml b/auth/helm/aaf/values.yaml index abea8902..e1fce7fe 100644 --- a/auth/helm/aaf/values.yaml +++ b/auth/helm/aaf/values.yaml @@ -40,7 +40,7 @@ ingress: enabled: false cadi: - hostname: "aaf.onap" + public_fqdn: "aaf.osaaf.org" cadi_latitude: "38.0" cadi_longitude: "-72.0" aaf_env: "DEV" diff --git a/auth/sample/bin/client.sh b/auth/sample/bin/client.sh index 42fe4d94..dde10720 100755 --- a/auth/sample/bin/client.sh +++ b/auth/sample/bin/client.sh @@ -39,11 +39,19 @@ OSAAF="/opt/app/osaaf" LOCAL="$OSAAF/local" DOT_AAF="$HOME/.aaf" SSO="$DOT_AAF/sso.props" - -JAVA_CADI="$JAVA -cp $CONFIG/bin/aaf-auth-cmd-*-full.jar org.onap.aaf.cadi.CmdLine" -JAVA_AGENT="$JAVA -cp $CONFIG/bin/aaf-auth-cmd-*-full.jar -Dcadi_prop_files=$SSO org.onap.aaf.cadi.configure.Agent" -JAVA_AGENT_SELF="$JAVA -cp $CONFIG/bin/aaf-auth-cmd-*-full.jar -Dcadi_prop_files=$LOCAL/${NS}.props org.onap.aaf.cadi.configure.Agent" -JAVA_AAFCLI="$JAVA -cp $CONFIG/bin/aaf-auth-cmd-*-full.jar -Dcadi_prop_files=$LOCAL/org.osaaf.aaf.props org.onap.aaf.auth.cmd.AAFcli" + +if [ -e "$CONFIG" ]; then + CONFIG_BIN="$CONFIG/bin" +else + CONFIG_BIN="." +fi + +CLPATH="$CONFIG_BIN/aaf-auth-cmd-*-full.jar" + +JAVA_CADI="$JAVA -cp $CLPATH org.onap.aaf.cadi.CmdLine" +JAVA_AGENT="$JAVA -cp $CLPATH -Dcadi_prop_files=$SSO org.onap.aaf.cadi.configure.Agent" +JAVA_AGENT_SELF="$JAVA -cp $CLPATH -Dcadi_prop_files=$LOCAL/${NS}.props org.onap.aaf.cadi.configure.Agent" +JAVA_AAFCLI="$JAVA -cp $CLPATH -Dcadi_prop_files=$LOCAL/org.osaaf.aaf.props org.onap.aaf.auth.cmd.AAFcli" # Check for local dir if [ ! -d $LOCAL ]; then @@ -57,9 +65,9 @@ fi # Setup Bash, first time only if [ ! -e "$HOME/.bashrc" ] || [ -z "$(grep cadi $HOME/.bashrc)" ]; then echo "alias cadi='$JAVA_CADI \$*'" >>$HOME/.bashrc - echo "alias agent='$CONFIG/bin/agent.sh agent \$*'" >>$HOME/.bashrc + echo "alias agent='$CONFIG_BIN/agent.sh agent \$*'" >>$HOME/.bashrc echo "alias aafcli='$JAVA_AAFCLI \$*'" >>$HOME/.bashrc - chmod a+x $CONFIG/bin/agent.sh + chmod a+x $CONFIG_BIN/agent.sh . $HOME/.bashrc fi @@ -80,14 +88,22 @@ if [ ! -e "$DOT_AAF/keyfile" ]; then if [ ! "${DEPLOY_PASSWORD}" = "" ]; then echo aaf_password=enc:$(sso_encrypt ${DEPLOY_PASSWORD}) >> ${SSO} fi - if [ ! -z "${CONTAINER_NS}" ]; then - echo "aaf_locator_container_ns=${CONTAINER_NS}" >> ${SSO} + + if [ ! -z "${aaf_locator_container}" ]; then + echo "aaf_locator_container=${aaf_locator_container}" >> ${SSO} + fi + if [ -z "${aaf_locator_container_ns}" ]; then + if [ !-z "${CONTAINER_NS}" ]; then + echo "aaf_locator_container_ns=${CONTAINER_NS}" >> ${SSO} + fi + else + echo "aaf_locator_container_ns=${aaf_locator_container_ns}" >> ${SSO} fi if [ ! -z "${AAF_ENV}" ]; then echo "aaf_env=${AAF_ENV}" >> ${SSO} fi echo aaf_locate_url=https://${AAF_FQDN}:8095 >> ${SSO} - echo aaf_url=https://AAF_LOCATE_URL/AAF_NS.service:${AAF_INTERFACE_VERSION} >> ${SSO} + echo aaf_url=https://AAF_LOCATE_URL/%CNS.%AAF_NS.service:${AAF_INTERFACE_VERSION} >> ${SSO} base64 -d $CONFIG/cert/truststoreONAPall.jks.b64 > $DOT_AAF/truststoreONAPall.jks echo "cadi_truststore=$DOT_AAF/truststoreONAPall.jks" >> ${SSO} @@ -98,10 +114,37 @@ fi # Only initialize once, automatically... if [ ! -e $LOCAL/${NS}.props ]; then + if [ -e '/opt/app/aaf_config/bin' ]; then + cp /opt/app/aaf_config/bin/*.jar $LOCAL + echo "#!/bin/bash" > agent + echo 'case "$1" in' >> agent + echo ' ""|-?|--help)CMD="";FQI="";FQDN="";;' >> agent + echo ' validate)CMD="$1";FQI="";FQDN="${2:-'"$NS.props"'}";;' >> agent + echo ' *)CMD="$1";FQI="${2:-'"$APP_FQI"'}";FQDN="${3:-'"$APP_FQDN"'}";;' >> agent + echo 'esac' >> agent + echo 'java -cp '$(ls aaf-auth-cmd-*-full.jar)' -Dcadi_prop_files='"$NS"'.props org.onap.aaf.cadi.configure.Agent $CMD $FQI $FQDN' >> agent + + echo "#!/bin/bash" > cadi + echo "java -cp $(ls aaf-auth-cmd-*-full.jar) -Dcadi_prop_files=$NS.props org.onap.aaf.cadi.CmdLine " '$*' >> cadi + # echo "#!/bin/bash" > aafcli + # echo "java -cp $(ls aaf-auth-cmd-*-full.jar) -Dcadi_prop_files=$NS.props org.onap.aaf.auth.cmd.AAFcli " '$*' >> aafcli + + echo "#!/bin/bash" > testConnectivity + echo "java -cp $(ls aaf-auth-cmd-*-full.jar) org.onap.aaf.cadi.aaf.TestConnectivity $NS.props" >> testConnectivity + chmod ug+x agent cadi testConnectivity + fi echo "#### Create Configuration files " $JAVA_AGENT config $APP_FQI \ aaf_url=https://AAF_LOCATE_URL/AAF_NS.locate:${AAF_INTERFACE_VERSION} \ cadi_etc_dir=$LOCAL +# Grab all properties passed in that start with "aaf_" or "cadi_" + for E in $(env); do + if [[ $E == aaf_* ]] || [[ $E == cadi_* ]]; then + if [ -z "$(grep $E $LOCAL/$NS.props)" ]; then + echo "${E}" >> $LOCAL/$NS.props + fi + fi + done cat $LOCAL/$NS.props echo @@ -119,7 +162,6 @@ if [ ! -e $LOCAL/${NS}.props ]; then cadi_etc_dir=$LOCAL echo "#### Validate Configuration and Certificate with live call" - $JAVA_AGENT_SELF validate echo "Obtained Certificates" INITIALIZED="true" else @@ -236,7 +278,7 @@ else ;; testConnectivity|testconnectivity) echo "--- Test Connectivity ---" - $JAVA -cp $CONFIG/bin/aaf-auth-cmd-*-full.jar org.onap.aaf.cadi.aaf.TestConnectivity $LOCAL/org.osaaf.aaf.props + $JAVA -cp $CONFIG_BIN/aaf-auth-cmd-*-full.jar org.onap.aaf.cadi.aaf.TestConnectivity $LOCAL/org.osaaf.aaf.props ;; --help | -?) case "$1" in @@ -272,7 +314,7 @@ else ### Possible Dublin # sample) # echo "--- run Sample Servlet App ---" - # $JAVA -Dcadi_prop_files=$LOCAL/${NS}.props -cp $CONFIG/bin/aaf-auth-cmd-*-full.jar:$CONFIG/bin/aaf-cadi-servlet-sample-*-sample.jar org.onap.aaf.sample.cadi.jetty.JettyStandalone ${NS}.props + # $JAVA -Dcadi_prop_files=$LOCAL/${NS}.props -cp $CONFIG_BIN/aaf-auth-cmd-*-full.jar:$CONFIG_BIN/aaf-cadi-servlet-sample-*-sample.jar org.onap.aaf.sample.cadi.jetty.JettyStandalone ${NS}.props # ;; *) $JAVA_AGENT "$CMD" "$@" diff --git a/auth/sample/etc/org.osaaf.aaf.oauth.props b/auth/sample/etc/org.osaaf.aaf.oauth.props index 8c813898..a2d5fc56 100644 --- a/auth/sample/etc/org.osaaf.aaf.oauth.props +++ b/auth/sample/etc/org.osaaf.aaf.oauth.props @@ -22,8 +22,8 @@ ## cadi_prop_files=/opt/app/osaaf/local/org.osaaf.aaf.props:/opt/app/osaaf/etc/org.osaaf.aaf.log4j.props:/opt/app/osaaf/local/org.osaaf.aaf.cassandra.props aaf_locator_entries=oauth,token,introspect -aaf_locator_fqdn.helm=%CNS.aaf-oauth -aaf_locator_fqdn.oom=%CNS.aaf-oauth +aaf_locator_fqdn.helm=aaf-oauth.%CNS +aaf_locator_fqdn.oom=aaf-oauth.%CNS port=8140 aaf_locator_public_port.helm=30082 aaf_locator_public_port.oom=31112 diff --git a/auth/sample/local/initialConfig.props b/auth/sample/local/initialConfig.props index 2bcaf7c4..6ea1d537 100644 --- a/auth/sample/local/initialConfig.props +++ b/auth/sample/local/initialConfig.props @@ -32,7 +32,7 @@ aaf_locator_app_ns=%AAF_NS aaf_locator_name=%NS.%N aaf_locator_name.docker=%CNS.%NS.%N aaf_locator_name.helm=%CNS.%NS.%N -aaf_locator_name.oom=%CNS.%NS.%N +aaf_locator_name.oom=%CNS%.%NS.%N aaf_locator_fqdn.docker=aaf-%N aaf_locator_fqdn.helm=aaf-%N.%CNS aaf_locator_fqdn.oom=aaf-%N.%CNS diff --git a/cadi/aaf/src/main/java/org/onap/aaf/cadi/aaf/TestConnectivity.java b/cadi/aaf/src/main/java/org/onap/aaf/cadi/aaf/TestConnectivity.java index 004c43c5..d3804743 100644 --- a/cadi/aaf/src/main/java/org/onap/aaf/cadi/aaf/TestConnectivity.java +++ b/cadi/aaf/src/main/java/org/onap/aaf/cadi/aaf/TestConnectivity.java @@ -142,9 +142,19 @@ public class TestConnectivity { } private static URI uri(PropAccess access, String ms) throws URISyntaxException { - String aaf_root_ns = access.getProperty(Config.AAF_ROOT_NS,"AAF_NS"); + String aaf_root_ns = access.getProperty(Config.AAF_ROOT_NS,Config.AAF_ROOT_NS_DEF); String aaf_api_version = access.getProperty(Config.AAF_API_VERSION,Config.AAF_DEFAULT_API_VERSION); String aaf_locate_url = access.getProperty(Config.AAF_LOCATE_URL,Defaults.AAF_LOCATE_CONST); + String aaf_container = access.getProperty(Config.AAF_LOCATOR_CONTAINER,null); + if(aaf_container!=null) { + String ns = access.getProperty(Config.AAF_LOCATOR_CONTAINER_NS+'.'+aaf_container,null); + if(ns==null) { + ns = access.getProperty(Config.AAF_LOCATOR_CONTAINER_NS,null); + } + if(ns!=null) { + aaf_root_ns=ns + '.' + aaf_root_ns; + } + } if("cm".equals(ms) && "2.0".equals(aaf_api_version)) { ms = "certman"; } @@ -187,6 +197,7 @@ public class TestConnectivity { if (tokenURL==null || (tokenURL.contains("/locate/") && locateURL!=null)) { tokenURL=Config.OAUTH2_TOKEN_URL_DEF; } + try { HRenewingTokenSS hrtss = new HRenewingTokenSS(access, tokenURL); diff --git a/cadi/aaf/src/main/java/org/onap/aaf/cadi/configure/Agent.java b/cadi/aaf/src/main/java/org/onap/aaf/cadi/configure/Agent.java index c7a74965..e04015c4 100644 --- a/cadi/aaf/src/main/java/org/onap/aaf/cadi/configure/Agent.java +++ b/cadi/aaf/src/main/java/org/onap/aaf/cadi/configure/Agent.java @@ -50,7 +50,6 @@ import org.onap.aaf.cadi.CmdLine; import org.onap.aaf.cadi.LocatorException; import org.onap.aaf.cadi.PropAccess; import org.onap.aaf.cadi.Symm; -import org.onap.aaf.cadi.aaf.Defaults; import org.onap.aaf.cadi.aaf.client.ErrMessage; import org.onap.aaf.cadi.aaf.v2_0.AAFCon; import org.onap.aaf.cadi.aaf.v2_0.AAFConHttp; diff --git a/cadi/aaf/src/main/java/org/onap/aaf/cadi/configure/PropHolder.java b/cadi/aaf/src/main/java/org/onap/aaf/cadi/configure/PropHolder.java index d066d97a..1b8b76e4 100644 --- a/cadi/aaf/src/main/java/org/onap/aaf/cadi/configure/PropHolder.java +++ b/cadi/aaf/src/main/java/org/onap/aaf/cadi/configure/PropHolder.java @@ -152,7 +152,7 @@ public class PropHolder { pw.println(System.getProperty("user.name")); pw.print("# on "); pw.println(Chrono.dateStamp()); - pw.println("# @copyright 2016, AT&T"); + pw.println("# @copyright 2019, AT&T"); for (int i=0;i<60;++i) { pw.print('#'); } @@ -160,16 +160,9 @@ public class PropHolder { for (Map.Entry me : props.entrySet()) { String key = me.getKey(); - //if ( key.startsWith("cm_") -// || key.startsWith(Config.HOSTNAME) -// || key.startsWith("aaf") -// || key.startsWith("cadi") -// || key.startsWith("Challenge") -// ) { pw.print(key); pw.print('='); pw.println(me.getValue()); -// } } } finally { pw.close(); diff --git a/cadi/aaf/src/test/java/org/onap/aaf/cadi/register/test/JU_RegistrationCreator.java b/cadi/aaf/src/test/java/org/onap/aaf/cadi/register/test/JU_RegistrationCreator.java index 06ef0ca5..6f3884b7 100644 --- a/cadi/aaf/src/test/java/org/onap/aaf/cadi/register/test/JU_RegistrationCreator.java +++ b/cadi/aaf/src/test/java/org/onap/aaf/cadi/register/test/JU_RegistrationCreator.java @@ -141,7 +141,7 @@ public class JU_RegistrationCreator { String k8s_public_hostname="k8s.public.com"; int public_port = 30001; - pa.setProperty(Config.AAF_LOCATOR_PUBLIC_HOSTNAME,k8s_public_hostname); + pa.setProperty(Config.AAF_LOCATOR_PUBLIC_FQDN,k8s_public_hostname); pa.setProperty(Config.AAF_LOCATOR_PUBLIC_PORT+DOT_OOM,Integer.toString(public_port)); pa.setProperty(Config.AAF_LOCATOR_APP_NS, Config.AAF_ROOT_NS_DEF); rc = new RegistrationCreator(pa); diff --git a/cadi/core/src/main/java/org/onap/aaf/cadi/config/Config.java b/cadi/core/src/main/java/org/onap/aaf/cadi/config/Config.java index 3dc7f06c..07a791e8 100644 --- a/cadi/core/src/main/java/org/onap/aaf/cadi/config/Config.java +++ b/cadi/core/src/main/java/org/onap/aaf/cadi/config/Config.java @@ -180,7 +180,7 @@ public class Config { public static final String AAF_LOCATOR_FQDN = "aaf_locator_fqdn"; public static final String AAF_LOCATOR_NAME = "aaf_locator_name"; public static final String AAF_LOCATOR_PUBLIC_PORT = "aaf_locator_public_port"; - public static final String AAF_LOCATOR_PUBLIC_HOSTNAME = "aaf_locator_public_hostname"; + public static final String AAF_LOCATOR_PUBLIC_FQDN = "aaf_locator_public_fqdn"; public static final String AAF_APPID = "aaf_id"; public static final String AAF_APPPASS = "aaf_password"; diff --git a/cadi/core/src/main/java/org/onap/aaf/cadi/config/RegistrationPropHolder.java b/cadi/core/src/main/java/org/onap/aaf/cadi/config/RegistrationPropHolder.java index 87abb963..997803bb 100644 --- a/cadi/core/src/main/java/org/onap/aaf/cadi/config/RegistrationPropHolder.java +++ b/cadi/core/src/main/java/org/onap/aaf/cadi/config/RegistrationPropHolder.java @@ -34,7 +34,7 @@ public class RegistrationPropHolder { private final Access access; public String hostname; private int port; - public String public_hostname; + public String public_fqdn; private Integer public_port; public Float latitude; public Float longitude; @@ -85,9 +85,9 @@ public class RegistrationPropHolder { access.printf(Level.INIT, REGI,"hostname",hostname); } - public_hostname = access.getProperty(Config.AAF_LOCATOR_PUBLIC_HOSTNAME, hostname); + public_fqdn = access.getProperty(Config.AAF_LOCATOR_PUBLIC_FQDN, hostname); if(firstlog) { - access.printf(Level.INIT, REGI,"public_hostname",public_hostname); + access.printf(Level.INIT, REGI,"public_fqdn",public_fqdn); } default_name = access.getProperty(Config.AAF_LOCATOR_NAME, PUBLIC_NAME); @@ -121,11 +121,11 @@ public class RegistrationPropHolder { // Note: only one of the ports can be public... Therefore, only the last for(String le : Split.splitTrim(',', lcontainer)) { dot_le = le.isEmpty()?le :"."+le; - str = access.getProperty(Config.AAF_LOCATOR_PUBLIC_HOSTNAME+dot_le,null); + str = access.getProperty(Config.AAF_LOCATOR_PUBLIC_FQDN+dot_le,null); if( str != null && !str.isEmpty()) { - public_hostname=str; + public_fqdn=str; if(firstlog) { - access.printf(Level.INIT, "RegistrationProperty: public_hostname(overloaded by %s)='%s'",dot_le,public_hostname); + access.printf(Level.INIT, "RegistrationProperty: public_hostname(overloaded by %s)='%s'",dot_le,public_fqdn); } } } @@ -153,8 +153,8 @@ public class RegistrationPropHolder { public String getEntryFQDN(final String entry, final String dot_le) { String str; - if(public_hostname!=null && dot_le.isEmpty()) { - str = public_hostname; + if(public_fqdn!=null && dot_le.isEmpty()) { + str = public_fqdn; } else { str = access.getProperty(Config.AAF_LOCATOR_FQDN+dot_le, default_fqdn); } @@ -164,7 +164,7 @@ public class RegistrationPropHolder { public String getEntryName(final String entry, final String dot_le) { String str; if(dot_le.isEmpty()) { - str = PUBLIC_NAME; + str = default_name; } else { str = access.getProperty(Config.AAF_LOCATOR_NAME+dot_le, default_name); } @@ -245,10 +245,10 @@ public class RegistrationPropHolder { // aaf_root_ns if(value.indexOf("AAF_NS")>=0) { - str = access.getProperty(Config.AAF_ROOT_NS, Config.AAF_ROOT_NS_DEF); - String temp = value.replace("%AAF_NS", str); + str = access.getProperty(Config.AAF_ROOT_NS, Config.AAF_ROOT_NS_DEF) + '.'; + String temp = value.replace("%AAF_NS.", str); if(temp.equals(value)) { // intended - value = value.replace("AAF_NS", str); // Backward Compatibility + value = value.replace("AAF_NS.", str); // Backward Compatibility } else { value = temp; } @@ -263,8 +263,8 @@ public class RegistrationPropHolder { if(default_fqdn!=null) { value = value.replace("%DF", default_fqdn); } - if(public_hostname!=null) { - value = value.replace("%PH", public_hostname); + if(public_fqdn!=null) { + value = value.replace("%PH", public_fqdn); } } access.printf(Level.DEBUG, diff --git a/cadi/core/src/test/java/org/onap/aaf/cadi/config/test/JU_RegistrationPropHolder.java b/cadi/core/src/test/java/org/onap/aaf/cadi/config/test/JU_RegistrationPropHolder.java index 359b3c2d..68235e1a 100644 --- a/cadi/core/src/test/java/org/onap/aaf/cadi/config/test/JU_RegistrationPropHolder.java +++ b/cadi/core/src/test/java/org/onap/aaf/cadi/config/test/JU_RegistrationPropHolder.java @@ -67,7 +67,7 @@ public class JU_RegistrationPropHolder { for(String dot_le : new String[] {"",".helm"}) { assertEquals(rph.hostname,rph.default_fqdn); assertEquals("",rph.lcontainer); - assertEquals(rph.hostname,rph.public_hostname); + assertEquals(rph.hostname,rph.public_fqdn); assertEquals(ju_port,rph.getEntryPort(dot_le)); assertEquals(rph.hostname,rph.getEntryFQDN("",dot_le)); } @@ -77,7 +77,7 @@ public class JU_RegistrationPropHolder { for(String dot_le : new String[] {"",".helm"}) { assertEquals(rph.hostname,rph.default_fqdn); assertEquals("",rph.lcontainer); - assertEquals(rph.hostname,rph.public_hostname); + assertEquals(rph.hostname,rph.public_fqdn); assertEquals(ju_port,rph.getEntryPort(dot_le)); assertEquals(rph.hostname,rph.getEntryFQDN("",dot_le)); } @@ -87,7 +87,7 @@ public class JU_RegistrationPropHolder { for(String dot_le : new String[] {"",".helm"}) { assertEquals(rph.hostname,rph.default_fqdn); assertEquals("",rph.lcontainer); - assertEquals(rph.hostname,rph.public_hostname); + assertEquals(rph.hostname,rph.public_fqdn); assertEquals(ju_port,rph.getEntryPort(dot_le)); assertEquals(rph.hostname,rph.getEntryFQDN("",dot_le)); } @@ -97,10 +97,10 @@ public class JU_RegistrationPropHolder { //////////////// String public_hostname = "com.public.hostname"; int public_port = 999; - pa.setProperty(Config.AAF_LOCATOR_PUBLIC_HOSTNAME, public_hostname); + pa.setProperty(Config.AAF_LOCATOR_PUBLIC_FQDN, public_hostname); pa.setProperty(Config.AAF_LOCATOR_PUBLIC_PORT,Integer.toString(public_port)); RegistrationPropHolder pubRPH = new RegistrationPropHolder(pa,ju_port); - assertEquals(public_hostname,pubRPH.public_hostname); + assertEquals(public_hostname,pubRPH.public_fqdn); assertEquals(public_port,pubRPH.getEntryPort("")); -- cgit 1.2.3-korg