@@ -185,9 +185,7 @@ def post(self, *args, **kwargs):
185185 except Exception , e :
186186 log .exception (e )
187187 raise exceptions .RackAplError (e )
188-
189- # Create Foreman entries for rack switches
190- facade .api_foreman (rack )
188+ # SEPARAR AQUI!
191189
192190 datas = dict ()
193191 success_map = dict ()
@@ -209,6 +207,33 @@ def post(self, *args, **kwargs):
209207 raise api_exceptions .NetworkAPIException (e )
210208
211209
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+ #===============================================@====================================================
212237class RackConfigView (APIView ):
213238
214239 @commit_on_success
0 commit comments