Пример #1
0
def day1_underlay(revert_snapshot, config, hardware):
    """Fixture that should provide SSH access to underlay objects.

    - Starts the 'hardware' environment and creates 'underlay' with required
      configuration.
    - Fills the following object using the 'hardware' fixture:
      config.underlay.ssh = JSONList of SSH access credentials for nodes.
                            This list will be used for initialization the
                            model UnderlaySSHManager, see it for details.

    :rtype UnderlaySSHManager: Object that encapsulate SSH credentials;
                               - provide list of underlay nodes;
                               - provide SSH access to underlay nodes using
                                 node names or node IPs.
    """
    # Create Underlay
    if not config.day1_underlay.ssh:
        # If config.underlay.ssh wasn't provided from external config, then
        # try to get necessary data from hardware manager (fuel-devops)

        # for devops manager: power on nodes and wait for SSH
        # for empty manager: do nothing
        # for maas manager: provision nodes and wait for SSH
        # hardware.start(underlay_node_roles=config.underlay.roles,
        hardware.start(
            underlay_node_roles=['salt_master'],
            timeout=config.underlay.bootstrap_timeout)

        config.day1_underlay.ssh = hardware.get_ssh_data(
            roles=config.underlay.roles)

        underlay = underlay_ssh_manager.UnderlaySSHManager(config)

        LOG.info("Generate MACs for MaaS")
        macs = {
            n.name.split('.')[0]: {
                "interface": {
                    "mac": n.get_interface_by_network_name('admin').mac_address}}  # noqa
            for n in hardware.slave_nodes}

        config.day1_cfg_config.maas_machines_macs = {
            "parameters": {
                "maas": {
                    "region": {
                        "machines": macs}}}}

        hardware.create_snapshot(ext.SNAPSHOT.day1_underlay)

    else:
        # 1. hardware environment created and powered on
        # 2. config.underlay.ssh contains SSH access to provisioned nodes
        #    (can be passed from external config with TESTS_CONFIGS variable)
        underlay = underlay_ssh_manager.UnderlaySSHManager(config)

    return underlay
Пример #2
0
def get_control_plane_targets():
    config = config_fixtures.config()
    underlay = underlay_ssh_manager.UnderlaySSHManager(config)
    saltmanager = salt_manager.SaltManager(config, underlay)
    targets = list()
    telemetry_exists = False
    barbican_exists = False
    try:
        targets += saltmanager.run_state("I@keystone:server",
                                         'test.ping')[0]['return'][0].keys()
        targets += saltmanager.run_state(
            "I@nginx:server and not I@salt:master",
            "test.ping")[0]['return'][0].keys()
        telemetry_exists = saltmanager.get_single_pillar(
            "I@salt:master", "_param:openstack_telemetry_hostname")
        barbican_exists = saltmanager.get_single_pillar(
            "I@salt:master", "_param:barbican_enabled")
    except BaseException as err:
        LOG.warning("Can't retrieve data from Salt. \
            Maybe cluster is not deployed completely.\
            Err: {}".format(err))

    # check for Manila  existence
    # if saltmanager.get_single_pillar("I@salt:master",
    #                                  "_param:manila_service_protocol"):
    #     targets.append('share*')

    # check for Tenant Telemetry  existence
    if telemetry_exists:
        targets.append('mdb*')

    # check for Barbican existence
    if barbican_exists:
        targets.append('kmn*')
    return targets
Пример #3
0
def underlay(revert_snapshot, config, hardware):
    """Fixture that should provide SSH access to underlay objects.

    - Starts the 'hardware' environment and creates 'underlay' with required
      configuration.
    - Fills the following object using the 'hardware' fixture:
      config.underlay.ssh = JSONList of SSH access credentials for nodes.
                            This list will be used for initialization the
                            model UnderlaySSHManager, see it for details.

    :rtype UnderlaySSHManager: Object that encapsulate SSH credentials;
                               - provide list of underlay nodes;
                               - provide SSH access to underlay nodes using
                                 node names or node IPs.
    """
    # If no snapshot was reverted, then try to revert the snapshot
    # that belongs to the fixture.
    # Note: keep fixtures in strict dependences from each other!
    if not revert_snapshot:
        if hardware.has_snapshot(ext.SNAPSHOT.underlay) and \
                hardware.has_snapshot_config(ext.SNAPSHOT.underlay):
            hardware.revert_snapshot(ext.SNAPSHOT.underlay)

    # Create Underlay
    if not config.underlay.ssh:
        # If config.underlay.ssh wasn't provided from external config, then
        # try to get necessary data from hardware manager (fuel-devops)
        config.underlay.ssh = hardware.get_ssh_data(
            roles=config.underlay.roles)

        underlay = underlay_ssh_manager.UnderlaySSHManager(config)

        if not config.underlay.lvm:
            underlay.enable_lvm(hardware.lvm_storages())
            config.underlay.lvm = underlay.config_lvm

        hardware.create_snapshot(ext.SNAPSHOT.underlay)

    else:
        # 1. hardware environment created and powered on
        # 2. config.underlay.ssh contains SSH access to provisioned nodes
        #    (can be passed from external config with TESTS_CONFIGS variable)
        underlay = underlay_ssh_manager.UnderlaySSHManager(config)

    return underlay
