summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--distribution/cassandra/Dockerfile3
-rw-r--r--distribution/cassandra/docker-entrypoint.sh17
-rw-r--r--distribution/cassandra/music_single.cql2
-rw-r--r--distribution/dockermusic/README.md17
-rw-r--r--distribution/dockermusic/properties/music.properties19
-rw-r--r--distribution/dockermusic/start.sh82
-rwxr-xr-xpom.xml2
-rwxr-xr-xsrc/main/java/org/onap/music/main/CachingUtil.java18
-rw-r--r--src/main/java/org/onap/music/main/MusicCore.java7
-rwxr-xr-xsrc/main/java/org/onap/music/main/MusicUtil.java4
-rwxr-xr-xsrc/main/java/org/onap/music/rest/RestMusicAdminAPI.java14
-rwxr-xr-xsrc/main/java/org/onap/music/rest/RestMusicDataAPI.java7
-rw-r--r--src/test/java/org/onap/music/unittests/MusicUtilTest.java4
-rw-r--r--version.properties2
14 files changed, 175 insertions, 23 deletions
diff --git a/distribution/cassandra/Dockerfile b/distribution/cassandra/Dockerfile
index 0e851f47..9405fcb3 100644
--- a/distribution/cassandra/Dockerfile
+++ b/distribution/cassandra/Dockerfile
@@ -4,5 +4,6 @@ RUN mkdir -p /docker-entrypoint-initdb.d && mkdir -p /home/cassandra/.cassandra
COPY cassandra.yaml /etc/cassandra/
COPY music_single.cql /docker-entrypoint-initdb.d/
COPY docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh
-RUN chmod 755 /usr/local/bin/docker-entrypoint.sh
+RUN chmod 755 /usr/local/bin/docker-entrypoint.sh && chown -R cassandra /docker-entrypoint-initdb.d
+
ENTRYPOINT ["docker-entrypoint.sh"]
diff --git a/distribution/cassandra/docker-entrypoint.sh b/distribution/cassandra/docker-entrypoint.sh
index e46dea9f..cec4587b 100644
--- a/distribution/cassandra/docker-entrypoint.sh
+++ b/distribution/cassandra/docker-entrypoint.sh
@@ -60,10 +60,25 @@ if [ "$1" = 'cassandra' ]; then
fi
done
fi
+
+for f in /docker-entrypoint-initdb.d/*.cql; do
+ if [ "${CASSUSER}" ]; then
+ sed -ri 's/CASSUSER/'${CASSUSER}'/' "$f"
+ fi
+ if [ "${CASSPASS}" ]; then
+ sed -ri 's/CASSPASS/'${CASSPASS}'/' "$f"
+ fi
+done
+
+
+
+
echo "################################ Let run Scripts ##############################"
for f in /docker-entrypoint-initdb.d/*; do
+
case "$f" in
- *.cql) echo "$0: running $f" && until cqlsh -u cassandra -p cassandra -f "$f"; do >&2 echo "Cassandra is unavailable - sleeping"; sleep 2; done & ;;
+ *.cql)
+ echo "$0: running $f" && until cqlsh -u cassandra -p cassandra -f "$f"; do >&2 echo "Cassandra is unavailable - sleeping"; sleep 2; done & ;;
*) echo "$0: ignoring $f" ;;
esac
echo
diff --git a/distribution/cassandra/music_single.cql b/distribution/cassandra/music_single.cql
index 11eb2df0..b8a60cd1 100644
--- a/distribution/cassandra/music_single.cql
+++ b/distribution/cassandra/music_single.cql
@@ -16,5 +16,5 @@ CREATE TABLE IF NOT EXISTS admin.keyspace_master (
PRIMARY KEY (uuid)
);
-CREATE ROLE IF NOT EXISTS nelson24 WITH PASSWORD = 'winman123' AND SUPERUSER = True AND LOGIN = True;
+CREATE ROLE IF NOT EXISTS CASSUSER WITH PASSWORD = 'CASSPASS' AND SUPERUSER = True AND LOGIN = True;
ALTER ROLE cassandra WITH PASSWORD = 'SomeLongRandomStringNoonewillthinkof';
diff --git a/distribution/dockermusic/README.md b/distribution/dockermusic/README.md
new file mode 100644
index 00000000..436921b0
--- /dev/null
+++ b/distribution/dockermusic/README.md
@@ -0,0 +1,17 @@
+### Docker Setup for Single instance of MUSIC
+
+<p>Please update the <b>properties/music.properties</b> file to fit your env.<br/>
+Update the start.sh file.<br/>
+The beginning of the <b>start.sh</b> file contains various variables.<br/></p>
+
+CASS_IMG - Cassandra Image<br/>
+TOMCAT_IMG - Tomcat Image<br/>
+ZK_IMG - Zookeeper Image<br/>
+MUSIC_IMG - Music Image containing the MUSIC war file.<br/>
+WORK_DIR - Default to PWD.<br/>
+CASS_USERNAME - Username for Cassandra - should match cassandra.user in music.properties
+file<br/>
+CASS_PASSWORD - Password for Cassandra - should match cassandra.password in music.properties.<br/>
+
+MUSIC Logs will be saved in logs/MUSIC after start of tomcat.<br/>
+
diff --git a/distribution/dockermusic/properties/music.properties b/distribution/dockermusic/properties/music.properties
new file mode 100644
index 00000000..02ba435c
--- /dev/null
+++ b/distribution/dockermusic/properties/music.properties
@@ -0,0 +1,19 @@
+my.public.ip=localhost
+all.public.ips=localhost
+my.id=0
+all.ids=0
+#######################################
+# Optional current values are defaults
+#######################################
+zookeeper.host=music-zk
+cassandra.host=music-db
+#music.ip=localhost
+#debug=true
+#music.rest.ip=localhost
+#lock.lease.period=6000
+cassandra.user=xxuserxxx
+cassandra.password=xxpasswordxx
+# AAF Endpoint if using AAF
+#aaf.endpoint.url=
+
+
diff --git a/distribution/dockermusic/start.sh b/distribution/dockermusic/start.sh
new file mode 100644
index 00000000..57b05890
--- /dev/null
+++ b/distribution/dockermusic/start.sh
@@ -0,0 +1,82 @@
+#
+# -------------------------------------------------------------------------
+# Copyright (c) 2017 AT&T Intellectual Property
+#
+# 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.
+#
+# -------------------------------------------------------------------------
+# In this example we are building a docker bridge network(music-net) for all
+# the containers
+# Then we connect the host bridge network(bridge) to the internal network(music-net)
+#
+#
+#
+CASS_IMG=nexus3.onap.org:10001/onap/music/cassandra_music:latest
+TOMCAT_IMG=nexus3.onap.org:10001/library/tomcat:8.0
+ZK_IMG=nexus3.onap.org:10001/library/zookeeper:3.4
+MUSIC_IMG=nexus3.onap.org:10001/onap/music/music:latest
+WORK_DIR=${PWD}
+CASS_USERNAME=cassandra1
+CASS_PASSWORD=cassandra1
+
+if [ "$1" = "start" ]; then
+
+# Create Volume for mapping war file and tomcat
+docker volume create music-vol;
+
+# Create a network for all the containers to run in.
+docker network create music-net;
+
+# Start Cassandra
+docker run -d --rm --name music-db --network music-net \
+-p "7000:7000" -p "7001:7001" -p "7199:7199" -p "9042:9042" -p "9160:9160" \
+-e CASSNAME=${CASS_USERNAME} \
+-e CASSPASS=${CASS_PASSWORD} \
+${CASS_IMG};
+
+# Start Music war
+docker run -d --rm --name music-war \
+-v music-vol:/app \
+${MUSIC_IMG};
+
+# Start Zookeeper
+docker run -d --rm --name music-zk --network music-net
+-p "2181:2181" -p "2888:2888" -p "3888:3888" \
+${ZK_IMG};
+
+# Delay for Cassandra
+sleep 20;
+
+# Start Up tomcat - Needs to have properties,logs dir and war file volume mapped.
+docker run -d --rm --name music-tomcat --network music-net -p "8080:8080" \
+-v music-vol:/usr/local/tomcat/webapps \
+-v ${WORK_DIR}/properties:/opt/app/music/etc:ro \
+-v ${WORK_DIR}/logs:/opt/app/music/logs \
+${TOMCAT_IMG};
+
+# Connect tomcat to host bridge network so that its port can be seen.
+docker network connect bridge music-tomcat;
+
+fi
+
+
+# Shutdown and clean up.
+if [ "$1" = "stop" ]; then
+docker stop music-war;
+docker stop music-db;
+docker stop music-zk;
+docker stop music-tomcat;
+docker network rm music-net;
+sleep 5;
+docker volume rm music-vol;
+fi
diff --git a/pom.xml b/pom.xml
index dbc24ba2..891c3a2b 100755
--- a/pom.xml
+++ b/pom.xml
@@ -15,7 +15,7 @@
<groupId>org.onap.music</groupId>
<artifactId>MUSIC</artifactId>
<packaging>war</packaging>
- <version>2.4.14</version>
+ <version>2.4.15</version>
<description>
This is the MUSIC REST interface, packaged as a war file.
</description>
diff --git a/src/main/java/org/onap/music/main/CachingUtil.java b/src/main/java/org/onap/music/main/CachingUtil.java
index 40dffa2d..aee3abbf 100755
--- a/src/main/java/org/onap/music/main/CachingUtil.java
+++ b/src/main/java/org/onap/music/main/CachingUtil.java
@@ -392,11 +392,9 @@ public class CachingUtil implements Runnable {
}
PreparedQueryObject queryObject = new PreparedQueryObject();
queryObject.appendQueryString(
- "select * from admin.keyspace_master where application_name = ? and username = ? and password = ? allow filtering");
+ "select * from admin.keyspace_master where application_name = ? allow filtering");
try {
queryObject.addValue(MusicUtil.convertToActualDataType(DataType.text(), ns));
- queryObject.addValue(MusicUtil.convertToActualDataType(DataType.text(), userId));
- queryObject.addValue(MusicUtil.convertToActualDataType(DataType.text(), password));
} catch(Exception e) {
resultMap.put("Exception",
"Unable to process input data. Invalid input data type. Please check ns, userId and password values. "+e.getMessage());
@@ -412,16 +410,20 @@ public class CachingUtil implements Runnable {
return resultMap;
}
if (rs == null) {
- logger.error(EELFLoggerDelegate.errorLogger,"", AppMessages.AUTHENTICATIONERROR, ErrorSeverity.WARN, ErrorTypes.AUTHENTICATIONERROR);
- logger.error(EELFLoggerDelegate.errorLogger,"Namespace, UserId and password doesn't match. namespace: "+ns+" and userId: "+userId);
-
- resultMap.put("Exception", "Namespace, UserId and password doesn't match. namespace: "+ns+" and userId: "+userId);
+ logger.error(EELFLoggerDelegate.errorLogger,"Application is not onboarded. Please contact admin.");
+ resultMap.put("Exception", "Application is not onboarded. Please contact admin.");
} else {
+ if(!(rs.getString("username").equals(userId)) && !(rs.getString("password").equals("password"))) {
+ logger.error(EELFLoggerDelegate.errorLogger,"", AppMessages.AUTHENTICATIONERROR, ErrorSeverity.WARN, ErrorTypes.AUTHENTICATIONERROR);
+ logger.error(EELFLoggerDelegate.errorLogger,"Namespace, UserId and password doesn't match. namespace: "+ns+" and userId: "+userId);
+ resultMap.put("Exception", "Namespace, UserId and password doesn't match. namespace: "+ns+" and userId: "+userId);
+ return resultMap;
+ }
boolean is_aaf = rs.getBool("is_aaf");
String keyspace = rs.getString("keyspace_name");
if (!is_aaf) {
if (!keyspace.equals(MusicUtil.DEFAULTKEYSPACENAME)) {
- logger.error(EELFLoggerDelegate.errorLogger,"", AppMessages.MISSINGINFO ,ErrorSeverity.WARN, ErrorTypes.DATAERROR);
+ logger.error(EELFLoggerDelegate.errorLogger,"", AppMessages.MISSINGINFO ,ErrorSeverity.WARN, ErrorTypes.DATAERROR);
logger.error(EELFLoggerDelegate.errorLogger,"Non AAF applications are allowed to have only one keyspace per application.");
resultMap.put("Exception",
"Non AAF applications are allowed to have only one keyspace per application.");
diff --git a/src/main/java/org/onap/music/main/MusicCore.java b/src/main/java/org/onap/music/main/MusicCore.java
index fdf43a45..73a6ee55 100644
--- a/src/main/java/org/onap/music/main/MusicCore.java
+++ b/src/main/java/org/onap/music/main/MusicCore.java
@@ -119,7 +119,12 @@ public class MusicCore {
logger.info(EELFLoggerDelegate.applicationLogger,"Acquiring data store handle");
long start = System.currentTimeMillis();
if (mDstoreHandle == null) {
- mDstoreHandle = new MusicDataStore();
+ // Quick Fix - Best to put this into every call to getDSHandle?
+ if (! MusicUtil.getMyCassaHost().equals("localhost") ) {
+ mDstoreHandle = new MusicDataStore(MusicUtil.getMyCassaHost());
+ } else {
+ mDstoreHandle = new MusicDataStore();
+ }
}
if(mDstoreHandle.getSession() == null) {
String message = "Connection to Cassandra has not been enstablished."
diff --git a/src/main/java/org/onap/music/main/MusicUtil.java b/src/main/java/org/onap/music/main/MusicUtil.java
index 5bc9f94f..0f77614e 100755
--- a/src/main/java/org/onap/music/main/MusicUtil.java
+++ b/src/main/java/org/onap/music/main/MusicUtil.java
@@ -394,7 +394,7 @@ public class MusicUtil {
MusicUtil.cassPwd = cassPwd;
}
- public static String convertToCQLDataType(DataType type, Object valueObj) {
+ public static String convertToCQLDataType(DataType type, Object valueObj) throws Exception {
String value = "";
switch (type.getName()) {
@@ -459,7 +459,7 @@ public class MusicUtil {
* @return
*/
- public static String jsonMaptoSqlString(Map<String, Object> jMap, String lineDelimiter) {
+ public static String jsonMaptoSqlString(Map<String, Object> jMap, String lineDelimiter) throws Exception{
StringBuilder sqlString = new StringBuilder();
int counter = 0;
for (Map.Entry<String, Object> entry : jMap.entrySet()) {
diff --git a/src/main/java/org/onap/music/rest/RestMusicAdminAPI.java b/src/main/java/org/onap/music/rest/RestMusicAdminAPI.java
index 849c3a98..cbe9ec9c 100755
--- a/src/main/java/org/onap/music/rest/RestMusicAdminAPI.java
+++ b/src/main/java/org/onap/music/rest/RestMusicAdminAPI.java
@@ -167,8 +167,14 @@ public class RestMusicAdminAPI {
Row row = (Row) it.next();
resultMap.put( row.getUUID("uuid").toString(),row.getString("keyspace_name"));
}
- if (resultMap.isEmpty())
- resultMap.put("ERROR", "Application is not onboarded. Please contact admin.");
+ if (resultMap.isEmpty()) {
+ if(uuid != null)
+ resultMap.put("Exception", "Please make sure Aid is correct and application is onboarded.");
+ else {
+ resultMap.put("Exception",
+ "Application is not onboarded. Please make sure all the information is correct.");
+ }
+ }
return resultMap;
}
@@ -212,7 +218,7 @@ public class RestMusicAdminAPI {
resultMap.put("Success", "Your application has been deleted successfully");
} else {
resultMap.put("Exception",
- "Oops. Spomething went wrong. Please make sure Aid is correct or Application is onboarded");
+ "Oops. Something went wrong. Please make sure Aid is correct or Application is onboarded");
}
return resultMap;
}
@@ -329,7 +335,7 @@ public class RestMusicAdminAPI {
resultMap.put("Success", "Your application has been updated successfully");
} else {
resultMap.put("Exception",
- "Oops. Spomething went wrong. Please make sure Aid is correct and application is onboarded");
+ "Oops. Something went wrong. Please make sure Aid is correct and application is onboarded");
}
return resultMap;
diff --git a/src/main/java/org/onap/music/rest/RestMusicDataAPI.java b/src/main/java/org/onap/music/rest/RestMusicDataAPI.java
index ed586d06..e7af8f9f 100755
--- a/src/main/java/org/onap/music/rest/RestMusicDataAPI.java
+++ b/src/main/java/org/onap/music/rest/RestMusicDataAPI.java
@@ -181,7 +181,12 @@ public class RestMusicDataAPI {
boolean result = false;
long start = System.currentTimeMillis();
Map<String, Object> replicationInfo = kspObject.getReplicationInfo();
- String repString = "{" + MusicUtil.jsonMaptoSqlString(replicationInfo, ",") + "}";
+ String repString = null;
+ try {
+ repString = "{" + MusicUtil.jsonMaptoSqlString(replicationInfo, ",") + "}";
+ } catch (Exception e) {
+ logger.error(EELFLoggerDelegate.errorLogger, e.getMessage());
+ }
queryObject.appendQueryString(
"CREATE KEYSPACE " + keyspaceName + " WITH replication = " + repString);
if (kspObject.getDurabilityOfWrites() != null) {
diff --git a/src/test/java/org/onap/music/unittests/MusicUtilTest.java b/src/test/java/org/onap/music/unittests/MusicUtilTest.java
index f8cab32a..47edc1e3 100644
--- a/src/test/java/org/onap/music/unittests/MusicUtilTest.java
+++ b/src/test/java/org/onap/music/unittests/MusicUtilTest.java
@@ -169,7 +169,7 @@ public class MusicUtilTest {
}
@Test
- public void testConvertToCQLDataType() {
+ public void testConvertToCQLDataType() throws Exception {
Map<String,Object> myMap = new HashMap<String,Object>();
myMap.put("name","tom");
assertEquals(MusicUtil.convertToCQLDataType(DataType.varchar(),"Happy People"),"'Happy People'");
@@ -195,7 +195,7 @@ public class MusicUtilTest {
}
@Test
- public void testJsonMaptoSqlString() {
+ public void testJsonMaptoSqlString() throws Exception {
Map<String,Object> myMap = new HashMap<>();
myMap.put("name","tom");
myMap.put("value",5);
diff --git a/version.properties b/version.properties
index ba681f30..632fc91b 100644
--- a/version.properties
+++ b/version.properties
@@ -4,7 +4,7 @@
major=2
minor=4
-patch=14
+patch=15
base_version=${major}.${minor}.${patch}