nailgun.entities

This module defines all entities which Foreman exposes.

Each class in this module allows you to work with a certain set of logically related API paths exposed by the server. For example, nailgun.entities.Host lets you work with the /api/v2/hosts API path and sub-paths. Each class attribute corresponds an attribute of that entity. For example, the Host.name class attribute represents the name of a host. These class attributes are used by the various mixins, such as nailgun.entity_mixins.EntityCreateMixin.

Several classes contain work-arounds for bugs. These bugs often affect only specific server releases, and ideally, the work-arounds should only be attempted if communicating with an affected server. However, work-arounds can only be conditionally triggered if NailGun has a facility for determining which software version the server is running. Until then, the safe route will be taken, and all work-arounds will be attempted all the time. Each method that makes use of a work-around notes so in its docstring.

nailgun.entity_mixins.Entity provides more insight into the inner workings of entity classes.

exception nailgun.entities.APIResponseError

Indicates an error if response returns unexpected result.

class nailgun.entities.AbstractComputeResource(server_config=None, **kwargs)

A representation of a Compute Resource entity.

associate(synchronous=True, **kwargs)

Associate the host

Parameters: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.
available_flavors(synchronous=True, **kwargs)

Get flavors available to be added to the compute resource

Parameters:
  • 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.
  • 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.

available_images(synchronous=True, **kwargs)

Get images available to be added to the compute resource

Parameters:
  • 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.
  • 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.

available_networks(synchronous=True, **kwargs)

Get networks available to be selected for host provisioning

Parameters:
  • 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.
  • 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.

available_zones(synchronous=True, **kwargs)

Get images available to be added to the compute resource

Parameters:
  • 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.
  • 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.

create_payload()

Wrap submitted data within an extra dict.

For more information, see Bugzilla #1151220.

images(synchronous=True, **kwargs)

Get images created in a compute resource

Parameters:
  • 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.
  • 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.

path(which=None)

Extend nailgun.entity_mixins.Entity.path. The format of the returned path depends on the value of which:

available_images
/api/compute_resources/:id/available_images
available_flavors
/api/compute_resources/:id/available_flavors
available_zones
/api/compute_resources/:id/available_zones
available_networks
/api/compute_resources/:id/available_networks
images
/api/compute_resources/:id/images
associate
/api/compute_resources/:id/associate

Otherwise, call super.

update(fields=None)

Fetch a complete set of attributes for this entity.

For more information, see Bugzilla #1250922.

update_payload(fields=None)

Wrap submitted data within an extra dict.

class nailgun.entities.AbstractContentViewFilter(server_config=None, **kwargs)

A representation of a Content View Filter entity.

class nailgun.entities.ActivationKey(server_config=None, **kwargs)

A representation of a Activation Key entity.

add_host_collection(synchronous=True, **kwargs)

Helper for associating host collection with activation key.

Parameters:
  • 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.
  • 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.

add_subscriptions(synchronous=True, **kwargs)

Helper for adding subscriptions to activation key.

Parameters:
  • 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.
  • 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.

content_override(synchronous=True, **kwargs)

Override the content of an activation key.

Parameters:
  • 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.
  • 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.

copy(synchronous=True, **kwargs)

Copy provided activation key.

Parameters:
  • 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.
  • 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.

path(which=None)

Extend nailgun.entity_mixins.Entity.path.

The format of the returned path depends on the value of which:

add_subscriptions
/activation_keys/<id>/add_subscriptions
copy
/activation_keys/<id>/copy
content_override
/activation_keys/<id>/content_override
product_content
/activation_keys/<id>/product_content
releases
/activation_keys/<id>/releases
remove_subscriptions
/activation_keys/<id>/remove_subscriptions
subscriptions
/activation_keys/<id>/subscriptions

super is called otherwise.

product_content(synchronous=True, **kwargs)

Helper for showing content available for activation key.

Parameters:
  • 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.
  • 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.

remove_host_collection(synchronous=True, **kwargs)

Helper for disassociating host collection from the activation key.

Parameters:
  • 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.
  • 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.

remove_subscriptions(synchronous=True, **kwargs)

Helper for removing subscriptions from an activation key.

Parameters:
  • 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.
  • 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.

subscriptions(synchronous=True, **kwargs)

Helper for retrieving subscriptions on an activation key.

Parameters:
  • 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.
  • 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.

class nailgun.entities.Architecture(server_config=None, **kwargs)

A representation of a Architecture entity.

create_payload()

Wrap submitted data within an extra dict.

For more information, see Bugzilla #1151220.

update(fields=None)

Fetch a complete set of attributes for this entity.

For more information, see Bugzilla #1234964.

class nailgun.entities.ArfReport(server_config=None, **kwargs)

A representation of a Arf Report entity.

# Read Arf report ArfReport(id=<id>).read() # Delete Arf report ArfReport(id=<id>).delete() # Download Arf report in HTML ArfReport(id=<id>).download_html()

download_html(synchronous=True, **kwargs)

Download ARF report in HTML

Parameters:
  • 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.
  • 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.

path(which=None)

Extend nailgun.entity_mixins.Entity.path. The format of the returned path depends on the value of which:

download_html
/api/compliance/arf_reports/:id/download_html

Otherwise, call super.

class nailgun.entities.Audit(server_config=None, **kwargs)

A representation of Audit entity.

class nailgun.entities.AuthSourceLDAP(server_config=None, **kwargs)

A representation of a AuthSourceLDAP entity.

create_missing()

Possibly set several extra instance attributes.

If onthefly_register is set and is true, set the following instance attributes:

  • account_password
  • account_firstname
  • account_lastname
  • attr_login
  • attr_mail
read(entity=None, attrs=None, ignore=None, params=None)

Do not read the account_password attribute. Work around a bug.

For more information, see Bugzilla #1243036.

class nailgun.entities.AzureRMComputeResource(server_config=None, **kwargs)

A representation for compute resources with AzureRM provider

read(entity=None, attrs=None, ignore=None, params=None)

Make sure, secret_key is in the ignore list for read

class nailgun.entities.Bookmark(server_config=None, **kwargs)

A representation of a Bookmark entity.

class nailgun.entities.Capsule(server_config=None, **kwargs)

A representation of a Capsule entity.

content_add_lifecycle_environment(synchronous=True, **kwargs)

Helper to associate lifecycle environment with capsule

Parameters:
  • 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.
  • 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.

content_get_sync(synchronous=True, **kwargs)

Helper to get content sync status on capsule

Parameters:
  • 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.
  • 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.

content_lifecycle_environments(synchronous=True, **kwargs)

Helper to get all the lifecycle environments, associated with capsule

Parameters:
  • 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.
  • 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.

content_sync(synchronous=True, **kwargs)

Helper to sync content on a capsule

Parameters:
  • 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.
  • 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.

path(which=None)

Extend nailgun.entity_mixins.Entity.path.

The format of the returned path depends on the value of which:

content_lifecycle_environments
/capsules/<id>/content/lifecycle_environments
content_sync
/capsules/<id>/content/sync

super is called otherwise.

class nailgun.entities.CommonParameter(server_config=None, **kwargs)

A representation of a Common Parameter entity.

class nailgun.entities.CompliancePolicies(server_config=None, **kwargs)

A representation of a Policy entity.

update(fields=None)

Fetch a complete set of attributes for this entity.

For more information, see Bugzilla #1746934.

class nailgun.entities.ComputeAttribute(server_config=None, **kwargs)

A representation of a Compute Attribute entity.

class nailgun.entities.ComputeProfile(server_config=None, **kwargs)

A representation of a Compute Profile entity.

class nailgun.entities.ConfigGroup(server_config=None, **kwargs)

A representation of a Config Group entity.

class nailgun.entities.ContentCredential(server_config=None, **kwargs)

A representation of a Content Credential entity.

class nailgun.entities.ContentUpload(server_config=None, **kwargs)

A representation of a Content Upload entity.

path(which=None)

Extend nailgun.entity_mixins.Entity.path.

