Skip to content

Commit

Permalink
update configuration web page
Browse files Browse the repository at this point in the history
  • Loading branch information
voxparcxls committed Jun 6, 2024
1 parent cc46426 commit 467c52f
Show file tree
Hide file tree
Showing 10 changed files with 127 additions and 111 deletions.
9 changes: 5 additions & 4 deletions ci/ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ DB_PASS=${8}

ES_PROTOCOL=${9}
ES_HOST=${10}
ES_INDEX_NAME=${11}
ES_INDEX_PREFIX=${11}
ES_PORT=${12}
ES_USE_AUTH=${13}
ES_USERNAME=${14}
Expand Down Expand Up @@ -106,7 +106,7 @@ project_webapp_root=proj
cws_enable_cloud_autoscaling=n
elasticsearch_protocol=${ES_PROTOCOL}
elasticsearch_host=${ES_HOST}
elasticsearch_index_name=${ES_INDEX_NAME}
elasticsearch_index_prefix=${ES_INDEX_PREFIX}
elasticsearch_use_auth=${ES_USE_AUTH}
elasticsearch_port=${ES_PORT}
elasticsearch_username=${ES_USERNAME}
Expand All @@ -117,7 +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_name
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 @@ -170,12 +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_name=${ES_INDEX_NAME}
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
4 changes: 2 additions & 2 deletions ci/run_ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ ADMIN_EMAIL="/"

