Skip to content

Commit

Permalink
Add helper to delete LCE from capsule (#935) (#938)
Browse files Browse the repository at this point in the history
(cherry picked from commit 162e767)

Co-authored-by: vsedmik <[email protected]>
  • Loading branch information
Satellite-QE and vsedmik committed Jun 20, 2023
1 parent 997f8eb commit 4230434
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
28 changes: 28 additions & 0 deletions nailgun/entities.py
Original file line number Diff line number Diff line change
Expand Up @@ -858,6 +858,34 @@ def content_add_lifecycle_environment(self, synchronous=True, timeout=None, **kw
response = client.post(self.path('content_lifecycle_environments'), **kwargs)
return _handle_response(response, self._server_config, synchronous, timeout)

def content_delete_lifecycle_environment(self, synchronous=True, timeout=None, **kwargs):
"""Helper to disassociate lifecycle environment from capsule
Here is an example of how to use this method::
capsule.content_delete_lifecycle_environment(data={'environment_id': lce.id})
Constructs path:
/katello/api/capsules/:capsule_id/content/lifecycle_environments/:id
:param synchronous: What should happen if the server returns an HTTP
202 (accepted) status code? Wait for the task to complete if
``True``. Immediately return the server's response otherwise.
:param timeout: Maximum number of seconds to wait until timing out.
Defaults to ``nailgun.entity_mixins.TASK_TIMEOUT``.
:param kwargs: Arguments to pass to requests.
:returns: The server's response, with all JSON decoded.
:raises: ``requests.exceptions.HTTPError`` If the server responds with
an HTTP 4XX or 5XX message.
"""
kwargs = kwargs.copy()
kwargs.update(self._server_config.get_client_kwargs())
path = (
f'{self.path("content_lifecycle_environments")}/{kwargs["data"].pop("environment_id")}'
)
response = client.delete(path, **kwargs)
return _handle_response(response, self._server_config, synchronous, timeout)

def content_lifecycle_environments(self, synchronous=True, timeout=None, **kwargs):
"""Helper to get all the lifecycle environments, associated with
capsule
Expand Down
6 changes: 6 additions & 0 deletions tests/test_entities.py
Original file line number Diff line number Diff line change
Expand Up @@ -2201,9 +2201,15 @@ def setUpClass(cls):
(entities.Template(**generic).exports, 'post'),
(entities.VirtWhoConfig(**generic).deploy_script, 'get'),
)
capsule = {'server_config': cfg, 'id': 1}
repo_set = {'server_config': cfg, 'id': 1, 'product': 2}
snapshot = {'server_config': cfg, 'id': 'snapshot-1', 'host': 1}
cls.intelligent_methods_requests = (
(
entities.Capsule(**capsule).content_delete_lifecycle_environment,
'delete',
{'environment_id': 2},
),
(entities.RepositorySet(**repo_set).available_repositories, 'get', {'product_id': 2}),
(entities.RepositorySet(**repo_set).disable, 'put', {'product_id': 2}),
(entities.RepositorySet(**repo_set).enable, 'put', {'product_id': 2}),
Expand Down

0 comments on commit 4230434

Please sign in to comment.