@@ -144,13 +144,23 @@ def _is_aborted(self):
144144 def run (self ):
145145 """Builds a MiCADO node and deploys an application"""
146146 if not r .hexists (self .threadID , "micado_id" ):
147- # Load inputs and parameters
148- deployment_adt , micado_node_data = self ._get_micado_inputs ()
149- parameters = self ._load_params ()
147+ # Check ADT data is valid
148+ self ._get_adt ().close ()
150149
151- # Create MiCADO and submit app
150+ # Create MiCADO
151+ micado_node_data = _get_micado_spec ()
152152 try :
153153 self ._create_micado_node (micado_node_data )
154+ except Exception as e :
155+ r .expire (self .threadID , 90 )
156+ self .status_detail = str (e )
157+ self .status = STATUS_ERROR
158+ self .set_status ()
159+ raise
160+
161+ deployment_adt = self ._get_adt ()
162+ parameters = self ._load_params ()
163+ try :
154164 self ._submit_app (deployment_adt , parameters )
155165 except Exception as e :
156166 self .status_detail = str (e )
@@ -179,20 +189,18 @@ def run(self):
179189 break
180190 time .sleep (15 )
181191
182- def _get_micado_inputs (self ):
192+ def _get_adt (self ):
183193 """Get inputs for YAML or CSAR"""
184194 if self .artefact_data ["downloadUrl" ].endswith (".yaml" ):
185195 deployment_adt = base64_to_yaml (self .artefact_data ["downloadUrl_content" ])
186- micado_node_data = _get_micado_spec (deployment_adt )
187196 else :
188197 file_content = base64 .b64decode (self .artefact_data ["downloadUrl_content" ])
189198 file_name = f"{ self .artefact_data ['id' ]} .csar"
190199 with open (file_name , "wb+" ) as f :
191200 f .write (file_content )
192201 deployment_adt = open (file_name , "rb" )
193- micado_node_data = _get_micado_spec ({})
194202
195- return deployment_adt , micado_node_data
203+ return deployment_adt
196204
197205 def _load_params (self ):
198206 """Loads parameter data"""
@@ -298,14 +306,8 @@ def _is_valid_param(self, key_to_check):
298306 return len (available ) > 0
299307
300308
301- def _get_micado_spec (adt ):
309+ def _get_micado_spec ():
302310 """Retrieves the MiCADO node configuration"""
303- try :
304- node = adt ["topology_template" ]["node_templates" ].pop ("micado" , {})
305- return node ["properties" ]
306- except KeyError :
307- pass
308-
309311 try :
310312 properties = load_yaml_file (DEFAULT_MICADO_YAML )["properties" ]
311313 except (yaml .YAMLError , KeyError ):
0 commit comments