read(entity=None, attrs=None, ignore=None, params=None)

Provide a default value for entity.

By default, nailgun.entity_mixins.EntityReadMixin.read provides a default value for entity like so:

entity = type(self)()

However, ContentUpload requires that a repository be provided, so this technique will not work. Do this instead:

entity = type(self)(repository=self.repository.id)
update(fields=None, **kwargs)

Update the current entity.

Make an HTTP PUT call to self.path('base'). Return the response.

Parameters:fields – An iterable of field names. Only the fields named in this iterable will be updated. No fields are updated if an empty iterable is passed in. All fields are updated if None is passed in.
Returns:A requests.response object.
upload(filepath, content_type=None, filename=None)

Upload content.

Parameters:
  • filepath – path to the file that should be chunked and uploaded
  • content_type – type of content
  • filename – name of the file on the server, defaults to the last part of the filepath if not set
Returns:

The server’s response, with all JSON decoded.

Raises:

requests.exceptions.HTTPError If the server responds with an HTTP 4XX or 5XX message.

Raises:

nailgun.entities.APIResponseError – If the response has a status other than “success”.

class nailgun.entities.ContentView(server_config=None, **kwargs)

A representation of a Content View entity.

available_puppet_modules(synchronous=True, **kwargs)

Get puppet modules available to be added to the content view.

Parameters:
  • 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.
  • 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.

copy(synchronous=True, **kwargs)

Clone provided content view.

Parameters:
  • 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.
  • 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.

delete_from_environment(environment, synchronous=True)

Delete this content view version from an environment.

This method acts much like nailgun.entity_mixins.EntityDeleteMixin.delete(). The documentation on that method describes how the deletion procedure works in general. This method differs only in accepting an environment parameter.

Parameters:environment – A nailgun.entities.Environment object. The environment’s id parameter must be specified. As a convenience, an environment ID may be passed in instead of an Environment object.
path(which=None)

Extend nailgun.entity_mixins.Entity.path.

The format of the returned path depends on the value of which:

content_view_puppet_modules
/content_views/<id>/content_view_puppet_modules
content_view_versions
/content_views/<id>/content_view_versions
publish
/content_views/<id>/publish
available_puppet_module_names
/content_views/<id>/available_puppet_module_names

super is called otherwise.

publish(synchronous=True, **kwargs)

Helper for publishing an existing content view.

Parameters:
  • 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.
  • 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.

read(entity=None, attrs=None, ignore=None, params=None)

Fetch an attribute missing from the server’s response.

For more information, see Bugzilla #1237257.

Add content_view_component to the response if needed, as nailgun.entity_mixins.EntityReadMixin.read() can’t initialize content_view_component.

search(fields=None, query=None, filters=None)

Search for entities.

Parameters:
  • fields – A set naming which fields should be used when generating a search query. If None, all values on the entity are used. If an empty set, no values are used.
  • query – A dict containing a raw search query. This is melded in to the generated search query like so: {generated: query}.update({manual: query}).
  • filters – A dict. Used to filter search results locally.
Returns:

A list of entities, all of type type(self).

class nailgun.entities.ContentViewComponent(server_config=None, **kwargs)

A representation of a Content View Components entity.

add(synchronous=True, **kwargs)

Add provided Content View Component.

Parameters:
  • 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.
  • 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.

path(which=None)

Extend nailgun.entity_mixins.Entity.path. The format of the returned path depends on the value of which:

add
/content_view_components/add
remove
/content_view_components/remove

Otherwise, call super.

read(entity=None, attrs=None, ignore=None, params=None)

Add composite_content_view to the response if needed, as nailgun.entity_mixins.EntityReadMixin.read() can’t initialize composite_content_view.

remove(synchronous=True, **kwargs)

remove provided Content View Component.

Parameters:
  • 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.
  • 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.

class nailgun.entities.ContentViewFilterRule(server_config=None, **kwargs)

A representation of a Content View Filter Rule entity.

create_payload()

Reset errata_id from DB ID to errata_id.

read(entity=None, attrs=None, ignore=None, params=None)

Do not read certain fields.

Do not expect the server to return the content_view_filter attribute. This has no practical impact, as the attribute must be provided when a nailgun.entities.ContentViewFilterRule is instantiated.

Also, ignore any field that is not returned by the server. For more information, see Bugzilla #1238408.

search_payload(fields=None, query=None)

Reset errata_id from DB ID to errata_id.

update_payload(fields=None)

Reset errata_id from DB ID to errata_id.

class nailgun.entities.ContentViewPuppetModule(server_config=None, **kwargs)

A representation of a Content View Puppet Module entity.

content_view must be passed in when this entity is instantiated.

Raises:TypeError if content_view is not passed in.
read(entity=None, attrs=None, ignore=None, params=None)

Provide a default value for entity.

By default, nailgun.entity_mixins.EntityReadMixin.read provides a default value for ``entity like so:

entity = type(self)()

However, ContentViewPuppetModule requires that an content_view be provided, so this technique will not work. Do this instead:

entity = type(self)(content_view=self.content_view.id)
class nailgun.entities.ContentViewVersion(server_config=None, **kwargs)

A representation of a Content View Version non-entity.

incremental_update(synchronous=True, **kwargs)

Helper for incrementally updating a content view version.

Parameters:
  • 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.
  • 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.

path(which=None)

Extend nailgun.entity_mixins.Entity.path.

The format of the returned path depends on the value of which:

incremental_update
/content_view_versions/incremental_update
promote
/content_view_versions/<id>/promote

super is called otherwise.

promote(synchronous=True, **kwargs)

Helper for promoting an existing published content view.

Parameters:
  • 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.
  • 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.

class nailgun.entities.DiscoveredHost(server_config=None, **kwargs)

A representation of a Foreman Discovered Host entity.

create_payload()

Wrap submitted data within an extra dict.

For more information, see Bugzilla #1151220.

facts(synchronous=True, **kwargs)

Helper to update facts for discovered host, and create the host.

Parameters:
  • 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.
  • 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.

path(which=None)

Extend nailgun.entity_mixins.Entity.path.

The format of the returned path depends on the value of which:

facts
/discovered_hosts/facts
refresh_facts
/discovered_hosts/<id>/refresh_facts
reboot
/discovered_hosts/<id>/reboot

super is called otherwise.

read(entity=None, attrs=None, ignore=None, params=None)

Make sure, ip, mac, root_pass and hostgroup are in the ignore list for read

reboot(synchronous=True, **kwargs)

Helper to reboot the discovered host

Parameters:
  • 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.
  • 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.

refresh_facts(synchronous=True, **kwargs)

Helper to refresh facts for discovered host

Parameters:
  • 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.
  • 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.

update_payload(fields=None)

Wrap submitted data within an extra dict.

class nailgun.entities.DiscoveryRule(server_config=None, **kwargs)

A representation of a Foreman Discovery Rule entity.

Note

The search_ field is named as such due to a naming conflict with nailgun.entity_mixins.Entity.path().

create(create_missing=None)

Do extra work to fetch a complete set of attributes for this entity.

For more information, see Bugzilla #1381129.

create_payload()

Wrap submitted data within an extra dict.

For more information, see Bugzilla #1151220.

In addition, rename the search_ field to search.

read(entity=None, attrs=None, ignore=None, params=None)

Work around a bug. Rename search to search_.

For more information on the bug, see Bugzilla #1257255.

update(fields=None)

Fetch a complete set of attributes for this entity.

For more information, see Bugzilla #1381129.

update_payload(fields=None)

Wrap submitted data within an extra dict.

class nailgun.entities.Domain(server_config=None, **kwargs)

A representation of a Domain entity.

create(create_missing=None)

Manually fetch a complete set of attributes for this entity.

For more information, see Bugzilla #1219654.

create_missing()

Customize the process of auto-generating instance attributes.

By default, nailgun.entity_fields.StringField.gen_value() can produce strings in both lower and upper cases, but domain name should be always in lower case due logical reason.

create_payload()

Wrap submitted data within an extra dict.

