Fix the loop deploy issue
Fix deploy UI issue and update the deployment payload.
Issue-ID: CLAMP-791
Change-Id: I2e652bc321e27be7c21ae12c66e98880e2eed4b5
Signed-off-by: xuegao <xg353y@intl.att.com>
diff --git a/src/main/java/org/onap/clamp/loop/components/external/DcaeComponent.java b/src/main/java/org/onap/clamp/loop/components/external/DcaeComponent.java
index 89332bb..8fce5ca 100644
--- a/src/main/java/org/onap/clamp/loop/components/external/DcaeComponent.java
+++ b/src/main/java/org/onap/clamp/loop/components/external/DcaeComponent.java
@@ -47,6 +47,7 @@
private static final String DEPLOYMENT_PARAMETER = "dcaeDeployParameters";
private static final String DCAE_SERVICETYPE_ID = "serviceTypeId";
private static final String DCAE_INPUTS = "inputs";
+ private static final String SINGLE_BLUEPRINT_POLICYID = "loop template blueprint";
private String name;
@@ -131,7 +132,7 @@
*/
public static String getDeployPayload(Loop loop) {
JsonObject globalProp = loop.getGlobalPropertiesJson();
- JsonObject deploymentProp = globalProp.getAsJsonObject(DEPLOYMENT_PARAMETER);
+ JsonObject deploymentProp = globalProp.getAsJsonObject(DEPLOYMENT_PARAMETER).getAsJsonObject(SINGLE_BLUEPRINT_POLICYID);
String serviceTypeId = loop.getLoopTemplate().getDcaeBlueprintId();
diff --git a/src/test/java/org/onap/clamp/loop/DcaeComponentTest.java b/src/test/java/org/onap/clamp/loop/DcaeComponentTest.java
index fc7e1c9..b42ba98 100644
--- a/src/test/java/org/onap/clamp/loop/DcaeComponentTest.java
+++ b/src/test/java/org/onap/clamp/loop/DcaeComponentTest.java
@@ -47,7 +47,7 @@
private Loop createTestLoop() {
Loop loopTest = new Loop("ControlLoopTest", "<xml></xml>");
loopTest.setGlobalPropertiesJson(
- new Gson().fromJson("{\"dcaeDeployParameters\":" + "{\"policy_id\": \"name\"}}", JsonObject.class));
+ new Gson().fromJson("{\"dcaeDeployParameters\":{\"loop template blueprint\": {\"policy_id\": \"name\"}}}", JsonObject.class));
loopTest.setLastComputedState(LoopState.DESIGN);
loopTest.setDcaeDeploymentId("123456789");
loopTest.setDcaeDeploymentStatusUrl("http4://localhost:8085");
diff --git a/src/test/java/org/onap/clamp/loop/DeployFlowTestItCase.java b/src/test/java/org/onap/clamp/loop/DeployFlowTestItCase.java
index f1d2992..98134e8 100644
--- a/src/test/java/org/onap/clamp/loop/DeployFlowTestItCase.java
+++ b/src/test/java/org/onap/clamp/loop/DeployFlowTestItCase.java
@@ -71,7 +71,8 @@
@Test
@Transactional
public void deployWithSingleBlueprintTest() throws JsonSyntaxException, IOException {
- Loop loopTest = createLoop("ControlLoopTest", "<xml></xml>", "yamlcontent", "{\"testname\":\"testvalue\"}",
+ Loop loopTest = createLoop("ControlLoopTest", "<xml></xml>", "yamlcontent",
+ "{\"dcaeDeployParameters\":{\"loop template blueprint\": {\"policy_id\": \"name\"}}}",
"UUID-blueprint");
LoopTemplate template = new LoopTemplate();
template.setName("templateName");
diff --git a/ui-react/src/components/dialogs/Loop/DeployLoopModal.js b/ui-react/src/components/dialogs/Loop/DeployLoopModal.js
index 6468e9f..d034ee5 100644
--- a/ui-react/src/components/dialogs/Loop/DeployLoopModal.js
+++ b/ui-react/src/components/dialogs/Loop/DeployLoopModal.js
@@ -75,14 +75,14 @@
}
handleClose(){
+ this.setState({ show: false });
this.props.history.push('/');
}
+
handleSave() {
const loopName = this.props.loopCache.getLoopName();
// save the global propserties
LoopService.updateGlobalProperties(loopName, this.state.temporaryPropertiesJson).then(resp => {
- this.setState({ show: false });
-
LoopActionService.performAction(loopName, "deploy").then(pars => {
this.props.showAlert("Action deploy successfully performed");
// refresh status and update loop logs
@@ -94,16 +94,16 @@
this.refreshStatus(loopName);
});
});
+ this.setState({ show: false });
+ this.props.history.push('/');
}
refreshStatus(loopName) {
LoopActionService.refreshStatus(loopName).then(data => {
this.props.updateLoopFunction(data);
- this.props.history.push('/');
})
.catch(error => {
this.props.showAlert("Refresh status failed");
- this.props.history.push('/');
});
}
handleChange(event) {