14
14
15
15
import collections
16
16
from datetime import datetime
17
+ import os
17
18
18
19
from os_capacity .data import flavors
19
20
from os_capacity .data import metrics
20
21
from os_capacity .data import resource_provider
21
22
from os_capacity .data import server as server_data
22
23
from os_capacity .data import users
23
24
25
+ IGNORE_CUSTOM_RC = 'OS_CAPACITY_IGNORE_CUSTOM_RC' in os .environ
26
+
24
27
25
28
def get_flavors (app ):
26
29
app .LOG .debug ("Getting flavors" )
@@ -54,10 +57,11 @@ def group_providers_by_type_with_capacity(app):
54
57
grouped_flavors = collections .defaultdict (list )
55
58
for flavor in all_flavors :
56
59
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
61
65
62
66
key = (flavor .vcpus , flavor .ram_mb , flavor .disk_gb , custom_rc )
63
67
grouped_flavors [key ] += [flavor .name ]
@@ -83,7 +87,8 @@ def group_providers_by_type_with_capacity(app):
83
87
if "DISK" in inventory .resource_class :
84
88
disk_gb += inventory .total
85
89
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
87
92
key = (vcpus , ram_mb , disk_gb , custom_rc )
88
93
89
94
inventory_counts [key ] += 1
0 commit comments