Example #1
0
 def set_successful_response(self, resp, body="", status="200"):
     if not isinstance(body, str):
         try:
             body = jsonify(body)
         except Exception as e:
             self.log.exception(e)
             raise ValueError("The response body should be a string")
     resp.status = status
     resp.body = body
Example #2
0
 def get(self, id):
     # return list of available fetch types
     ret = {
         "description": "List of available fetch calls for this interface",
         "types": {
             "regions": "Regions of this environment",
             "projects": "Projects (tenants) of this environment",
             "availability_zones": "Availability zones",
             "aggregates": "Host aggregates",
             "aggregate_hosts": "Hosts in aggregate X (parameter: id)",
             "az_hosts": "Host in availability_zone X (parameter: id)"
         }
     }
     return jsonify(ret)
Example #3
0
 def get_objects(self, qry, type, id):
     return jsonify(self.get_objects_list(qry, type))
Example #4
0
 def set_error_response(self, title="", code="", message="", body=""):
     if body:
         raise exceptions.CalipsoApiException(code, body, message)
     body = {"error": {"message": message, "code": code, "title": title}}
     body = jsonify(body)
     raise exceptions.CalipsoApiException(code, body, message)
Example #5
0
 def get_catalog(self, pretty):
     return jsonify(self.regions, pretty)