Skip to content

Commit

Permalink
[6.12.z]Add read template support 6.12.z (SatelliteQE#903)
Browse files Browse the repository at this point in the history
* Add support for reading a Provisioning Template

Signed-off-by: Shubham Ganar <shubhamsg123m@gmail.com>

* metadata update

---------

Signed-off-by: Shubham Ganar <shubhamsg123m@gmail.com>
  • Loading branch information
shubhamsg199 authored Mar 24, 2023
1 parent 2a17685 commit 5fb6bf5
Showing 1 changed file with 28 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 @@ -4337,6 +4337,7 @@ def path(self, which=None):
'disassociate',
'traces',
'traces/resolve',
'template',
):
return f'{super().path(which="self")}/{which}'
elif which in (
Expand Down Expand Up @@ -4402,6 +4403,33 @@ def delete_puppetclass(self, synchronous=True, timeout=None, **kwargs):
client.delete(path, **kwargs), self._server_config, synchronous, timeout
)

def read_template(self, synchronous=True, timeout=None, **kwargs):
"""Fetches and reads the provisioning template for given host
Here is an example of how to use this method::
host.read_template(data={'template_kind': 'iPXE'})
Constructs path:
api/hosts/:id/template/:kind
: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 content 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())
kind = f'{kwargs["data"].pop("template_kind")}'
path = f'{self.path("template")}/{kind}'
response = client.get(path, **kwargs)
return _handle_response(response, self._server_config, synchronous, timeout)

def list_scparams(self, synchronous=True, timeout=None, **kwargs):
"""List all smart class parameters
Expand Down

0 comments on commit 5fb6bf5

Please sign in to comment.