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 #1839: missing methods in Contact class #1840

Open
wants to merge 4 commits 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
17 changes: 17 additions & 0 deletions shinken/objects/contact.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,23 @@ def get_name(self):
except AttributeError:
return 'UnnamedContact'

def get_groupname(self):
groupname = ''
for cg in self.contactgroups:
groupname = "%s" % (cg.alias)
return groupname


def get_groupnames(self):
groupnames = ''
for cg in self.contactgroups:
if groupnames == '':
groupnames = cg.get_name()
else:
groupnames = "%s, %s" % (groupnames, cg.get_name())
return groupnames


# Search for notification_options with state and if t is
# in service_notification_period
def want_service_notification(self, t, state, type, business_impact, cmd=None):
Expand Down
6 changes: 6 additions & 0 deletions shinken/objects/contactgroup.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,12 @@ def linkify_cg_by_cont(self, contacts):
# We find the id, we replace the names
cg.replace_members(new_mbrs)

# Now register us in our members
for c in cg.members:
c.contactgroups.append(cg)
# and be sure we are uniq in it
c.contactgroups = list(set(c.contactgroups))

# Add a contact string to a contact member
# if the contact group do not exist, create it
def add_member(self, cname, cgname):
Expand Down