Merge "[refactor]  Use pythonic way to join in list_to_target_string"
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..303da24
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,41 @@
+# Automatically generated by `hgimportsvn`
+.svn
+.hgsvn
+
+# Ignore local virtualenvs
+lib/
+bin/
+include/
+.Python/
+
+# These lines are suggested according to the svn:ignore property
+# Feel free to enable them by uncommenting them
+*.pyc
+*.pyo
+*.swp
+*.class
+*.orig
+*~
+.hypothesis/
+
+# autogenerated
+src/_pytest/_version.py
+# setuptools
+.eggs/
+
+doc/*/_build
+build/
+dist/
+*.egg-info
+issue/
+env/
+.env/
+3rdparty/
+.tox
+.cache
+.pytest_cache
+.coverage
+.ropeproject
+.idea
+.hypothesis
+
diff --git a/cvp_checks/fixtures/base.py b/cvp_checks/fixtures/base.py
index 96abad9..2407a63 100644
--- a/cvp_checks/fixtures/base.py
+++ b/cvp_checks/fixtures/base.py
@@ -12,3 +12,22 @@
 @pytest.fixture(scope='session', params=nodes.values(), ids=nodes.keys())
 def nodes_in_group(request):
     return request.param
+
+
+def pytest_namespace():
+    return {'contrail': None}
+
+
+@pytest.fixture(scope='module')
+def contrail(local_salt_client):
+    probe = local_salt_client.cmd(
+        'opencontrail:control',
+        'pillar.get',
+        'opencontrail:control:version',
+        expr_form='pillar')
+    if not probe:
+        pytest.skip("Contrail is not found on this environment")
+    versions = set(probe.values())
+    if len(versions) != 1:
+        pytest.fail('Contrail versions are not the same: {}'.format(probe))
+    pytest.contrail = str(versions.pop())[:1]
diff --git a/cvp_checks/global_config.yaml b/cvp_checks/global_config.yaml
index 7072fcc..40303d6 100644
--- a/cvp_checks/global_config.yaml
+++ b/cvp_checks/global_config.yaml
@@ -62,7 +62,7 @@
 # this test may skip groups (see example)
 test_mtu:
   { #"skipped_groups": ["dbs"]
-    "skipped_ifaces": ["bonding_masters", "lo", "veth", "tap", "cali", "qv", "qb"]}
+    "skipped_ifaces": ["bonding_masters", "lo", "veth", "tap", "cali", "qv", "qb", "br-int", "vxlan"]}
 # mask for interfaces to skip
 
 drivetrain_version: ''
diff --git a/cvp_checks/tests/ceph/test_ceph_pg_count.py b/cvp_checks/tests/ceph/test_ceph_pg_count.py
index 46e50c4..28783e8 100644
--- a/cvp_checks/tests/ceph/test_ceph_pg_count.py
+++ b/cvp_checks/tests/ceph/test_ceph_pg_count.py
@@ -22,7 +22,7 @@
     pg_num and pgp_num should be the same and 
     set according formula to higher value of powered 2
     """
-    
+    pytest.skip("This test needs redesign. Skipped for now")
     ceph_monitors = local_salt_client.cmd(
         'ceph:mon', 
         'test.ping', 
diff --git a/cvp_checks/tests/ceph/test_ceph_tell_bench.py b/cvp_checks/tests/ceph/test_ceph_tell_bench.py
index db45435..b275022 100644
--- a/cvp_checks/tests/ceph/test_ceph_tell_bench.py
+++ b/cvp_checks/tests/ceph/test_ceph_tell_bench.py
@@ -12,6 +12,7 @@
     and gives the "bytes_per_sec" speed for each OSD.
 
     """
+    pytest.skip("This test needs redesign. Skipped for now")
     ceph_monitors = local_salt_client.cmd(
         'ceph:mon', 
         'test.ping', 
diff --git a/cvp_checks/tests/test_contrail.py b/cvp_checks/tests/test_contrail.py
index 22242f7..2d358e9 100644
--- a/cvp_checks/tests/test_contrail.py
+++ b/cvp_checks/tests/test_contrail.py
@@ -1,21 +1,21 @@
 import pytest
 import json
 
+pytestmark = pytest.mark.usefixtures("contrail")
+
+STATUS_FILTER = r'grep -Pv "(==|^$|Disk|unix|support|boot|\*\*|FOR NODE)"'
+STATUS_COMMAND = "contrail-status"
+
+def get_contrail_status(salt_client, pillar, command, processor):
+    return salt_client.cmd(
+        pillar, 'cmd.run',
+        ['{} | {}'.format(command, processor)],
+        expr_form='pillar'
+    )
 
 def test_contrail_compute_status(local_salt_client):
-    probe = local_salt_client.cmd(
-        'opencontrail:control', 'cmd.run',
-        ['contrail-status | grep -Pv \'(==|^$|Disk|unix|support)\''],
-        expr_form='pillar'
-    )
-    if not probe:
-        pytest.skip("Contrail is not found on this environment")
-
-    cs = local_salt_client.cmd(
-        'nova:compute', 'cmd.run',
-        ['contrail-status | grep -Pv \'(==|^$)\''],
-        expr_form='pillar'
-    )
+    cs = get_contrail_status(local_salt_client, 'nova:compute',
+                             STATUS_COMMAND, STATUS_FILTER)
     broken_services = []
 
     for node in cs:
@@ -38,18 +38,17 @@
 
 
 def test_contrail_node_status(local_salt_client):
-    cs = local_salt_client.cmd(
-        'opencontrail:client:analytics_node', 'cmd.run',
-        ['contrail-status | grep -Pv \'(==|^$|Disk|unix|support|boot)\''],
-        expr_form='pillar'
+    command = STATUS_COMMAND
+
+    # TODO: what will be in OpenContrail 5?
+    if pytest.contrail == '4':
+        command = "doctrail all " + command
+    cs = get_contrail_status(local_salt_client,
+                             'opencontrail:client:analytics_node',
+                             command, STATUS_FILTER)
+    cs.update(get_contrail_status(local_salt_client, 'opencontrail:control',
+                                  command, STATUS_FILTER)
     )
-    cs.update(local_salt_client.cmd(
-        'opencontrail:control', 'cmd.run',
-        ['contrail-status | grep -Pv \'(==|^$|Disk|unix|support|boot)\''],
-        expr_form='pillar')
-    )
-    if not cs:
-        pytest.skip("Contrail is not found on this environment")
     broken_services = []
     for node in cs:
         for line in cs[node].split('\n'):
@@ -69,17 +68,9 @@
 
 
 def test_contrail_vrouter_count(local_salt_client):
-    probe = local_salt_client.cmd(
-        'opencontrail:control', 'cmd.run',
-        ['contrail-status | grep -Pv \'(==|^$|Disk|unix|support)\''],
-        expr_form='pillar'
-    )
-    if not probe:
-        pytest.skip("Contrail is not found on this environment")
-    cs = local_salt_client.cmd(
-        'nova:compute', 'cmd.run', ['contrail-status | grep -Pv \'(==|^$)\''],
-        expr_form='pillar'
-    )
+    cs = get_contrail_status(local_salt_client, 'nova:compute',
+                             STATUS_COMMAND, STATUS_FILTER)
+
     # TODO: what if compute lacks these service unintentionally?
     if not cs:
         pytest.skip("Contrail services were not found on compute nodes")
diff --git a/cvp_checks/tests/test_mtu.py b/cvp_checks/tests/test_mtu.py
index 940c145..9054ba3 100644
--- a/cvp_checks/tests/test_mtu.py
+++ b/cvp_checks/tests/test_mtu.py
@@ -8,7 +8,7 @@
     testname = os.path.basename(__file__).split('.')[0]
     config = utils.get_configuration()
     skipped_ifaces = config.get(testname)["skipped_ifaces"] or \
-        ["bonding_masters", "lo", "veth", "tap", "cali"]
+        ["bonding_masters", "lo", "veth", "tap", "cali", "qv", "qb", "br-int", "vxlan"]
     total = {}
     network_info = local_salt_client.cmd(
         "L@"+','.join(nodes_in_group), 'cmd.run', ['ls /sys/class/net/'], expr_form='compound')
diff --git a/cvp_checks/tests/test_packet_checker.py b/cvp_checks/tests/test_packet_checker.py
index a583c24..f76c339 100644
--- a/cvp_checks/tests/test_packet_checker.py
+++ b/cvp_checks/tests/test_packet_checker.py
@@ -1,26 +1,24 @@
 import pytest
 import json
-import os
-from cvp_checks import utils
 
 
 def test_check_package_versions(local_salt_client, nodes_in_group):
-    output = local_salt_client.cmd("L@"+','.join(nodes_in_group), 'lowpkg.list_pkgs', expr_form='compound')
+    output = local_salt_client.cmd("L@"+','.join(nodes_in_group),
+                                   'lowpkg.list_pkgs',
+                                   expr_form='compound')
     # Let's exclude cid01 and dbs01 nodes from this check
     exclude_nodes = local_salt_client.cmd("I@galera:master or I@gerrit:client",
                                           'test.ping',
                                           expr_form='compound').keys()
-
-    if len(output.keys()) < 2:
+    total_nodes = [i for i in output.keys() if i not in exclude_nodes]
+    if len(total_nodes) < 2:
         pytest.skip("Nothing to compare - only 1 node")
 
     nodes = []
     pkts_data = []
     my_set = set()
 
-    for node in output:
-        if node in exclude_nodes:
-            continue
+    for node in total_nodes:
         nodes.append(node)
         my_set.update(output[node].keys())
 
@@ -44,19 +42,29 @@
 
 def test_check_module_versions(local_salt_client, nodes_in_group):
     pre_check = local_salt_client.cmd(
-        "L@"+','.join(nodes_in_group), 'cmd.run', ['dpkg -l | grep "python-pip "'], expr_form='compound')
+        "L@"+','.join(nodes_in_group),
+        'cmd.run',
+        ['dpkg -l | grep "python-pip "'],
+        expr_form='compound')
     if pre_check.values().count('') > 0:
         pytest.skip("pip is not installed on one or more nodes")
-    if len(pre_check.keys()) < 2:
+
+    exclude_nodes = local_salt_client.cmd("I@galera:master or I@gerrit:client",
+                                          'test.ping',
+                                          expr_form='compound').keys()
+    total_nodes = [i for i in pre_check.keys() if i not in exclude_nodes]
+
+    if len(total_nodes) < 2:
         pytest.skip("Nothing to compare - only 1 node")
-    output = local_salt_client.cmd("L@"+','.join(nodes_in_group), 'pip.freeze', expr_form='compound')
+    output = local_salt_client.cmd("L@"+','.join(nodes_in_group),
+                                   'pip.freeze', expr_form='compound')
 
     nodes = []
 
     pkts_data = []
     my_set = set()
 
-    for node in output:
+    for node in total_nodes:
         nodes.append(node)
         my_set.update([x.split("=")[0] for x in output[node]])
         output[node] = dict([x.split("==") for x in output[node]])