cfme.utils.appliance package¶
Subpackages¶
Submodules¶
Module contents¶
-
class
cfme.utils.appliance.
Appliance
(hostname, ui_protocol='https', ui_port=None, browser_steal=False, project=None, container=None, openshift_creds=None, db_host=None, db_port=None, ssh_port=None, is_dev=False)[source]¶ Bases:
cfme.utils.appliance.IPAppliance
Appliance represents an already provisioned cfme appliance vm
DO NOT INSTANTIATE DIRECTLY - USE :py:meth:`from_provider`
-
configure
(*args, **kwargs)¶
-
configure_fleecing
(*args, **kwargs)¶
-
classmethod
from_provider
(provider_key, vm_name, name=None, **kwargs)[source]¶ Constructor of this Appliance.
Retrieves the IP address of the appliance from the provider and then instantiates it, adding some extra parameters that are required by this class.
Parameters: - provider_name – Name of the provider this appliance is running under
- vm_name – Name of the VM this appliance is running as
- browser_steal – Setting of the browser_steal attribute.
-
ipapp
¶
-
is_on_rhev
¶
-
is_on_vsphere
¶
-
is_running
¶
-
remove_rhev_direct_lun_disk
(*args, **kwargs)¶
-
-
class
cfme.utils.appliance.
ApplianceConsole
(appliance)[source]¶ Bases:
object
ApplianceConsole is used for navigating and running appliance_console commands against an appliance.
-
class
cfme.utils.appliance.
ApplianceConsoleCli
(appliance)[source]¶ Bases:
object
-
configure_appliance_dedicated_ha_primary
(username, password, reptype, primhost, node, dbname)[source]¶
-
configure_appliance_dedicated_ha_standby
(username, password, reptype, primhost, standhost, node, dbname, dbdisk)[source]¶
-
configure_appliance_external_create
(region, dbhostname, username, password, dbname, fetch_key, sshlogin, sshpass)[source]¶
-
configure_appliance_external_join
(dbhostname, username, password, dbname, fetch_key, sshlogin, sshpass)[source]¶
-
-
exception
cfme.utils.appliance.
ApplianceException
[source]¶ Bases:
exceptions.Exception
-
exception
cfme.utils.appliance.
ApplianceSummoningWarning
[source]¶ Bases:
exceptions.Warning
to ease filtering/erroring on magical appliance creation based on script vs code
-
class
cfme.utils.appliance.
DummyAppliance
(version=Version('5.8.0'), collections=NOTHING)[source]¶ Bases:
object
a dummy with minimal attribute set
-
__ge__
(other)¶ Automatically created by attrs.
-
__gt__
(other)¶ Automatically created by attrs.
-
__le__
(other)¶ Automatically created by attrs.
-
__lt__
(other)¶ Automatically created by attrs.
-
__ne__
(other)¶ Check equality and either forward a NotImplemented or return the result negated.
-
__repr__
()¶ Automatically created by attrs.
-
browser_steal
= False¶
-
build
= 'missing :)'¶
-
hostname
= 'DummyApplianceHostname'¶
-
is_dev
= False¶
-
is_downstream
= True¶
-
is_pod
= False¶
-
managed_known_providers
= []¶
-
-
class
cfme.utils.appliance.
IPAppliance
(hostname, ui_protocol='https', ui_port=None, browser_steal=False, project=None, container=None, openshift_creds=None, db_host=None, db_port=None, ssh_port=None, is_dev=False)[source]¶ Bases:
object
IPAppliance represents an already provisioned cfme appliance whos provider is unknown but who has an IP address. This has a lot of core functionality that Appliance uses, since it knows both the provider, vm_name and can there for derive the IP address.
Parameters: - hostname – The IP address or host name of the provider
- ui_protocol – The protocol used in the URL
- ui_port – The port where the UI runs.
- browser_steal – If True then then current browser is killed and the new appliance is used to generate a new session.
- container – If the appliance is running as a container or as a pod, specifies its name.
- project – openshift’s project where the appliance is deployed
- openshift_creds – If the appliance runs as a project on openshift, provides credentials for the openshift host so the framework can interact with the project.
- db_host – If the database is located somewhere else than on the appliance itself, specify the host here.
- db_port – Database port.
- ssh_port – SSH port.
-
CONFIG_MAPPING
= {'ssh_port': 'ssh_port', 'openshift_creds': 'openshift_creds', 'ui_protocol': 'ui_protocol', 'db_port': 'db_port', 'is_dev': 'is_dev', 'pod': 'container', 'container': 'container', 'ui_port': 'ui_port', 'hostname': 'hostname', 'project': 'project', 'db_host': 'db_host', 'browser_steal': 'browser_steal'}¶
-
CONFIG_NONGLOBAL
= set(['hostname'])¶
-
CONF_FILES
= {'downstream_templates': '/opt/rh/cfme-appliance/TEMPLATE', 'httpd_remote_user': '/etc/httpd/conf.d/manageiq-remote-user.conf', 'sssd': '/etc/sssd/sssd.conf', 'upstream_templates': '/var/www/miq/system/TEMPLATE', 'openldap': '/etc/openldap/ldap.conf', 'pam_httpd_auth': '/etc/pam.d/httpd-auth', 'httpd_ext_auth': '/etc/httpd/conf.d/manageiq-external-auth.conf'}¶
-
PROTOCOL_PORT_MAPPING
= {'http': 80, 'https': 443}¶
-
__call__
(**kwargs)[source]¶ Syntactic sugar for overriding certain instance variables for context managers.
Currently possible variables are:
- browser_steal
-
add_pglogical_replication_subscription
(host)[source]¶ Add a pglogical replication subscription without using the Web UI.
-
add_product_repo
(repo_url, **kwargs)[source]¶ - This method ensures that when we add a new repo URL, there will be no other version
- of such product present in the yum.repos.d. You can specify conf options in kwargs. They will be applied only to newly created repo file.
Returns: The repo id.
-
advanced_settings
¶ Get settings from the base api/settings endpoint for appliance
-
appliance
¶
-
as_json
¶ Dumps the arguments that can create this appliance as a JSON. None values are ignored.
-
build
¶
-
build_date
¶
-
build_datetime
¶
-
clone_domain
(*args, **kwargs)¶
-
company_name
¶
-
configure
(*args, **kwargs)¶
-
configure_freeipa
(*args, **kwargs)¶
-
configure_openldap
(*args, **kwargs)¶
-
configure_vm_console_cert
(*args, **kwargs)¶
-
coverage
¶
-
db
¶
-
default_zone
¶
-
deploy_merkyl
(*args, **kwargs)¶
-
diagnose_evm_failure
()[source]¶ Go through various EVM processes, trying to figure out what fails
Returns: A string describing the error, or None if no errors occurred.
This is intended to be run after an appliance is configured but failed for some reason, such as in the template tester.
-
disable_freeipa
(*args, **kwargs)¶
-
disable_openldap
(*args, **kwargs)¶
-
disks
¶ Returns list of disks only, excludes their partitions
-
disks_and_partitions
¶ Returns list of all disks and partitions
-
enable_embedded_ansible_role
()[source]¶ Enables embbeded ansible role
This is necessary because server_roles does not wait long enough
-
event_listener
()[source]¶ Returns an instance of the event listening class pointed to this appliance.
-
evm_id
¶
-
evmserverd
¶
-
find_product_repos
()[source]¶ Returns a dictionary of products, where the keys are names of product (repos) and values are dictionaries where keys are the versions and values the names of the repositories.
-
fix_ntp_clock
(*args, **kwargs)¶
-
fqdn
¶ fqdn from appliance_console This should likely be ‘hostname’ as that is what its called on the appliance Currently hostname attribute holds IP addr
-
classmethod
from_url
(url, **kwargs)[source]¶ Create an appliance instance from a URL.
Supported format using a simple regexp expression:
(https?://)?hostname_or_ip(:port)?/?
Parameters: - url – URL to be parsed from
- **kwargs – For setting and overriding the params parsed from the URL
Returns: A
IPAppliance
instance.
-
get_disabled_regions
(provider=None)[source]¶ Fetch appliance advanced config, get disabled regions for given provider’s type
Only relevant for cloud providers azure and ec2 at the moment
Parameters: provider – A BaseProvider object with settings_key attribute Returns: Dict of ems_<provider> keys and values of disabled_regions map when provider given: disabled_regions list from config when no matching config found: None Return type: Default
-
get_host_address
¶
-
get_repofile_list
()[source]¶ Returns list of repofiles present at the appliance.
Ignores certain files, like redhat.repo.
-
guid
¶
-
has_cli
¶
-
httpd
¶
-
install_netapp_sdk
(*args, **kwargs)¶
-
install_vddk
(*args, **kwargs)¶
-
is_downstream
¶
-
is_embedded_ansible_role_enabled
¶
-
is_embedded_ansible_running
¶
-
is_evm_service_running
(*args, **kwargs)¶
-
is_idle
¶ Return appliance idle state measured by last production.log activity. It runs one liner script, which first gathers current date on appliance and then gathers date of last entry in production.log(which has to be parsed) with /api calls filtered (These calls occur every minute.) Then it deducts that last time in log from current date and if it is lower than idle_time it returns False else True.
Args:
Returns: True if appliance is idling for longer or equal to idle_time seconds. False if appliance is not idling for longer or equal to idle_time seconds.
-
is_miqqe_patch_candidate
¶
-
is_nginx_running
¶
-
is_rabbitmq_running
¶
-
is_registration_complete
(used_repo_or_channel)[source]¶ Checks if an appliance has the correct repos enabled with RHSM or SAT6
-
is_ssh_running
¶
-
is_storage_enabled
¶
-
is_supervisord_running
¶
-
is_web_ui_running
(unsure=False)[source]¶ Triple checks if web UI is up and running
Parameters: unsure – Variable to return when not sure if web UI is running or not (default False
)
-
log
¶
-
managed_known_providers
¶ Returns a set of provider crud objects of known providers managed by this appliance
Note
Recognized by name only.
-
managed_provider_names
¶ Returns a list of names for all providers configured on the appliance
Note
Unlike
managed_known_providers
, this will also return names of providers that were not recognized, but are present.
-
miqqe_patch_applied
¶
-
miqqe_version
¶ Returns version of applied JS patch or None if not present
-
new_rest_api_instance
(entry_point=None, auth=None, logger='default', verify_ssl=False)[source]¶ Returns new REST API instance.
-
os_version
¶
-
patch_with_miqqe
(*args, **kwargs)¶
-
precompile_assets
(*args, **kwargs)¶
-
product_name
¶
-
product_url_regexp
= <_sre.SRE_Pattern object at 0x3effab0>¶
-
provider_based_collection
(provider, coll_type='vms')[source]¶ Given a provider, fetches a collection for the given collection type
Some collections are provider based, like infra vms and cloud instances This provides an easy way to pick which one is right for your provider
Parameters: - provider – provider class/instance for lookup
- coll_type – which collection type to return based on the provider type
Notes
Add coll_type support as there are collections dependent on a provider type
Examples
# returns the infra_vms collection appliance.collections.provider_based_collection(rhevm_provider, ‘vms’)
-
reboot
(*args, **kwargs)¶
-
rest_api
¶
-
rest_logger
¶
-
restart_evm_service
(*args, **kwargs)¶
-
server
¶
-
server_roles
¶ Return a dictionary of server roles from database
-
set_cap_and_util_all_via_rails
()[source]¶ Turns on Collect for All Clusters and Collect for all Datastores without using Web UI.
-
set_cfme_server_relationship
(vm_name, server_id=1)[source]¶ Set MiqServer record to the id of a VM by name, effectively setting the CFME Server Relationship without using the Web UI.
-
set_disabled_regions
(provider, *regions)[source]¶ Modify config to set disabled regions to given regions for the given provider’s type
Only relevant for cloud providers azure and ec2 at the moment
Does NOT APPEND to the list of disabled regions, SETS it
Parameters: - provider – A BaseProvider object with settings_key attribute
- *regions – none, one or many region names, on None enables all regions for provider type
Raises: - AssertionError - when the disabled regions don’t match after setting
- ApplianceException - when there’s a KeyError modifying the yaml
-
set_pglogical_replication
(replication_type=':none')[source]¶ Set pglogical replication type (:none, :remote, :global) without using the Web UI.
-
set_resolvable_hostname
(*args, **kwargs)¶
-
set_rubyrep_replication
(host, port=5432, database='vmdb_production', username='root', password=None)[source]¶ Sets up rubyrep replication via advanced configuration settings yaml.
-
set_session_timeout
(timeout=86400, quiet=True)[source]¶ Sets the timeout of UI timeout.
Parameters: - timeout – Timeout in seconds
- quiet – Whether to ignore any errors
-
ssh_client
¶ Creates an ssh client connected to this appliance
Returns: A configured :py:class:
utils.ssh.SSHClient
instance.Usage:
with appliance.ssh_client as ssh: result = ssh.run_command('...')
Note
The credentials default to those found under
ssh
key incredentials.yaml
.
-
sssd
¶
-
start_evm_service
(*args, **kwargs)¶
-
stop_evm_service
(*args, **kwargs)¶
-
swap
¶ Retrieves the value of swap for the appliance. Might raise an exception if SSH fails.
Returns: An integer value of swap in the VM in megabytes. If None
is returned, it means it was not possible to parse the command output.Raises: paramiko.ssh_exception.SSHException
orsocket.error
-
uninstall_vddk
(*args, **kwargs)¶
-
unpartitioned_disks
¶ Returns list of any disks that have no partitions
-
update_advanced_settings
(settings_dict)[source]¶ PATCH settings from the master server’s api/server/:id/settings endpoint
Uses REST API for CFME 5.9+, uses rails console on lower versions
Will automatically update existing settings dictionary with settings_dict
Parameters: data_dict – dictionary of the changes to be made to the yaml configuration JSON dumps data_dict to pass as raw hash data to rest_api session Raises: ApplianceException when server_id isn’t set
-
update_guid
(*args, **kwargs)¶
-
update_rhel
(*args, **kwargs)¶
-
url
¶ Returns a proper URL of the appliance.
If the ports do not correspond the protocols’ default port numbers, then the ports are explicitly specified as well.
-
url_path
(path)[source]¶ generates URL with an additional path. Useful for generating REST or SSUI URLs.
-
use_dev_branch
(*args, **kwargs)¶
-
user
¶
-
version
¶
-
wait_for_embedded_ansible
(timeout=900)[source]¶ Waits for embedded ansible to be ready
Parameters: timeout – Number of seconds to wait until timeout (default 900
)
-
wait_for_evm_service
(*args, **kwargs)¶
-
wait_for_miq_server_workers_started
(evm_tail=None, poll_interval=5)[source]¶ Waits for the CFME’s workers to be started by tailing evm.log for: ‘INFO – : MIQ(MiqServer#wait_for_started_workers) All workers have been started’
-
wait_for_ssh
(timeout=600)[source]¶ Waits for appliance SSH connection to be ready
Parameters: timeout – Number of seconds to wait until timeout (default 600
)
-
wait_for_web_ui
(*args, **kwargs)¶
-
workaround_missing_gemfile
(*args, **kwargs)¶
-
class
cfme.utils.appliance.
MiqApi
(entry_point, auth, logger=None, verify_ssl=True, ca_bundle_path=None)[source]¶ Bases:
manageiq_client.api.ManageIQClient
-
class
cfme.utils.appliance.
MiqImplementationContext
(implementations, implementation_chooser=NOTHING, strict_calls=False)[source]¶ Bases:
sentaku.context.ImplementationContext
Our context for Sentaku
-
config
= <dectate.app.Config object>¶
-
dectate
= <dectate.config.Configurable object>¶
-
Bases:
object
NavigatableMixin ensures that an object can navigate properly
The NavigatableMixin object ensures that a Collection/Entity object inside the framework has access to be able to create a Widgetastic View, and that it has access to the browser.
- Note: The browser access will have to change once proliferation of the Sentaku
- system becomes common place
-
cfme.utils.appliance.
load_appliances
(appliance_list, global_kwargs)[source]¶ Instantiate a list of appliances from configuration data.
Parameters: - appliance_list – List of dictionaries that contain parameters for
IPAppliance
- global_kwargs – Arguments that will be defined for each appliances. Appliance can override.
- Result:
- List of
IPAppliance
- appliance_list – List of dictionaries that contain parameters for
-
cfme.utils.appliance.
load_appliances_from_config
(config)[source]¶ Instantiate IPAppliance objects based on data in
appliances
section of config.The
config
contains some global values andappliances
key which contains a list of dicts that have the same keys asIPAppliance.CONFIG_MAPPING
‘s keys.The global values in the root of the dict have lesser priority than the values in appliance definitions themselves
Parameters: config – A dictionary with the configuration
-
cfme.utils.appliance.
provision_appliance
(version=None, vm_name_prefix='cfme', template=None, provider_name=None, vm_name=None)[source]¶ Provisions fresh, unconfigured appliance of a specific version
Note
Version must be mapped to template name under
appliance_provisioning > versions
incfme_data.yaml
. If no matching template for given version is found, and trackerbot is set up, the latest available template of the same stream will be used. E.g.: if there is no template for 5.5.5.1 but there is 5.5.5.3, it will be used instead. If both template name and version are specified, template name takes priority.Parameters: - version – version of appliance to provision
- vm_name_prefix – name prefix to use when deploying the appliance vm
Returns: Unconfigured appliance; instance of
Appliance
Usage:
my_appliance = provision_appliance('5.5.1.8', 'my_tests') my_appliance.fix_ntp_clock() ...other configuration... my_appliance.db.enable_internal() my_appliance.wait_for_web_ui() or my_appliance = provision_appliance('5.5.1.8', 'my_tests') my_appliance.configure()