def get_proxys_data(self): ret = [] try: response = api.dsl_get_all_nodes(self.request) if 200 <= response.status_code < 300: strobj = response.text else: error_message = 'Unable to get nodes.' raise sdsexception.SdsException(error_message) except Exception as e: strobj = '[]' exceptions.handle(self.request, _(e.message)) nodes = json.loads(strobj) for node in nodes: if node['type'] == 'proxy': ret.append(nodes_models.ProxyNode(node['name'], node['ip'], node['last_ping'])) return ret
def get_storagenodes_data(self): ret = [] try: response = api.dsl_get_all_nodes(self.request) if 200 <= response.status_code < 300: strobj = response.text else: error_message = 'Unable to get nodes.' raise sdsexception.SdsException(error_message) except Exception as e: strobj = '[]' exceptions.handle(self.request, _(e.message)) nodes = json.loads(strobj) for node in nodes: if node['type'] == 'object': devices = [] # for k, v in node['devices'].iteritems(): # used = v['size'] - v['free'] # device_str = k + ': ' + str(float(used)/v['size']) + "% used of " + str(v['size']) + ' bytes' # devices.append(device_str) ret.append(nodes_models.StorageNode(node['name'], node['ip'], node['last_ping'], node['devices'])) return ret