Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JobTemplate read() seems requires unnecessary field 'audit_comment'? #739

Open
ssiuhk opened this issue Jul 20, 2020 · 0 comments
Open

JobTemplate read() seems requires unnecessary field 'audit_comment'? #739

ssiuhk opened this issue Jul 20, 2020 · 0 comments

Comments

@ssiuhk
Copy link

ssiuhk commented Jul 20, 2020

Hi,
According to foreman API doc apidoc/v2/job_templates/show.html, showing a job template should not require attribute audit_comment.
However, when I try to use the class to read a job template, it errors out with

>>> jobtmpl.read()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/sam/.pyenv/versions/3.6.1/lib/python3.6/site-packages/nailgun/entities.py", line 1614, in read
    ignore=ignore, params=params)
  File "/home/sam/.pyenv/versions/3.6.1/lib/python3.6/site-packages/nailgun/entity_mixins.py", line 822, in read
    setattr(entity, field_name, attrs[field_name])
KeyError: 'audit_comment'

Steps to reproduce:
On a fresh installed foreman server

>>> from nailgun.entities import JobTemplate
>>> from nailgun.config import ServerConfig
>>> server_config = ServerConfig(auth=('admin', 'pass'), url='https://foreman',verify=False)
>>> jobtmpl = JobTemplate(server_config, organization=[1])
>>> jobtmpl.search()
**[nailgun.entities.JobTemplate(description_format='Run Ansible roles', job_category='Ansible Playbook', name='Ansible Roles - Ansible Default', provider_type='Ansible', snippet=False, id=155)**, nailgun.entities.JobTemplate(description_format="Install roles '%{ansible_roles_list}' from Galaxy", job_category='Ansible Galaxy', name='Ansible Roles - Install from Galaxy', provider_type='Ansible', snippet=False, id=156), nailgun.entities.JobTemplate(description_format='Clone roles from git repository to %{location}', job_category='Ansible Roles Installation', name='Ansible Roles - Install from git', provider_type='Ansible', snippet=False, id=157), nailgun.entities.JobTemplate(description_format='Insights maintenance plan for host', job_category='Ansible Playbook', name='Ansible - Run insights maintenance plan', provider_type='Ansible', snippet=False, id=159), nailgun.entities.JobTemplate(description_format=None, job_category='Ansible Playbook', name='Ansible - Run playbook', provider_type='Ansible', snippet=False, id=165), nailgun.entities.JobTemplate(description_format='Check for package updates', job_category='Packages', name='Check Update - SSH Default', provider_type='SSH', snippet=False, id=128), nailgun.entities.JobTemplate(description_format=None, job_category='Ansible Playbook', name='Connect Red Hat receptor controller', provider_type='Ansible', snippet=False, id=158), nailgun.entities.JobTemplate(description_format='Install errata %{errata}', job_category='Katello via Ansible', name='Install Errata - Katello Ansible Default', provider_type='Ansible', snippet=False, id=140), nailgun.entities.JobTemplate(description_format='Install errata %{errata}', job_category='Katello', name='Install Errata - Katello SSH Default', provider_type='SSH', snippet=False, id=139), nailgun.entities.JobTemplate(description_format='Install package group(s) %{package}', job_category='Katello via Ansible', name='Install Group - Katello Ansible Default', provider_type='Ansible', snippet=False, id=142), nailgun.entities.JobTemplate(description_format='Install package group(s) %{package}', job_category='Katello', name='Install Group - Katello SSH Default', provider_type='SSH', snippet=False, id=141), nailgun.entities.JobTemplate(description_format='Install package(s) %{package}', job_category='Katello via Ansible', name='Install Package - Katello Ansible Default', provider_type='Ansible', snippet=False, id=144), nailgun.entities.JobTemplate(description_format='Install package(s) %{package}', job_category='Katello', name='Install Package - Katello SSH Default', provider_type='SSH', snippet=False, id=143), nailgun.entities.JobTemplate(description_format='Module %{action} %{module_spec}', job_category='Ansible Modules', name='Module Action - Ansible Default', provider_type='Ansible', snippet=False, id=160), nailgun.entities.JobTemplate(description_format='Module %{action} %{module_spec}', job_category='Modules', name='Module Action - SSH Default', provider_type='SSH', snippet=False, id=129), nailgun.entities.JobTemplate(description_format='Package %{name}: %{state}', job_category='Ansible Packages', name='Package Action - Ansible Default', provider_type='Ansible', snippet=False, id=161), nailgun.entities.JobTemplate(description_format='%{action} package(s) %{package}', job_category='Packages', name='Package Action - SSH Default', provider_type='SSH', snippet=False, id=130), nailgun.entities.JobTemplate(description_format='%{action} host', job_category='Ansible Power', name='Power Action - Ansible Default', provider_type='Ansible', snippet=False, id=162), nailgun.entities.JobTemplate(description_format='%{action} host', job_category='Power', name='Power Action - SSH Default', provider_type='SSH', snippet=False, id=131), nailgun.entities.JobTemplate(description_format='Disable Puppet agent', job_category='Puppet', name='Puppet Agent Disable - SSH Default', provider_type='SSH', snippet=False, id=132)]
>>> jobtmpl.id=155
>>> jobtmpl.read()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/sam/.pyenv/versions/3.6.1/lib/python3.6/site-packages/nailgun/entities.py", line 1614, in read
    ignore=ignore, params=params)
  File "/home/sam/.pyenv/versions/3.6.1/lib/python3.6/site-packages/nailgun/entity_mixins.py", line 822, in read
    setattr(entity, field_name, attrs[field_name])
KeyError: 'audit_comment'

I checked the source code seems when ignore is None it will add 'template_input' into ignore.
Could you please check if 'audit_comment' should be added as well?
Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant