Added test to check nova services, hosts are consistent

Added test to check nova hosts are consistent in nova-services,
openstack hosts and hypervisors. While deploying clouds, we faced
several times when nova hosts were inconsistent after deployment
(due to incorrect deployment steps), in this case hypervisor list
has some computes missing, but they are present in nova-services.
So, there can be some issues like "host is not mapped to any cell",
or boot VM error. So, it is better to check these nova lists are
consistent.

Related-PROD: PROD-28210

Change-Id: I9705417817e6075455dc4ccf5e25f2ab3439108c
diff --git a/test_set/cvp-sanity/tests/test_nova_services.py b/test_set/cvp-sanity/tests/test_nova_services.py
index 8fdadd6..471e5dd 100644
--- a/test_set/cvp-sanity/tests/test_nova_services.py
+++ b/test_set/cvp-sanity/tests/test_nova_services.py
@@ -1,16 +1,49 @@
 import pytest
 
 
+@pytest.mark.usefixtures('check_openstack')
 def test_nova_services_status(local_salt_client):
     result = local_salt_client.cmd(
         'keystone:server',
         'cmd.run',
-        ['. /root/keystonercv3; nova service-list | grep "down\|disabled" | grep -v "Forced down"'],
+        ['. /root/keystonercv3;'
+         'nova service-list | grep "down\|disabled" | grep -v "Forced down"'],
         expr_form='pillar')
 
-    if not result:
-        pytest.skip("Nova service or keystone:server pillar \
-        are not found on this environment.")
-
     assert result[result.keys()[0]] == '', \
         '''Some nova services are in wrong state'''
+
+
+@pytest.mark.usefixtures('check_openstack')
+def test_nova_hosts_consistent(local_salt_client):
+    all_cmp_services = local_salt_client.cmd(
+        'keystone:server',
+        'cmd.run',
+        ['. /root/keystonercv3;'
+         'nova service-list | grep "nova-compute" | wc -l'],
+        expr_form='pillar').values()[0]
+    enabled_cmp_services = local_salt_client.cmd(
+        'keystone:server',
+        'cmd.run',
+        ['. /root/keystonercv3;'
+         'nova service-list | grep "nova-compute" | grep "enabled" | wc -l'],
+        expr_form='pillar').values()[0]
+    hosts = local_salt_client.cmd(
+        'keystone:server',
+        'cmd.run',
+        ['. /root/keystonercv3;'
+         'openstack host list | grep "compute" | wc -l'],
+        expr_form='pillar').values()[0]
+    hypervisors = local_salt_client.cmd(
+        'keystone:server',
+        'cmd.run',
+        ['. /root/keystonercv3;'
+         'openstack hypervisor list | egrep -v "\-----|ID" | wc -l'],
+        expr_form='pillar').values()[0]
+
+    assert all_cmp_services == hypervisors, \
+        "Number of nova-compute services ({}) does not match number of " \
+        "hypervisors ({}).".format(all_cmp_services, hypervisors)
+    assert enabled_cmp_services == hosts, \
+        "Number of enabled nova-compute services ({}) does not match number \
+        of hosts ({}).".format(enabled_cmp_services, hosts)