For more information, see Bugzilla #1151220.

read(entity=None, attrs=None, ignore=None, params=None)

Deal with weirdly named data returned from the server.

For more information, see Bugzilla #1233245.

update(fields=None)

Fetch a complete set of attributes for this entity.

For more information, see Bugzilla #1234999.

update_payload(fields=None)

Wrap submitted data within an extra dict.

class nailgun.entities.Environment(server_config=None, **kwargs)

A representation of a Environment entity.

create_payload()

Wrap submitted data within an extra dict.

For more information, see Bugzilla #1151220.

list_scparams(synchronous=True, **kwargs)

List all smart class parameters

Parameters:
  • 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.
  • 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.

path(which=None)

Extend nailgun.entity_mixins.Entity.path. The format of the returned path depends on the value of which:

smart_class_parameters
/api/environments/:environment_id/smart_class_parameters

Otherwise, call super.

update(fields=None)

Fetch a complete set of attributes for this entity.

For more information, see Bugzilla #1262029.

update_payload(fields=None)

Wrap submitted data within an extra dict.

class nailgun.entities.Errata(server_config=None, **kwargs)

A representation of an Errata entity.

compare(synchronous=True, **kwargs)

Compare errata from different content view versions

Parameters:
  • 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.
  • 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.

path(which=None)

Extend nailgun.entity_mixins.Entity.path.

The format of the returned path depends on the value of which:

compare
/katello/api/errata/compare

Otherwise, call super.

read(entity=None, attrs=None, ignore=None, params=None)

Following fields are only accessible for filtering search results and are never returned by the server: content_view_version_id, environment_id, repository_id.

class nailgun.entities.ErratumContentViewFilter(server_config=None, **kwargs)

A representation of a Content View Filter of type “erratum”.

class nailgun.entities.ExternalUserGroup(server_config=None, **kwargs)

A representation of a External Usergroup entity.

usergroup must be passed in when this entity is instantiated.

Raises:

TypeError if usergroup is not passed in.

# Create external usergroup ExternalUserGroup(name=’foobargroup’,usergroup=usergroup,auth_source=auth).create() # Read external usergroup ExternalUserGroup(id=<id>, usergroup=usergroup).read() # Delete external usergroup ExternalUserGroup(id=<id>, usergroup=usergroup).delete() # Refresh external usergroup ExternalUserGroup(id=<id>, usergroup=usergroup).refresh()

path(which=None)

Extend nailgun.entity_mixins.Entity.path.

The format of the returned path depends on the value of which:

refresh
/api/usergroups/:usergroup_id/external_usergroups/:id/refresh
read(entity=None, attrs=None, ignore=None, params=None)

Ignore usergroup from read and alter auth_source_ldap with auth_source

refresh(synchronous=True, **kwargs)

Refresh external usergroup.

Parameters:
  • 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.
  • 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.

class nailgun.entities.File(server_config=None, **kwargs)

A representation of a Package entity.

class nailgun.entities.Filter(server_config=None, **kwargs)

A representation of a Filter entity.

create_payload()

Wrap submitted data within an extra dict.

For more information, see Bugzilla #1151220.

read(entity=None, attrs=None, ignore=None, params=None)

Deal with different named data returned from the server

update_payload(fields=None)

Wrap submitted data within an extra dict.

class nailgun.entities.ForemanStatus(server_config=None, **kwargs)

A representation of the Foreman Status entity.

class nailgun.entities.ForemanTask(server_config=None, **kwargs)

A representation of a Foreman task.

path(which=None)

Extend nailgun.entity_mixins.Entity.path.

The format of the returned path depends on the value of which:

bulk_resume
/foreman_tasks/api/tasks/bulk_resume
bulk_search
/foreman_tasks/api/tasks/bulk_search
summary
/foreman_tasks/api/tasks/summary

Otherwise, call super.

poll(poll_rate=None, timeout=None)

Return the status of a task or timeout.

There are several API calls that trigger asynchronous tasks, such as synchronizing a repository, or publishing or promoting a content view. It is possible to check on the status of a task if you know its UUID. This method polls a task once every poll_rate seconds and, upon task completion, returns information about that task.

Parameters:
  • poll_rate – Delay between the end of one task check-up and the start of the next check-up. Defaults to nailgun.entity_mixins.TASK_POLL_RATE.
  • timeout – Maximum number of seconds to wait until timing out. Defaults to nailgun.entity_mixins.TASK_TIMEOUT.
Returns:

Information about the asynchronous task.

Raises:

nailgun.entity_mixins.TaskTimedOutError if the task completes with any result other than “success”.

Raises:

nailgun.entity_mixins.TaskFailedError if the task finishes with any result other than “success”.

Raises:

requests.exceptions.HTTPError If the API returns a message with an HTTP 4XX or 5XX status code.

summary(synchronous=True, **kwargs)

Helper to view a summary of tasks.

Parameters:
  • 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.
  • 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.

class nailgun.entities.GCEComputeResource(server_config=None, **kwargs)

A representation of a Google Compute Resource entity.

class nailgun.entities.GPGKey(server_config=None, **kwargs)

A representation of a GPG Key entity.

class nailgun.entities.HTTPProxy(server_config=None, **kwargs)

A representation of a HTTP Proxy entity.

create_payload()

Wrap submitted data within an extra dict. For more information, see Bugzilla #1151220.

read(entity=None, attrs=None, ignore=None, params=None)

Make sure, password, organization and location is in the ignore list for read. For more information, see Bugzilla #1779642.

update_payload(fields=None)

Wrap submitted data within an extra dict.

class nailgun.entities.Host(server_config=None, **kwargs)

A representation of a Host entity.

add_puppetclass(synchronous=True, **kwargs)

Add a Puppet class to host

Here is an example of how to use this method::
host.add_puppetclass(data={‘puppetclass_id’: puppet.id})
Parameters:
  • 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.
  • 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.

create(create_missing=None)

Manually fetch a complete set of attributes for this entity.

For more information, see Bugzilla #1449749.

create_missing()

Create a bogus managed host.

The exact set of attributes that are required varies depending on whether the host is managed or inherits values from a host group and other factors. Unfortunately, the rules for determining which attributes should be filled in are mildly complex, and it is hard to know which scenario a user is aiming for.

Populate the values necessary to create a bogus managed host. The resultant dependency graph will look, in part, like this:

     .-> medium --------.
     |-> architecture <-V-.
host --> operatingsystem -|
     |-> ptable <---------'
     |-> domain
     '-> environment

If nested entities were passed by id (i.e. entity was only initialized and not read, and therefore contains only id field) perform additional read request.

create_payload()

Wrap submitted data within an extra dict.

For more information, see Bugzilla #1151220.

delete_puppetclass(synchronous=True, **kwargs)

Remove a Puppet class from host

Here is an example of how to use this method::
host.delete_puppetclass(data={‘puppetclass_id’: puppet.id})
Constructs path:
/api/hosts/:hostgroup_id/puppetclass_ids/:id
Parameters:
  • 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.
  • 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.

disassociate(synchronous=True, **kwargs)

Disassociate the host

Parameters: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.
enc(synchronous=True, **kwargs)

Return external node classifier (ENC) information

Parameters:
  • 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.
  • 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.

errata(synchronous=True, **kwargs)

List errata available for the host

Parameters:
  • 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.
  • 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.

errata_applicability(synchronous=True, **kwargs)

Force regenerate errata applicability

Parameters:
  • 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.
  • 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.

errata_apply(synchronous=True, **kwargs)

Schedule errata for installation

Parameters:
  • 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.
  • 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.

get_facts(synchronous=True, **kwargs)

List all fact values of a given host

Parameters:
  • 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.
  • 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.

get_values()

Correctly set the owner_type attribute.

install_content(synchronous=True, **kwargs)

Install content on one or more hosts

Parameters:
  • 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.
  • 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.

list_scparams(synchronous=True, **kwargs)

List all smart class parameters

Parameters:
  • 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.
  • 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.

