Added configuration options for delete and service timeout
Change-Id: If137e954f8ba2dbf094af359570ad85c383d7d69
Signed-off-by: Dirk Fauth <Dirk.Fauth@de.bosch.com>
diff --git a/manager/src/main/java/org/eclipse/app4mc/cloud/manager/ServiceConfiguration.java b/manager/src/main/java/org/eclipse/app4mc/cloud/manager/ServiceConfiguration.java
index 1f21f09..e0c175c 100644
--- a/manager/src/main/java/org/eclipse/app4mc/cloud/manager/ServiceConfiguration.java
+++ b/manager/src/main/java/org/eclipse/app4mc/cloud/manager/ServiceConfiguration.java
@@ -36,4 +36,13 @@
public List<ServiceConfigurationParameter> getParameterList() {
return this.parameter;
}
+
+ public ServiceConfigurationParameter getParameter(String key) {
+ for (ServiceConfigurationParameter param : this.parameter) {
+ if (param.getKey().equals(key)) {
+ return param;
+ }
+ }
+ return null;
+ }
}
diff --git a/manager/src/main/java/org/eclipse/app4mc/cloud/manager/WorkflowController.java b/manager/src/main/java/org/eclipse/app4mc/cloud/manager/WorkflowController.java
index b5fc464..5d02059 100644
--- a/manager/src/main/java/org/eclipse/app4mc/cloud/manager/WorkflowController.java
+++ b/manager/src/main/java/org/eclipse/app4mc/cloud/manager/WorkflowController.java
@@ -149,6 +149,27 @@
ws.addConfiguration(selected, config);
}
+ // specify default configuration parameter
+ ServiceConfiguration configuration = ws.getConfiguration(selected);
+ if (configuration == null) {
+ configuration = new ServiceConfiguration(selected);
+ ws.addConfiguration(selected, configuration);
+ }
+
+ ServiceConfigurationParameter timeOut = new ServiceConfigurationParameter();
+ timeOut.setName("Timeout (in ms)");
+ timeOut.setKey("timeout");
+ timeOut.setValue("60000");
+ timeOut.setType("Long");
+ configuration.addParameter(timeOut);
+
+ ServiceConfigurationParameter deleteResult = new ServiceConfigurationParameter();
+ deleteResult.setName("Delete result ");
+ deleteResult.setKey("deleteResult");
+ deleteResult.setValue("true");
+ deleteResult.setType("boolean");
+ configuration.addParameter(deleteResult);
+
// render the form view
return "workflow";
}
@@ -348,6 +369,21 @@
// TODO make this asynchronous using websockets
long start = System.currentTimeMillis();
long end = System.currentTimeMillis();
+
+ long timeout = 60_000l;
+ ServiceConfiguration serviceConfiguration = workflowStatus.getConfiguration(serviceName);
+ if (serviceConfiguration != null) {
+ ServiceConfigurationParameter timeoutParam = serviceConfiguration.getParameter("timeout");
+ if (timeoutParam != null) {
+ try {
+ timeout = Long.valueOf(timeoutParam.getValue());
+ } catch (Exception e) {
+ workflowStatus.addMessage(serviceName + " timeout value " + timeoutParam.getValue() + " invalid. Using default of 60_000");
+ timeout = 60_000l;
+ }
+ }
+ }
+
while (linkHeaders.size() <= 1) {
try {
Thread.sleep(1000);
@@ -361,9 +397,9 @@
end = System.currentTimeMillis();
- // don't request for more than 60 seconds
- if (end - start > 60_000) {
- workflowStatus.addMessage(serviceName + " status requested for 60 seconds");
+ // don't request for more than configured timeout
+ if (end - start > timeout) {
+ workflowStatus.addMessage(serviceName + " status requested for " + (timeout/1000) + " seconds");
break;
}
}
@@ -472,8 +508,15 @@
}
}
- // TODO add check for delete configuration parameter
- if (deleteUrl != null) {
+ boolean deleteResult = true;
+ if (serviceConfiguration != null) {
+ ServiceConfigurationParameter deleteParam = serviceConfiguration.getParameter("deleteResult");
+ if (deleteParam != null) {
+ deleteResult = Boolean.valueOf(deleteParam.getValue());
+ }
+ }
+
+ if (deleteUrl != null && deleteResult) {
// delete upload again
Unirest.delete(deleteUrl).asEmpty();
workflowStatus.addMessage(serviceName + " cleaned up");
diff --git a/manager/src/main/resources/templates/selectedServices.html b/manager/src/main/resources/templates/selectedServices.html
index 60fc357..8be22b4 100644
--- a/manager/src/main/resources/templates/selectedServices.html
+++ b/manager/src/main/resources/templates/selectedServices.html
@@ -26,16 +26,31 @@
<div th:each="config : *{configurations}" class="mb-3">
<h4 th:text="${config.key + ' Configuration'}">Config</h4>
<div th:each="parameter, parameterStatus : ${config.value.parameterList}">
+ <!-- single non-boolean value -->
+ <div th:if="${parameter.cardinality == 'single' and parameter.type != 'boolean'}">
+ <label class="form-check-label" th:text="${parameter.name}">Label</label>
+ <input
+ class="form-control"
+ type="text"
+ th:field="*{configurations[__${config.key}__].parameterList[__${parameterStatus.index}__].value}"/>
+ </div>
+ <!-- single boolean value -->
+ <div th:if="${parameter.cardinality == 'single' and parameter.type == 'boolean'}" class="form-check">
+ <input
+ class="form-check-input"
+ type="checkbox"
+ th:field="*{configurations[__${config.key}__].parameterList[__${parameterStatus.index}__].value}"
+ th:value="true">
+ <label class="form-check-label" th:text="${parameter.name}" th:for="${parameter.key}">Label</label>
+ </div>
<!-- multiple possible values + cardinality multiple = checkboxes -->
<div th:if="${parameter.cardinality == 'multiple' and parameter.possibleValues.size() > 1}">
<label th:text="${parameter.name}">Label</label>
<div th:each="pv : ${parameter.possibleValues}" class="form-check">
<input
- class="form-check-input"
- type="checkbox"
th:field="*{configurations[__${config.key}__].parameterList[__${parameterStatus.index}__].value}"
th:value="${pv}">
- <label class="form-check-label" th:text="${pv}">Profile</label>
+ <label class="form-check-label" th:text="${pv}">Value</label>
</div>
</div>
<!-- multiple possible values + cardinality single = combobox -->
@@ -52,15 +67,6 @@
</option>
</select>
</div>
- <!-- single boolean value -->
- <div th:if="${parameter.cardinality == 'single' and parameter.type == 'boolean'}" class="form-check">
- <input
- class="form-check-input"
- type="checkbox"
- th:field="*{configurations[__${config.key}__].parameterList[__${parameterStatus.index}__].value}"
- value="true">
- <label class="form-check-label" th:text="${parameter.name}" th:for="${parameter.key}">Label</label>
- </div>
</div>
</div>
</div>