Beispiel #1
0
 def update_cell(self, request, datum, id, cell_name, new_cell_value):
     try:
         # updating changed value by new value
         response = api.bw_get_sla(request, id)
         data = json.loads(response.text)
         data[cell_name] = new_cell_value
         api.bw_update_sla(request, id, data)
     except Conflict:
         # Returning a nice error message about name conflict. The message
         # from exception is not that clear for the user
         message = _("Cant change value")
         raise ValidationError(message)
     except Exception:
         exceptions.handle(request, ignore=True)
         return False
     return True
Beispiel #2
0
 def handle(self, request, data):
     try:
         sla_id = self.initial["id"]
         response = api.bw_update_sla(request, sla_id, data)
         if 200 <= response.status_code < 300:
             messages.success(request, _("Successfully sla update."))
             return data
         else:
             raise sdsexception.SdsException(response.text)
     except Exception as ex:
         redirect = reverse("horizon:sdscontroller:bandwidth_differentiation:index")
         error_message = "Unable to update sla.\t %s" % ex.message
         exceptions.handle(request, _(error_message), redirect=redirect)