robottelo.cli.base

Generic base class for cli hammer commands.

Module Contents

Classes

Base

@param command_base: base command of hammer.

exception robottelo.cli.base.CLIError

Bases: Exception

Indicates that a CLI command could not be run.

exception robottelo.cli.base.CLIBaseError(return_code, stderr, msg)

Bases: Exception

Indicates that a CLI command has finished with return code different from zero.

Parameters
  • return_code – CLI command return code

  • stderr – contents of the stderr

  • msg – explanation of the error

__str__(self)

Include class name, return_code, stderr and msg to string repr so assertRaisesRegexp can be used to assert error present on any attribute

__repr__(self)

Include class name return_code, stderr and msg to improve logging

exception robottelo.cli.base.CLIReturnCodeError(return_code, stderr, msg)

Bases: CLIBaseError

Error to be raised when an error occurs due to some validation error when execution hammer cli. See: https://github.com/SatelliteQE/robottelo/issues/3790 for more details

exception robottelo.cli.base.CLIDataBaseError(return_code, stderr, msg)

Bases: CLIBaseError

Error to be raised when an error occurs due to some missing parameter which cause a data base error on hammer See: https://github.com/SatelliteQE/robottelo/issues/3790 for more details

class robottelo.cli.base.Base

@param command_base: base command of hammer. See Subcommands section in hammer –help output on your Satellite.

command_base
command_sub
command_requires_org = False
hostname
logger
_db_error_regex
classmethod _handle_response(cls, response, ignore_stderr=None)

Verify return_code of the CLI command.

Check for a non-zero return code or any stderr contents.

Parameters
  • response – a SSHCommandResult object, returned by robottelo.ssh.command.

  • ignore_stderr – indicates whether to throw a warning in logs if stderr is not empty.

Returns

contents of stdout.

Raises

robottelo.cli.base.CLIReturnCodeError – If return code is different from zero.

classmethod add_operating_system(cls, options=None)

Adds OS to record.

classmethod create(cls, options=None, timeout=None)

Creates a new record using the arguments passed via dictionary.

classmethod delete(cls, options=None, timeout=None)

Deletes existing record.

classmethod delete_parameter(cls, options=None)

Deletes parameter from record.

classmethod dump(cls, options=None)

Displays the content for existing partition table.

classmethod _get_username_password(cls, username=None, password=None)

Lookup for the username and password for cli command in following order:

  1. user or password parameters

  2. foreman_admin_username or foreman_admin_password attributes

  3. foreman.admin.username or foreman.admin.password configuration

Returns

A tuple with the username and password found

Return type

tuple

classmethod execute(cls, command, hostname=None, user=None, password=None, output_format=None, timeout=None, ignore_stderr=None, return_raw_response=None, connection_timeout=None)

Executes the cli command on the server via ssh

classmethod exists(cls, options=None, search=None)

Search for an entity using the query search[0]="search[1]"

Will be used the list command with the --search option to do the search.

If options argument already have a search key, then the search argument will not be evaluated. Which allows different search query.

classmethod info(cls, options=None, output_format=None, return_raw_response=None)

Reads the entity information.

classmethod list(cls, options=None, per_page=True, output_format='csv')

List information. @param options: ID (sometimes name works as well) to retrieve info.

classmethod puppetclasses(cls, options=None)

Lists all puppet classes.

classmethod remove_operating_system(cls, options=None)

Removes OS from record.

classmethod sc_params(cls, options=None)

Lists all smart class parameters.

classmethod set_parameter(cls, options=None)

Creates or updates parameter for a record.

classmethod update(cls, options=None, return_raw_response=None)

Updates existing record.

classmethod with_user(cls, username=None, password=None)

Context Manager for credentials

classmethod _construct_command(cls, options=None)

Build a hammer cli command based on the options passed