@@ -170,7 +170,9 @@ def create_subscription_allocation(self):
170
170
cmd_kwargs = allocation_data ,
171
171
).json ()
172
172
logger .debug (f"Received response { self .allocation } when attempting to create allocation." )
173
- self .allocation_uuid = self .allocation ["body" ]["uuid" ]
173
+ self .allocation_uuid = (
174
+ self .allocation .uuid if self .is_mock else self .allocation ["body" ]["uuid" ]
175
+ )
174
176
if self .simple_content_access == "disabled" :
175
177
simple_retry (
176
178
self .requester .put ,
@@ -185,7 +187,7 @@ def create_subscription_allocation(self):
185
187
f"Subscription allocation created with name { self .allocation_name } "
186
188
f"and UUID { self .allocation_uuid } "
187
189
)
188
- update_inventory (self .subscription_allocations )
190
+ update_inventory (self .subscription_allocations , uuid = self . allocation_uuid )
189
191
return self .allocation_uuid
190
192
191
193
def delete_subscription_allocation (self , uuid = None ):
@@ -196,14 +198,14 @@ def delete_subscription_allocation(self, uuid=None):
196
198
"proxies" : self .manifest_data .get ("proxies" ),
197
199
"params" : {"force" : "true" },
198
200
}
199
- if self .is_mock :
200
- self .allocation_uuid = self .allocation_uuid .uuid
201
201
response = simple_retry (
202
202
self .requester .delete ,
203
203
cmd_args = [f"{ self .allocations_url } /{ uuid if uuid else self .allocation_uuid } " ],
204
204
cmd_kwargs = data ,
205
205
)
206
- update_inventory (self .subscription_allocations )
206
+ update_inventory (
207
+ self .subscription_allocations , remove = True , uuid = uuid if uuid else self .allocation_uuid
208
+ )
207
209
return response
208
210
209
211
def add_entitlements_to_allocation (self , pool_id , entitlement_quantity ):
@@ -322,15 +324,15 @@ def process_subscription_pools(self, subscription_pools, subscription_data):
322
324
f"{ subscription_data ['name' ]} to the allocation."
323
325
)
324
326
self ._active_pools .append (match )
325
- update_inventory (self .subscription_allocations )
327
+ update_inventory (self .subscription_allocations , uuid = self . allocation_uuid )
326
328
break
327
329
elif add_entitlements .status_code == SUCCESS_CODE :
328
330
logger .debug (
329
331
f"Successfully added { subscription_data ['quantity' ]} entitlements of "
330
332
f"{ subscription_data ['name' ]} to the allocation."
331
333
)
332
334
self ._active_pools .append (match )
333
- update_inventory (self .subscription_allocations )
335
+ update_inventory (self .subscription_allocations , uuid = self . allocation_uuid )
334
336
break
335
337
else :
336
338
raise RuntimeError (
@@ -405,11 +407,8 @@ def trigger_manifest_export(self):
405
407
local_file .write_bytes (manifest .content )
406
408
manifest .path = local_file
407
409
manifest .name = self .manifest_name
408
- if self .is_mock :
409
- manifest .uuid = self .allocation_uuid .uuid
410
- else :
411
- manifest .uuid = self .allocation_uuid
412
- update_inventory (self .subscription_allocations )
410
+ manifest .uuid = self .allocation_uuid
411
+ update_inventory (self .subscription_allocations , uuid = self .allocation_uuid )
413
412
return manifest
414
413
415
414
def get_manifest (self ):
@@ -437,4 +436,3 @@ def __enter__(self):
437
436
def __exit__ (self , * tb_args ):
438
437
"""Deletes subscription allocation on teardown unless using CLI."""
439
438
self .delete_subscription_allocation ()
440
- update_inventory (self .subscription_allocations )
0 commit comments