From 3505a52ac853c134ecaf40f2977667de8770ec59 Mon Sep 17 00:00:00 2001 From: Instrumental Date: Thu, 31 Jan 2019 14:49:24 -0600 Subject: Implement public private locator Issue-ID: AAF-723 Change-Id: Ib5507ccaab0b7e565c98a16733d1b42dfb608095 Signed-off-by: Instrumental --- .../java/org/onap/aaf/auth/dao/CassAccess.java | 2 +- .../test/java/org/onap/aaf/auth/cm/JU_AAF_CM.java | 3 +- .../java/org/onap/aaf/auth/server/AbsService.java | 4 +- .../onap/aaf/auth/server/JettyServiceStarter.java | 2 +- .../java/org/onap/aaf/auth/server/TestKill.java | 65 ------ .../onap/aaf/auth/server/test/JU_AbsService.java | 2 +- .../aaf/auth/server/test/JU_AbsServiceStarter.java | 2 +- .../java/org/onap/aaf/auth/util/test/TestKill.java | 65 ++++++ .../java/org/onap/aaf/auth/fs/test/JU_AAF_FS.java | 2 +- auth/docker/dbuild.sh | 8 +- auth/docker/dclean.sh | 2 +- auth/docker/drun.sh | 2 +- auth/docker/dstop.sh | 2 +- auth/helm/aaf/Chart.yaml | 2 +- auth/helm/aaf/templates/aaf-cass.yaml | 23 ++- auth/helm/aaf/templates/aaf-cm.yaml | 44 ++++- auth/helm/aaf/templates/aaf-fs.yaml | 49 ++++- auth/helm/aaf/templates/aaf-gui.yaml | 41 +++- auth/helm/aaf/templates/aaf-hello.yaml | 47 +++-- auth/helm/aaf/templates/aaf-locate.yaml | 45 ++++- auth/helm/aaf/templates/aaf-oauth.yaml | 46 +++-- auth/helm/aaf/templates/aaf-service.yaml | 44 +++-- auth/helm/aaf/values.yaml | 6 +- auth/sample/bin/service.sh | 3 + auth/sample/etc/org.osaaf.aaf.cm.props | 2 +- auth/sample/etc/org.osaaf.aaf.fs.props | 2 +- auth/sample/etc/org.osaaf.aaf.gui.props | 2 +- auth/sample/etc/org.osaaf.aaf.hello.props | 2 +- auth/sample/etc/org.osaaf.aaf.locate.props | 2 +- auth/sample/etc/org.osaaf.aaf.oauth.props | 2 +- auth/sample/etc/org.osaaf.aaf.service.props | 2 +- auth/sample/local/aaf.props | 6 - auth/sample/local/initialConfig.props | 34 +++- auth/sample/logs/taillog | 2 +- .../org/onap/aaf/cadi/aaf/TestConnectivity.java | 93 +++++---- .../aaf/cadi/register/RegistrationCreator.java | 157 ++------------- .../cadi/register/test/JU_RegistrationCreator.java | 177 +++++++++++++++++ .../main/java/org/onap/aaf/cadi/config/Config.java | 60 +++--- .../aaf/cadi/config/RegistrationPropHolder.java | 220 +++++++++++++++++++++ .../java/org/onap/aaf/cadi/util/FixURIinfo.java | 2 +- .../main/java/org/onap/aaf/cadi/util/Split.java | 2 +- .../config/test/JU_RegistrationPropHolder.java | 155 +++++++++++++++ docs/sections/release-notes.rst | 4 +- 43 files changed, 1043 insertions(+), 394 deletions(-) delete mode 100644 auth/auth-core/src/main/java/org/onap/aaf/auth/server/TestKill.java create mode 100644 auth/auth-core/src/test/java/org/onap/aaf/auth/util/test/TestKill.java create mode 100644 cadi/aaf/src/test/java/org/onap/aaf/cadi/register/test/JU_RegistrationCreator.java create mode 100644 cadi/core/src/main/java/org/onap/aaf/cadi/config/RegistrationPropHolder.java create mode 100644 cadi/core/src/test/java/org/onap/aaf/cadi/config/test/JU_RegistrationPropHolder.java diff --git a/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/CassAccess.java b/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/CassAccess.java index 6fe9bde5..cde26117 100644 --- a/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/CassAccess.java +++ b/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/CassAccess.java @@ -112,7 +112,7 @@ public class CassAccess { env.init().printf("Service Latitude,Longitude = %f,%f",lat,lon); str = env.getProperty(pre+CASSANDRA_CLUSTERS,env.getProperty(CASSANDRA_CLUSTERS,"localhost")); - env.init().log("Cass Clusters = ",str ); + env.init().printf("Cass Clusters = '%s'\n",str ); String[] machs = Split.split(',', str); String[] cpoints = new String[machs.length]; String bestDC = null; diff --git a/auth/auth-certman/src/test/java/org/onap/aaf/auth/cm/JU_AAF_CM.java b/auth/auth-certman/src/test/java/org/onap/aaf/auth/cm/JU_AAF_CM.java index 58efa2a0..8841eb21 100644 --- a/auth/auth-certman/src/test/java/org/onap/aaf/auth/cm/JU_AAF_CM.java +++ b/auth/auth-certman/src/test/java/org/onap/aaf/auth/cm/JU_AAF_CM.java @@ -26,7 +26,6 @@ import static org.mockito.MockitoAnnotations.initMocks; import java.lang.reflect.Field; import java.lang.reflect.Modifier; -import java.security.NoSuchAlgorithmException; import java.util.Properties; import javax.servlet.Filter; @@ -86,7 +85,7 @@ public class JU_AAF_CM { Properties props=new Properties(); Mockito.doReturn(props).when(access).getProperties(); props.setProperty("cm_ca.props", "test"); - Mockito.doReturn("test:2.1").when(access).getProperty(Config.AAF_LOCATOR_NAMES, null); + Mockito.doReturn("test:2.1").when(access).getProperty(Config.AAF_LOCATOR_ENTRIES, null); Mockito.doReturn("test").when(access).getProperty("https.protocols","TLSv1.1,TLSv1.2"); Mockito.doReturn("test").when(env).getProperty("cm_ca.props.perm_type",null); Mockito.doReturn("test").when(env).getProperty("cm_ca.props.baseSubject",null); diff --git a/auth/auth-core/src/main/java/org/onap/aaf/auth/server/AbsService.java b/auth/auth-core/src/main/java/org/onap/aaf/auth/server/AbsService.java index 9ece4847..e2317a52 100644 --- a/auth/auth-core/src/main/java/org/onap/aaf/auth/server/AbsService.java +++ b/auth/auth-core/src/main/java/org/onap/aaf/auth/server/AbsService.java @@ -62,10 +62,10 @@ public abstract class AbsService exte this.access = access; this.env = env; - String str = access.getProperty(Config.AAF_LOCATOR_NAMES, null); + String str = access.getProperty(Config.AAF_LOCATOR_ENTRIES, null); String[] scomp = Split.splitTrim(',', str); if(scomp.length==0) { - throw new CadiException(Config.AAF_LOCATOR_NAMES + " must be defined."); + throw new CadiException(Config.AAF_LOCATOR_ENTRIES + " must be defined."); } else { str = ROOT_NS + '.' + scomp[0]; } diff --git a/auth/auth-core/src/main/java/org/onap/aaf/auth/server/JettyServiceStarter.java b/auth/auth-core/src/main/java/org/onap/aaf/auth/server/JettyServiceStarter.java index d29b8f26..413b7919 100644 --- a/auth/auth-core/src/main/java/org/onap/aaf/auth/server/JettyServiceStarter.java +++ b/auth/auth-core/src/main/java/org/onap/aaf/auth/server/JettyServiceStarter.java @@ -130,7 +130,7 @@ public class JettyServiceStarter ex throw new CadiException("No Truststore Password configured for " + truststore); } sslContextFactory.setTrustStorePath(truststore); - sslContextFactory.setTrustStorePassword(access().decrypt(truststorePassword, true)); + sslContextFactory.setTrustStorePassword(access().decrypt(truststorePassword, false)); } // Be able to accept only certain protocols, i.e. TLSv1.1+ String subprotocols = access().getProperty(Config.CADI_PROTOCOLS, SecurityInfo.HTTPS_PROTOCOLS_DEFAULT); diff --git a/auth/auth-core/src/main/java/org/onap/aaf/auth/server/TestKill.java b/auth/auth-core/src/main/java/org/onap/aaf/auth/server/TestKill.java deleted file mode 100644 index 78172a22..00000000 --- a/auth/auth-core/src/main/java/org/onap/aaf/auth/server/TestKill.java +++ /dev/null @@ -1,65 +0,0 @@ -/** - * ============LICENSE_START==================================================== - * org.onap.aaf - * =========================================================================== - * Copyright (c) 2018 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==================================================== - */ - -package org.onap.aaf.auth.server; - -import java.io.IOException; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.Future; - -public class TestKill implements Runnable { - - public static void main(String[] args) { - ExecutorService es = Executors.newSingleThreadExecutor(); - TestKill tk = new TestKill(); - Future app = es.submit(tk); - Runtime.getRuntime().addShutdownHook(new Thread() { - @Override - public void run() { - System.out.println("Shutdown Hook, thread: setting interrupt"); - app.cancel(true); - tk.longProcess(); - es.shutdown(); - } - }); - System.out.println("Service Start"); - System.out.print("Hit to end:"); - try { - System.in.read(); - System.exit(0); - } catch (IOException e) { - } - } - - @Override - public void run() { - } - - private void longProcess() { - System.out.println("Starting long cleanup process"); - try { - Thread.sleep(10000); - } catch (InterruptedException e) { - e.printStackTrace(); - } - System.out.println("Ending long cleanup process"); - } -} diff --git a/auth/auth-core/src/test/java/org/onap/aaf/auth/server/test/JU_AbsService.java b/auth/auth-core/src/test/java/org/onap/aaf/auth/server/test/JU_AbsService.java index 65f019f0..b89e2e5d 100644 --- a/auth/auth-core/src/test/java/org/onap/aaf/auth/server/test/JU_AbsService.java +++ b/auth/auth-core/src/test/java/org/onap/aaf/auth/server/test/JU_AbsService.java @@ -103,7 +103,7 @@ public class JU_AbsService { BasicEnv bEnv = new BasicEnv(); PropAccess prop = new PropAccess(); - prop.setProperty(Config.AAF_LOCATOR_NAMES, "te.st"); + prop.setProperty(Config.AAF_LOCATOR_ENTRIES, "te.st"); prop.setProperty(Config.AAF_LOCATOR_VERSION, "te.st"); prop.setLogLevel(Level.DEBUG); AbsServiceStub absServiceStub = new AbsServiceStub(prop, bEnv); //Testing other branches requires "fails" due to exception handling, will leave that off for now. diff --git a/auth/auth-core/src/test/java/org/onap/aaf/auth/server/test/JU_AbsServiceStarter.java b/auth/auth-core/src/test/java/org/onap/aaf/auth/server/test/JU_AbsServiceStarter.java index 1fe98d84..2fa9e123 100644 --- a/auth/auth-core/src/test/java/org/onap/aaf/auth/server/test/JU_AbsServiceStarter.java +++ b/auth/auth-core/src/test/java/org/onap/aaf/auth/server/test/JU_AbsServiceStarter.java @@ -131,7 +131,7 @@ public class JU_AbsServiceStarter { BasicEnv bEnv = new BasicEnv(); PropAccess prop = new PropAccess(); - prop.setProperty(Config.AAF_LOCATOR_NAMES, "te.st"); + prop.setProperty(Config.AAF_LOCATOR_ENTRIES, "te.st"); prop.setProperty(Config.AAF_LOCATOR_VERSION, "te.st"); prop.setLogLevel(Level.DEBUG); absServiceStub = new AbsServiceStub(prop, bEnv); diff --git a/auth/auth-core/src/test/java/org/onap/aaf/auth/util/test/TestKill.java b/auth/auth-core/src/test/java/org/onap/aaf/auth/util/test/TestKill.java new file mode 100644 index 00000000..c6ddc79f --- /dev/null +++ b/auth/auth-core/src/test/java/org/onap/aaf/auth/util/test/TestKill.java @@ -0,0 +1,65 @@ +/** + * ============LICENSE_START==================================================== + * org.onap.aaf + * =========================================================================== + * Copyright (c) 2018 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==================================================== + */ + +package org.onap.aaf.auth.util.test; + +import java.io.IOException; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.Future; + +public class TestKill implements Runnable { + + public static void main(String[] args) { + ExecutorService es = Executors.newSingleThreadExecutor(); + TestKill tk = new TestKill(); + Future app = es.submit(tk); + Runtime.getRuntime().addShutdownHook(new Thread() { + @Override + public void run() { + System.out.println("Shutdown Hook, thread: setting interrupt"); + app.cancel(true); + tk.longProcess(); + es.shutdown(); + } + }); + System.out.println("Service Start"); + System.out.print("Hit to end:"); + try { + System.in.read(); + System.exit(0); + } catch (IOException e) { + } + } + + @Override + public void run() { + } + + private void longProcess() { + System.out.println("Starting long cleanup process"); + try { + Thread.sleep(10000); + } catch (InterruptedException e) { + e.printStackTrace(); + } + System.out.println("Ending long cleanup process"); + } +} diff --git a/auth/auth-fs/src/test/java/org/onap/aaf/auth/fs/test/JU_AAF_FS.java b/auth/auth-fs/src/test/java/org/onap/aaf/auth/fs/test/JU_AAF_FS.java index e7e5543a..c390afd5 100644 --- a/auth/auth-fs/src/test/java/org/onap/aaf/auth/fs/test/JU_AAF_FS.java +++ b/auth/auth-fs/src/test/java/org/onap/aaf/auth/fs/test/JU_AAF_FS.java @@ -73,7 +73,7 @@ public class JU_AAF_FS { aEnv = new AuthzEnv(); aEnv.staticSlot("test"); aEnv.access().setProperty("aaf_public_dir", "test"); - aEnv.access().setProperty(Config.AAF_LOCATOR_NAMES, "aaf_com"); + aEnv.access().setProperty(Config.AAF_LOCATOR_ENTRIES, "aaf_com"); aEnv.access().setProperty(Config.AAF_LOCATOR_VERSION, "1.1"); Server serverMock = mock(Server.class); JettyServiceStarter jssMock = mock(JettyServiceStarter.class); diff --git a/auth/docker/dbuild.sh b/auth/docker/dbuild.sh index 4eb349b9..924feea0 100755 --- a/auth/docker/dbuild.sh +++ b/auth/docker/dbuild.sh @@ -32,9 +32,9 @@ DOCKER=${DOCKER:=docker} echo "Building Containers for aaf components, version $VERSION" # AAF_cass now needs a version... -#cd ../auth-cass/docker -#bash ./dbuild.sh -#cd - +cd ../auth-cass/docker +bash ./dbuild.sh +cd - # AAF Base version - set the core image, etc sed -e 's/${AAF_VERSION}/'${VERSION}'/g' \ @@ -57,7 +57,7 @@ sed -e 's/${AAF_VERSION}/'${VERSION}'/g' \ docker/Dockerfile.config > sample/Dockerfile $DOCKER build -t ${ORG}/${PROJECT}/aaf_config:${VERSION} sample $DOCKER tag ${ORG}/${PROJECT}/aaf_config:${VERSION} ${DOCKER_REPOSITORY}/${ORG}/${PROJECT}/aaf_config:${VERSION} -$DOCKER tag ${ORG}/${PROJECT}/aaf_config:${VERSION} ${DOCKER_REPOSITORY}/${ORG}/${PROJECT}/latest +$DOCKER tag ${ORG}/${PROJECT}/aaf_config:${VERSION} ${DOCKER_REPOSITORY}/${ORG}/${PROJECT}/aaf_config:latest cp ../cadi/servlet-sample/target/aaf-cadi-servlet-sample-${VERSION}-sample.jar sample/bin # AAF Agent Image (for Clients) diff --git a/auth/docker/dclean.sh b/auth/docker/dclean.sh index 38ce5189..4fb4e07a 100644 --- a/auth/docker/dclean.sh +++ b/auth/docker/dclean.sh @@ -23,7 +23,7 @@ DOCKER=${DOCKER:=docker} if [ "$1" == "" ]; then - AAF_COMPONENTS="$(cat components) config core agent" + AAF_COMPONENTS="$(cat components) config core agent " else AAF_COMPONENTS="$@" fi diff --git a/auth/docker/drun.sh b/auth/docker/drun.sh index cdd8b3c4..32660760 100644 --- a/auth/docker/drun.sh +++ b/auth/docker/drun.sh @@ -71,7 +71,7 @@ for AAF_COMPONENT in ${AAF_COMPONENTS}; do ;; "fs") PUBLISH="--publish 80:8096" - LINKS="" + LINKS="--link aaf-locate" CMD_LINE="cd /opt/app/aaf && /bin/bash bin/pod_wait.sh aaf-fs aaf-locate && exec bin/fs" ;; "hello") diff --git a/auth/docker/dstop.sh b/auth/docker/dstop.sh index 4d302bd1..256385d5 100644 --- a/auth/docker/dstop.sh +++ b/auth/docker/dstop.sh @@ -23,7 +23,7 @@ DOCKER=${DOCKER:=docker} if [ "$1" == "" ]; then - AAF_COMPONENTS=$(cat components) + AAF_COMPONENTS=$(tail -r components) else AAF_COMPONENTS="$@" fi diff --git a/auth/helm/aaf/Chart.yaml b/auth/helm/aaf/Chart.yaml index 62e3f5e8..9582a394 100644 --- a/auth/helm/aaf/Chart.yaml +++ b/auth/helm/aaf/Chart.yaml @@ -22,4 +22,4 @@ apiVersion: v1 appVersion: "1.0" description: AAF Helm Chart name: aaf -version: 2.1.7-SNAPSHOT +version: 2.1.10-SNAPSHOT diff --git a/auth/helm/aaf/templates/aaf-cass.yaml b/auth/helm/aaf/templates/aaf-cass.yaml index f9c31fc1..5d4354b6 100644 --- a/auth/helm/aaf/templates/aaf-cass.yaml +++ b/auth/helm/aaf/templates/aaf-cass.yaml @@ -22,6 +22,8 @@ kind: Service apiVersion: v1 metadata: name: aaf-cass + labels: + app: aaf-cass spec: selector: app: aaf-cass @@ -59,6 +61,9 @@ spec: - name: {{ .Chart.Name }}-cass-vol persistentVolumeClaim: claimName: {{ .Chart.Name }}-cass-pvc + - name: {{ .Chart.Name }}-status-vol + persistentVolumeClaim: + claimName: {{ .Chart.Name }}-status-pvc containers: ### ### AAF-CASS @@ -69,8 +74,10 @@ spec: # installing with cmd "onap" will not only initialize the DB, but add ONAP bootstrap data as well command: ["/bin/bash","/opt/app/aaf/cass_init/cmd.sh","onap"] volumeMounts: - - mountPath: "/var/lib/cassandra" - name: {{ .Chart.Name }}-cass-vol + - mountPath: "/var/lib/cassandra" + name: {{ .Chart.Name }}-cass-vol + - mountPath: "/opt/app/aaf/status" + name: {{ .Chart.Name }}-status-vol ports: - name: storage containerPort: 7000 @@ -89,3 +96,15 @@ spec: value: "512M" - name: MAX_HEAP_SIZE value: "1024M" + - name: MY_POD_NAME + valueFrom: + fieldRef: + fieldPath: metadata.name + - name: MY_POD_NAMESPACE + valueFrom: + fieldRef: + fieldPath: metadata.namespace + - name: MY_POD_IP + valueFrom: + fieldRef: + fieldPath: status.podIP diff --git a/auth/helm/aaf/templates/aaf-cm.yaml b/auth/helm/aaf/templates/aaf-cm.yaml index fbac3882..f58d81b1 100644 --- a/auth/helm/aaf/templates/aaf-cm.yaml +++ b/auth/helm/aaf/templates/aaf-cm.yaml @@ -32,7 +32,7 @@ spec: - name: aaf-cm protocol: TCP port: 8150 - NodePort: 30084 + nodePort: 30084 --- apiVersion: apps/v1 kind: Deployment @@ -53,27 +53,44 @@ spec: volumes: # Use this Pod Sharing dir to declare various States of starting - name: {{ .Chart.Name }}-config-vol - emptyDir: {} + persistentVolumeClaim: + claimName: {{ .Chart.Name }}-config-pvc + - name: {{ .Chart.Name }}-status-vol + persistentVolumeClaim: + claimName: {{ .Chart.Name }}-status-pvc initContainers: - name: {{ .Chart.Name }}-config-container image: {{ .Values.image.repository }}onap/aaf/aaf_config:{{ .Values.image.version }} imagePullPolicy: IfNotPresent + command: ["bash","/opt/app/aaf_config/bin/agent.sh"] volumeMounts: - mountPath: "/opt/app/osaaf" name: {{ .Chart.Name }}-config-vol env: - name: AAF_ENV value: "{{ .Values.cadi.aaf_env }}" - - name: AAF_REGISTER_AS - value: "aaf-cm" - - name: AAF_LOCATOR_AS - value: "{{ .Values.cadi.aaf_locate_as }}" - name: LATITUDE value: "{{ .Values.cadi.cadi_latitude }}" - name: LONGITUDE value: "{{ .Values.cadi.cadi_longitude }}" - - name: CASS_HOST + - name: aaf_locator_container + value: "helm" + - name: aaf_locator_container_ns + valueFrom: + fieldRef: + fieldPath: metadata.namespace + - name: aaf_locate_url + value: "https://aaf-locate.onap:8095" + - name: aaf_locator_public_hostname + value: "aaf.osaaf.org" + - name: CASSANDRA_CLUSTER value: "aaf-cass" +# - name: CASSANDRA_USER +# value: "" +# - name: CASSANDRA_PASSWORD +# value: "" +# - name: CASSANDRA_PORT +# value: "" containers: ### ### AAF-CERTMAN @@ -81,11 +98,18 @@ spec: - name: {{ .Chart.Name }}-cm image: {{ .Values.image.repository }}onap/aaf/aaf_cm:{{ .Values.image.version }} imagePullPolicy: IfNotPresent - command: ["/bin/bash","/opt/app/aaf/pod/pod_wait.sh","aaf_cm","sleep","45", "cd /opt/app/aaf;bin/cm"] + command: ["/bin/bash","-c","cd /opt/app/aaf && /bin/bash bin/pod_wait.sh aaf-cm aaf-locate && exec bin/cm"] volumeMounts: - - mountPath: "/opt/app/osaaf" - name: {{ .Chart.Name }}-config-vol + - mountPath: "/opt/app/osaaf" + name: {{ .Chart.Name }}-config-vol + - mountPath: "/opt/app/aaf/status" + name: {{ .Chart.Name }}-status-vol ports: - name: aaf-cm protocol: TCP containerPort: 8150 + env: + - name: aaf_locator_ns + valueFrom: + fieldRef: + fieldPath: metadata.namespace diff --git a/auth/helm/aaf/templates/aaf-fs.yaml b/auth/helm/aaf/templates/aaf-fs.yaml index b38257f1..746bd5b7 100644 --- a/auth/helm/aaf/templates/aaf-fs.yaml +++ b/auth/helm/aaf/templates/aaf-fs.yaml @@ -32,7 +32,7 @@ spec: - name: aaf-fs protocol: TCP port: 8096 - NodePort: 30085 + nodePort: 30085 --- apiVersion: apps/v1 kind: Deployment @@ -53,27 +53,42 @@ spec: volumes: # Use this Pod Sharing dir to declare various States of starting - name: {{ .Chart.Name }}-config-vol - emptyDir: {} + persistentVolumeClaim: + claimName: {{ .Chart.Name }}-config-pvc + - name: {{ .Chart.Name }}-status-vol + persistentVolumeClaim: + claimName: {{ .Chart.Name }}-status-pvc initContainers: - name: {{ .Chart.Name }}-config-container image: {{ .Values.image.repository }}onap/aaf/aaf_config:{{ .Values.image.version }} imagePullPolicy: IfNotPresent + command: ["bash","/opt/app/aaf_config/bin/agent.sh"] volumeMounts: - mountPath: "/opt/app/osaaf" name: {{ .Chart.Name }}-config-vol env: - name: AAF_ENV value: "{{ .Values.cadi.aaf_env }}" - - name: AAF_REGISTER_AS - value: "aaf-fs" - - name: AAF_LOCATOR_AS - value: "{{ .Values.cadi.aaf_locate_as }}" - name: LATITUDE value: "{{ .Values.cadi.cadi_latitude }}" - name: LONGITUDE value: "{{ .Values.cadi.cadi_longitude }}" - - name: CASS_HOST + - name: aaf_locator_container + value: "helm" + - name: aaf_locator_fqdn + valueFrom: + fieldRef: + fieldPath: status.podIP + - name: aaf_locate_url + value: "https://aaf-locate:8095" + - name: CASSANDRA_CLUSTER value: "aaf-cass" +# - name: CASSANDRA_USER +# value: "" +# - name: CASSANDRA_PASSWORD +# value: "" +# - name: CASSANDRA_PORT +# value: "" containers: ### ### AAF-FS @@ -81,11 +96,25 @@ spec: - name: {{ .Chart.Name }}-fs image: {{ .Values.image.repository }}onap/aaf/aaf_fs:{{ .Values.image.version }} imagePullPolicy: IfNotPresent - command: ["/bin/bash","/opt/app/aaf/pod/pod_wait.sh","aaf_fs","sleep","50", "cd /opt/app/aaf;bin/fs"] + command: ["/bin/bash","-c","cd /opt/app/aaf && /bin/bash bin/pod_wait.sh aaf-fs aaf-locate && exec bin/fs"] volumeMounts: - - mountPath: "/opt/app/osaaf" - name: {{ .Chart.Name }}-config-vol + - mountPath: "/opt/app/osaaf" + name: {{ .Chart.Name }}-config-vol + - mountPath: "/opt/app/aaf/status" + name: {{ .Chart.Name }}-status-vol ports: - name: aaf-fs protocol: TCP containerPort: 8096 + env: + - name: aaf_locator_container + value: "helm" + - name: aaf_locator_container_ns + valueFrom: + fieldRef: + fieldPath: metadata.namespace + - name: aaf_locate_url + value: "https://aaf-locate.onap:8095" + - name: aaf_locator_public_hostname + value: "aaf.osaaf.org" + diff --git a/auth/helm/aaf/templates/aaf-gui.yaml b/auth/helm/aaf/templates/aaf-gui.yaml index a8dd6d38..526616c1 100644 --- a/auth/helm/aaf/templates/aaf-gui.yaml +++ b/auth/helm/aaf/templates/aaf-gui.yaml @@ -32,7 +32,7 @@ spec: - name: aaf-gui protocol: TCP port: 8200 - NodePort: 30083 + nodePort: 30083 --- apiVersion: apps/v1 kind: Deployment @@ -53,27 +53,44 @@ spec: volumes: # Use this Pod Sharing dir to declare various States of starting - name: {{ .Chart.Name }}-config-vol - emptyDir: {} + persistentVolumeClaim: + claimName: {{ .Chart.Name }}-config-pvc + - name: {{ .Chart.Name }}-status-vol + persistentVolumeClaim: + claimName: {{ .Chart.Name }}-status-pvc initContainers: - name: {{ .Chart.Name }}-config-container image: {{ .Values.image.repository }}onap/aaf/aaf_config:{{ .Values.image.version }} imagePullPolicy: IfNotPresent + command: ["bash","/opt/app/aaf_config/bin/agent.sh"] volumeMounts: - mountPath: "/opt/app/osaaf" name: {{ .Chart.Name }}-config-vol env: - name: AAF_ENV value: "{{ .Values.cadi.aaf_env }}" - - name: AAF_REGISTER_AS - value: "aaf-gui" - - name: AAF_LOCATOR_AS - value: "{{ .Values.cadi.aaf_locate_as }}" - name: LATITUDE value: "{{ .Values.cadi.cadi_latitude }}" - name: LONGITUDE value: "{{ .Values.cadi.cadi_longitude }}" - - name: CASS_HOST + - name: aaf_locator_container + value: "helm" + - name: aaf_locator_container_ns + valueFrom: + fieldRef: + fieldPath: metadata.namespace + - name: aaf_locate_url + value: "https://aaf-locate.onap:8095" + - name: aaf_locator_public_hostname + value: "aaf.osaaf.org" + - name: CASSANDRA_CLUSTER value: "aaf-cass" +# - name: CASSANDRA_USER +# value: "" +# - name: CASSANDRA_PASSWORD +# value: "" +# - name: CASSANDRA_PORT +# value: "" containers: ### ### AAF-GUI @@ -81,11 +98,15 @@ spec: - name: {{ .Chart.Name }}-gui image: {{ .Values.image.repository }}onap/aaf/aaf_gui:{{ .Values.image.version }} imagePullPolicy: IfNotPresent - command: ["/bin/bash","/opt/app/aaf/pod/pod_wait.sh","aaf_gui","sleep","50", "cd /opt/app/aaf;bin/gui"] + command: ["/bin/bash","-c","cd /opt/app/aaf && /bin/bash bin/pod_wait.sh aaf-gui aaf-locate && exec bin/gui"] volumeMounts: - - mountPath: "/opt/app/osaaf" - name: {{ .Chart.Name }}-config-vol + - mountPath: "/opt/app/osaaf" + name: {{ .Chart.Name }}-config-vol + - mountPath: "/opt/app/aaf/status" + name: {{ .Chart.Name }}-status-vol ports: - name: aaf-gui protocol: TCP containerPort: 8200 + + diff --git a/auth/helm/aaf/templates/aaf-hello.yaml b/auth/helm/aaf/templates/aaf-hello.yaml index 05e361ef..2b605724 100644 --- a/auth/helm/aaf/templates/aaf-hello.yaml +++ b/auth/helm/aaf/templates/aaf-hello.yaml @@ -32,7 +32,7 @@ spec: - name: aaf-hello protocol: TCP port: 8130 - NodePort: 30086 + nodePort: 30086 --- apiVersion: apps/v1 kind: Deployment @@ -41,7 +41,7 @@ metadata: labels: app: aaf-hello spec: - replicas: 1 + replicas: 0 selector: matchLabels: app: aaf-hello @@ -53,27 +53,42 @@ spec: volumes: # Use this Pod Sharing dir to declare various States of starting - name: {{ .Chart.Name }}-config-vol - emptyDir: {} + persistentVolumeClaim: + claimName: {{ .Chart.Name }}-config-pvc + - name: {{ .Chart.Name }}-status-vol + persistentVolumeClaim: + claimName: {{ .Chart.Name }}-status-pvc initContainers: - name: {{ .Chart.Name }}-config-container image: {{ .Values.image.repository }}onap/aaf/aaf_config:{{ .Values.image.version }} imagePullPolicy: IfNotPresent + command: ["bash","/opt/app/aaf_config/bin/agent.sh"] volumeMounts: - mountPath: "/opt/app/osaaf" name: {{ .Chart.Name }}-config-vol env: - name: AAF_ENV value: "{{ .Values.cadi.aaf_env }}" - - name: AAF_REGISTER_AS - value: "aaf-hello" - - name: AAF_LOCATOR_AS - value: "{{ .Values.cadi.aaf_locate_as }}" - name: LATITUDE value: "{{ .Values.cadi.cadi_latitude }}" - name: LONGITUDE value: "{{ .Values.cadi.cadi_longitude }}" - - name: CASS_HOST - value: "aaf-cass" + - name: aaf_locator_container + value: "helm" + - name: aaf_locator_container_ns + valueFrom: + fieldRef: + fieldPath: metadata.namespace + - name: aaf_locate_url + value: "https://aaf-locate.onap:8095" + - name: aaf_locator_public_hostname + value: "aaf.osaaf.org" +# - name: CASSANDRA_USER +# value: "" +# - name: CASSANDRA_PASSWORD +# value: "" +# - name: CASSANDRA_PORT +# value: "" containers: ### ### AAF-HELLO @@ -81,11 +96,19 @@ spec: - name: {{ .Chart.Name }}-hello image: {{ .Values.image.repository }}onap/aaf/aaf_hello:{{ .Values.image.version }} imagePullPolicy: IfNotPresent - command: ["/bin/bash","/opt/app/aaf/pod/pod_wait.sh","aaf_hello","sleep","50", "cd /opt/app/aaf;bin/hello"] + command: ["/bin/bash","-c","cd /opt/app/aaf && /bin/bash bin/pod_wait.sh aaf-hello aaf-locate && exec bin/hello"] volumeMounts: - - mountPath: "/opt/app/osaaf" - name: {{ .Chart.Name }}-config-vol + - mountPath: "/opt/app/osaaf" + name: {{ .Chart.Name }}-config-vol + - mountPath: "/opt/app/aaf/status" + name: {{ .Chart.Name }}-status-vol ports: - name: aaf-hello protocol: TCP containerPort: 8130 + env: + - name: aaf_locator_ns + valueFrom: + fieldRef: + fieldPath: metadata.namespace + diff --git a/auth/helm/aaf/templates/aaf-locate.yaml b/auth/helm/aaf/templates/aaf-locate.yaml index 9bf1e8ad..7bb9135b 100644 --- a/auth/helm/aaf/templates/aaf-locate.yaml +++ b/auth/helm/aaf/templates/aaf-locate.yaml @@ -32,7 +32,7 @@ spec: - name: aaf-locate protocol: TCP port: 8095 - NodePort: 30081 + nodePort: 30081 --- apiVersion: apps/v1 kind: Deployment @@ -53,27 +53,44 @@ spec: volumes: # Use this Pod Sharing dir to declare various States of starting - name: {{ .Chart.Name }}-config-vol - emptyDir: {} + persistentVolumeClaim: + claimName: {{ .Chart.Name }}-config-pvc + - name: {{ .Chart.Name }}-status-vol + persistentVolumeClaim: + claimName: {{ .Chart.Name }}-status-pvc initContainers: - name: {{ .Chart.Name }}-config-container image: {{ .Values.image.repository }}onap/aaf/aaf_config:{{ .Values.image.version }} imagePullPolicy: IfNotPresent + command: ["bash","/opt/app/aaf_config/bin/agent.sh"] volumeMounts: - mountPath: "/opt/app/osaaf" name: {{ .Chart.Name }}-config-vol env: - name: AAF_ENV value: "{{ .Values.cadi.aaf_env }}" - - name: AAF_REGISTER_AS - value: "aaf-locate" - - name: AAF_LOCATOR_AS - value: "{{ .Values.cadi.aaf_locate_as }}" - name: LATITUDE value: "{{ .Values.cadi.cadi_latitude }}" - name: LONGITUDE value: "{{ .Values.cadi.cadi_longitude }}" - - name: CASS_HOST + - name: aaf_locator_container + value: "helm" + - name: aaf_locator_container_ns + valueFrom: + fieldRef: + fieldPath: metadata.namespace + - name: aaf_locate_url + value: "https://aaf-locate.onap:8095" + - name: aaf_locator_public_hostname + value: "aaf.osaaf.org" + - name: CASSANDRA_CLUSTER value: "aaf-cass" +# - name: CASSANDRA_USER +# value: "" +# - name: CASSANDRA_PASSWORD +# value: "" +# - name: CASSANDRA_PORT +# value: ""jjjjn containers: ### ### AAF-LOCATE @@ -81,11 +98,19 @@ spec: - name: {{ .Chart.Name }}-locate image: {{ .Values.image.repository }}onap/aaf/aaf_locate:{{ .Values.image.version }} imagePullPolicy: IfNotPresent - command: ["/bin/bash","/opt/app/aaf/pod/pod_wait.sh","aaf_locate","sleep","50", "cd /opt/app/aaf;bin/locate"] + command: ["/bin/bash","-c","cd /opt/app/aaf && /bin/bash bin/pod_wait.sh aaf-locate aaf-service && exec bin/locate"] volumeMounts: - - mountPath: "/opt/app/osaaf" - name: {{ .Chart.Name }}-config-vol + - mountPath: "/opt/app/osaaf" + name: {{ .Chart.Name }}-config-vol + - mountPath: "/opt/app/aaf/status" + name: {{ .Chart.Name }}-status-vol ports: - name: aaf-locate protocol: TCP containerPort: 8095 + env: + - name: aaf_locator_ns + valueFrom: + fieldRef: + fieldPath: metadata.namespace + diff --git a/auth/helm/aaf/templates/aaf-oauth.yaml b/auth/helm/aaf/templates/aaf-oauth.yaml index f5e5e20e..f59a7d24 100644 --- a/auth/helm/aaf/templates/aaf-oauth.yaml +++ b/auth/helm/aaf/templates/aaf-oauth.yaml @@ -32,7 +32,7 @@ spec: - name: aaf-oauth protocol: TCP port: 8140 - NodePort: 30082 + nodePort: 30082 --- apiVersion: apps/v1 kind: Deployment @@ -41,7 +41,7 @@ metadata: labels: app: aaf-oauth spec: - replicas: 2 + replicas: 1 selector: matchLabels: app: aaf-oauth @@ -53,27 +53,44 @@ spec: volumes: # Use this Pod Sharing dir to declare various States of starting - name: {{ .Chart.Name }}-config-vol - emptyDir: {} + persistentVolumeClaim: + claimName: {{ .Chart.Name }}-config-pvc + - name: {{ .Chart.Name }}-status-vol + persistentVolumeClaim: + claimName: {{ .Chart.Name }}-status-pvc initContainers: - name: {{ .Chart.Name }}-config-container image: {{ .Values.image.repository }}onap/aaf/aaf_config:{{ .Values.image.version }} imagePullPolicy: IfNotPresent + command: ["bash","/opt/app/aaf_config/bin/agent.sh"] volumeMounts: - mountPath: "/opt/app/osaaf" name: {{ .Chart.Name }}-config-vol env: - name: AAF_ENV value: "{{ .Values.cadi.aaf_env }}" - - name: AAF_REGISTER_AS - value: "aaf-oauth" - - name: AAF_LOCATOR_AS - value: "{{ .Values.cadi.aaf_locate_as }}" - name: LATITUDE value: "{{ .Values.cadi.cadi_latitude }}" - name: LONGITUDE value: "{{ .Values.cadi.cadi_longitude }}" - - name: CASS_HOST + - name: aaf_locator_container + value: "helm" + - name: aaf_locator_container_ns + valueFrom: + fieldRef: + fieldPath: metadata.namespace + - name: aaf_locate_url + value: "https://aaf-locate.onap:8095" + - name: aaf_locator_public_hostname + value: "aaf.osaaf.org" + - name: CASSANDRA_CLUSTER value: "aaf-cass" +# - name: CASSANDRA_USER +# value: "" +# - name: CASSANDRA_PASSWORD +# value: "" +# - name: CASSANDRA_PORT +# value: "" containers: ### ### AAF-OAUTH @@ -81,11 +98,18 @@ spec: - name: {{ .Chart.Name }}-oauth image: {{ .Values.image.repository }}onap/aaf/aaf_oauth:{{ .Values.image.version }} imagePullPolicy: IfNotPresent - command: ["/bin/bash","/opt/app/aaf/pod/pod_wait.sh","aaf_oauth","sleep","50", "cd /opt/app/aaf;bin/oauth"] + command: ["/bin/bash","-c","cd /opt/app/aaf && /bin/bash bin/pod_wait.sh aaf-oauth aaf-service && exec bin/oauth"] volumeMounts: - - mountPath: "/opt/app/osaaf" - name: {{ .Chart.Name }}-config-vol + - mountPath: "/opt/app/osaaf" + name: {{ .Chart.Name }}-config-vol + - mountPath: "/opt/app/aaf/status" + name: {{ .Chart.Name }}-status-vol ports: - name: aaf-oauth protocol: TCP containerPort: 8140 + env: + - name: aaf_locator_ns + valueFrom: + fieldRef: + fieldPath: metadata.namespace diff --git a/auth/helm/aaf/templates/aaf-service.yaml b/auth/helm/aaf/templates/aaf-service.yaml index a91929e9..117a0753 100644 --- a/auth/helm/aaf/templates/aaf-service.yaml +++ b/auth/helm/aaf/templates/aaf-service.yaml @@ -25,14 +25,15 @@ apiVersion: v1 metadata: name: aaf-service spec: + type: NodePort selector: app: aaf-service - type: NodePort ports: - name: aaf-service protocol: TCP + nodePort: 30080 port: 8100 - NodePort: 30080 + targetPort: 8100 --- apiVersion: apps/v1 kind: Deployment @@ -53,29 +54,43 @@ spec: volumes: - name: {{ .Chart.Name }}-config-vol persistentVolumeClaim: - claimName: {{ .Chart.Name }}-config-pvc - #- name: {{ .Chart.Name }}-config-vol - # emptyDir: {} + claimName: {{ .Chart.Name }}-config-pvc + - name: {{ .Chart.Name }}-status-vol + persistentVolumeClaim: + claimName: {{ .Chart.Name }}-status-pvc initContainers: - name: {{ .Chart.Name }}-config-container image: {{ .Values.image.repository }}onap/aaf/aaf_config:{{ .Values.image.version }} imagePullPolicy: IfNotPresent + command: ["bash","/opt/app/aaf_config/bin/agent.sh"] volumeMounts: - mountPath: "/opt/app/osaaf" name: {{ .Chart.Name }}-config-vol env: - name: AAF_ENV value: "{{ .Values.cadi.aaf_env }}" - - name: AAF_REGISTER_AS - value: "aaf-service" - - name: AAF_LOCATOR_AS - value: "{{ .Values.cadi.aaf_locate_as }}" - name: LATITUDE value: "{{ .Values.cadi.cadi_latitude }}" - name: LONGITUDE value: "{{ .Values.cadi.cadi_longitude }}" - - name: CASS_HOST + - name: aaf_locator_container + value: "helm" + - name: aaf_locator_container_ns + valueFrom: + fieldRef: + fieldPath: metadata.namespace + - name: aaf_locate_url + value: "https://aaf-locate.onap:8095" + - name: aaf_locator_public_hostname + value: "aaf.osaaf.org" + - name: CASSANDRA_CLUSTER value: "aaf-cass" +# - name: CASSANDRA_USER +# value: "" +# - name: CASSANDRA_PASSWORD +# value: "" +# - name: CASSANDRA_PORT +# value: "" containers: ### ### AAF-SERVICE @@ -83,11 +98,14 @@ spec: - name: {{ .Chart.Name }}-service image: {{ .Values.image.repository }}onap/aaf/aaf_service:{{ .Values.image.version }} imagePullPolicy: IfNotPresent - command: ["/bin/bash","/opt/app/aaf/pod/pod_wait.sh","aaf_service","sleep","50", "cd /opt/app/aaf;bin/service"] + command: ["/bin/bash","-c","cd /opt/app/aaf && /bin/bash bin/pod_wait.sh aaf-service aaf-cass && exec bin/service"] volumeMounts: - - mountPath: "/opt/app/osaaf" - name: {{ .Chart.Name }}-config-vol + - mountPath: "/opt/app/osaaf" + name: {{ .Chart.Name }}-config-vol + - mountPath: "/opt/app/aaf/status" + name: {{ .Chart.Name }}-status-vol ports: - name: service protocol: TCP containerPort: 8100 + diff --git a/auth/helm/aaf/values.yaml b/auth/helm/aaf/values.yaml index 236a3e0e..9e344dfa 100644 --- a/auth/helm/aaf/values.yaml +++ b/auth/helm/aaf/values.yaml @@ -28,7 +28,7 @@ global: persistence: enabled: true common: - namespace: onap + namespace: "onap" ingress: enabled: false @@ -38,8 +38,6 @@ cadi: cadi_latitude: "38.0" cadi_longitude: "-72.0" aaf_env: "DEV" - aaf_register_as: "aaf.onap" - aaf_locate_as: "aaf-locate" persistence: # Note: Minikube will persist to /data on your host machine @@ -69,7 +67,7 @@ image: # When using Docker Repo, add, and include trailing "/" # repository: nexus3.onap.org:10003/ # repository: localhost:5000/ - version: 2.1.8-SNAPSHOT + version: 2.1.10-SNAPSHOT resources: {} # We usually recommend not to specify default resources and to leave this as a conscious diff --git a/auth/sample/bin/service.sh b/auth/sample/bin/service.sh index 20be29c4..75d658d1 100644 --- a/auth/sample/bin/service.sh +++ b/auth/sample/bin/service.sh @@ -36,6 +36,9 @@ JAVA_AAFCLI="$JAVA -cp $CONFIG/bin/aaf-auth-cmd-*-full.jar -Dcadi_prop_files=$LO # If doesn't exist... still create mkdir -p $OSAAF +# If not created by separate PV, create +mkdir -p /opt/app/aaf/status + # Temp use for clarity of code FILE= diff --git a/auth/sample/etc/org.osaaf.aaf.cm.props b/auth/sample/etc/org.osaaf.aaf.cm.props index dc43c282..9781ea42 100644 --- a/auth/sample/etc/org.osaaf.aaf.cm.props +++ b/auth/sample/etc/org.osaaf.aaf.cm.props @@ -23,7 +23,7 @@ ## Note: Link to CA Properties in "local" dir ## 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:/opt/app/osaaf/etc/org.osaaf.aaf.orgs.props:/opt/app/osaaf/local/org.osaaf.aaf.cm.ca.props -aaf_locator_names=cm +aaf_locator_entries=cm port=8100 aaf_locator_public_port.helm=30084 # aaf_locator_public_port.oom= diff --git a/auth/sample/etc/org.osaaf.aaf.fs.props b/auth/sample/etc/org.osaaf.aaf.fs.props index 9de81af6..02dc0ac9 100644 --- a/auth/sample/etc/org.osaaf.aaf.fs.props +++ b/auth/sample/etc/org.osaaf.aaf.fs.props @@ -22,7 +22,7 @@ ## AAF Fileserver Properties ## cadi_prop_files=/opt/app/osaaf/local/org.osaaf.aaf.props:/opt/app/osaaf/etc/org.osaaf.aaf.log4j.props -aaf_locator_names=fs +aaf_locator_entries=fs port=8096 aaf_locator_port.helm=30085 # aaf_locator_port.oom= diff --git a/auth/sample/etc/org.osaaf.aaf.gui.props b/auth/sample/etc/org.osaaf.aaf.gui.props index 81d04ea0..b6e9072b 100644 --- a/auth/sample/etc/org.osaaf.aaf.gui.props +++ b/auth/sample/etc/org.osaaf.aaf.gui.props @@ -22,7 +22,7 @@ ## AAF GUI Properties ## cadi_prop_files=/opt/app/osaaf/local/org.osaaf.aaf.props:/opt/app/osaaf/etc/org.osaaf.aaf.log4j.props:/opt/app/osaaf/etc/org.osaaf.aaf.orgs.props -aaf_locator_names=gui +aaf_locator_entries=gui port=8200 aaf_locator_port.helm=30083 #aaf_locator_port.oom= diff --git a/auth/sample/etc/org.osaaf.aaf.hello.props b/auth/sample/etc/org.osaaf.aaf.hello.props index 5add3014..ea31b3a6 100644 --- a/auth/sample/etc/org.osaaf.aaf.hello.props +++ b/auth/sample/etc/org.osaaf.aaf.hello.props @@ -22,7 +22,7 @@ ## AAF Hello Properties ## cadi_prop_files=/opt/app/osaaf/local/org.osaaf.aaf.props:/opt/app/osaaf/etc/org.osaaf.aaf.log4j.props -aaf_locator_names=hello +aaf_locator_entries=hello port=8130 aaf_locator_public_port.helm=30086 #aaf_locator_public_port.oom= diff --git a/auth/sample/etc/org.osaaf.aaf.locate.props b/auth/sample/etc/org.osaaf.aaf.locate.props index 1b74f654..09798334 100644 --- a/auth/sample/etc/org.osaaf.aaf.locate.props +++ b/auth/sample/etc/org.osaaf.aaf.locate.props @@ -22,7 +22,7 @@ ## AAF Locator Properties ## cadi_prop_files=/opt/app/osaaf/local/org.osaaf.aaf.props:/opt/app/osaaf/etc/org.osaaf.aaf.log4j.props:/opt/app/osaaf/etc/org.osaaf.aaf.orgs.props:/opt/app/osaaf/local/org.osaaf.aaf.cassandra.props -aaf_locator_names=locator +aaf_locator_entries=locator port=8095 aaf_locator_public_port.helm=30081 #aaf_locator_public_port.oom= diff --git a/auth/sample/etc/org.osaaf.aaf.oauth.props b/auth/sample/etc/org.osaaf.aaf.oauth.props index a968b949..d9b17064 100644 --- a/auth/sample/etc/org.osaaf.aaf.oauth.props +++ b/auth/sample/etc/org.osaaf.aaf.oauth.props @@ -21,7 +21,7 @@ ## AAF OAuth2 Properties ## 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_names=oauth,token,introspect +aaf_locator_entries=oauth,token,introspect port=8140 aaf_locator_public_port.helm=30082 #aaf_locator_public_port.oom= diff --git a/auth/sample/etc/org.osaaf.aaf.service.props b/auth/sample/etc/org.osaaf.aaf.service.props index 5c9714c4..87924ba8 100644 --- a/auth/sample/etc/org.osaaf.aaf.service.props +++ b/auth/sample/etc/org.osaaf.aaf.service.props @@ -22,7 +22,7 @@ ## AAF Service Properties ## 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:/opt/app/osaaf/etc/org.osaaf.aaf.orgs.props -aaf_locator_names=service +aaf_locator_entries=service port=8100 aaf_locator_public_port.helm=30080 #aaf_locator_public_port.oom= diff --git a/auth/sample/local/aaf.props b/auth/sample/local/aaf.props index bae24d42..4eb70a9b 100644 --- a/auth/sample/local/aaf.props +++ b/auth/sample/local/aaf.props @@ -35,12 +35,6 @@ cadi_truststore=/opt/app/osaaf/public/truststoreONAPall.jks cadi_truststore_password=changeit cadi_x509_issuers= -# Locator info -aaf_locator_ns=AAF_NS -aaf_locator_fqdn.docker=aaf-%N -aaf_locator_fqdn.oom=%CNS.aaf-%N -aaf_locator_fqdn.helm=%CNS.aaf-%N - # Other aaf_data_dir=/opt/app/osaaf/data cadi_token_dir=/opt/app/osaaf/tokens diff --git a/auth/sample/local/initialConfig.props b/auth/sample/local/initialConfig.props index 9c7e3df0..91d5338f 100644 --- a/auth/sample/local/initialConfig.props +++ b/auth/sample/local/initialConfig.props @@ -19,10 +19,32 @@ # cadi_protocols=TLSv1.1,TLSv1.2 +################################ +# Locator info +# +# Sample versions for +# 1) no container +# 2) Docker +# 3) Helm (Kubernetes and Helm) +# 4) OOM (Kubernetes with OOM) +################################ +aaf_locator_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_fqdn.docker=aaf-%N +aaf_locator_fqdn.helm=aaf-%N.%CNS +aaf_locator_fqdn.oom=aaf-%N.%CNS + +################################ +# AAF URLs +################################ aaf_locate_url=https://localhost:8095 -aaf_url=https://AAF_LOCATE_URL/%C%AAF_NS.service:2.1 -aaf_oauth2_introspect_url=https://AAF_LOCATE_URL/%C%AAF_NS.introspect:2.1/introspect -aaf_oauth2_token_url=https://AAF_LOCATE_URL/%C%AAF_NS.token:2.1/token -cm_url=https://AAF_LOCATE_URL/%C%AAF_NS.cm:2.1 -gui_url=https://AAF_LOCATE_URL/%C%AAF_NS.gui.2.1 -fs_url=https://AAF_LOCATE_URL/%C%AAF_NS.fs.2.1 +aaf_url=https://AAF_LOCATE_URL/%C.%AAF_NS.service:2.1 +aaf_oauth2_introspect_url=https://AAF_LOCATE_URL/%C.%AAF_NS.oauth:2.1/introspect +aaf_oauth2_token_url=https://AAF_LOCATE_URL/%C.%AAF_NS.oauth:2.1/token +cm_url=https://AAF_LOCATE_URL/%C.%AAF_NS.cm:2.1 +gui_url=https://AAF_LOCATE_URL/%C.%AAF_NS.gui.2.1 +fs_url=https://AAF_LOCATE_URL/%C.%AAF_NS.fs.2.1 + diff --git a/auth/sample/logs/taillog b/auth/sample/logs/taillog index 5689caa4..77eb4581 100644 --- a/auth/sample/logs/taillog +++ b/auth/sample/logs/taillog @@ -1,3 +1,3 @@ #!/bin/bash cd /opt/app/osaaf/logs -tail -f `find ./$1 -name *service*.log -ctime 0` +tail -f `find ./$1 -name *service*.log -mtime 0` 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 30ea1c21..bf7ed6d9 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 @@ -46,6 +46,7 @@ import org.onap.aaf.cadi.config.SecurityInfoC; import org.onap.aaf.cadi.http.HBasicAuthSS; import org.onap.aaf.cadi.http.HClient; import org.onap.aaf.cadi.http.HX509SS; +import org.onap.aaf.cadi.locator.SingleEndpointLocator; import org.onap.aaf.cadi.oauth.HRenewingTokenSS; import org.onap.aaf.cadi.util.FixURIinfo; import org.onap.aaf.misc.env.APIException; @@ -80,45 +81,56 @@ public class TestConnectivity { List> lss = loadSetters(access,si); ///////// - print(true,"Test Connections driven by AAFLocator"); - URI serviceURI = uri(access,"service"); - - for (URI uri : new URI[] { - serviceURI, - uri(access,"token"), - uri(access,"introspect"), - uri(access,"cm"), - uri(access,"gui"), - uri(access,"fs"), - uri(access,"hello") - }) { - Locator locator = new AAFLocator(si, uri); - try { - connectTest(locator, uri); - } catch (Exception e) { - e.printStackTrace(); - System.err.flush(); - } - } - - ///////// - print(true,"Test Service for Perms driven by AAFLocator"); - Locator locator = new AAFLocator(si,serviceURI); - for (SecuritySetter ss : lss) { + String directAAFURL = access.getProperty(Config.AAF_URL,null); + if(directAAFURL!=null && !directAAFURL.contains("AAF_LOCATE")) { + print(true,"Test Connections by non-located aaf_url"); + Locator locator = new SingleEndpointLocator(directAAFURL); + connectTest(locator,new URI(directAAFURL)); + + SecuritySetter ss = si.defSS; permTest(locator,ss); - } + } else { + ///////// + print(true,"Test Connections driven by AAFLocator"); + URI serviceURI = uri(access,"service"); + + for (URI uri : new URI[] { + serviceURI, + uri(access,"token"), + uri(access,"introspect"), + uri(access,"cm"), + uri(access,"gui"), + uri(access,"fs"), + uri(access,"hello") + }) { + Locator locator = new AAFLocator(si, uri); + try { + connectTest(locator, uri); + } catch (Exception e) { + e.printStackTrace(); + System.err.flush(); + } + } - ////////// - print(true,"Test essential BasicAuth Service call, driven by AAFLocator"); - boolean hasBath=false; - for (SecuritySetter ss : lss) { - if (ss instanceof HBasicAuthSS) { - hasBath=true; - basicAuthTest(new AAFLocator(si, serviceURI),ss); - } - } - if(!hasBath) { - System.out.println("No User/Password to test"); + ///////// + print(true,"Test Service for Perms driven by AAFLocator"); + Locator locator = new AAFLocator(si,serviceURI); + for (SecuritySetter ss : lss) { + permTest(locator,ss); + } + + ////////// + print(true,"Test essential BasicAuth Service call, driven by AAFLocator"); + boolean hasBath=false; + for (SecuritySetter ss : lss) { + if (ss instanceof HBasicAuthSS) { + hasBath=true; + basicAuthTest(new AAFLocator(si, serviceURI),ss); + } + } + if(!hasBath) { + System.out.println("No User/Password to test"); + } } } catch (Exception e) { @@ -266,13 +278,16 @@ public class TestConnectivity { if (ss instanceof HRenewingTokenSS) { System.out.println(" " + ((HRenewingTokenSS)ss).tokenURL()); } else { - System.out.println(); + System.out.println(); } HClient client = new HClient(ss, uri, 3000); client.setMethod("GET"); String user = ss.getID(); - client.setPathInfo("/authz/perms/user/"+user); + String pathInfo = "/authz/perms/user/"+user; + client.setPathInfo(pathInfo); + System.out.println(pathInfo); + client.send(); Future future = client.futureReadString(); if (future.get(7000)) { diff --git a/cadi/aaf/src/main/java/org/onap/aaf/cadi/register/RegistrationCreator.java b/cadi/aaf/src/main/java/org/onap/aaf/cadi/register/RegistrationCreator.java index 7e519c52..aba13fb4 100644 --- a/cadi/aaf/src/main/java/org/onap/aaf/cadi/register/RegistrationCreator.java +++ b/cadi/aaf/src/main/java/org/onap/aaf/cadi/register/RegistrationCreator.java @@ -20,7 +20,6 @@ package org.onap.aaf.cadi.register; -import java.net.Inet4Address; import java.net.UnknownHostException; import java.util.List; @@ -28,13 +27,13 @@ import org.onap.aaf.cadi.Access; import org.onap.aaf.cadi.CadiException; import org.onap.aaf.cadi.aaf.Defaults; import org.onap.aaf.cadi.config.Config; +import org.onap.aaf.cadi.config.RegistrationPropHolder; import org.onap.aaf.cadi.util.Split; import locate.v1_0.MgmtEndpoint; import locate.v1_0.MgmtEndpoints; public class RegistrationCreator { - private static final String MUST_BE_DEFINED = " must be defined\n"; private Access access; public RegistrationCreator(Access access) { @@ -47,171 +46,41 @@ public class RegistrationCreator { MgmtEndpoint defData = null; MgmtEndpoint locate = null; - - StringBuilder errs = new StringBuilder(); try { - String hostname = access.getProperty(Config.HOSTNAME, null); - if (hostname==null) { - hostname = Inet4Address.getLocalHost().getHostName(); - } - if (hostname==null) { - errs.append(Config.HOSTNAME); - errs.append(MUST_BE_DEFINED); - } - - Float latitude=null; - String slatitude = access.getProperty(Config.CADI_LATITUDE, null); - if(slatitude == null) { - errs.append(Config.CADI_LATITUDE); - errs.append(MUST_BE_DEFINED); - } else { - latitude = Float.parseFloat(slatitude); - } - - Float longitude=null; - String slongitude = access.getProperty(Config.CADI_LONGITUDE, null); - if(slongitude == null) { - errs.append(Config.CADI_LONGITUDE); - errs.append(MUST_BE_DEFINED); - } else { - longitude = Float.parseFloat(slongitude); - } - - if(errs.length()>0) { - throw new CadiException(errs.toString()); - } - String dot_le; - String ns; String version=null; - String lentries = access.getProperty(Config.AAF_LOCATOR_CONTAINER, null); - if(lentries==null) { - lentries=""; - } else { - lentries=',' + lentries; // "" makes a blank default Public Entry - } - - String defaultName = null; - String str; - int public_port = port; - // Note: only one of the ports can be public... Therefore, only the la - for(String le : Split.splitTrim(',', lentries)) { - dot_le = le.isEmpty()?"":"."+le; - str = access.getProperty(Config.AAF_LOCATOR_PUBLIC_PORT+dot_le, null); - if(str!=null) { // Get Public Port - public_port = Integer.decode(str); - } - } - - String public_hostname = hostname; - for(String le : Split.splitTrim(',', lentries)) { - dot_le = le.isEmpty()?"":"."+le; - String ph = access.getProperty(Config.AAF_LOCATOR_PUBLIC_HOSTNAME+dot_le,null); - if( ph != null) { - public_hostname=ph; - } - } - String default_fqdn = access.getProperty(Config.AAF_LOCATOR_FQDN, public_hostname); + RegistrationPropHolder ph = new RegistrationPropHolder(access, port); - // Now, loop through by Container - for(String le : Split.splitTrim(',', lentries)) { - // Add variable entries - String names; - if(le.length()>0) { - dot_le = '.' + le; - names = access.getProperty(Config.AAF_LOCATOR_NAMES+dot_le,null); - if(names==null) { - // Go for Default - names = access.getProperty(Config.AAF_LOCATOR_NAMES,""); - } + for(String le : Split.splitTrim(',', ph.lcontainer)) { + if(le.isEmpty()) { + dot_le = le; } else { - dot_le = ""; - names=access.getProperty(Config.AAF_LOCATOR_NAMES,dot_le); + dot_le = "."+le; } - - for(String name : Split.splitTrim(',', names)) { + + for(String entry : Split.splitTrim(',', ph.lentries)) { if(defData==null) { defData = locate = new MgmtEndpoint(); - defaultName = name; version = access.getProperty(Config.AAF_LOCATOR_VERSION, Defaults.AAF_VERSION); locate.setProtocol(access.getProperty(Config.AAF_LOCATOR_PROTOCOL,null)); List ls = locate.getSubprotocol(); for(String sp : Split.splitTrim(',', access.getProperty(Config.AAF_LOCATOR_SUBPROTOCOL,""))) { ls.add(sp); } - locate.setLatitude(latitude); - locate.setLongitude(longitude); + locate.setLatitude(ph.latitude); + locate.setLongitude(ph.longitude); } else { locate = copy(defData); } - str = access.getProperty(Config.HOSTNAME+dot_le, null); - if(str==null) { - str = access.getProperty(Config.HOSTNAME, hostname); - } - locate.setHostname(hostname); - - ns = access.getProperty(Config.AAF_LOCATOR_NS+dot_le,null); - if(ns==null) { - ns = access.getProperty(Config.AAF_LOCATOR_NS,""); - } - switch(ns) { - case Defaults.AAF_NS: - ns = access.getProperty(Config.AAF_ROOT_NS, ""); - // Fallthrough on purpose. - } - - String ns_dot; - if(ns.isEmpty()) { - ns_dot = ns; - } else { - ns_dot = ns + '.'; - } - - String container_id = access.getProperty(Config.AAF_LOCATOR_CONTAINER_ID+dot_le, ""); - if(!container_id.isEmpty()) { - ns_dot = container_id + '.' + ns_dot; - } - - if(!le.isEmpty()) { - ns_dot = le + '.' + ns_dot; - } - - if(name.isEmpty()) { - locate.setName(ns_dot + defaultName); - } else { - locate.setName(ns_dot + name); - } - - if(dot_le.isEmpty()) { - locate.setHostname(access.getProperty(Config.AAF_LOCATOR_FQDN, default_fqdn)); - } else { - str = access.getProperty(Config.AAF_LOCATOR_FQDN+dot_le, null); - if(str==null) { - locate.setHostname(default_fqdn); - } else { - String container_ns = access.getProperty(Config.AAF_LOCATOR_CONTAINER_NS+dot_le, ""); - str = str.replace("%CNS", container_ns); - String container = access.getProperty(Config.AAF_LOCATOR_CONTAINER+dot_le, ""); - str = str.replace("%C", container); - str = str.replace("%NS", ns); - str = str.replace("%N", name); - str = str.replace("%DF", default_fqdn); - str = str.replace("%PH", public_hostname); - locate.setHostname(str); - } - } + locate.setName(ph.getEntryName(entry,dot_le)); + locate.setHostname(ph.getEntryFQDN(entry,dot_le)); + locate.setPort(ph.getEntryPort(dot_le)); - if(le.isEmpty()) { - locate.setPort(public_port); - } else { - locate.setPort(port); - } - String specificVersion = access.getProperty(Config.AAF_LOCATOR_VERSION + dot_le,null); if(specificVersion == null && locate == defData) { specificVersion = version; 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 new file mode 100644 index 00000000..dc671c83 --- /dev/null +++ b/cadi/aaf/src/test/java/org/onap/aaf/cadi/register/test/JU_RegistrationCreator.java @@ -0,0 +1,177 @@ +/** + * ============LICENSE_START==================================================== + * org.onap.aaf + * =========================================================================== + * Copyright (c) 2018 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==================================================== + */ + +package org.onap.aaf.cadi.register.test; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.fail; + +import java.net.Inet4Address; +import java.net.UnknownHostException; + +import org.junit.Test; +import org.onap.aaf.cadi.CadiException; +import org.onap.aaf.cadi.PropAccess; +import org.onap.aaf.cadi.config.Config; +import org.onap.aaf.cadi.register.RegistrationCreator; + +import junit.framework.Assert; +import locate.v1_0.MgmtEndpoint; + +public class JU_RegistrationCreator { + + private static final String DOT_OOM = ".oom"; + + @Test + public void test() { + PropAccess pa = new PropAccess(); + pa.setProperty(Config.CADI_LATITUDE, "32.7"); + pa.setProperty(Config.CADI_LONGITUDE, "-72.0"); + + try { + String hostname = Inet4Address.getLocalHost().getHostName(); + String entry = ""; + RegistrationCreator rc = new RegistrationCreator(pa); + int port = 999; + for(MgmtEndpoint me : rc.create(port).getMgmtEndpoint()) { + assertEquals(hostname,me.getHostname()); + assertEquals(port,me.getPort()); + assertEquals(pa.getProperty(Config.CADI_LATITUDE),Float.toString(me.getLatitude())); + assertEquals(pa.getProperty(Config.CADI_LONGITUDE),Float.toString(me.getLongitude())); + assertEquals(2,me.getMajor()); + assertEquals(1,me.getMinor()); + assertEquals(0,me.getPatch()); + assertEquals(0,me.getPkg()); + assertEquals(entry,me.getName()); + assertEquals(null,me.getProtocol()); + assertEquals(0,me.getSpecialPorts().size()); + } + + String protocol = "http"; + pa.setProperty(Config.AAF_LOCATOR_PROTOCOL, protocol); + rc = new RegistrationCreator(pa); + for(MgmtEndpoint me : rc.create(port).getMgmtEndpoint()) { + assertEquals(hostname,me.getHostname()); + assertEquals(port,me.getPort()); + assertEquals(pa.getProperty(Config.CADI_LATITUDE),Float.toString(me.getLatitude())); + assertEquals(pa.getProperty(Config.CADI_LONGITUDE),Float.toString(me.getLongitude())); + assertEquals(2,me.getMajor()); + assertEquals(1,me.getMinor()); + assertEquals(0,me.getPatch()); + assertEquals(0,me.getPkg()); + assertEquals("",me.getName()); + assertEquals(protocol,me.getProtocol()); + assertEquals(0,me.getSpecialPorts().size()); + } + + pa.setProperty(Config.AAF_LOCATOR_ENTRIES, "service"); + rc = new RegistrationCreator(pa); + for(MgmtEndpoint me : rc.create(port).getMgmtEndpoint()) { + switch(me.getName()) { + case "": + assertEquals(hostname,me.getHostname()); + assertEquals(port,me.getPort()); + break; + case "service": + assertEquals(hostname,me.getHostname()); + assertEquals(port,me.getPort()); + break; + default: + fail("unknown Locator Entry"); + } + assertEquals(pa.getProperty(Config.CADI_LATITUDE),Float.toString(me.getLatitude())); + assertEquals(pa.getProperty(Config.CADI_LONGITUDE),Float.toString(me.getLongitude())); + assertEquals(2,me.getMajor()); + assertEquals(1,me.getMinor()); + assertEquals(0,me.getPatch()); + assertEquals(0,me.getPkg()); + assertEquals(protocol,me.getProtocol()); + assertEquals(0,me.getSpecialPorts().size()); + } + + entry = "service"; + pa.setProperty(Config.AAF_LOCATOR_ENTRIES, entry); + rc = new RegistrationCreator(pa); + for(MgmtEndpoint me : rc.create(port).getMgmtEndpoint()) { + switch(me.getName()) { + case "": + assertEquals(hostname,me.getHostname()); + assertEquals(port,me.getPort()); + break; + case "service": + assertEquals(hostname,me.getHostname()); + assertEquals(port,me.getPort()); + break; + default: + fail("unknown Locator Entry"); + } + assertEquals(pa.getProperty(Config.CADI_LATITUDE),Float.toString(me.getLatitude())); + assertEquals(pa.getProperty(Config.CADI_LONGITUDE),Float.toString(me.getLongitude())); + assertEquals(2,me.getMajor()); + assertEquals(1,me.getMinor()); + assertEquals(0,me.getPatch()); + assertEquals(0,me.getPkg()); + assertEquals(protocol,me.getProtocol()); + assertEquals(0,me.getSpecialPorts().size()); + } + + pa.setProperty(Config.AAF_LOCATOR_CONTAINER, "oom"); + pa.setProperty(Config.AAF_ROOT_NS, Config.AAF_ROOT_NS_DEF); + pa.setProperty(Config.AAF_LOCATOR_NAME,"%NS.%N"); + pa.setProperty(Config.AAF_LOCATOR_NAME+DOT_OOM,"%CNS.%NS.%N"); + pa.setProperty(Config.AAF_LOCATOR_CONTAINER_NS+DOT_OOM, "onap"); + 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_PORT+DOT_OOM,Integer.toString(public_port)); + rc = new RegistrationCreator(pa); + for(MgmtEndpoint me : rc.create(port).getMgmtEndpoint()) { + switch(me.getName()) { + case "org.osaaf.aaf.service": + assertEquals(k8s_public_hostname,me.getHostname()); + assertEquals(public_port,me.getPort()); + break; + case "onap.org.osaaf.aaf.service": + assertEquals(hostname,me.getHostname()); + assertEquals(port,me.getPort()); + break; + default: + fail("unknown Entry Name, " + me.getName()); + } + assertEquals(pa.getProperty(Config.CADI_LATITUDE),Float.toString(me.getLatitude())); + assertEquals(pa.getProperty(Config.CADI_LONGITUDE),Float.toString(me.getLongitude())); + assertEquals(2,me.getMajor()); + assertEquals(1,me.getMinor()); + assertEquals(0,me.getPatch()); + assertEquals(0,me.getPkg()); + assertEquals(protocol,me.getProtocol()); + assertEquals(0,me.getSpecialPorts().size()); + } + + + } catch (CadiException | UnknownHostException e) { + Assert.fail(e.getMessage()); + } + + + } + +} 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 245b6539..f265947a 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 @@ -36,6 +36,8 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; +import javax.servlet.Registration; + import org.onap.aaf.cadi.AbsUserCache; import org.onap.aaf.cadi.Access; import org.onap.aaf.cadi.Access.Level; @@ -147,7 +149,7 @@ public class Config { public static final String AAF_ROOT_NS_DEF = "org.osaaf.aaf"; public static final String AAF_ROOT_COMPANY = "aaf_root_company"; public static final String AAF_LOCATE_URL = "aaf_locate_url"; //URL for AAF locator - private static final String AAF_LOCATE_URL_TAG = "AAF_LOCATE_URL"; // Name of Above for use in Config Variables. + public static final String AAF_LOCATE_URL_TAG = "AAF_LOCATE_URL"; // Name of Above for use in Config Variables. public static final String AAF_DEFAULT_API_VERSION = "2.1"; public static final String AAF_API_VERSION = "aaf_api_version"; public static final String AAF_URL = "aaf_url"; //URL for AAF... Use to trigger AAF configuration @@ -174,8 +176,9 @@ public class Config { public static final String AAF_LOCATOR_PROTOCOL = "aaf_locator_protocol"; public static final String AAF_LOCATOR_SUBPROTOCOL = "aaf_locator_subprotocol"; public static final String AAF_LOCATOR_NS = "aaf_locator_ns"; - public static final String AAF_LOCATOR_NAMES = "aaf_locator_names"; + public static final String AAF_LOCATOR_ENTRIES = "aaf_locator_entries"; 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"; @@ -814,28 +817,37 @@ public class Config { if (_url==null) { access.log(Level.INIT,"No URL passed to 'loadLocator'. Disabled"); } else { - String url = _url.replace("/AAF_NS.", "/%C%CID%AAF_NS."); - String root_ns = access.getProperty(Config.AAF_ROOT_NS, null); - if(url.indexOf('%')>=0) { - String str = access.getProperty(Config.AAF_LOCATOR_CONTAINER_ID, null); - if(str==null) { - url = url.replace("%CID",""); - } else { - url = url.replace("%CID",str+'.'); - } - str = access.getProperty(Config.AAF_LOCATOR_CONTAINER, null); - if(str==null) { - url = url.replace("%C",""); - } else { - url = url.replace("%C",str+'.'); - } - - if (root_ns==null) { - url = url.replace("%AAF_NS",""); - } else { - url = url.replace("%AAF_NS",root_ns); - } - } +// String url = _url.replace("/AAF_NS.", "/%C%CID%AAF_NS."); +// String root_ns = access.getProperty(Config.AAF_ROOT_NS, null); + String url; + RegistrationPropHolder rph; + try { + rph = new RegistrationPropHolder(access, 0); + url = rph.replacements(_url, null, null); + } catch (UnknownHostException | CadiException e1) { + throw new LocatorException(e1); + } + +// if(url.indexOf('%')>=0) { +// String str = access.getProperty(Config.AAF_LOCATOR_CONTAINER_ID, null); +// if(str==null) { +// url = url.replace("%CID",""); +// } else { +// url = url.replace("%CID",str+'.'); +// } +// str = access.getProperty(Config.AAF_LOCATOR_CONTAINER, null); +// if(str==null) { +// url = url.replace("%C",""); +// } else { +// url = url.replace("%C",str+'.'); +// } +// +// if (root_ns==null) { +// url = url.replace("%AAF_NS",""); +// } else { +// url = url.replace("%AAF_NS",root_ns); +// } +// } String replacement; int idxAAFLocateUrl; if ((idxAAFLocateUrl=url.indexOf(AAF_LOCATE_URL_TAG))>0 && ((replacement=access.getProperty(AAF_LOCATE_URL, null))!=null)) { 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 new file mode 100644 index 00000000..c8139646 --- /dev/null +++ b/cadi/core/src/main/java/org/onap/aaf/cadi/config/RegistrationPropHolder.java @@ -0,0 +1,220 @@ +/** + * ============LICENSE_START==================================================== + * org.onap.aaf + * =========================================================================== + * Copyright (c) 2018 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==================================================== + */ + +package org.onap.aaf.cadi.config; + +import java.net.Inet4Address; +import java.net.UnknownHostException; + +import org.onap.aaf.cadi.Access; +import org.onap.aaf.cadi.CadiException; +import org.onap.aaf.cadi.util.Split; + +public class RegistrationPropHolder { + + private final Access access; + public String hostname; + private int port; + public String public_hostname; + private Integer public_port; + public Float latitude; + public Float longitude; + public final String default_fqdn; + public final String default_container_ns; + public final String lentries; + public final String lcontainer; + + public RegistrationPropHolder(final Access access, final int port) throws UnknownHostException, CadiException { + this.access = access; + StringBuilder errs = new StringBuilder(); + String str; + this.port = port; + + lentries=access.getProperty(Config.AAF_LOCATOR_ENTRIES,""); + + str = access.getProperty(Config.AAF_LOCATOR_CONTAINER, ""); + if(!str.isEmpty()) { + lcontainer=',' + str; // "" makes a blank default Public Entry + str = access.getProperty(Config.AAF_LOCATOR_PUBLIC_PORT+'.'+str, null); + if(str==null) { + str = access.getProperty(Config.AAF_LOCATOR_PUBLIC_PORT, null); + } + } else { + lcontainer=str; + str = access.getProperty(Config.AAF_LOCATOR_PUBLIC_PORT, null); + } + if(str!=null) { + public_port=Integer.decode(str); + } + + hostname = access.getProperty(Config.HOSTNAME, null); + if (hostname==null) { + hostname = Inet4Address.getLocalHost().getHostName(); + } + if (hostname==null) { + mustBeDefined(errs,Config.HOSTNAME); + } + + public_hostname = access.getProperty(Config.AAF_LOCATOR_PUBLIC_HOSTNAME, hostname); + + latitude=null; + String slatitude = access.getProperty(Config.CADI_LATITUDE, null); + if(slatitude == null) { + mustBeDefined(errs,Config.CADI_LATITUDE); + } else { + latitude = Float.parseFloat(slatitude); + } + + longitude=null; + String slongitude = access.getProperty(Config.CADI_LONGITUDE, null); + if(slongitude == null) { + mustBeDefined(errs,Config.CADI_LONGITUDE); + } else { + longitude = Float.parseFloat(slongitude); + } + + String dot_le; + // Note: only one of the ports can be public... Therefore, only the last + for(String le : Split.splitTrim(',', lcontainer)) { + dot_le = le.isEmpty()?"":"."+le; + str = access.getProperty(Config.AAF_LOCATOR_PUBLIC_HOSTNAME+dot_le,null); + if( str != null) { + public_hostname=str; + } + } + + default_fqdn = access.getProperty(Config.AAF_LOCATOR_FQDN, public_hostname); + default_container_ns = access.getProperty(Config.AAF_LOCATOR_CONTAINER_NS,""); + + if(errs.length()>0) { + throw new CadiException(errs.toString()); + } + } + + private void mustBeDefined(StringBuilder errs, String propname) { + errs.append('\n'); + errs.append(propname); + errs.append(" must be defined."); + + } + + public String getEntryFQDN(final String entry, final String dot_le) { + String str; + if(public_hostname!=null && dot_le.isEmpty()) { + str = public_hostname; + } else { + str = access.getProperty(Config.AAF_LOCATOR_FQDN+dot_le, null); + if(str==null) { + str = access.getProperty(Config.AAF_LOCATOR_FQDN, hostname); + } + } + return replacements(str,entry,dot_le); + } + + public String getEntryName(final String entry, final String dot_le) { + String str; + str = access.getProperty(Config.AAF_LOCATOR_NAME+dot_le, "%NS.%N"); + return replacements(str,entry,dot_le); + } + + + private String getNS(String dot_le) { + String ns; + ns = access.getProperty(Config.AAF_LOCATOR_NS+dot_le,null); + if(ns==null) { + ns = access.getProperty(Config.AAF_ROOT_NS, ""); + } + return ns; + } + + + public String replacements(String source, final String name, final String dot_le) { + if(source == null) { + return ""; + } else if(source.isEmpty()) { + return source; + } + String str; + // aaf_locate_url + if(source.indexOf(Config.AAF_LOCATE_URL_TAG)>=0) { + str = access.getProperty(Config.AAF_LOCATE_URL, null); + if(str!=null) { + if(!str.endsWith("/")) { + str+='/'; + } + if(!str.endsWith("/locate/")) { + str+="locate/"; + } + source = source.replace("https://AAF_LOCATE_URL/", str); + } + } + + if(source.indexOf("%NS")>=0) { + str = getNS(dot_le); + if(str==null || str.isEmpty()) { + source = source.replace("%NS"+'.', str); + } + source = source.replace("%NS", str); + } + + // aaf_root_ns + if(source.indexOf("AAF_NS")>=0) { + str = access.getProperty(Config.AAF_ROOT_NS, null); + if(str!=null) { + String temp = source.replace("%AAF_NS", str); + if(temp == source) { // intended + source = source.replace("AAF_NS", str); // Backward Compatibility + } else { + source = temp; + } + } + } + + int atC = source.indexOf("%C"); + if(atC>=0) { + // aaf_locator_container_ns + str = access.getProperty(Config.AAF_LOCATOR_CONTAINER_NS+dot_le, default_container_ns); + if(str.isEmpty()) { + source = source.replace("%CNS"+'.', str); + } + source = source.replace("%CNS", str); + + str = access.getProperty(Config.AAF_LOCATOR_CONTAINER+dot_le, ""); + if(str.isEmpty()) { + source = source.replace("%C"+'.', str); + } + source = source.replace("%C", str); + } + + if(source.indexOf('%')>=0) { + // These shouldn't be expected to have dot elements + source = source.replace("%N", name); + source = source.replace("%DF", default_fqdn); + source = source.replace("%PH", public_hostname); + } + return source; + } + + public int getEntryPort(final String dot_le) { + return public_port!=null && dot_le.isEmpty()? + public_port: + port; + } +} \ No newline at end of file diff --git a/cadi/core/src/main/java/org/onap/aaf/cadi/util/FixURIinfo.java b/cadi/core/src/main/java/org/onap/aaf/cadi/util/FixURIinfo.java index 7e3a239b..b4085361 100644 --- a/cadi/core/src/main/java/org/onap/aaf/cadi/util/FixURIinfo.java +++ b/cadi/core/src/main/java/org/onap/aaf/cadi/util/FixURIinfo.java @@ -37,7 +37,7 @@ public class FixURIinfo { public FixURIinfo(URI uri) { auth = uri.getAuthority(); host = uri.getHost(); - if(host==null) { + if(host==null || (auth!=null && auth.startsWith(host))) { if(auth!=null) { int colon = auth.indexOf(':'); if(colon >= 0 ) { diff --git a/cadi/core/src/main/java/org/onap/aaf/cadi/util/Split.java b/cadi/core/src/main/java/org/onap/aaf/cadi/util/Split.java index 97afa65c..c6f8bd0a 100644 --- a/cadi/core/src/main/java/org/onap/aaf/cadi/util/Split.java +++ b/cadi/core/src/main/java/org/onap/aaf/cadi/util/Split.java @@ -76,7 +76,7 @@ public class Split { if (count==1) { rv[0]=value.substring(start,end).trim(); } else { - int last=0; + int last=start; count=-1; for (idx=value.indexOf(c,start);idx>=0 && idx