Skip to content

Commit 03c3246

Browse files
authored
Merge pull request #2 from stackhpc/skip-custom
Add flag to skip looking at custom resource class
2 parents 7de508d + 715fc7a commit 03c3246

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

os_capacity/utils.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,16 @@
1414

1515
import collections
1616
from datetime import datetime
17+
import os
1718

1819
from os_capacity.data import flavors
1920
from os_capacity.data import metrics
2021
from os_capacity.data import resource_provider
2122
from os_capacity.data import server as server_data
2223
from os_capacity.data import users
2324

25+
IGNORE_CUSTOM_RC = 'OS_CAPACITY_IGNORE_CUSTOM_RC' in os.environ
26+
2427

2528
def get_flavors(app):
2629
app.LOG.debug("Getting flavors")
@@ -54,10 +57,11 @@ def group_providers_by_type_with_capacity(app):
5457
grouped_flavors = collections.defaultdict(list)
5558
for flavor in all_flavors:
5659
custom_rc = None
57-
for extra_spec in flavor.extra_specs:
58-
if extra_spec.startswith('resources:CUSTOM'):
59-
custom_rc = extra_spec.replace('resources:', '')
60-
break # Assuming a good Ironic setup here
60+
if not IGNORE_CUSTOM_RC:
61+
for extra_spec in flavor.extra_specs:
62+
if extra_spec.startswith('resources:CUSTOM'):
63+
custom_rc = extra_spec.replace('resources:', '')
64+
break # Assuming a good Ironic setup here
6165

6266
key = (flavor.vcpus, flavor.ram_mb, flavor.disk_gb, custom_rc)
6367
grouped_flavors[key] += [flavor.name]
@@ -83,7 +87,8 @@ def group_providers_by_type_with_capacity(app):
8387
if "DISK" in inventory.resource_class:
8488
disk_gb += inventory.total
8589
if inventory.resource_class.startswith('CUSTOM_'):
86-
custom_rc = inventory.resource_class # Ironic specific
90+
if not IGNORE_CUSTOM_RC:
91+
custom_rc = inventory.resource_class # Ironic specific
8792
key = (vcpus, ram_mb, disk_gb, custom_rc)
8893

8994
inventory_counts[key] += 1

0 commit comments

Comments
 (0)