list_smart_variables(synchronous=True, **kwargs)

List all smart variables

Parameters:
  • 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.
  • 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.

module_streams(synchronous=True, **kwargs)

List module_streams available for the host

Parameters:
  • 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.
  • 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.

owner_type

Return _owner_type.

packages(synchronous=True, **kwargs)

List packages installed on the host

Parameters:
  • 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.
  • 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.

path(which=None)

Extend nailgun.entity_mixins.Entity.path. The format of the returned path depends on the value of which:

bulk/install_content
/api/hosts/:host_id/bulk/install_content
errata
/api/hosts/:host_id/errata
power
/api/hosts/:host_id/power
errata/apply
/api/hosts/:host_id/errata/apply
puppetclass_ids
/api/hosts/:host_id/puppetclass_ids
smart_class_parameters
/api/hosts/:host_id/smart_class_parameters
smart_variables
/api/hosts/:host_id/smart_class_variables
module_streams
/api/hosts/:host_id/module_streams
disassociate
/api/hosts/:host_id/disassociate

Otherwise, call super.

power(synchronous=True, **kwargs)

Power the host off or on

Parameters: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.
read(entity=None, attrs=None, ignore=None, params=None)

Deal with oddly named and structured data returned by the server.

For more information, see Bugzilla #1235019 and Bugzilla #1449749.

content_facet_attributes are returned only in case any of facet attributes were actually set.

Also add image to the response if needed, as nailgun.entity_mixins.EntityReadMixin.read() can’t initialize image.

search(fields=None, query=None, filters=None)

Search for entities.

Parameters:
  • fields – A set naming which fields should be used when generating a search query. If None, all values on the entity are used. If an empty set, no values are used.
  • query – A dict containing a raw search query. This is melded in to the generated search query like so: {generated: query}.update({manual: query}).
  • filters – A dict. Used to filter search results locally.
Returns:

A list of entities, all of type type(self).

update(fields=None)

Fetch a complete set of attributes for this entity.

For more information, see Bugzilla #1235049.

Warning

Several attributes cannot be updated. See Bugzilla #1235041.

update_payload(fields=None)

Wrap submitted data within an extra dict.

upload_facts(synchronous=True, **kwargs)

Upload facts for a host, creating the host if required

Parameters:
  • 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.
  • 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.

class nailgun.entities.HostCollection(server_config=None, **kwargs)

A representation of a Host Collection entity.

create(create_missing=None)

Manually fetch a complete set of attributes for this entity.

For more information, see Bugzilla #1654383.

create_payload()

Rename system_ids to system_uuids.

update_payload(fields=None)

Rename system_ids to system_uuids.

class nailgun.entities.HostCollectionErrata(server_config=None, **kwargs)

A representation of a Host Collection Errata entity.

class nailgun.entities.HostCollectionPackage(server_config=None, **kwargs)

A representation of a Host Collection Package entity.

class nailgun.entities.HostGroup(server_config=None, **kwargs)

A representation of a Host Group entity.

add_puppetclass(synchronous=True, **kwargs)

Add a Puppet class to host group

Here is an example of how to use this method::
hostgroup.add_puppetclass(data={‘puppetclass_id’: puppet.id})
Parameters:
  • 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.
  • 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.

clone(synchronous=True, **kwargs)

Helper to clone an existing host group

Parameters:
  • 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.
  • 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.

create(create_missing=None)

Do extra work to fetch a complete set of attributes for this entity.

For more information, see Bugzilla #1235377.

create_payload()

Wrap submitted data within an extra dict.

For more information, see Bugzilla #1151220.

delete_puppetclass(synchronous=True, **kwargs)

Remove a Puppet class from host group

Here is an example of how to use this method::
hostgroup.delete_puppetclass(data={‘puppetclass_id’: puppet.id})
Constructs path:
/api/hostgroups/:hostgroup_id/puppetclass_ids/:id
Parameters:
  • 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.
  • 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.

list_scparams(synchronous=True, **kwargs)

List all smart class parameters

Parameters:
  • 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.
  • 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.

list_smart_variables(synchronous=True, **kwargs)

List all smart variables

Parameters:
  • 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.
  • 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.

path(which=None)

Extend nailgun.entity_mixins.Entity.path. The format of the returned path depends on the value of which:

clone
/api/hostgroups/:hostgroup_id/clone
puppetclass_ids
/api/hostgroups/:hostgroup_id/puppetclass_ids
rebuild_config
/api/hostgroups/:hostgroup_id/rebuild_config
smart_class_parameters
/api/hostgroups/:hostgroup_id/smart_class_parameters
smart_class_variables
/api/hostgroups/:hostgroup_id/smart_variables

Otherwise, call super.

read(entity=None, attrs=None, ignore=None, params=None)

Deal with several bugs.

For more information, see:

rebuild_config(synchronous=True, **kwargs)

Helper to ‘Rebuild orchestration config’ of an existing host group

Parameters:
  • 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.
  • 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.

update(fields=None)

Deal with several bugs.

For more information, see:

update_payload(fields=None)

Wrap submitted data within an extra dict.

class nailgun.entities.HostPackage(server_config=None, **kwargs)

A representation of a Host Package entity.

class nailgun.entities.HostSubscription(server_config=None, **kwargs)

A representation of a Host Subscription entity.

add_subscriptions(synchronous=True, **kwargs)

Helper for adding subscriptions to host

Parameters:
  • 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.
  • 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.

path(which=None)

Extend nailgun.entity_mixins.Entity.path.

The format of the returned path depends on the value of which:

add_subscriptions
/hosts/<id>/add_subscriptions
remove_subscriptions
/hosts/<id>/remove_subscriptions

super is called otherwise.

remove_subscriptions(synchronous=True, **kwargs)

Helper for removing subscriptions from host

Parameters:
  • 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.
  • 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.

class nailgun.entities.Image(server_config=None, **kwargs)

A representation of a Image entity.

create_payload()

Wrap submitted data within an extra dict.

read(entity=None, attrs=None, ignore=None, params=None)

Provide a default value for entity.

By default, nailgun.entity_mixins.EntityReadMixin.read provides a default value for entity like so:

entity = type(self)()

However, Image requires that an compute_resource be provided, so this technique will not work. Do this instead:

entity = type(self)(compute_resource=self.compute_resource.id)
update_payload(fields=None)

Wrap submitted data within an extra dict.

class nailgun.entities.Interface(server_config=None, **kwargs)

A representation of a Interface entity.

host must be passed in when this entity is instantiated.

Raises:TypeError if host is not passed in.
read(entity=None, attrs=None, ignore=None, params=None)

Provide a default value for entity.

By default, nailgun.entity_mixins.EntityReadMixin.read provides a default value for entity like so:

entity = type(self)()

However, Interface requires that a host must be provided, so this technique will not work. Do this instead:

entity = type(self)(host=self.host)

In addition, some of interface fields are specific to its type and are never returned for different type so ignoring all the redundant fields.

search_normalize(results)

Append host id to search results to be able to initialize found Interface successfully

class nailgun.entities.JobInvocation(server_config=None, **kwargs)

A representation of a Job invocation entity.

run(synchronous=True, **kwargs)

Helper to run existing job template

Parameters:
  • 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.
  • kwargs

    Arguments to pass to requests. ‘data’ supports next fields:

    required:
    job_template_id/feature, targeting_type, search_query/bookmark_id, inputs
    optional:
    description_format, concurrency_control scheduling, ssh, recurrence, execution_timeout_interval
Returns:

The server’s response, with all JSON decoded.

Raises:

requests.exceptions.HTTPError If the server responds with an HTTP 4XX or 5XX message.

class nailgun.entities.JobTemplate(server_config=None, **kwargs)

A representation of a Job Template entity.

create_payload()

Wrap submitted data within an extra dict.

read(entity=None, attrs=None, ignore=None, params=None)

Ignore the template inputs when initially reading the job template. Look up each TemplateInput entity separately and afterwords add them to the JobTemplate entity.

update_payload(fields=None)

