Exemple #1
0
def main():
    config = utils.load_config()
    auth = config.get("auth")
    cert_content = auth["public_ssl"]["cert_data"]["content"]
    if not cert_content:
        exit()
    ip = auth["public_vip"]
    hostname = auth["public_ssl"]["hostname"]
    script = utils.get_fixture("update_hosts.sh")
    subprocess.check_call(["sudo", script, ip, hostname])
def determinate_services():
    env_type = utils.load_config().get("env", {}).get("type", "")
    services_checks = {
        'libvirtd': 'libvirt_check',
        'rabbitmq-server': 'rabbitmq_check',
        'memcached': 'memcached_check',
        'mysql': 'mysql_check'
    }
    if not env_type == 'mk':
        services_checks['apache2'] = 'apache_check'

    return {
        service: (service, check)
        for service, check in services_checks.items()
    }
def determinate_components_names():
    env_type = utils.load_config().get("env", {}).get("type", "")
    with open(utils.get_fixture("components_names.yaml",
                                ("tests", ))) as names_file:
        components_names = yaml.load(names_file)

    # TODO(rpromyshlennikov): temporary fix: ovs service was not included,
    # because openvswitch-agent is managed by pacemaker
    # ["neutron-openvswitch-agent", ""]
    components = components_names["fuel"]["0"]

    if settings.INFLUXDB_GRAFANA_PLUGIN_VERSION.startswith("1."):
        components = components_names["fuel"]["1"]

    if env_type == "mk":
        components = components_names["mk"]

    return components
Exemple #4
0
def get_all_grafana_dashboards_names():
    env_type = utils.load_config().get("env", {}).get("type", "")
    dashboard_names = {
        "Apache", "LMA self-monitoring", "Cinder", "Elasticsearch", "Glance",
        "HAProxy", "Heat", "Hypervisor", "InfluxDB", "Keystone", "Main",
        "Memcached", "MySQL", "Neutron", "Nova", "RabbitMQ", "System"
    }
    if env_type == "mk":
        # Add new dashboards for mk
        dashboard_names.update({
            "Cassandra", "GlusterFS", "Grafana", "Kibana", "Nginx",
            "OpenContrail"
        })
        # Remove not actual dashboards for mk
        dashboard_names.difference_update({"Apache", "LMA self-monitoring"})

    return {
        panel_name.lower().replace(" ", "-")
        for panel_name in dashboard_names
    }
Exemple #5
0
from __future__ import print_function
import pytest

from stacklight_tests.tests import base_test
from stacklight_tests import utils

env_type = utils.load_config().get("env", {}).get("type", "")
default_time_range = "now-1m"
if env_type != "mk":
    default_time_range = "now-15m"


class TestKibana(base_test.BaseLMATest):
    def log_is_presented(self, query_filter, time_range=default_time_range):
        # type: (str) -> None
        res = self.elasticsearch_api.query_elasticsearch(
            query_filter=query_filter, time_range=time_range)
        return len(res['hits']['hits']) > 0

    def get_absent_programs_for_group(self, program_group, **kwargs):
        return {
            program
            for program in program_group
            if not self.log_is_presented(program, **kwargs)
        }

    def test_haproxy_logs(self):
        """Check logs for haproxy backends programs.
        Scenario:
            1. Run elasticsearch query to validate presence of a haproxy logs.
def env_config():
    return utils.load_config()
Exemple #7
0
    def setup_class(cls):
        cls.config = utils.load_config()
        # TODO(rpromyshlennikov): make types as enum?
        cls.env_type = cls.config.get("env", {}).get("type", "")
        cls.is_mk = cls.env_type == 'mk'

        nodes = cls.config.get("nodes")
        cls.cluster = objects.Cluster()

        for node_args in nodes:
            cls.cluster.add_host(objects.Host(**node_args))

        lma = cls.config.get("lma")
        cls.influxdb_api = influxdb_grafana_api.InfluxdbApi(
            address=lma["influxdb_vip"],
            port=lma["influxdb_port"],
            username=lma["influxdb_username"],
            password=lma["influxdb_password"],
            db_name=lma["influxdb_db_name"])

        cls.grafana_api = influxdb_grafana_api.GrafanaApi(
            address=lma["grafana_vip"],
            port=lma["grafana_port"],
            username=lma["grafana_username"],
            password=lma["grafana_password"],
            influxdb=cls.influxdb_api,
        )

        cls.elasticsearch_api = es_kibana_api.ElasticSearchApi(
            host=lma["elasticsearch_vip"],
            port=lma["elasticsearch_port"],
        )

        cls.nagios_api = nagios_api.NagiosApi(
            address=lma["nagios_vip"],
            port=lma["nagios_port"],
            username=lma["nagios_username"],
            password=lma["nagios_password"],
            tls_enabled=lma["nagios_tls"],
        )

        cls.kibana_api = es_kibana_api.KibanaApi(
            host=lma["elasticsearch_vip"],
            port=lma["kibana_port"],
        )

        # NOTE(rpromyshlennikov): It may need refactor,
        # if we use deploy without SSL
        auth = cls.config.get("auth")
        public_vip = auth["public_vip"]
        auth_url = "http://{}:5000/".format(public_vip)

        cert = False

        if auth.get("public_ssl") is not None:
            cert_content = auth["public_ssl"]["cert_data"]["content"]
            cert = utils.write_cert(cert_content) if cert_content else False
            hostname = auth["public_ssl"]["hostname"]
            auth_url = "https://{}:5000/".format(hostname)

        cls.os_clients = os_clients.OfficialClientManager(
            username=auth["access"]["user"],
            password=auth["access"]["password"],
            tenant_name=auth["access"]["tenant"],
            auth_url=auth_url,
            cert=cert,
            domain=auth["access"].get("domain", "Default"),
        )