Пример #4
0
def underlay(revert_snapshot, config, hardware):
    """Fixture that should provide SSH access to underlay objects.

    - Starts the 'hardware' environment and creates 'underlay' with required
      configuration.
    - Fills the following object using the 'hardware' fixture:
      config.underlay.ssh = JSONList of SSH access credentials for nodes.
                            This list will be used for initialization the
                            model UnderlaySSHManager, see it for details.

    :rtype UnderlaySSHManager: Object that encapsulate SSH credentials;
                               - provide list of underlay nodes;
                               - provide SSH access to underlay nodes using
                                 node names or node IPs.
    """
    # Create Underlay
    if not config.underlay.ssh:
        # If config.underlay.ssh wasn't provided from external config, then
        # try to get necessary data from hardware manager (fuel-devops)

        # for devops manager: power on nodes and wait for SSH
        # for empty manager: do nothing
        # for maas manager: provision nodes and wait for SSH
        hardware.start(underlay_node_roles=config.underlay.roles,
                       timeout=config.underlay.bootstrap_timeout)

        config.underlay.ssh = hardware.get_ssh_data(
            roles=config.underlay.roles)

        underlay = underlay_ssh_manager.UnderlaySSHManager(config)

        if not config.underlay.lvm:
            underlay.enable_lvm(hardware.lvm_storages())
            config.underlay.lvm = underlay.config_lvm

        hardware.create_snapshot(ext.SNAPSHOT.underlay)

    else:
        # 1. hardware environment created and powered on
        # 2. config.underlay.ssh contains SSH access to provisioned nodes
        #    (can be passed from external config with TESTS_CONFIGS variable)
        underlay = underlay_ssh_manager.UnderlaySSHManager(config)

    return underlay
Пример #5
0
def main():
    tests_configs = os.environ.get('TESTS_CONFIGS', None)
    if not tests_configs or not os.path.isfile(tests_configs):
        print("Please set TESTS_CONFIGS environment variable whith"
              "the path to INI file with lab metadata.")
        return 1
    config = config_fixtures.config()
    underlay = underlay_ssh_manager.UnderlaySSHManager(config)
    saltmanager = salt_manager.SaltManager(config, underlay)
    saltmanager.create_env_jenkins_cicd()
    saltmanager.create_env_k8s()
Пример #6
0
def underlay_actions(config):
    """Fixture that provides SSH access to underlay objects.

    :param config: oslo_config object that keeps various parameters
                   across the fixtures, tests and test runs.
                   All SSH data is taken from the provided config.
    :rtype UnderlaySSHManager: Object that encapsulate SSH credentials;
                               - provide list of underlay nodes;
                               - provide SSH access to underlay nodes using
                                 node names or node IPs.
    """
    return underlay_ssh_manager.UnderlaySSHManager(config)
Пример #7
0
def main():
    parser = load_params()
    opts = parser.parse_args()

    tests_configs = os.environ.get('TESTS_CONFIGS', None)
    if not tests_configs or not os.path.isfile(tests_configs):
        print("Download logs and debug info from salt minions. "
              "Please set TESTS_CONFIGS environment variable whith"
              "the path to INI file with lab metadata.")
        return 11

    config = config_fixtures.config()
    underlay = underlay_ssh_manager.UnderlaySSHManager(config)

    underlay.get_logs(opts.archive_name_prefix)
Пример #8
0
def main():
    """Create fuel-devops environment from template"""
    parser = load_params()
    opts = parser.parse_args()

    if opts.path_to_template is None:
        parser.print_help()
        return 10

    path = os.path.abspath(opts.path_to_template)
    label = opts.template_steps_label
    if not label:
        label = os.path.basename(path).split('.')[0]

    config = config_fixtures.config()
    underlay = underlay_ssh_manager.UnderlaySSHManager(config)

    commands = underlay.read_template(path)

    commander = execute_commands.ExecuteCommandsMixin(config, underlay)
    commander.execute_commands(commands, label=label)