Wrap submitted data within an extra dict.

class nailgun.entities.KatelloStatus(server_config=None, **kwargs)

A representation of a Status entity.

class nailgun.entities.LibvirtComputeResource(server_config=None, **kwargs)

A representation of a Libvirt Compute Resource entity.

class nailgun.entities.LifecycleEnvironment(server_config=None, **kwargs)

A representation of a Lifecycle Environment entity.

create_missing()

Automatically populate additional instance attributes.

When a new lifecycle environment is created, it must either:

  • Reference a parent lifecycle environment in the tree of lifecycle environments via the prior field, or
  • have a name of “Library”.

Within a given organization, there can only be a single lifecycle environment with a name of ‘Library’. This lifecycle environment is at the root of a tree of lifecycle environments, so its prior field is blank.

This method finds the ‘Library’ lifecycle environment within the current organization and points to it via the prior field. This is not done if the current lifecycle environment has a name of ‘Library’.

create_payload()

Rename the payload key “prior_id” to “prior”.

For more information, see Bugzilla #1238757.

class nailgun.entities.Location(server_config=None, **kwargs)

A representation of a Location entity.

create(create_missing=None)

Manually fetch a complete set of attributes for this entity.

For more information, see Bugzilla #1216236.

create_payload()

Wrap submitted data within an extra dict.

For more information, see Bugzilla #1151220.

read(entity=None, attrs=None, ignore=None, params=None)

Work around a bug in the server’s response.

Do not read the realm attribute. See Bugzilla #1216234.

update(fields=None)

Fetch a complete set of attributes for this entity.

Beware of Bugzilla #1236008: “Cannot use HTTP PUT to associate location with media”

update_payload(fields=None)

Wrap submitted data within an extra dict.

class nailgun.entities.Media(server_config=None, **kwargs)

A representation of a Media entity.

Note

The path_ field is named as such due to a naming conflict with nailgun.entity_mixins.Entity.path().

create(create_missing=None)

Manually fetch a complete set of attributes for this entity.

For more information, see Bugzilla #1219653.

create_payload()

Wrap submitted data within an extra dict and rename path_.

For more information on wrapping submitted data, see Bugzilla #1151220.

read(entity=None, attrs=None, ignore=None, params=None)

Rename path to path_.

update(fields=None)

Fetch a complete set of attributes for this entity.

Beware of Bugzilla #1261047: “PUT /api/v2/medium/:id doesn’t return all attributes”

update_payload(fields=None)

Wrap submitted data within an extra dict.

class nailgun.entities.Model(server_config=None, **kwargs)

A representation of a Model entity.

class nailgun.entities.ModuleStream(server_config=None, **kwargs)

A representation of a Module Stream entity.

class nailgun.entities.ModuleStreamContentViewFilter(server_config=None, **kwargs)

A representation of a Content View Filter of type “modulemd”.

class nailgun.entities.OSDefaultTemplate(server_config=None, **kwargs)

A representation of a OS Default Template entity.

read(entity=None, attrs=None, ignore=None, params=None)

Fetch as many attributes as possible for this entity. Since operatingsystem is needed to instanciate, prepare the entity accordingly.

update_payload(fields=None)

Wrap payload in os_default_template relates to Redmine #21169.

class nailgun.entities.OVirtComputeResource(server_config=None, **kwargs)

A representation for compute resources with Ovirt provider

read(entity=None, attrs=None, ignore=None, params=None)

Make sure, password is in the ignore list for read

class nailgun.entities.OperatingSystem(server_config=None, **kwargs)

A representation of a Operating System entity.

major is listed as a string field in the API docs, but only numeric values are accepted, and they may be no longer than 5 digits long. Also see Bugzilla #1122261.

title field is valid despite not being listed in the API docs. This may be changed in future as both title and description fields share similar purpose. See Bugzilla #1290359 for more details.

create_payload()

Wrap submitted data within an extra dict.

For more information, see Bugzilla #1151220.

update_payload(fields=None)

Wrap submitted data within an extra dict.

class nailgun.entities.OperatingSystemParameter(server_config=None, **kwargs)

A representation of a parameter for an operating system.

organization must be passed in when this entity is instantiated.

Raises:TypeError if operatingsystem is not passed in.
read(entity=None, attrs=None, ignore=None, params=None)

Provide a default value for entity.

By default, nailgun.entity_mixins.EntityReadMixin.read provides a default value for entity like so:

entity = type(self)()

However, OperatingSystemParameter requires that an operatingsystem be provided, so this technique will not work. Do this instead:

entity = type(self)(operatingsystem=self.operatingsystem.id)
class nailgun.entities.Organization(server_config=None, **kwargs)

A representation of an Organization entity.

create(create_missing=None)

Do extra work to fetch a complete set of attributes for this entity.

For more information, see Bugzilla #1230873.

download_debug_certificate(synchronous=True, **kwargs)

Get debug certificate for particular organization.

Parameters:
  • 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.
  • 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.

path(which=None)

Extend nailgun.entity_mixins.Entity.path.

The format of the returned path depends on the value of which:

download_debug_certificate
/organizations/<id>/download_debug_certificate
subscriptions
/organizations/<id>/subscriptions
subscriptions/upload
/organizations/<id>/subscriptions/upload
subscriptions/delete_manifest
/organizations/<id>/subscriptions/delete_manifest
subscriptions/refresh_manifest
/organizations/<id>/subscriptions/refresh_manifest
sync_plans
/organizations/<id>/sync_plans

Otherwise, call super.

read(entity=None, attrs=None, ignore=None, params=None)

Fetch as many attributes as possible for this entity.

Do not read the realm attribute. For more information, see Bugzilla #1230873.

update(fields=None)

Fetch a complete set of attributes for this entity.

For more information, see Bugzilla #1232871.

Warning

Several attributes cannot be updated. See Bugzilla #1230865.

update_payload(fields=None)

Wrap submitted data within an extra dict.

class nailgun.entities.OverrideValue(server_config=None, **kwargs)

A representation of a Override Value entity.

create_payload()

Remove smart_class_parameter_id or smart_variable_id

read(entity=None, attrs=None, ignore=None, params=None)

Provide a default value for entity.

By default, nailgun.entity_mixins.EntityReadMixin.read provides a default value for ``entity like so:

entity = type(self)()

However, OverrideValue requires that an smart_class_parameter or smart_varaiable be provided, so this technique will not work. Do this instead:

entity = type(self)(
    smart_class_parameter=self.smart_class_parameter)
entity = type(self)(smart_variable=self.smart_variable)
class nailgun.entities.Package(server_config=None, **kwargs)

A representation of a Package entity.

class nailgun.entities.PackageGroup(server_config=None, **kwargs)

A representation of a Package Group entity.

class nailgun.entities.PackageGroupContentViewFilter(server_config=None, **kwargs)

A representation of a Content View Filter of type “package_group”.

class nailgun.entities.Parameter(server_config=None, **kwargs)

A representation of a Parameter entity.

read(entity=None, attrs=None, ignore=None, params=None)

Ignore path related fields as they’re never returned by the server and are only added to entity to be able to use proper path.

class nailgun.entities.PartitionTable(server_config=None, **kwargs)

A representation of a Partition Table entity.

Currently a Partition Table with one character in name cannot be created. For more information, see Bugzilla #1229384.

Note: Having a name length of 2 had failures again. Updating the length to 4.

class nailgun.entities.Permission(server_config=None, **kwargs)

A representation of a Permission entity.

class nailgun.entities.Ping(server_config=None, **kwargs)

A representation of a Ping entity.

class nailgun.entities.Product(server_config=None, **kwargs)

A representation of a Product entity.

path(which=None)

Extend nailgun.entity_mixins.Entity.path.

The format of the returned path depends on the value of which:

sync
/products/<product_id>/sync

super is called otherwise.

read(entity=None, attrs=None, ignore=None, params=None)

Fetch an attribute missing from the server’s response.

Also add sync plan to the responce if needed, as nailgun.entity_mixins.EntityReadMixin.read() can’t initialize sync plan.

