def get_data(self):
     try:
         bgpvpn_id = self.kwargs['bgpvpn_id']
         return bgpvpn_api.bgpvpn_get(self.request, bgpvpn_id)
     except Exception:
         exceptions.handle(self.request,
                           _('Unable to retrieve BGPVPN details.'),
                           redirect=reverse(self.redirect_url))
Ejemplo n.º 2
0
 def get_initial(self):
     bgpvpn_id = self.kwargs['bgpvpn_id']
     try:
         # Get initial bgpvpn information
         bgpvpn = bgpvpn_api.bgpvpn_get(self.request, bgpvpn_id)
         data = bgpvpn.to_dict()
         data['bgpvpn_id'] = data.pop('id')
         return data
     except Exception:
         exceptions.handle(self.request,
                           _('Unable to retrieve BGPVPN details.'),
                           redirect=self.success_url)
Ejemplo n.º 3
0
 def _get_data(self):
     bgpvpn = {}
     bgpvpn_id = None
     try:
         bgpvpn_id = self.tab_group.kwargs['bgpvpn_id']
         bgpvpn = bgpvpn_api.bgpvpn_get(self.request, bgpvpn_id)
         bgpvpn.set_id_as_name_if_empty(length=0)
     except Exception:
         msg = _('Unable to retrieve details for bgpvpn "%s".') % (
             bgpvpn_id)
         exceptions.handle(self.request, msg)
     return bgpvpn
Ejemplo n.º 4
0
 def get_initial(self):
     bgpvpn_id = self.kwargs['bgpvpn_id']
     try:
         # Get initial bgpvpn information
         bgpvpn = bgpvpn_api.bgpvpn_get(self.request, bgpvpn_id)
     except Exception:
         exceptions.handle(self.request,
                           _('Unable to retrieve BGPVPN details.'),
                           redirect=self.success_url)
     else:
         data = bgpvpn.to_dict()
         if self.request.user.is_superuser:
             for attribute in bgpvpn_common.RT_FORMAT_ATTRIBUTES:
                 data[attribute] = self._join_rts(bgpvpn[attribute])
         data['bgpvpn_id'] = data.pop('id')
         return data