@@ -104,7 +104,7 @@ public class ToscaOrchestrator {
104104
105105 private ExecutorService executorPool ;
106106
107- public void deployIacTemplate (String iacTemplateContent , Map <String , String > inputs , BaseCmd .HTTPMethod httpMethod ) {
107+ public ToscaServiceTemplate deployIacTemplate (String iacTemplateContent , Map <String , String > inputs , BaseCmd .HTTPMethod httpMethod ) {
108108 ToscaServiceTemplate serviceTemplate = parseServiceTemplate (iacTemplateContent );
109109 resolveServiceTemplateInputs (serviceTemplate , inputs );
110110
@@ -114,6 +114,7 @@ public void deployIacTemplate(String iacTemplateContent, Map<String, String> inp
114114 getCurrentNimbleExecutorPoolStatus ("before creating provisioning tasks" );
115115 provisioningTasksFutures .putAll (createProvisioningTasksFutures (serviceTemplate , errors , cancelAllProvisioningTasks , httpMethod ));
116116 awaitDeployCompletion (provisioningTasksFutures , errors , cancelAllProvisioningTasks );
117+ return serviceTemplate ;
117118 }
118119
119120 public ToscaServiceTemplate parseServiceTemplate (String iacTemplateContent ) {
@@ -221,7 +222,7 @@ private Map<String, CompletableFuture<Void>> createProvisioningTasksFutures(Tosc
221222 }
222223
223224 taskFuture .whenComplete ((result , ex ) -> {
224- handleTaskCompletion (ex , errors , cancelAllProvisioningTasks );
225+ handleTaskCompletion (nodeTemplate , ex , errors , cancelAllProvisioningTasks );
225226 getCurrentNimbleExecutorPoolStatus (String .format ("after node template [%s] provisioning" , node ));
226227 });
227228
@@ -232,23 +233,27 @@ private Map<String, CompletableFuture<Void>> createProvisioningTasksFutures(Tosc
232233 return futures ;
233234 }
234235
235- private void handleTaskCompletion (Throwable ex , List <Throwable > errors , Runnable cancelAllProvisioningTasks ) {
236+ private void handleTaskCompletion (ToscaNodeTemplate nodeTemplate , Throwable ex , List <Throwable > errors , Runnable cancelAllProvisioningTasks ) {
236237 if (ex == null ) {
237238 logger .trace ("The provisioning of the node template completed successfully. Skipping error handling." );
239+ nodeTemplate .setProvisioningState (ToscaNodeTemplate .ProvisioningState .SUCCEEDED );
238240 return ;
239241 }
240242
241243 if (ex instanceof CompletionException ) {
242244 ex = ex .getCause ();
243245 }
244246
245- if (!(ex instanceof CancellationException )) {
246- logger .trace ("An error occurred during the provisioning of a node template. Adding it to the list of errors." , ex );
247- errors .add (ex );
248- cancelAllProvisioningTasks .run ();
249- } else {
247+ if (ex instanceof CancellationException ) {
250248 logger .trace ("The provisioning of the node template was cancelled. Skipping error handling." , ex );
249+ nodeTemplate .setProvisioningState (ToscaNodeTemplate .ProvisioningState .CANCELLED );
250+ return ;
251251 }
252+
253+ logger .trace ("An error occurred during the provisioning of a node template. Adding it to the list of errors." , ex );
254+ nodeTemplate .setProvisioningState (ToscaNodeTemplate .ProvisioningState .FAILED );
255+ errors .add (ex );
256+ cancelAllProvisioningTasks .run ();
252257 }
253258
254259 // O(|V|+|E|)
0 commit comments