For more information, see Bugzilla #1237283 and nailgun#261.

search(fields=None, query=None, filters=None)

Search for entities with missing attribute

Parameters:
  • fields – A set naming which fields should be used when generating a search query. If None, all values on the entity are used. If an empty set, no values are used.
  • query – A dict containing a raw search query. This is melded in to the generated search query like so: {generated: query}.update({manual: query}).
  • filters – A dict. Used to filter search results locally.
Returns:

A list of entities, all of type type(self).

For more information, see Bugzilla #1237283 and nailgun#261.

sync(synchronous=True, **kwargs)

Synchronize repositories in this product.

Parameters:
  • 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.
  • 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.

class nailgun.entities.ProductBulkAction(server_config=None, **kwargs)

A representation of a Products bulk actions entity.

destroy(synchronous=True, **kwargs)

Helper to destroy one or more products.

Parameters:
  • 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.
  • 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.

http_proxy(synchronous=True, **kwargs)

Helper to update the http proxy configuration on the repositories of one or more products.

Parameters:
  • 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.
  • 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.

path(which=None)

Extend nailgun.entity_mixins.Entity.path.

The format of the returned path depends on the value of which:

destroy
/products/bulk/destroy
sync
/products/bulk/sync
sync_plan
/products/bulk/sync_plan
http_proxy
/products/bulk/http_proxy

super is called otherwise.

sync(synchronous=True, **kwargs)

Helper to sync one or more products.

Parameters:
  • 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.
  • 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.

sync_plan(synchronous=True, **kwargs)

Helper to sync one or more products.

Parameters:
  • 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.
  • 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.

class nailgun.entities.ProvisioningTemplate(server_config=None, **kwargs)

A representation of a Provisioning Template entity.

build_pxe_default(synchronous=True, **kwargs)

Helper to build pxe default template.

Parameters:
  • 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.
  • 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.

clone(synchronous=True, **kwargs)

Helper to clone an existing provision template

Parameters:
  • 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.
  • 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.

create_missing()

Customize the process of auto-generating instance attributes.

Populate template_kind if:

  • this template is not a snippet, and
  • the template_kind instance attribute is unset.
create_payload()

Wrap submitted data within an extra dict.

For more information, see Bugzilla #1151220.

path(which=None)

Extend nailgun.entity_mixins.Entity.path.

The format of the returned path depends on the value of which:

build_pxe_default
/provisioning_templates/build_pxe_default
clone
/provisioning_templates/clone
revision
/provisioning_templates/revision

super is called otherwise.

read(entity=None, attrs=None, ignore=None, params=None)

Provide a default value for entity.

By default, nailgun.entity_mixins.EntityReadMixin.read provides a default value for entity like so:

entity = type(self)()

However, ProvisioningTemplate requires that a audit_comment is provided, so this technique will not work.

update_payload(fields=None)

Wrap submitted data within an extra dict.

class nailgun.entities.PuppetClass(server_config=None, **kwargs)

A representation of a Puppet Class entity.

list_scparams(synchronous=True, **kwargs)

List of smart class parameters for a specific Puppet class

Parameters:
  • 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.
  • 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.

list_smart_variables(synchronous=True, **kwargs)

List all smart variables

Parameters:
  • 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.
  • 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.

path(which=None)

Extend nailgun.entity_mixins.Entity.path. The format of the returned path depends on the value of which:

smart_class_parameters
/api/puppetclasses/:puppetclass_id/smart_class_parameters

Otherwise, call super.

search_normalize(results)

Flattens results. nailgun.entity_mixins.EntitySearchMixin.search_normalize() expects structure like list(dict_1(name: class_1), dict_2(name: class_2)), while Puppet Class entity returns dictionary with lists of subclasses split by main puppet class.

class nailgun.entities.PuppetModule(server_config=None, **kwargs)

A representation of a Puppet Module entity.

class nailgun.entities.RHCIDeployment(server_config=None, **kwargs)

A representation of a RHCI deployment entity.

deploy(synchronous=True, **kwargs)

Kickoff the RHCI deployment.

Parameters:
  • 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.
  • 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.

path(which=None)

Extend nailgun.entity_mixins.Entity.path.

The format of the returned path depends on the value of which:

deploy
/deployments/<id>/deploy

super is called otherwise.

read(entity=None, attrs=None, ignore=None, params=None)

Normalize the data returned by the server.

The server’s JSON response is in this form:

{
    "organizations": […],
    "lifecycle_environments": […],
    "discovered_hosts": […],
    "deployment": {…},
}

The inner “deployment” dict contains information about this entity. The response does not contain a value for the rhev_engine_host argument.

class nailgun.entities.RPMContentViewFilter(server_config=None, **kwargs)

A representation of a Content View Filter of type “rpm”.

class nailgun.entities.Realm(server_config=None, **kwargs)

A representation of a Realm entity.

create(create_missing=None)

Do extra work to fetch a complete set of attributes for this entity.

For more information, see Bugzilla #1232855.

class nailgun.entities.RecurringLogic(server_config=None, **kwargs)

A representation of a Recurring logic entity.

cancel(synchronous=True, **kwargs)

Helper for canceling a recurring logic

Parameters:
  • 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.
  • 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.

path(which=None)

Extend nailgun.entity_mixins.RecurringLogic.path. The format of the returned path depends on the value of which:

cancel
/foreman_tasks/api/recurring_logics/:id/cancel

Otherwise, call super.

class nailgun.entities.Report(server_config=None, **kwargs)

A representation of a Report entity.

class nailgun.entities.ReportTemplate(server_config=None, **kwargs)

A representation of a Report Template entity.

clone(synchronous=True, **kwargs)

Helper to clone an existing report template

Parameters:
  • 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.
  • 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.

create_payload()

Wrap submitted data within an extra dict.

For more information, see Bugzilla #1151220.

generate(synchronous=True, **kwargs)

Helper to generate an existing report template

Parameters:
  • 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.
  • 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.

path(which=None)

Extend nailgun.entity_mixins.Entity.path.

The format of the returned path depends on the value of which:

clone
/report_templates/<id>/clone
generate
/report_templates/<id>/generate

super is called otherwise.

report_data(synchronous=True, **kwargs)

Helper to call report_data on an existing scheduled report

Parameters:
  • 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.
  • 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.

schedule_report(synchronous=True, **kwargs)

Helper to schedule an existing report template

Parameters:
  • 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.
  • 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.

update_payload(fields=None)

Wrap submitted data within an extra dict.

class nailgun.entities.Repository(server_config=None, **kwargs)

A representation of a Repository entity.

create_missing()

Conditionally mark docker_upstream_name as required.

Mark docker_upstream_name as required if content_type is “docker”.

errata(synchronous=True, **kwargs)

List errata inside repository.

Parameters:
  • 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.
  • 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.

files(synchronous=True, **kwargs)

List files associated with repository

Parameters:
  • 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.
  • 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.

import_uploads(content_type=None, uploads=None, upload_ids=None, synchronous=True, **kwargs)

Import uploads into a repository

It expects either a list of uploads or upload_ids (but not both).

Parameters:
  • content_type – content type (‘deb’, ‘docker_manifest’, ‘file’, ‘ostree’, ‘puppet_module’, ‘rpm’, ‘srpm’)
  • uploads – Array of uploads to be imported
  • upload_ids – Array of upload ids to be imported
  • 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.
  • 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.

module_streams(synchronous=True, **kwargs)

List module_streams associated with repository

Parameters:
  • 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.
  • 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.

packages(synchronous=True, **kwargs)

List packages associated with repository

Parameters:
  • 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.
  • 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.

path(which=None)

Extend nailgun.entity_mixins.Entity.path.

The format of the returned path depends on the value of which:

errata
/repositories/<id>/errata
files
/repositories/<id>/files
packages
/repositories/<id>/packages
module_streams
/repositories/<id>/module_streams
puppet_modules
/repositories/<id>/puppet_modules
remove_content
/repositories/<id>/remove_content
sync
/repositories/<id>/sync
upload_content
/repositories/<id>/upload_content
import_uploads
/repositories/<id>/import_uploads

