@@ -153,25 +153,30 @@ def determine_cadf_action(self, req, target_type_uri=None):
153
153
"""
154
154
cadf_action = taxonomy .UNKNOWN
155
155
156
- # is this an ../action request with a json body, then check the json body for the openstack action
157
- if common .is_action_request (req ):
158
- cadf_action = self ._cadf_action_from_body (req .json )
156
+ try :
157
+ # is this an ../action request with a json body, then check the json body for the openstack action
158
+ if common .is_action_request (req ):
159
+ cadf_action = self ._cadf_action_from_body (req .json )
160
+
161
+ # get target type URI from request path if still unknown
162
+ if common .is_none_or_unknown (target_type_uri ):
163
+ target_type_uri = self .determine_target_type_uri (req )
159
164
160
- # get target type URI from request path if still unknown
161
- if common .is_none_or_unknown (target_type_uri ):
162
- target_type_uri = self .determine_target_type_uri (req )
165
+ # lookup action in custom mapping if one exists
166
+ if self .custom_action_config :
167
+ custom_cadf_action = self ._cadf_action_from_custom_action_config (target_type_uri , req .method , cadf_action )
168
+ if not common .is_none_or_unknown (custom_cadf_action ):
169
+ cadf_action = custom_cadf_action
163
170
164
- # lookup action in custom mapping if one exists
165
- if self .custom_action_config :
166
- custom_cadf_action = self ._cadf_action_from_custom_action_config (target_type_uri , req .method , cadf_action )
167
- if not common .is_none_or_unknown (custom_cadf_action ):
168
- cadf_action = custom_cadf_action
171
+ # if nothing was found, return cadf action based on request method and path
172
+ if common .is_none_or_unknown (cadf_action ):
173
+ cadf_action = self ._cadf_action_from_method_and_target_type_uri (req .method , target_type_uri )
169
174
170
- # if nothing was found, return cadf action based on request method and path
171
- if common .is_none_or_unknown (cadf_action ):
172
- cadf_action = self ._cadf_action_from_method_and_target_type_uri (req .method , target_type_uri )
175
+ except Exception as e :
176
+ self .logger .debug ("error while determining cadf action: {0}" .format (str (e )))
173
177
174
- return cadf_action
178
+ finally :
179
+ return cadf_action
175
180
176
181
def _cadf_action_from_method_and_target_type_uri (self , method , path ):
177
182
"""
@@ -235,7 +240,7 @@ def _cadf_action_from_body(self, json_body):
235
240
if os_action and len (os_action ) > 2 :
236
241
# add prefix to os_action
237
242
cadf_action = self .cadf_os_action_prefix + str (os_action )
238
- return
243
+
239
244
except Exception as e :
240
245
self .logger .debug ("error while determining action from json body: {0}" .format (str (e )))
241
246
0 commit comments