libvirt check: use unqualified hostname

Nova will always use an unqualified host name for an instance's
compute node. If monasca-agent is configured to use a compute
node's fully qualified host name for metrics and that gets used for
looking up the instances running on that node, Nova will return
zero results. This commit fixes this problem by always reducing
the the host name to its first component.

Change-Id: Ie29cb2dc305c8b2d4c551d1512e0e755f9e38cb6
Story: 2001251
Task: 5781
This commit is contained in:
Johannes Grassler 2017-10-18 17:36:30 +02:00
parent c9895dcde2
commit 48729136a7
1 changed files with 1 additions and 1 deletions

View File

@ -145,7 +145,7 @@ class LibvirtCheck(AgentCheck):
client_version=ma_version.version_string)
self._get_this_host_aggregate(nova_client)
instances = nova_client.servers.list(
search_opts={'all_tenants': 1, 'host': self.hostname})
search_opts={'all_tenants': 1, 'host': self.hostname.split('.')[0]})
# Lay the groundwork for fetching VM IPs and network namespaces
if self.init_config.get('ping_check'):
nu = neutron_client.Client(