ES_PROTOCOL="HTTP"
ES_HOST="http://localhost"
ES_INDEX_NAME="cws"
ES_INDEX_PREFIX="cws-index"
ES_PORT=9200
ES_USE_AUTH=n
ES_USERNAME="na"
Expand All @@ -45,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_INDEX_NAME} ${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: 13 additions & 13 deletions cws-installer/src/main/java/jpl/cws/task/CwsInstaller.java
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +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_name;
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 @@ -1370,18 +1370,18 @@ private static void setupElasticsearch() {
log.debug("elasticsearch_port: " + elasticsearch_port);

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

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

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

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


// PROMPT USER ELASTICSEARCH AUTH
Expand Down Expand Up @@ -1799,7 +1799,7 @@ private static void showInstallationInfo() {
print("....................................................................................");
print("Elasticsearch Protocol = " + elasticsearch_protocol);
print("Elasticsearch Host = " + elasticsearch_host);
print("Elasticsearch Index Name = " + elasticsearch_index_name);
print("Elasticsearch Index Prefix = " + elasticsearch_index_prefix);
print("Elasticsearch Port = " + elasticsearch_port);
if (elasticsearch_use_auth.equalsIgnoreCase("Y")) {
print("Elasticsearch User = " + elasticsearch_username);
Expand Down Expand Up @@ -2459,7 +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_name=" + elasticsearch_index_name + " ");
print(" elasticsearch_index_prefix=" + elasticsearch_index_prefix + " ");
print(" elasticsearch_port=" + elasticsearch_port + " ");
print(" .........................................................................................");
print("");
Expand Down Expand Up @@ -2982,7 +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_NAME__", elasticsearch_index_name);
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 @@ -3105,7 +3105,7 @@ 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_NAME__", elasticsearch_index_name);
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);
if (elasticsearch_use_auth.equalsIgnoreCase("Y")) {
Expand Down Expand Up @@ -3350,7 +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_NAME__", elasticsearch_index_name);
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 @@ -3436,7 +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_name", elasticsearch_index_name);
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
72 changes: 40 additions & 32 deletions cws-service/src/main/java/jpl/cws/controller/MvcCore.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,21 @@
@Component
public class MvcCore {
private static final Logger log = LoggerFactory.getLogger(MvcCore.class);

@Autowired protected CamundaExecutionService cwsExecutionService;
@Autowired protected SchedulerQueueUtils cwsSchedulerUtils;
@Autowired private CwsConsoleService cwsConsoleService;

@Value("${cws.console.app.root}") private String appRoot;
@Value("${cws.version}") private String version;
@Value("${cws.db.type}") private String dbType;
@Value("${cws.db.host}") private String dbHost;
@Value("${cws.db.name}") private String dbName;
@Value("${cws.db.port}") private String dbPort;
@Value("${cws.elasticsearch.protocol}") private String esProtocol;
@Value("${cws.elasticsearch.hostname}") private String esHost;
@Value("${cws.elasticsearch.index.prefix}") private String esIndexPrefix;
@Value("${cws.elasticsearch.port}") private String esPort;
@Value("${cws.auth.scheme}") private String authScheme;
@Value("${cws.install.dir}") private String installDir;
@Value("${cws.tomcat.lib}") private String tomcatLib;
Expand All @@ -41,7 +45,7 @@ public class MvcCore {
@Value("${cws.history.level}") private String historyLevel;

public MvcCore() {}

protected ModelAndView buildModel(String page, String message) {
ModelAndView model = new ModelAndView(page);
model.addObject("base", appRoot);
Expand All @@ -52,13 +56,13 @@ protected ModelAndView buildModel(String page, String message) {
log.debug("MODEL: "+model.getModel());
return model;
}


protected ModelAndView buildHomeModel(String message) {
ModelAndView model = new ModelAndView("home");
model.addObject("base", appRoot);
model.addObject("msg", message);

log.trace("MODEL for Home page: "+model.getModel());
return model;
}
Expand All @@ -83,8 +87,8 @@ protected ModelAndView buildSummaryModel(String message) {
log.trace("MODEL for Summary page: "+model.getModel());
return model;
}


protected ModelAndView buildDeploymentsModel(String message) {
log.trace("buildDeploymentsModel...");
ModelAndView model = new ModelAndView("deployments");
Expand All @@ -95,7 +99,7 @@ protected ModelAndView buildDeploymentsModel(String message) {
// Add list of (the latest) process definitions to the model
//
model.addObject("procDefs", cwsExecutionService.listProcessDefinitions());

log.trace("MODEL for Deployments page: "+model.getModel());
}
catch (Throwable t) {
Expand Down Expand Up @@ -123,24 +127,24 @@ protected ModelAndView buildLogsModel(String message) {
}
return model;
}

protected ModelAndView buildHistoryModel(String message) {
log.trace("buildHistoryModel...");
ModelAndView model = new ModelAndView("history");
try {
model.addObject("base", appRoot);
model.addObject("msg", message);

log.trace("MODEL for History page: "+model.getModel());
}
catch (Throwable t) {
log.error("Unexpected exception", t);
}
return model;
}

/**
*
*
*/
protected ModelAndView buildProcessesModel(String message) {
ModelAndView model = new ModelAndView("processes");
Expand All @@ -159,10 +163,10 @@ protected ModelAndView buildProcessesModel(String message) {
}
return model;
}


/**
*
*
*/
protected ModelAndView buildConfigurationModel(String message) {
ModelAndView model = new ModelAndView("configuration");
Expand All @@ -175,6 +179,10 @@ protected ModelAndView buildConfigurationModel(String message) {
model.addObject("dbHost", dbHost);
model.addObject("dbName", dbName);
model.addObject("dbPort", dbPort);
model.addObject("esProtocol", esProtocol);
model.addObject("esHost", esHost);
model.addObject("esIndexPrefix", esIndexPrefix);
model.addObject("esPort", esPort);
model.addObject("authScheme", authScheme);
model.addObject("installDir", installDir);
model.addObject("tomcatLib", tomcatLib);
Expand All @@ -188,37 +196,37 @@ protected ModelAndView buildConfigurationModel(String message) {
model.addObject("camundaVersion", System.getenv("CAMUNDA_VER"));

DiskUsage diskUsage = cwsConsoleService.getDiskUsage();

model.addObject("databaseSize", diskUsage.databaseSize);
model.addObject("workersInfo", diskUsage.workers);

log.trace("MODEL for Configuration page: "+model.getModel());
}
catch (Throwable t) {
log.error("Unexpected exception", t);
}
return model;
}

/**
*
*
*/
protected ModelAndView buildModelerModel() {
ModelAndView model = new ModelAndView("modeler");
try {
model.addObject("base", appRoot);

log.trace("MODEL for Modeler page: "+model.getModel());
}
catch (Throwable t) {
log.error("Unexpected exception", t);
}
return model;
}


/**
*
*
*/
protected ModelAndView buildDocumentationModel(String message) {
ModelAndView model = new ModelAndView("documentation");
Expand All @@ -232,11 +240,11 @@ protected ModelAndView buildDocumentationModel(String message) {
}
return model;
}


/**
* Model for "Workers" web page
*
*
*/
protected ModelAndView buildWorkersModel() {
ModelAndView model = new ModelAndView("workers");
Expand All @@ -247,19 +255,19 @@ protected ModelAndView buildWorkersModel() {
//
List<ProcessDefinition> procDefs = cwsExecutionService.listProcessDefinitions();
model.addObject("procDefs", procDefs);

model.addObject("workers", cwsConsoleService.getWorkersUiDTO(procDefs));
model.addObject("externalWorkers", cwsConsoleService.getExternalWorkersUiDTO());

model.addObject("workersTitle", cwsConsoleService.getWorkersTitle());

try {
Set<org.apache.activemq.broker.Connection> clients = cwsSchedulerUtils.getAmqClients();
model.addObject("amqClients", clients);
} catch (Exception e) {
log.error("There was a problem getting listing of AMQ clients", e);
}

return model;
}

Expand All @@ -277,6 +285,6 @@ protected ModelAndView buildModelerModel(String message) {
}
return model;
}

}

2 changes: 1 addition & 1 deletion dev.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ DB_USER=${7}
DB_PASS=${8}
ES_PROTOCOL=${9}
ES_HOST=${10}
ES_INDEX_NAME=${11}
ES_INDEX_PREFIX=${11}
ES_PORT=${12}
ES_USE_AUTH=${13}
ES_USERNAME=${14}
Expand Down
Loading

0 comments on commit 467c52f

Please sign in to comment.