Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix #1612 #1616

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 22 additions & 6 deletions shinken/misc/datamanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,18 @@ def get_realm(self, r):
# Get the hosts tags sorted by names, and zero size in the end
def get_host_tags_sorted(self):
r = []
names = self.rg.tags.keys()
names.sort()
names = set()
for sched_instance_id in self.rg.hosts_tags:
for tpl_name in self.rg.hosts_tags.get(sched_instance_id):
names.add(tpl_name)
names = sorted(names)
for n in names:
r.append((n, self.rg.tags[n]))
# we may have the same template in some schedulers, because
# hosts in different schedulers may use the same host template
count = 0
for sched_instance_id in self.rg.hosts_tags:
count += self.rg.hosts_tags.get(sched_instance_id).get(n, 0)
r.append((n, count))
return r

# Get the hosts tagged with a specific tag
Expand All @@ -153,10 +161,18 @@ def get_hosts_tagged_with(self, tag):
# Get the services tags sorted by names, and zero size in the end
def get_service_tags_sorted(self):
r = []
names = self.rg.services_tags.keys()
names.sort()
names = set()
for sched_instance_id in self.rg.services_tags:
for tpl_name in self.rg.services_tags.get(sched_instance_id):
names.add(tpl_name)
names = sorted(names)
for n in names:
r.append((n, self.rg.services_tags[n]))
# we may have the same template in some schedulers, because
# hosts in different schedulers may use the same host template
count = 0
for sched_instance_id in self.rg.services_tags:
count += self.rg.services_tags.get(sched_instance_id).get(n, 0)
r.append((n, count))
return r

def get_important_impacts(self):
Expand Down
28 changes: 21 additions & 7 deletions shinken/misc/regenerator.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def __init__(self):
self.receivers = ReceiverLinks([])
# From now we only look for realms names
self.realms = set()
self.tags = {}
self.hosts_tags = {}
self.services_tags = {}

# And in progress one
Expand Down Expand Up @@ -228,9 +228,9 @@ def all_done_linking(self, inst_id):

# Linkify tags
for t in h.tags:
if t not in self.tags:
self.tags[t] = 0
self.tags[t] += 1
if t not in self.hosts_tags[inst_id]:
self.hosts_tags[inst_id][t] = 0
self.hosts_tags[inst_id][t] += 1

# We can really declare this host OK now
self.hosts.add_item(h)
Expand Down Expand Up @@ -287,9 +287,9 @@ def all_done_linking(self, inst_id):

# Linkify services tags
for t in s.tags:
if t not in self.services_tags:
self.services_tags[t] = 0
self.services_tags[t] += 1
if t not in self.services_tags[inst_id]:
self.services_tags[inst_id][t] = 0
self.services_tags[inst_id][t] += 1

# We can really declare this host OK now
self.services.add_item(s, index=True)
Expand Down Expand Up @@ -494,6 +494,20 @@ def manage_program_status_brok(self, b):

# Clean the old "hard" objects

# if this is the first time WebUI load the program_status brok,
# then we should add an entry for the corresponding 'instance_id';
# otherwise it should be a reload phrase, then we just need to clear
# the tags corresponding to the 'instance_id'.
if c_id in self.hosts_tags:
self.hosts_tags[c_id].clear()
else:
self.hosts_tags[c_id] = {}

if c_id in self.services_tags:
self.services_tags[c_id].clear()
else:
self.services_tags[c_id] = {}

# We should clean all previously added hosts and services
safe_print("Clean hosts/service of", c_id)
to_del_h = [h for h in self.hosts if h.instance_id == c_id]
Expand Down