@@ -311,6 +311,9 @@ def collect(self):
311
311
print (f"Collect started { collect_id } " )
312
312
guages = []
313
313
314
+ skip_project_usage = int (os .environ .get ('OS_CAPACITY_SKIP_PROJECT_USAGE' , "0" ))
315
+ skip_host_usage = int (os .environ .get ('OS_CAPACITY_SKIP_HOST_USAGE' , "0" ))
316
+
314
317
conn = openstack .connect ()
315
318
openstack .enable_logging (debug = False )
316
319
try :
@@ -321,19 +324,23 @@ def collect(self):
321
324
322
325
host_time = time .perf_counter ()
323
326
host_duration = host_time - start_time
324
- print (f"1 of 3 host flavor capacity complete for { collect_id } it took { host_duration } seconds" )
325
-
326
- guages += get_project_usage (conn .identity , conn .placement , conn .compute )
327
-
328
- project_time = time .perf_counter ()
329
- project_duration = project_time - host_time
330
- print (f"2 of 3 project usage complete for { collect_id } it took { project_duration } seconds" )
331
-
332
- guages += get_host_usage (resource_providers , conn .placement )
333
-
334
- host_usage_time = time .perf_counter ()
335
- host_usage_duration = host_usage_time - project_time
336
- print (f"3 of 3 host usage complete for { collect_id } it took { host_usage_duration } seconds" )
327
+ print (f"1 of 3: host flavor capacity complete for { collect_id } it took { host_duration } seconds" )
328
+
329
+ if not skip_project_usage :
330
+ guages += get_project_usage (conn .identity , conn .placement , conn .compute )
331
+ project_time = time .perf_counter ()
332
+ project_duration = project_time - host_time
333
+ print (f"2 of 3: project usage complete for { collect_id } it took { project_duration } seconds" )
334
+ else :
335
+ print ("2 of 3: skipping project usage" )
336
+
337
+ if not skip_project_usage :
338
+ guages += get_host_usage (resource_providers , conn .placement )
339
+ host_usage_time = time .perf_counter ()
340
+ host_usage_duration = host_usage_time - project_time
341
+ print (f"3 of 3: host usage complete for { collect_id } it took { host_usage_duration } seconds" )
342
+ else :
343
+ print ("3 of 3: skipping host usage" )
337
344
except Exception as e :
338
345
print (f"error { e } " )
339
346
0 commit comments