super is called otherwise.

puppet_modules(synchronous=True, **kwargs)

“List puppet modules associated with repository

Parameters:
  • 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.
  • 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.

read(entity=None, attrs=None, ignore=None, params=None)

Ignore organization field as it’s never returned by the server and is only added to entity to be able to use organization path dependent helpers and also upstream_password as it is not returned for security reasons.

remove_content(synchronous=True, **kwargs)

Remove content from a repository

It expects packages/puppet modules/docker manifests ids sent as data. Here is an example of how to use this method:

repository.remove_content(data={'ids': [package.id]})
Parameters:
  • 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.
  • 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.

sync(synchronous=True, **kwargs)

Helper for syncing an existing repository.

Parameters:
  • 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.
  • 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.

upload_content(synchronous=True, **kwargs)

Upload a file or files to the current repository.

Here is an example of how to upload content:

with open('my_content.rpm') as content:
    repo.upload_content(files={'content': content})

This method accepts the same keyword arguments as Requests. As a result, the following examples can be adapted for use here:

Parameters:
  • 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.
  • 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.

Raises:

nailgun.entities.APIResponseError – If the response has a status other than “success”.

class nailgun.entities.RepositorySet(server_config=None, **kwargs)

A representation of a Repository Set entity

available_repositories(**kwargs)

Lists available repositories for the repository set

Parameters:
  • 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.
  • 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.

disable(synchronous=True, **kwargs)

Disables the RedHat Repository

Parameters:
  • 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.
  • 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.

enable(synchronous=True, **kwargs)

Enables the RedHat Repository

RedHat Repos needs to be enabled first, so that we can sync it.

Parameters:
  • 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.
  • 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.

path(which=None)

Extend nailgun.entity_mixins.Entity.path.

The format of the returned path depends on the value of which:

available_repositories
/repository_sets/<id>/available_repositories
enable
/repository_sets/<id>/enable
disable
/repository_sets/<id>/disable

super is called otherwise.

read(entity=None, attrs=None, ignore=None, params=None)

Provide a default value for entity.

By default, nailgun.entity_mixins.EntityReadMixin.read provides a default value for entity like so:

entity = type(self)()

However, RepositorySet requires that a product be provided, so this technique will not work. Do this instead:

entity = type(self)(product=self.product.id)
class nailgun.entities.Role(server_config=None, **kwargs)

A representation of a Role entity.

clone(synchronous=True, **kwargs)

Helper to clone an existing Role

Parameters:
  • 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.
  • 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.

create_payload()

Wrap submitted data within an extra dict.

For more information, see Bugzilla #1151220.

path(which=None)

Extend nailgun.entity_mixins.Entity.path. The format of the returned path depends on the value of which:

clone
/api/roles/:role_id/clone

Otherwise, call super.

update_payload(fields=None)

Wrap submitted data within an extra dict.

class nailgun.entities.RoleLDAPGroups(server_config=None, **kwargs)

A representation of a Role LDAP Groups entity.

class nailgun.entities.SSHKey(server_config=None, **kwargs)

A representation of a SSH Key entity.

user must be passed in when this entity is instantiated.

Raises:TypeError if user is not passed in.
read(entity=None, attrs=None, ignore=None, params=None)

Provide a default value for entity.

By default, nailgun.entity_mixins.EntityReadMixin.read provides a default value for entity like so:

entity = type(self)()

However, SSHKey requires that an user be provided, so this technique will not work. Do this instead:

entity = type(self)(user=self.user.id)
search_normalize(results)

Append user id to search results to be able to initialize found User successfully

class nailgun.entities.ScapContents(server_config=None, **kwargs)

A representation of a ScapContents entity.

create(create_missing=None)

Do extra work to fetch a complete set of attributes for this entity.

For more information, see Bugzilla #1381129.

path(which=None)

Extend nailgun.entity_mixins.Entity.path. The format of the returned path depends on the value of which:

xml
api/compliance/scap_contents/:id/xml

Otherwise, call super.

read(entity=None, attrs=None, ignore=None, params=None)

Override nailgun.entity_mixins.EntityReadMixin.read() to ignore the scap_file

update(fields=None)

Fetch a complete set of attributes for this entity.

xml(synchronous=True, **kwargs)

Download an SCAP content as XML

Parameters:
  • 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.
  • 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.

class nailgun.entities.Setting(server_config=None, **kwargs)

A representation of a Setting entity.

update_payload(fields=None)

Wrap submitted data within an extra dict.

class nailgun.entities.SmartClassParameters(server_config=None, **kwargs)

A representation of a Smart Class Parameters.

read(entity=None, attrs=None, ignore=None, params=None)

Do not read the hidden_value attribute.

class nailgun.entities.SmartProxy(server_config=None, **kwargs)

A representation of a Smart Proxy entity.

import_puppetclasses(synchronous=True, **kwargs)

Import puppet classes from puppet Capsule.

Parameters:
  • 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.
  • 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.

path(which=None)

Extend nailgun.entity_mixins.Entity.path. The format of the returned path depends on the value of which:

refresh
/api/smart_proxies/:id/refresh

Otherwise, call super.

read(entity=None, attrs=None, ignore=None, params=None)

Ignore download_policy field as it’s never returned by the server.

For more information, see Bugzilla #1486609.

refresh(synchronous=True, **kwargs)

Refresh Capsule features

Parameters:
  • 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.
  • 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.

update(fields=None)

Fetch a complete set of attributes for this entity.

For more information, see Bugzilla #1262037.

update_payload(fields=None)

Wrap submitted data within an extra dict.

class nailgun.entities.SmartVariable(server_config=None, **kwargs)

A representation of a Smart Variable entity.

create_payload()

Wrap submitted data within an extra dict.

read(entity=None, attrs=None, ignore=None, params=None)

Do not read the hidden_value attribute.

update_payload(fields=None)

Wrap submitted data within an extra dict.

class nailgun.entities.Snapshot(server_config=None, **kwargs)

A representation of a Snapshot entity. Foreman_snapshot as mentioned in the plugin: https://github.com/ATIX-AG/foreman_snapshot_management # Read Snapshot Snapshot(host=<host_id>, id=<snapshot_id>).read() # Search Snapshots Snapshot(host=<host_id>).search() # Create Snapshot Snapshot(host=<host_id>, name=<snapshot_name>).create() # Update Snapshot Snapshot(host=<host_id>, id=<snapshot_id>, description=<snapshot_description>).update() # Revert Snapshot Snapshot(host=<host_id>, id=<snapshot_id>).revert() # Delete Snapshot Snapshot(host=<host_id>, id=<snapshot_id>).delete()

path(which=None)

Extend nailgun.entity_mixins.Entity.path. revert /api/v2/hosts/<host-id>/snapshots/<snapshot-id>/revert

read(entity=None, attrs=None, ignore=None, params=None)

Provide a default value for entity.

By default, nailgun.entity_mixins.EntityReadMixin.read provides a default value for entity like so:

entity = type(self)()

However, Snapshot requires that an host be provided, so this technique will not work. Do this instead:

entity = type(self)(host=self.host)
revert(**kwargs)

Rollbacks the Snapshot

Makes HTTP PUT call to revert the snapshot.

search_normalize(results)

Append host id to search results to be able to initialize found Snapshot successfully

class nailgun.entities.Srpms(server_config=None, **kwargs)

A representation of a Srpms entity.

class nailgun.entities.Status(server_config=None, **kwargs)

A representation of a Status entity.

class nailgun.entities.Subnet(server_config=None, **kwargs)

A representation of a Subnet entity.

create_payload()

Wrap submitted data within an extra dict.

For more information, see Bugzilla #1151220.

In addition, rename the from_ field to from.

read(entity=None, attrs=None, ignore=None, params=None)

Fetch as many attributes as possible for this entity.

Do not read the discovery attribute. For more information, see Bugzilla #1217146.

