@@ -116,7 +116,7 @@ def _get_now():
116
116
"project_id" , "user_id" ))
117
117
118
118
119
- def get_allocations_with_server_info (app , flat_usage = True ):
119
+ def get_allocations_with_server_info (app , flat_usage = True , get_names = False ):
120
120
"""Get allocations, add in server and resource provider details."""
121
121
resource_providers = resource_provider .get_all (app .placement_client )
122
122
rp_dict = {rp .uuid : rp .name for rp in resource_providers }
@@ -150,6 +150,28 @@ def get_allocations_with_server_info(app, flat_usage=True):
150
150
allocation_tuples .sort (key = lambda x : (x .project_id , x .user_id ,
151
151
x .days * - 1 , x .flavor_id ))
152
152
153
+ if get_names :
154
+ all_users = users .get_all (app .identity_client )
155
+ all_projects = users .get_all_projects (app .identity_client )
156
+ all_flavors_list = flavors .get_all (
157
+ app .compute_client , include_extra_specs = False )
158
+ all_flavors = {flavor .id : flavor .name for flavor in all_flavors_list }
159
+
160
+ updated = []
161
+ for allocation in allocation_tuples :
162
+ user_id = all_users .get (allocation .user_id )
163
+ project_id = all_projects .get (allocation .project_id )
164
+ flavor_id = all_flavors .get (allocation .flavor_id )
165
+ updated .append (AllocationList (
166
+ allocation .resource_provider_name ,
167
+ allocation .consumer_uuid ,
168
+ allocation .usage ,
169
+ flavor_id ,
170
+ allocation .days ,
171
+ project_id ,
172
+ user_id ))
173
+ allocation_tuples = updated
174
+
153
175
return allocation_tuples
154
176
155
177
0 commit comments