Avoid division by zero when calculating distribution
In case when there are no nodes. Change-Id: I20ae51f3d47d1605b4da9fd3610744a0c8907d91
This commit is contained in:
parent
af62f04147
commit
e664b0eb57
@ -162,8 +162,11 @@ class IndexView(views.IndexView):
|
||||
for node in nodes:
|
||||
distribution[node['role_name']] += 1
|
||||
for role in data['roles']:
|
||||
role['distribution'] = int(float(distribution[role['name']]) /
|
||||
len(nodes) * 100)
|
||||
if nodes:
|
||||
role['distribution'] = int(
|
||||
float(distribution[role['name']]) / len(nodes) * 100)
|
||||
else:
|
||||
role['distribution'] = 0
|
||||
|
||||
if api_base.is_service_enabled(request, 'metering'):
|
||||
for role in data['roles']:
|
||||
|
Loading…
x
Reference in New Issue
Block a user