In addition, rename the from_ field to from.

update_payload(fields=None)

Wrap submitted data within an extra dict.

class nailgun.entities.Subscription(server_config=None, **kwargs)

A representation of a Subscription entity.

delete_manifest(synchronous=True, **kwargs)

Delete manifest from Red Hat provider.

Parameters:
  • 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.
  • 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.

manifest_history(synchronous=True, **kwargs)

Obtain manifest history for subscriptions.

Parameters:
  • 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.
  • 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.

path(which=None)

Extend nailgun.entity_mixins.Entity.path.

The format of the returned path depends on the value of which:

delete_manifest
/katello/api/v2/organizations/:organization_id/subscriptions/delete_manifest
manifest_history
/katello/api/v2/organizations/:organization_id/subscriptions/manifest_history
refresh_manifest
/katello/api/v2/organizations/:organization_id/subscriptions/refresh_manifest
upload
/katello/api/v2/organizations/:organization_id/subscriptions/upload
read(entity=None, attrs=None, ignore=None, params=None)

Ignore organization field as it’s never returned by the server and is only added to entity to be able to use organization path dependent helpers.

refresh_manifest(synchronous=True, **kwargs)

Refresh previously imported manifest for Red Hat provider.

Parameters:
  • 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.
  • 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.

upload(synchronous=True, **kwargs)

Upload a subscription manifest.

Here is an example of how to use this method:

with open('my_manifest.zip') as manifest:
    sub.upload({'organization_id': org.id}, manifest)
Parameters:
  • 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.
  • 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.

class nailgun.entities.SyncPlan(server_config=None, **kwargs)

A representation of a Sync Plan entity.

organization must be passed in when this entity is instantiated.

Raises:TypeError if organization is not passed in.
add_products(synchronous=True, **kwargs)

Add products to this sync plan.

Note

The synchronous argument has no effect in certain versions of Satellite. See Bugzilla #1199150.

Parameters:
  • 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.
  • 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.

create_payload()

Convert sync_date to a string.

The sync_date instance attribute on the current object is not affected. However, the 'sync_date' key in the dict returned by create_payload is a string.

path(which=None)

Extend nailgun.entity_mixins.Entity.path.

The format of the returned path depends on the value of which:

add_products
/katello/api/v2/organizations/:organization_id/sync_plans/:sync_plan_id/add_products
remove_products
/katello/api/v2/organizations/:organization_id/sync_plans/:sync_plan_id/remove_products
read(entity=None, attrs=None, ignore=None, params=None)

Provide a default value for entity.

By default, nailgun.entity_mixins.EntityReadMixin.read provides a default value for entity like so:

entity = type(self)()

However, SyncPlan requires that an organization be provided, so this technique will not work. Do this instead:

entity = type(self)(organization=self.organization.id)
remove_products(synchronous=True, **kwargs)

Remove products from this sync plan.

Note

The synchronous argument has no effect in certain versions of Satellite. See Bugzilla #1199150.

Parameters:
  • 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.
  • 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.

update_payload(fields=None)

Convert sync_date to a string if datetime object provided.

class nailgun.entities.System(server_config=None, **kwargs)

A representation of a System entity.

path(which=None)

Extend nailgun.entity_mixins.Entity.path.

This method contains a workaround for Bugzilla #1202917.

Most entities are uniquely identified by an ID. System is a bit different: it has both an ID and a UUID, and the UUID is used to uniquely identify a System.

Return a path in the format katello/api/v2/systems/<uuid> if a UUID is available and:

  • which is None, or
  • which == 'this'.

Finally, return a path in the form katello/api/v2/systems/<uuid>/subscriptions if 'subscriptions' is passed in.

read(entity=None, attrs=None, ignore=None, params=None)

Fetch as many attributes as possible for this entity.

Do not read the facts, organization or type attributes. For more information, see Bugzilla #1202917.

class nailgun.entities.SystemPackage(server_config=None, **kwargs)

A representation of a System Package entity.

class nailgun.entities.TailoringFile(server_config=None, **kwargs)

A representation of a Tailoring File entity.

create(create_missing=None)

Do extra work to fetch a complete set of attributes for this entity.

For more information, see Bugzilla #1381129.

create_payload(**kwargs)

Wrap submitted data within an extra dict.

read(entity=None, attrs=None, ignore=None, params=None)

Ignore scap_file field.

update(fields=None)

Fetch a complete set of attributes for this entity.

For more information, see Bugzilla #1234964.

class nailgun.entities.Template(server_config=None, **kwargs)

A representation of a Template entity.

exports(synchronous=True, **kwargs)

Helper to export templates

Parameters:
  • 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.
  • 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.

imports(synchronous=True, **kwargs)

Helper to import templates

Parameters:
  • 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.
  • 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.

path(which=None)

Extend nailgun.entity_mixins.Entity.path.

The format of the returned path depends on the value of which:

import
/templates/import
export
/templates/export
class nailgun.entities.TemplateCombination(server_config=None, **kwargs)

A representation of a Template Combination entity.

class nailgun.entities.TemplateInput(server_config=None, **kwargs)

A representation of a Template Input entity.

read(entity=None, attrs=None, ignore=None, params=None)

Create a JobTemplate object before calling read() ignore ‘advanced’

class nailgun.entities.TemplateKind(server_config=None, **kwargs)

A representation of a Template Kind entity.

Unusually, the /api/v2/template_kinds/:id path is totally unsupported.

class nailgun.entities.User(server_config=None, **kwargs)

A representation of a User entity.

The LDAP authentication source with an ID of 1 is internal. It is nearly guaranteed to exist and be functioning. Thus, auth_source is set to “1” by default for a practical reason: it is much easier to use internal authentication than to spawn LDAP authentication servers for each new user.

create_payload()

Wrap submitted data within an extra dict.

For more information, see Bugzilla #1151220.

read(entity=None, attrs=None, ignore=None, params=None)

Do not read the password argument.

update(fields=None)

Fetch a complete set of attributes for this entity.

For more information, see Bugzilla #1235012.

update_payload(fields=None)

Wrap submitted data within an extra dict.

class nailgun.entities.UserGroup(server_config=None, **kwargs)

A representation of a User Group entity.

create(create_missing=None)

Do extra work to fetch a complete set of attributes for this entity.

For more information, see Bugzilla #1301658.

create_payload()

Wrap submitted data within an extra dict.

For more information, see Bugzilla #1151220.

read(entity=None, attrs=None, ignore=None, params=None)

Work around Redmine #9594.

An HTTP GET request to path('self') does not return the admin attribute, even though it should. Also see Bugzilla #1197871.

update_payload(fields=None)

Wrap submitted data within an extra dict.

For more information, see Bugzilla #1151220.

class nailgun.entities.VMWareComputeResource(server_config=None, **kwargs)

A representation for compute resources with Vmware provider

read(entity=None, attrs=None, ignore=None, params=None)

Make sure, password is in the ignore list for read

class nailgun.entities.VirtWhoConfig(server_config=None, **kwargs)

A representation of a VirtWho Config entity.

create_payload()

Wraps config in extra dict

deploy_script(synchronous=True, **kwargs)

Helper for Config’s deploy_script method.

Parameters:
  • 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.
  • 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.

get_organization_configs(synchronous=True, **kwargs)

Unusually, the /foreman_virt_who_configure/api/v2/organizations/ :organization_id/configs path is totally unsupported. Support to List of virt-who configurations per organization.

Parameters:
  • 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.
  • 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.

path(which=None)

Extend nailgun.entity_mixins.Entity.path.

The format of the returned path depends on the value of which:

deploy_script
/foreman_virt_who_configure/api/v2/configs/:id/deploy_script
configs
/foreman_virt_who_configure/api/v2/organizations/:organization_id/configs

super is called otherwise.

read(entity=None, attrs=None, ignore=None, params=None)

Override nailgun.entity_mixins.EntityReadMixin.read() to ignore the hypervisor_password

update_payload(fields=None)

Wraps config in extra dict