Skip to content

Commit

Permalink
Add delete method to Manifester class
Browse files Browse the repository at this point in the history
This commit adds a new method to the manifester class,
delete_subscription_allocation. This is necessary to prevent a buildup
of subscription allocations in RHSM accounts and to ensure that
subscriptions are not consumed by subscription allocations after those
allocations are no longer needed. Note that the first step in this
method is `self._access_token = None` because access tokens are only
valid for 5 minutes. Since it is likely that allocations will need to be
deleted more than five minutes after they are created, this step ensures
that a fresh, valid access token is passed with the DELETE request.
  • Loading branch information
synkd committed Aug 9, 2022
1 parent e5e4a90 commit ac9fb5c
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions manifester/manifester.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,20 @@ def create_subscription_allocation(self):
)
return self.allocation_uuid

def delete_subscription_allocation(self):
self._access_token = None
data = {
"headers": {"Authorization": f"Bearer {self.access_token}"},
"proxies": self.manifest_data.get("proxies", settings.proxies),
"params": {"force": "true"},
}
response = simple_retry(
requests.delete,
cmd_args=[f"{self.manifest_data.url.allocations}/{self.allocation_uuid}"],
cmd_kwargs=data,
)
return response

@property
def subscription_pools(self):
if not self._subscription_pools:
Expand Down

0 comments on commit ac9fb5c

Please sign in to comment.