Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IDS-10140: Configure Elasticsearch Index with Specified Prefix #210

Merged
merged 9 commits into from
Jun 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [X.Y.Z](https://github.com/NASA-AMMOS/<repo_name>/releases/tag/X.Y.Z) - 2023-MM-DD

### Added

-
### Added
- IDS-10140
- Configure Elasticsearch Index name with Prefix setting: `elasticsearch_index_prefix`

### Changed
### Deprecated
### Removed
### Fixed
### Security
31 changes: 18 additions & 13 deletions ci/ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,21 @@ DB_PASS=${8}

ES_PROTOCOL=${9}
ES_HOST=${10}
ES_PORT=${11}
ES_USE_AUTH=${12}
ES_USERNAME=${13}
ES_PASSWORD=${14}
ES_INDEX_PREFIX=${11}
ES_PORT=${12}
ES_USE_AUTH=${13}
ES_USERNAME=${14}
ES_PASSWORD=${15}

CLOUD=${15}
SECURITY=${16}
HOSTNAME=${17}
EMAIL_LIST=${18}
ADMIN_FIRST=${19}
ADMIN_LAST=${20}
ADMIN_EMAIL=${21}
NUM_WORKERS=${22}
WORKER_ABANDONED_DAYS=${23}
CLOUD=${16}
SECURITY=${17}
HOSTNAME=${18}
EMAIL_LIST=${19}
ADMIN_FIRST=${20}
ADMIN_LAST=${21}
ADMIN_EMAIL=${22}
NUM_WORKERS=${23}
WORKER_ABANDONED_DAYS=${24}


source ${ROOT}/../utils.sh
Expand Down Expand Up @@ -105,6 +106,7 @@ project_webapp_root=proj
cws_enable_cloud_autoscaling=n
elasticsearch_protocol=${ES_PROTOCOL}
elasticsearch_host=${ES_HOST}
elasticsearch_index_prefix=${ES_INDEX_PREFIX}
elasticsearch_use_auth=${ES_USE_AUTH}
elasticsearch_port=${ES_PORT}
elasticsearch_username=${ES_USERNAME}
Expand All @@ -115,6 +117,7 @@ default_cws_ldap_url=ldap://localhost:389
cws_ldap_url=ldap://localhost:389
default_elasticsearch_use_auth=n
aws_cloudwatch_endpoint=monitoring.us-west-1.amazonaws.com
default_elasticsearch_index_prefix=cws-index
default_elasticsearch_port=9200
default_aws_cloudwatch_endpoint=monitoring.us-west-1.amazonaws.com
aws_sqs_dispatcher_msgFetchLimit=1
Expand Down Expand Up @@ -167,11 +170,13 @@ email_subject=[CWS] You have been assigned a task (CWS_TASK_NAME)
email_body=fn:CWS_USER_FIRSTNAME<br/>ln:CWS_USER_LASTNAME,<br/>tn:(CWS_TASK_NAME), em:CWS_USER_EMAIL
elasticsearch_protocol=${ES_PROTOCOL}
elasticsearch_host=${ES_HOST}
elasticsearch_index_prefix=${ES_INDEX_PREFIX}
elasticsearch_use_auth=${ES_USE_AUTH}
elasticsearch_port=${ES_PORT}
elasticsearch_username=${ES_USERNAME}
elasticsearch_password=${ES_PASSWORD}
smtp_hostname=smtp.localhost
default_elasticsearch_index_prefix=cws-index
default_smtp_hostname=smtp.localhost
default_cws_ldap_url=ldap://localhost:389
cws_ldap_url=ldap://localhost:389
Expand Down
3 changes: 2 additions & 1 deletion ci/run_ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ ADMIN_EMAIL="/"

ES_PROTOCOL="HTTP"
ES_HOST="http://localhost"
ES_INDEX_PREFIX="cws-index"
ES_PORT=9200
ES_USE_AUTH=n
ES_USERNAME="na"
Expand All @@ -44,4 +45,4 @@ NUM_WORKERS=${2} # parameter is passed as an env through workflow file
WORKER_ABANDONED_DAYS=1

# Run the ci script
./ci.sh `pwd` ${USER} ${DB_TYPE} ${DB_HOST} ${DB_PORT} ${DB_NAME} ${DB_USER} ${DB_PASS} ${ES_PROTOCOL} ${ES_HOST} ${ES_PORT} ${ES_USE_AUTH} ${ES_USERNAME} ${ES_PASSWORD} ${CLOUD} ${SECURITY} ${HOSTNAME} ${EMAIL_LIST} ${ADMIN_FIRST} ${ADMIN_LAST} ${ADMIN_EMAIL} ${NUM_WORKERS} ${WORKER_ABANDONED_DAYS}
./ci.sh `pwd` ${USER} ${DB_TYPE} ${DB_HOST} ${DB_PORT} ${DB_NAME} ${DB_USER} ${DB_PASS} ${ES_PROTOCOL} ${ES_HOST} ${ES_INDEX_PREFIX} ${ES_PORT} ${ES_USE_AUTH} ${ES_USERNAME} ${ES_PASSWORD} ${CLOUD} ${SECURITY} ${HOSTNAME} ${EMAIL_LIST} ${ADMIN_FIRST} ${ADMIN_LAST} ${ADMIN_EMAIL} ${NUM_WORKERS} ${WORKER_ABANDONED_DAYS}
26 changes: 24 additions & 2 deletions cws-installer/src/main/java/jpl/cws/task/CwsInstaller.java
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ public class CwsInstaller {
private static String elasticsearch_protocol_init;
private static String elasticsearch_host;
private static String elasticsearch_host_init;
private static String elasticsearch_index_prefix;
private static String elasticsearch_port;
private static String elasticsearch_use_auth;
private static String elasticsearch_username;
Expand Down Expand Up @@ -1368,6 +1369,21 @@ private static void setupElasticsearch() {

log.debug("elasticsearch_port: " + elasticsearch_port);

// PROMPT USER FOR ELASTICSEARCH INDEX
elasticsearch_index_prefix = getPreset("elasticsearch_index_prefix");

if (elasticsearch_index_prefix == null) {
elasticsearch_index_prefix = getPreset("default_elasticsearch_index_prefix");
}

if (cws_installer_mode.equals("interactive")) {
elasticsearch_index_prefix = readLine("Enter the Elasticsearch Index. " +
"Default is " + elasticsearch_index_prefix + ": ", elasticsearch_index_prefix);
}

log.debug("elasticsearch_index_prefix: " + elasticsearch_index_prefix);


// PROMPT USER ELASTICSEARCH AUTH
elasticsearch_use_auth = getPreset("elasticsearch_use_auth");

Expand Down Expand Up @@ -1783,7 +1799,8 @@ private static void showInstallationInfo() {
print("....................................................................................");
print("Elasticsearch Protocol = " + elasticsearch_protocol);
print("Elasticsearch Host = " + elasticsearch_host);
print("Elasticsearch Port = " + elasticsearch_port);
print("Elasticsearch Index Prefix = " + elasticsearch_index_prefix);
print("Elasticsearch Port = " + elasticsearch_port);
if (elasticsearch_use_auth.equalsIgnoreCase("Y")) {
print("Elasticsearch User = " + elasticsearch_username);
print("Elasticsearch Password = ****** (hidden) ");
Expand Down Expand Up @@ -2442,6 +2459,7 @@ private static int validateElasticsearch() {
print(" [ELASTICSEARCH]: Configuration Details");
print(" elasticsearch_protocol=" + elasticsearch_protocol_init + " ");
print(" elasticsearch_host=" + elasticsearch_host_init + " ");
print(" elasticsearch_index_prefix=" + elasticsearch_index_prefix + " ");
print(" elasticsearch_port=" + elasticsearch_port + " ");
print(" .........................................................................................");
print("");
Expand Down Expand Up @@ -2964,6 +2982,7 @@ private static void updateCwsUiProperties() throws IOException {
content = content.replace("__CWS_CONSOLE_SSL_PORT__", cws_console_ssl_port);
content = content.replace("__CWS_ES_PROTOCOL__", elasticsearch_protocol);
content = content.replace("__CWS_ES_HOST__", elasticsearch_host);
content = content.replace("__CWS_ES_INDEX_PREFIX__", elasticsearch_index_prefix);
content = content.replace("__CWS_ES_PORT__", elasticsearch_port);
content = content.replace("__CWS_ES_USE_AUTH__", elasticsearch_use_auth);
content = content.replace("__CWS_ENABLE_CLOUD_AUTOSCALING__", cws_enable_cloud_autoscaling);
Expand Down Expand Up @@ -3086,8 +3105,9 @@ private static void updateCwsUiConfig() throws IOException {
content = getFileContents(path);
content = content.replace("__ES_PROTOCOL__", elasticsearch_protocol);
content = content.replace("__ES_HOST__", elasticsearch_host);
content = content.replace("__ES_INDEX_PREFIX__", elasticsearch_index_prefix);
content = content.replace("__ES_PORT__", elasticsearch_port);
content = content.replace("__ES_USE_AUTH__", elasticsearch_use_auth);
content = content.replace("__ES_USE_AUTH__", elasticsearch_use_auth);
if (elasticsearch_use_auth.equalsIgnoreCase("Y")) {
content = content.replace("__ES_USERNAME__", elasticsearch_username);
content = content.replace("__ES_PASSWORD__", elasticsearch_password);
Expand Down Expand Up @@ -3330,6 +3350,7 @@ private static void installLogstash() throws IOException {

logstashContent = logstashContent.replace("__CWS_ES_PROTOCOL__", elasticsearch_protocol);
logstashContent = logstashContent.replace("__CWS_ES_HOST__", elasticsearch_host);
logstashContent = logstashContent.replace("__CWS_ES_INDEX_PREFIX__", elasticsearch_index_prefix);
logstashContent = logstashContent.replace("__CWS_ES_PORT__", elasticsearch_port);
if (elasticsearch_use_auth.equalsIgnoreCase(("Y"))) {
// Construct the auth config for logstash
Expand Down Expand Up @@ -3415,6 +3436,7 @@ private static void writeOutConfigurationFile() throws IOException {
setPreset("cws_token_expiration_hours", cws_token_expiration_hours);
setPreset("elasticsearch_protocol", elasticsearch_protocol);
setPreset("elasticsearch_host", elasticsearch_host);
setPreset("elasticsearch_index_prefix", elasticsearch_index_prefix);
setPreset("elasticsearch_port", elasticsearch_port);
setPreset("elasticsearch_use_auth", elasticsearch_use_auth);
setPreset("elasticsearch_username", elasticsearch_username);
Expand Down
Loading
Loading