Skip to content

Commit

Permalink
Make settings machinery support Pulp 3
Browse files Browse the repository at this point in the history
When applied, this commit will redefine what a "valid" configuration
file is. Existing configuration files will continue to be valid. But in
addition, entirely new (and similar-looking) configuration files may
also be written.

The old configuration files are suitable for use when testing Pulp 2.
They let one declare information like "host pulp.example.com is running
rabbitmq." The new configuration files are suitable for testing Pulp 3.
They lew one declare information like "host pulp.example.com is running
redis."

In addition, this commit will update two pieces of machinery that are
related to the configuration file. Specifically, this commit will
overhaul the entire CLI interface (as accessed by the `pulp-smash`
executable) and re-implement the `PulpSmashConfig.get_services` method.

Fix: #965

Fix: #980
  • Loading branch information
Ichimonji10 committed Jul 17, 2018
1 parent fecde40 commit 504d1c2
Show file tree
Hide file tree
Showing 8 changed files with 492 additions and 310 deletions.
3 changes: 2 additions & 1 deletion docs/usage.rst
Expand Up @@ -89,7 +89,8 @@ you declare properties of the individual hosts that comprise the Pulp
application.

Each host must fulfill the "shell" role. In addition, the hosts must
collectively fulfill the :obj:`pulp_smash.config.REQUIRED_ROLES`.
collectively fulfill either :obj:`pulp_smash.config.P2_REQUIRED_ROLES` or
:obj:`pulp_smash.config.P3_REQUIRED_ROLES`.

Not all roles requires additional information. Currently, only the ``amqp
broker``, ``api`` and ``shell`` roles do. The ``amqp broker`` object must have a
Expand Down
14 changes: 10 additions & 4 deletions pulp_smash/cli.py
Expand Up @@ -7,6 +7,7 @@
from urllib.parse import urlsplit

import plumbum
from packaging.version import Version

from pulp_smash import exceptions

Expand Down Expand Up @@ -176,8 +177,10 @@ class Client(): # pylint:disable=too-few-public-methods
the host on which commands will be executed.
:param response_handler: A callback function. Defaults to
:func:`pulp_smash.cli.code_handler`.
:param pulp_smash.config.PulpHost pulp_host: A specific host to target,
instead of the first host with the ``pulp cli`` role.
:param pulp_smash.config.PulpHost pulp_host: A specific host to target.
Defaults to the first host with the ``pulp cli`` role when targeting
Pulp 2, and the first host with the ``shell`` role when targeting Pulp
3. If Pulp 3 gets a CLI, this latter default may change.
.. _Plumbum: http://plumbum.readthedocs.io/en/latest/index.html
"""
Expand All @@ -186,7 +189,10 @@ def __init__(self, cfg, response_handler=None, pulp_host=None):
"""Initialize this object with needed instance attributes."""
# How do we make requests?
if not pulp_host:
pulp_host = cfg.get_hosts('pulp cli')[0]
if cfg.pulp_version < Version('3'):
pulp_host = cfg.get_hosts('pulp cli')[0]
else:
pulp_host = cfg.get_hosts('shell')[0]
self.pulp_host = pulp_host
hostname = pulp_host.hostname
transport = pulp_host.roles.get('shell', {}).get('transport')
Expand Down Expand Up @@ -510,7 +516,7 @@ class ServiceManager(BaseServiceManager):
>>> from pulp_smash import cli, config
>>> cfg = config.get_config()
>>> pulp_host = cfg.get_get_services(('api',))[0]
>>> pulp_host = cfg.get_services(('api',))[0]
>>> svc_mgr = cli.ServiceManager(cfg, pulp_host)
>>> completed_process_list = svc_mgr.stop(['httpd'])
>>> completed_process_list = svc_mgr.start(['httpd'])
Expand Down

0 comments on commit 504d1c2

Please sign in to comment.