robottelo.cli.factory
¶
Factory object creation for all CLI methods
Module Contents¶
Functions¶
|
Creates <object> with dictionary of arguments. |
|
Create entity class using credentials. If credentials is None will |
|
Creates an Activation Key |
|
Creates an Architecture |
|
Creates a Content View |
|
Helper function to create CV with credentials |
|
Creates a Content View Filter |
|
Creates a Content View Filter Rule |
|
Creates a Discovery Rule |
|
Creates a GPG Key |
|
Creates a content credential. |
|
Creates a Location |
|
Creates a Hardware Model |
|
Creates a Partition Table |
|
Creates a Product |
|
Helper function to create product with credentials |
|
Wrapper function for make_product to make it wait before erroring out. |
|
Creates a Proxy |
|
Creates a Repository |
|
Helper function to create Repository with credentials |
|
Creates a Role |
|
Creates a Role Filter |
|
Creates a Scap Policy |
|
Creates a Subnet |
|
Creates a Sync Plan |
|
Creates a Host |
|
Wrapper function for make_host to pass all required options for creation |
|
Creates a Host Collection |
|
Creates a Job Invocation |
|
Creates a Job Template |
|
Creates a User |
|
Creates a User Group |
|
Creates an External User Group |
|
Creates an LDAP Auth Source |
|
Creates a Compute Resource |
|
Creates an Organization |
|
Helper function to create organization with credentials |
|
Creates a REALM |
|
Creates a Report Template |
|
Creates an Operating System |
|
Creates Scap Content |
|
Creates a Domain |
|
Creates a Hostgroup |
|
Creates a Medium |
|
Creates a Puppet Environment |
|
Creates a Lifecycle Environment |
|
Creates a tailoring File |
|
Creates a Template |
|
Creates Template Input |
|
Creates a Virt Who Configuration |
|
Helper function that adds subscription to an activation key |
|
Sets up Org for the given custom repo by: |
|
Sets up Org for the given Red Hat repository by: |
|
Wrapper above |
|
Create and configure org, loc, product, repo, env. Update proxy, |
|
Creates puppet repo, sync it via provided url and publish using |
|
Setup a Virtual machine with basic components and tasks. |
|
Return the right RH repos info for the capsule setup |
|
Create role permissions found in resource permissions dict |
|
Setup cdn and custom repositories |
|
Setup cdn and custom repositories, content view and activations key |
|
Create host entry in vm ssh config and know_hosts files to allow vm |
|
Copy ssh key to virtual machine ssh path and ensure proper permission is |
|
Configure virtual machine as hypervisor virt-who service |
|
Creates a HTTP Proxy |
Attributes¶
- robottelo.cli.factory.logger¶
- robottelo.cli.factory.ORG_KEYS = ['organization', 'organization-id', 'organization-label']¶
- robottelo.cli.factory.CONTENT_VIEW_KEYS = ['content-view', 'content-view-id']¶
- robottelo.cli.factory.LIFECYCLE_KEYS = ['lifecycle-environment', 'lifecycle-environment-id']¶
- exception robottelo.cli.factory.CLIFactoryError¶
Bases:
Exception
Indicates an error occurred while creating an entity using hammer
- robottelo.cli.factory.create_object(cli_object, options, values)¶
Creates <object> with dictionary of arguments.
- Parameters
cli_object – A valid CLI object.
options (dict) – The default options accepted by the cli_object create
values (dict) – Custom values to override default ones.
- Raises
robottelo.cli.factory.CLIFactoryError – Raise an exception if object cannot be created.
- Return type
dict
- Returns
A dictionary representing the newly created resource.
- robottelo.cli.factory._entity_with_credentials(credentials, cli_entity_cls)¶
Create entity class using credentials. If credentials is None will return cli_entity_cls itself
- Parameters
credentials – tuple (login, password)
cli_entity_cls – Cli Entity Class
- Returns
Cli Entity Class
- robottelo.cli.factory.make_activation_key(options=None)¶
Creates an Activation Key
- Parameters
options – Check options using hammer activation-key create –help on satellite.
:returns ActivationKey object
- robottelo.cli.factory.make_architecture(options=None)¶
Creates an Architecture
- Parameters
options – Check options using hammer architecture create –help on satellite.
:returns Architecture object
- robottelo.cli.factory.make_content_view(options=None)¶
Creates a Content View
- Parameters
options – Check options using hammer content-view create –help on satellite.
:returns ContentView object
- robottelo.cli.factory.make_content_view_with_credentials(options=None, credentials=None)¶
Helper function to create CV with credentials
If credentials is None, the default credentials in robottelo.properties will be used.
- robottelo.cli.factory.make_content_view_filter(options=None)¶
Creates a Content View Filter
- Parameters
options – Check options using hammer content-view filter create –help on satellite.
:returns ContentViewFilter object
- robottelo.cli.factory.make_content_view_filter_rule(options=None)¶
Creates a Content View Filter Rule
- Parameters
options – Check options using hammer content-view filter rule create –help on satellite.
:returns ContentViewFilterRule object
- robottelo.cli.factory.make_discoveryrule(options=None)¶
Creates a Discovery Rule
- Parameters
options – Check options using hammer discovery-rule create –help on satellite.
:returns DiscoveryRule object
- robottelo.cli.factory.make_gpg_key(options=None)¶
Creates a GPG Key
- Parameters
options – Check options using hammer gpg create –help on satellite.
:returns GPGKey object
- robottelo.cli.factory.make_content_credential(options=None)¶
Creates a content credential.
In Satellite 6.8, only gpg_key option is supported.
- Parameters
options – Check options using hammer content-credential create –help on satellite.
:returns ContentCredential object
- robottelo.cli.factory.make_location(options=None)¶
Creates a Location
- Parameters
options – Check options using hammer location create –help on satellite.
:returns Location object
- robottelo.cli.factory.make_model(options=None)¶
Creates a Hardware Model
- Parameters
options – Check options using hammer model create –help on satellite.
:returns Model object
- robottelo.cli.factory.make_partition_table(options=None)¶
Creates a Partition Table
- Parameters
options – Check options using hammer partition-table create –help on satellite.
:returns PartitionTable object
- robottelo.cli.factory.make_product(options=None)¶
Creates a Product
- Parameters
options – Check options using hammer product create –help on satellite.
:returns Product object
- robottelo.cli.factory.make_product_with_credentials(options=None, credentials=None)¶
Helper function to create product with credentials
- robottelo.cli.factory.make_product_wait(options=None, wait_for=5)¶
Wrapper function for make_product to make it wait before erroring out.
This is a temporary workaround for BZ#1332650: Sometimes cli product create errors for no reason when there are multiple product creation requests at the sametime although the product entities are created. This workaround will attempt to wait for 5 seconds and query the product again to make sure it is actually created. If it is not found, it will fail and stop.
Note: This wrapper method is created instead of patching make_product because this issue does not happen for all entities and this workaround should be removed once the root cause is identified/fixed.
- robottelo.cli.factory.make_proxy(options=None)¶
Creates a Proxy
- Parameters
options – Check options using hammer proxy create –help on satellite.
:returns Proxy object
- robottelo.cli.factory.make_repository(options=None)¶
Creates a Repository
- Parameters
options – Check options using hammer repository create –help on satellite.
:returns Repository object
- robottelo.cli.factory.make_repository_with_credentials(options=None, credentials=None)¶
Helper function to create Repository with credentials
- robottelo.cli.factory.make_role(options=None)¶
Creates a Role
- Parameters
options – Check options using hammer role create –help on satellite.
:returns Role object
- robottelo.cli.factory.make_filter(options=None)¶
Creates a Role Filter
- Parameters
options – Check options using hammer filter create –help on satellite.
:returns Role object
- robottelo.cli.factory.make_scap_policy(options=None)¶
Creates a Scap Policy
- Parameters
options – Check options using hammer policy create –help on satellite.
:returns Scappolicy object
- robottelo.cli.factory.make_subnet(options=None)¶
Creates a Subnet
- Parameters
options – Check options using hammer subnet create –help on satellite.
:returns Subnet object
- robottelo.cli.factory.make_sync_plan(options=None)¶
Creates a Sync Plan
- Parameters
options – Check options using hammer sync-plan create –help on satellite.
:returns SyncPlan object
- robottelo.cli.factory.make_host(options=None)¶
Creates a Host
- Parameters
options – Check options using hammer host create –help on satellite.
:returns Host object
- robottelo.cli.factory.make_fake_host(options=None)¶
Wrapper function for make_host to pass all required options for creation of a fake host
- robottelo.cli.factory.make_host_collection(options=None)¶
Creates a Host Collection
- Parameters
options – Check options using hammer host-collection create –help on satellite.
:returns HostCollection object
- robottelo.cli.factory.make_job_invocation(options=None)¶
Creates a Job Invocation
- Parameters
options – Check options using hammer job-invocation create –help on satellite.
:returns JobInvocation object
- robottelo.cli.factory.make_job_template(options=None)¶
Creates a Job Template
- Parameters
options – Check options using hammer job-template create –help on satellite.
:returns JobTemplate object
- robottelo.cli.factory.make_user(options=None)¶
Creates a User
- Parameters
options – Check options using hammer user create –help on satellite.
:returns User object
- robottelo.cli.factory.make_usergroup(options=None)¶
Creates a User Group
- Parameters
options – Check options using hammer user-group create –help on satellite.
:returns UserGroup object
- robottelo.cli.factory.make_usergroup_external(options=None)¶
Creates an External User Group
- Parameters
options – Check options using hammer user-group external create –help on satellite.
:returns UserGroupExternal object
- robottelo.cli.factory.make_ldap_auth_source(options=None)¶
Creates an LDAP Auth Source
- Parameters
options – Check options using hammer auth-source ldap create –help on satellite.
:returns LDAPAuthSource object
- robottelo.cli.factory.make_compute_resource(options=None)¶
Creates a Compute Resource
- Parameters
options – Check options using hammer compute-resource create –help on satellite.
:returns ComputeResource object
- robottelo.cli.factory.make_org(options=None)¶
Creates an Organization
- Parameters
options – Check options using hammer organization create –help on satellite.
:returns Organization object
- robottelo.cli.factory.make_org_with_credentials(options=None, credentials=None)¶
Helper function to create organization with credentials
- robottelo.cli.factory.make_realm(options=None)¶
Creates a REALM
- Parameters
options – Check options using hammer realm create –help on satellite.
:returns Realm object
- robottelo.cli.factory.make_report_template(options=None)¶
Creates a Report Template
- Parameters
options – Check options using hammer report-template create –help on satellite.
:returns ReportTemplate object
- robottelo.cli.factory.make_os(options=None)¶
Creates an Operating System
- Parameters
options – Check options using hammer os create –help on satellite.
:returns OperatingSys object
- robottelo.cli.factory.make_scapcontent(options=None)¶
Creates Scap Content
- Parameters
options – Check options using hammer scap-content create –help on satellite.
:returns ScapContent object
- robottelo.cli.factory.make_domain(options=None)¶
Creates a Domain
- Parameters
options – Check options using hammer domain create –help on satellite.
:returns Domain object
- robottelo.cli.factory.make_hostgroup(options=None)¶
Creates a Hostgroup
- Parameters
options – Check options using hammer hostgroup create –help on satellite.
:returns Hostgroup object
- robottelo.cli.factory.make_medium(options=None)¶
Creates a Medium
- Parameters
options – Check options using hammer medium create –help on satellite.
:returns Medium object
- robottelo.cli.factory.make_environment(options=None)¶
Creates a Puppet Environment
- Parameters
options – Check options using hammer environment create –help on satellite.
:returns Environment object
- robottelo.cli.factory.make_lifecycle_environment(options=None)¶
Creates a Lifecycle Environment
- Parameters
options – Check options using hammer lifecycle-environment create –help on satellite.
:returns LifecycleEnvironment object
- robottelo.cli.factory.make_tailoringfile(options=None)¶
Creates a tailoring File
- Parameters
options – Check options using hammer tailoring-file create –help on satellite.
:returns TailoringFile object
- robottelo.cli.factory.make_template(options=None)¶
Creates a Template
- Parameters
options – Check options using hammer template create –help on satellite.
:returns Template object
- robottelo.cli.factory.make_template_input(options=None)¶
Creates Template Input
- Parameters
options – Check options using hammer template-input create –help on satellite.
:returns TemplateInput object
- robottelo.cli.factory.make_virt_who_config(options=None)¶
Creates a Virt Who Configuration
- Parameters
options – Check options using hammer virt-who-config create –help on satellite.
:returns VirtWhoConfig object
- robottelo.cli.factory.activationkey_add_subscription_to_repo(options=None)¶
Helper function that adds subscription to an activation key
- robottelo.cli.factory.setup_org_for_a_custom_repo(options=None)¶
Sets up Org for the given custom repo by:
- Checks if organization and lifecycle environment were given, otherwise
creates new ones.
Creates a new product with the custom repo. Synchronizes the repo.
- Checks if content view was given, otherwise creates a new one and
adds the RH repo
publishes
promotes to the lifecycle environment
- Checks if activation key was given, otherwise creates a new one and
associates it with the content view.
Adds the custom repo subscription to the activation key
- Returns
A dictionary with the entity ids of Activation key, Content view, Lifecycle Environment, Organization, Product and Repository
- robottelo.cli.factory._setup_org_for_a_rh_repo(options=None)¶
Sets up Org for the given Red Hat repository by:
- Checks if organization and lifecycle environment were given, otherwise
creates new ones.
Clones and uploads manifest.
Enables RH repo and synchronizes it.
- Checks if content view was given, otherwise creates a new one and
adds the RH repo
publishes
promotes to the lifecycle environment
- Checks if activation key was given, otherwise creates a new one and
associates it with the content view.
Adds the RH repo subscription to the activation key
Note that in most cases you should use
setup_org_for_a_rh_repo
instead as it’s more flexible.- Returns
A dictionary with the entity ids of Activation key, Content view, Lifecycle Environment, Organization and Repository
- robottelo.cli.factory.setup_org_for_a_rh_repo(options=None, force_manifest_upload=False, force_use_cdn=False)¶
Wrapper above
_setup_org_for_a_rh_repo
to use custom downstream repo instead of CDN’s ‘Satellite Capsule’, ‘Satellite Tools’ and base OS repos ifsettings.cdn == 0
and URL for custom repositories is set in properties.- Parameters
options – a dict with options to pass to function
_setup_org_for_a_rh_repo
. See its docstring for more detailsforce_use_cdn – bool flag whether to use CDN even if there’s downstream repo available and
settings.cdn == 0
.force_manifest_upload – bool flag whether to upload a manifest to organization even if downstream custom repo is used instead of CDN. Useful when test relies on organization with manifest (e.g. uses some other RH repo afterwards). Defaults to False.
- Returns
a dict with entity ids (see
_setup_org_for_a_rh_repo
andsetup_org_for_a_custom_repo
).
- robottelo.cli.factory.configure_env_for_provision(org=None, loc=None)¶
Create and configure org, loc, product, repo, env. Update proxy, domain, subnet, compute resource, provision templates and medium with previously created entities and create a hostgroup using all mentioned entities.
- Parameters
org – Default Organization that should be used in both host discovering and host provisioning procedures
loc – Default Location that should be used in both host discovering and host provisioning procedures
- Returns
List of created entities that can be re-used further in provisioning or validation procedure (e.g. hostgroup or subnet)
- robottelo.cli.factory.publish_puppet_module(puppet_modules, repo_url, organization_id=None)¶
Creates puppet repo, sync it via provided url and publish using Content View publishing mechanism. It makes puppet class available via Puppet Environment created by Content View and returns Content View entity.
- Parameters
puppet_modules – List of dictionaries with module ‘author’ and module ‘name’ fields.
repo_url (str) – Url of the repo that can be synced using pulp: pulp repo or puppet forge.
organization_id – Organization id that is shared between created entities.
- Returns
Content View entity.
- robottelo.cli.factory.setup_virtual_machine(vm, org_label, rh_repos_id=None, repos_label=None, product_label=None, lce=None, activation_key=None, patch_os_release_distro=None, install_katello_agent=True)¶
Setup a Virtual machine with basic components and tasks.
- Parameters
vm (robottelo.vm.VirtualMachine) – The Virtual machine to setup.
org_label (str) – The Organization label.
rh_repos_id (list) – a list of RH repositories ids to enable.
repos_label (list) – a list of custom repositories labels to enable.
product_label (str) – product label if repos_label is applicable.
lce (str) – Lifecycle environment label if applicable.
activation_key (str) – Activation key name if applicable.
patch_os_release_distro (str) – distro name, to patch the VM with os version.
install_katello_agent (bool) – whether to install katello agent.
- robottelo.cli.factory._get_capsule_vm_distro_repos(distro)¶
Return the right RH repos info for the capsule setup
- robottelo.cli.factory.add_role_permissions(role_id, resource_permissions)¶
Create role permissions found in resource permissions dict
- Parameters
role_id – The role id
resource_permissions – a dict containing resources with permission names and other Filter options
Usage:
role = make_role({'organization-id': org['id']}) resource_permissions = { 'Katello::ActivationKey': { 'permissions': [ 'view_activation_keys', 'create_activation_keys', 'edit_activation_keys', 'destroy_activation_keys' ], 'search': "name ~ {}".format(ak_name_like) }, } add_role_permissions(role['id'], resource_permissions)
- robottelo.cli.factory.setup_cdn_and_custom_repositories(org_id, repos, download_policy='on_demand', synchronize=True)¶
Setup cdn and custom repositories
- Parameters
org_id (int) – The organization id
repos (list) – a list of dict repositories options
download_policy (str) – update the repositories with this download policy
synchronize (bool) – Whether to synchronize the repositories.
- Returns
a dict containing the content view and repos info
- robottelo.cli.factory.setup_cdn_and_custom_repos_content(org_id, lce_id=None, repos=None, upload_manifest=True, download_policy='on_demand', rh_subscriptions=None, default_cv=False)¶
Setup cdn and custom repositories, content view and activations key
- Parameters
org_id (int) – The organization id
lce_id (int) – the lifecycle environment id
repos (list) – a list of dict repositories options
default_cv (bool) – whether to use the Default Organization CV
upload_manifest (bool) – whether to upload the organization manifest
download_policy (str) – update the repositories with this download policy
rh_subscriptions (list) – a list of RH subscription to attach to activation key
- Returns
a dict containing the activation key, content view and repos info
- robottelo.cli.factory.vm_setup_ssh_config(vm, ssh_key_name, host, user=None)¶
Create host entry in vm ssh config and know_hosts files to allow vm to access host via ssh without password prompt
- Parameters
vm (robottelo.vm.VirtualMachine) – Virtual machine instance
ssh_key_name (str) – The ssh key file name to use to access host, the file must already exist in /root/.ssh directory
host (str) – the hostname to setup that will be accessed from vm
user (str) – the user that will access the host
- robottelo.cli.factory.vm_upload_ssh_key(vm, source_key_path, destination_key_name)¶
Copy ssh key to virtual machine ssh path and ensure proper permission is set
- Parameters
vm (robottelo.vm.VirtualMachine) – Virtual machine instance
source_key_path – The ssh key file path to copy to vm
destination_key_name – The ssh key file name when copied to vm
- robottelo.cli.factory.virt_who_hypervisor_config(config_id, virt_who_vm, org_id=None, lce_id=None, hypervisor_hostname=None, configure_ssh=False, hypervisor_user=None, subscription_name=None, exec_one_shot=False, upload_manifest=True, extra_repos=None)¶
Configure virtual machine as hypervisor virt-who service
- Parameters
config_id (int) – virt-who config id
virt_who_vm (robottelo.vm.VirtualMachine) – the Virtual machine instance to use for configuration
org_id (int) – the organization id
lce_id (int) – the lifecycle environment id to use
hypervisor_hostname (str) – the hypervisor hostname
hypervisor_user (str) – hypervisor user that connect with the ssh key
configure_ssh (bool) – whether to configure the ssh key to allow this virtual machine to connect to hypervisor
subscription_name (str) – the subscription name to assign to virt-who hypervisor guests
exec_one_shot (bool) – whether to run the virt-who one-shot command after startup
upload_manifest (bool) – whether to upload the organization manifest
extra_repos (list) – (Optional) a list of repositories dict options to setup additionally.
- robottelo.cli.factory.make_http_proxy(options=None)¶
Creates a HTTP Proxy
- Parameters
options – Check options using hammer http-proxy create –help on satellite.
:returns HttpProxy object