@@ -185,9 +185,7 @@ def post(self, *args, **kwargs):
185
185
except Exception , e :
186
186
log .exception (e )
187
187
raise exceptions .RackAplError (e )
188
-
189
- # Create Foreman entries for rack switches
190
- facade .api_foreman (rack )
188
+ # SEPARAR AQUI!
191
189
192
190
datas = dict ()
193
191
success_map = dict ()
@@ -209,6 +207,33 @@ def post(self, *args, **kwargs):
209
207
raise api_exceptions .NetworkAPIException (e )
210
208
211
209
210
+ class RackForeman (APIView ):
211
+ def post (self , * args , ** kwargs ):
212
+ try :
213
+ log .info ('RACK Foreman.' )
214
+
215
+ rack_id = kwargs .get ('rack_id' )
216
+ rack = facade .get_by_pk (rack_id )
217
+ # Create Foreman entries for rack switches
218
+ facade .api_foreman (rack )
219
+ raise api_exceptions .NetworkAPIException ('chegou' )
220
+ return Response (datas , status = status .HTTP_201_CREATED )
221
+
222
+ except exceptions .RackNumberNotFoundError , e :
223
+ log .exception (e )
224
+ raise exceptions .NetworkAPIException (e )
225
+
226
+ except var_exceptions .VariableDoesNotExistException , e :
227
+ log .error (e )
228
+ raise api_exceptions .NetworkAPIException (
229
+ 'Erro ao registrar o Switch no Foreman. Erro: %s' % e )
230
+
231
+ except Exception , e :
232
+ log .exception (e )
233
+ raise api_exceptions .NetworkAPIException (e )
234
+
235
+
236
+ #===============================================@====================================================
212
237
class RackConfigView (APIView ):
213
238
214
239
@commit_on_success
0 commit comments