def policyValues(self):
     resp = api.list_policies(self.request)
     if resp.status_code == 200:
         data = resp.json()
     else:
         error_message = "Unable to retrieve policies information."
         raise ValueError(error_message)
     #
     policies_list = []
     for d in data:
         name = d["name"]
         id = d["id"]
         policies_list.append((id, "%s" % name))
     return policies_list
Exemple #2
0
 def get_policies_data(self):
     ret = []
     try:           
         resp = api.list_policies(self.request)
         if 200 <= resp.status_code < 300:
             data = resp.json()
             for value in data:
                 ret.append(policies_models.Policy(value["id"], value["name"], value["san_name"], value["throttle_iops_read"], value["throttle_iops_write"], value["throttle_mbps_read"], value["throttle_mbps_write"], value["tier"], value["filters"], value["created_at"]))
         else:
             error_message = 'Unable to retrieve policies information.'
             raise ValueError(error_message)
     except Exception as e:
         strobj = "[]"
         exceptions.handle(self.request, _(e.message))
     return ret