Skip to content

Commit 49fb96f

Browse files
committed
Refactor host info
1 parent c21f1c6 commit 49fb96f

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

os_capacity/prometheus.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ def get_resource_provider_info(compute_client, placement_client):
136136
return resource_providers, project_to_aggregate
137137

138138

139-
def print_details(compute_client, placement_client):
139+
def print_host_details(compute_client, placement_client):
140140
flavors = list(compute_client.flavors())
141141
capacity_per_flavor = get_capacity_per_flavor(placement_client, flavors)
142142

@@ -145,7 +145,7 @@ def print_details(compute_client, placement_client):
145145
for flavor_name in flavor_names:
146146
counts = capacity_per_flavor.get(flavor_name, {}).values()
147147
total = 0 if not counts else sum(counts)
148-
print(f'openstack_total_capacity_per_flavor{{flavor="{flavor_name}"}} {total}')
148+
print(f'openstack_free_capacity_by_flavor{{flavor="{flavor_name}"}} {total}')
149149

150150
# capacity per host
151151
resource_providers, project_to_aggregate = get_resource_provider_info(
@@ -169,7 +169,7 @@ def print_details(compute_client, placement_client):
169169
if project_filter:
170170
host_str += f',project_filter="{project_filter}"'
171171
print(
172-
f'openstack_capacity_by_hostname{{{host_str},flavor="{flavor_name}"}} {our_count}'
172+
f'openstack_free_capacity_by_hypervisor{{{host_str},flavor="{flavor_name}"}} {our_count}'
173173
)
174174
free_space_found = True
175175
if not free_space_found:
@@ -178,14 +178,18 @@ def print_details(compute_client, placement_client):
178178
for project, names in project_to_aggregate.items():
179179
for name in names:
180180
print(
181-
f'openstack_project_filter{{project="{project}",aggregate="{name}"}} 1'
181+
f'openstack_project_filter_aggregate{{project="{project}",aggregate="{name}"}} 1'
182182
)
183183

184184

185+
def print_project_usage_(indentity_client, placement_client):
186+
pass
187+
188+
185189
def print_exporter_data(app):
186-
print_details(app.compute_client, app.placement_client)
190+
print_host_free_details(app.compute_client, app.placement_client)
187191

188192

189193
if __name__ == "__main__":
190194
conn = openstack.connect()
191-
print_details(conn.compute, conn.placement)
195+
print_host_details(conn.compute, conn.placement)

0 commit comments

Comments
 (0)