How to use the molecule.command.base function in molecule

To help you get started, we’ve selected a few molecule examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ansible / molecule / molecule / command / check.py View on Github external
#  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
#  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
#  DEALINGS IN THE SOFTWARE.

import os
import click

from molecule import logger
from molecule.command import base
from molecule import util

LOG = logger.get_logger(__name__)
MOLECULE_PARALLEL = os.environ.get('MOLECULE_PARALLEL', False)


class Check(base.Base):
    """
    .. program:: molecule check

    .. option:: molecule check

        Target the default scenario.

    .. program:: molecule check --scenario-name foo

    .. option:: molecule check --scenario-name foo

        Targeting a specific scenario.

    .. program:: molecule --debug check

    .. option:: molecule --debug check
github ansible / molecule / molecule / command / matrix.py View on Github external
#  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
#  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
#  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
#  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
#  DEALINGS IN THE SOFTWARE.

import click

from molecule import logger
from molecule import scenarios
from molecule.command import base

LOG = logger.get_logger(__name__)


class Matrix(base.Base):
    """
    .. program:: molecule matrix subcommand

    .. option:: molecule matrix subcommand

        Target the default scenario.

    .. program:: molecule matrix --scenario-name foo subcommand

    .. option:: molecule matrix --scenario-name foo subcommand

        Targeting a specific scenario.

    .. program:: molecule --debug matrix subcommand

    .. option:: molecule --debug matrix subcommand
github ansible / molecule / molecule / command / init / scenario.py View on Github external
def _default_scenario_exists(ctx, param, value):  # pragma: no cover
    if value == command_base.MOLECULE_DEFAULT_SCENARIO_NAME:
        return value

    default_scenario_directory = os.path.join(
        'molecule', command_base.MOLECULE_DEFAULT_SCENARIO_NAME
    )
    if not os.path.exists(default_scenario_directory):
        msg = (
            'The default scenario not found.  Please create a scenario '
            "named '{}' first."
        ).format(command_base.MOLECULE_DEFAULT_SCENARIO_NAME)
        util.sysexit_with_message(msg)
    return value
github ansible / molecule / molecule / command / syntax.py View on Github external
def syntax(ctx, scenario_name):  # pragma: no cover
    """ Use a provisioner to syntax check the role. """
    args = ctx.obj.get('args')
    command_args = {
        'subcommand': __name__,
        'scenario_name': scenario_name,
    }

    for c in base.get_configs(args, command_args):
        Syntax(c).execute()
github ansible / molecule / molecule / command / list.py View on Github external
#  DEALINGS IN THE SOFTWARE.

from __future__ import print_function

import click
import tabulate

from molecule import logger
from molecule import status
from molecule import util
from molecule.command import base

LOG = logger.get_logger(__name__)


class List(base.Base):
    def execute(self):
        """
        Execute the actions necessary to perform a `molecule list` and
        returns None.

        >>> molecule list

        Targeting a specific scenario:

        >>> molecule list --scenario-name foo

        Machine readable output:

        >>> molecule list --format plain
        >>> molecule list --format yaml
github ansible / molecule / molecule / command / lint.py View on Github external
def lint(ctx, scenario_name):  # pragma: no cover
    """ Lint the role (dependency, lint). """
    args = ctx.obj.get('args')
    subcommand = base._get_subcommand(__name__)
    command_args = {'subcommand': subcommand}

    base.execute_cmdline_scenarios(scenario_name, args, command_args)
github ansible / molecule / molecule / command / prepare.py View on Github external
#  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
#  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
#  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
#  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
#  DEALINGS IN THE SOFTWARE.

import click

from molecule import logger
from molecule.api import drivers
from molecule.command import base

LOG = logger.get_logger(__name__)


class Prepare(base.Base):
    """
    This action is for the purpose of preparing a molecule managed instance
    before the :py:class:`molecule.command.converge.Converge` action is run.
    Tasks contained within the ``prepare.yml`` playbook in the scenario
    directory will be run remotely on the managed instance. This action is run
    only once per test sequence.

    .. program:: molecule prepare

    .. option:: molecule prepare

        Target the default scenario.

    .. program:: molecule prepare --scenario-name foo

    .. option:: molecule prepare --scenario-name foo
github ansible / molecule / molecule / command / login.py View on Github external
import struct
import sys
import termios

import click
import pexpect

from molecule import logger
from molecule import scenarios
from molecule import util
from molecule.command import base

LOG = logger.get_logger(__name__)


class Login(base.Base):
    """
    .. program:: molecule login

    .. option:: molecule login

        Target the default scenario.

    .. program:: molecule login --scenario-name foo

    .. option:: molecule login --scenario-name foo

        Targeting a specific scenario.

    .. program:: molecule login --host hostname

    .. option:: molecule login --host hostname
github ansible / molecule / molecule / command / destroy.py View on Github external
#  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
#  DEALINGS IN THE SOFTWARE.

import os
import click

from molecule import logger
from molecule.api import drivers
from molecule.command import base
from molecule import util

LOG = logger.get_logger(__name__)
MOLECULE_PARALLEL = os.environ.get('MOLECULE_PARALLEL', False)


class Destroy(base.Base):
    """
    .. program:: molecule destroy

    .. option:: molecule destroy

        Target the default scenario.

    .. program:: molecule destroy --scenario-name foo

    .. option:: molecule destroy --scenario-name foo

        Targeting a specific scenario.

    .. program:: molecule destroy --all

    .. option:: molecule destroy --all
github ansible / molecule / molecule / command / syntax.py View on Github external
#  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
#  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
#  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
#  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
#  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
#  DEALINGS IN THE SOFTWARE.

import click

from molecule import logger
from molecule.command import base

LOG = logger.get_logger(__name__)


class Syntax(base.Base):
    """
    .. program:: molecule syntax

    .. option:: molecule syntax

        Target the default scenario.

    .. program:: molecule syntax --scenario-name foo

    .. option:: molecule syntax --scenario-name foo

        Targeting a specific scenario.

    .. program:: molecule --debug syntax

    .. option:: molecule --debug syntax