repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
Alignak-monitoring/alignak | alignak/objects/hostdependency.py | Hostdependencies.linkify_hd_by_tp | def linkify_hd_by_tp(self, timeperiods):
"""Replace dependency_period by a real object in host dependency
:param timeperiods: list of timeperiod, used to look for a specific one
:type timeperiods: alignak.objects.timeperiod.Timeperiods
:return: None
"""
for hostdep in se... | python | def linkify_hd_by_tp(self, timeperiods):
"""Replace dependency_period by a real object in host dependency
:param timeperiods: list of timeperiod, used to look for a specific one
:type timeperiods: alignak.objects.timeperiod.Timeperiods
:return: None
"""
for hostdep in se... | [
"def",
"linkify_hd_by_tp",
"(",
"self",
",",
"timeperiods",
")",
":",
"for",
"hostdep",
"in",
"self",
":",
"try",
":",
"tp_name",
"=",
"hostdep",
".",
"dependency_period",
"timeperiod",
"=",
"timeperiods",
".",
"find_by_name",
"(",
"tp_name",
")",
"if",
"tim... | Replace dependency_period by a real object in host dependency
:param timeperiods: list of timeperiod, used to look for a specific one
:type timeperiods: alignak.objects.timeperiod.Timeperiods
:return: None | [
"Replace",
"dependency_period",
"by",
"a",
"real",
"object",
"in",
"host",
"dependency"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/objects/hostdependency.py#L253-L269 | train |
Alignak-monitoring/alignak | alignak/objects/hostextinfo.py | HostsExtInfo.merge_extinfo | def merge_extinfo(host, extinfo):
"""Merge extended host information into a host
:param host: the host to edit
:type host: alignak.objects.host.Host
:param extinfo: the external info we get data from
:type extinfo: alignak.objects.hostextinfo.HostExtInfo
:return: None
... | python | def merge_extinfo(host, extinfo):
"""Merge extended host information into a host
:param host: the host to edit
:type host: alignak.objects.host.Host
:param extinfo: the external info we get data from
:type extinfo: alignak.objects.hostextinfo.HostExtInfo
:return: None
... | [
"def",
"merge_extinfo",
"(",
"host",
",",
"extinfo",
")",
":",
"properties",
"=",
"[",
"'notes'",
",",
"'notes_url'",
",",
"'icon_image'",
",",
"'icon_image_alt'",
",",
"'vrml_image'",
",",
"'statusmap_image'",
"]",
"for",
"prop",
"in",
"properties",
":",
"if"... | Merge extended host information into a host
:param host: the host to edit
:type host: alignak.objects.host.Host
:param extinfo: the external info we get data from
:type extinfo: alignak.objects.hostextinfo.HostExtInfo
:return: None | [
"Merge",
"extended",
"host",
"information",
"into",
"a",
"host"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/objects/hostextinfo.py#L136-L151 | train |
Alignak-monitoring/alignak | alignak/http/client.py | HTTPClient.set_proxy | def set_proxy(self, proxy): # pragma: no cover, not with unit tests
"""Set HTTP proxy
:param proxy: proxy url
:type proxy: str
:return: None
"""
if proxy:
logger.debug('PROXY SETTING PROXY %s', proxy)
self._requests_con.proxies = {
... | python | def set_proxy(self, proxy): # pragma: no cover, not with unit tests
"""Set HTTP proxy
:param proxy: proxy url
:type proxy: str
:return: None
"""
if proxy:
logger.debug('PROXY SETTING PROXY %s', proxy)
self._requests_con.proxies = {
... | [
"def",
"set_proxy",
"(",
"self",
",",
"proxy",
")",
":",
"if",
"proxy",
":",
"logger",
".",
"debug",
"(",
"'PROXY SETTING PROXY %s'",
",",
"proxy",
")",
"self",
".",
"_requests_con",
".",
"proxies",
"=",
"{",
"'http'",
":",
"proxy",
",",
"'https'",
":",
... | Set HTTP proxy
:param proxy: proxy url
:type proxy: str
:return: None | [
"Set",
"HTTP",
"proxy"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/http/client.py#L176-L188 | train |
Alignak-monitoring/alignak | alignak/http/client.py | HTTPClient.post | def post(self, path, args, wait=False):
"""POST an HTTP request to a daemon
:param path: path to do the request
:type path: str
:param args: args to add in the request
:type args: dict
:param wait: True for a long timeout
:type wait: bool
:return: Content... | python | def post(self, path, args, wait=False):
"""POST an HTTP request to a daemon
:param path: path to do the request
:type path: str
:param args: args to add in the request
:type args: dict
:param wait: True for a long timeout
:type wait: bool
:return: Content... | [
"def",
"post",
"(",
"self",
",",
"path",
",",
"args",
",",
"wait",
"=",
"False",
")",
":",
"uri",
"=",
"self",
".",
"make_uri",
"(",
"path",
")",
"timeout",
"=",
"self",
".",
"make_timeout",
"(",
"wait",
")",
"for",
"(",
"key",
",",
"value",
")",... | POST an HTTP request to a daemon
:param path: path to do the request
:type path: str
:param args: args to add in the request
:type args: dict
:param wait: True for a long timeout
:type wait: bool
:return: Content of the HTTP response if server returned 200
... | [
"POST",
"an",
"HTTP",
"request",
"to",
"a",
"daemon"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/http/client.py#L219-L247 | train |
Alignak-monitoring/alignak | alignak/http/client.py | HTTPClient.put | def put(self, path, args, wait=False): # pragma: no cover, looks never used!
# todo: remove this because it looks never used anywhere...
"""PUT and HTTP request to a daemon
:param path: path to do the request
:type path: str
:param args: data to send in the request
:typ... | python | def put(self, path, args, wait=False): # pragma: no cover, looks never used!
# todo: remove this because it looks never used anywhere...
"""PUT and HTTP request to a daemon
:param path: path to do the request
:type path: str
:param args: data to send in the request
:typ... | [
"def",
"put",
"(",
"self",
",",
"path",
",",
"args",
",",
"wait",
"=",
"False",
")",
":",
"uri",
"=",
"self",
".",
"make_uri",
"(",
"path",
")",
"timeout",
"=",
"self",
".",
"make_timeout",
"(",
"wait",
")",
"try",
":",
"logger",
".",
"debug",
"(... | PUT and HTTP request to a daemon
:param path: path to do the request
:type path: str
:param args: data to send in the request
:type args:
:return: Content of the HTTP response if server returned 200
:rtype: str | [
"PUT",
"and",
"HTTP",
"request",
"to",
"a",
"daemon"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/http/client.py#L249-L274 | train |
Alignak-monitoring/alignak | alignak/objects/hostescalation.py | Hostescalations.explode | def explode(self, escalations):
"""Create instance of Escalation for each HostEscalation object
:param escalations: list of escalation, used to add new ones
:type escalations: alignak.objects.escalation.Escalations
:return: None
"""
# Now we explode all escalations (host... | python | def explode(self, escalations):
"""Create instance of Escalation for each HostEscalation object
:param escalations: list of escalation, used to add new ones
:type escalations: alignak.objects.escalation.Escalations
:return: None
"""
# Now we explode all escalations (host... | [
"def",
"explode",
"(",
"self",
",",
"escalations",
")",
":",
"for",
"escalation",
"in",
"self",
":",
"properties",
"=",
"escalation",
".",
"__class__",
".",
"properties",
"name",
"=",
"getattr",
"(",
"escalation",
",",
"'host_name'",
",",
"getattr",
"(",
"... | Create instance of Escalation for each HostEscalation object
:param escalations: list of escalation, used to add new ones
:type escalations: alignak.objects.escalation.Escalations
:return: None | [
"Create",
"instance",
"of",
"Escalation",
"for",
"each",
"HostEscalation",
"object"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/objects/hostescalation.py#L109-L128 | train |
Alignak-monitoring/alignak | alignak/stats.py | Stats.register | def register(self, name, _type, statsd_host='localhost', statsd_port=8125,
statsd_prefix='alignak', statsd_enabled=False, broks_enabled=False):
"""Init instance with real values
:param name: daemon name
:type name: str
:param _type: daemon type
:type _type:
... | python | def register(self, name, _type, statsd_host='localhost', statsd_port=8125,
statsd_prefix='alignak', statsd_enabled=False, broks_enabled=False):
"""Init instance with real values
:param name: daemon name
:type name: str
:param _type: daemon type
:type _type:
... | [
"def",
"register",
"(",
"self",
",",
"name",
",",
"_type",
",",
"statsd_host",
"=",
"'localhost'",
",",
"statsd_port",
"=",
"8125",
",",
"statsd_prefix",
"=",
"'alignak'",
",",
"statsd_enabled",
"=",
"False",
",",
"broks_enabled",
"=",
"False",
")",
":",
"... | Init instance with real values
:param name: daemon name
:type name: str
:param _type: daemon type
:type _type:
:param statsd_host: host to post data
:type statsd_host: str
:param statsd_port: port to post data
:type statsd_port: int
:param statsd_... | [
"Init",
"instance",
"with",
"real",
"values"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/stats.py#L166-L222 | train |
Alignak-monitoring/alignak | alignak/stats.py | Stats.load_statsd | def load_statsd(self):
"""Create socket connection to statsd host
Note that because of the UDP protocol used by StatsD, if no server is listening the
socket connection will be accepted anyway :)
:return: True if socket got created else False and an exception log is raised
"""
... | python | def load_statsd(self):
"""Create socket connection to statsd host
Note that because of the UDP protocol used by StatsD, if no server is listening the
socket connection will be accepted anyway :)
:return: True if socket got created else False and an exception log is raised
"""
... | [
"def",
"load_statsd",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"statsd_enabled",
":",
"logger",
".",
"info",
"(",
"'Stats reporting is not enabled, connection is not allowed'",
")",
"return",
"False",
"if",
"self",
".",
"statsd_enabled",
"and",
"self",
"."... | Create socket connection to statsd host
Note that because of the UDP protocol used by StatsD, if no server is listening the
socket connection will be accepted anyway :)
:return: True if socket got created else False and an exception log is raised | [
"Create",
"socket",
"connection",
"to",
"statsd",
"host"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/stats.py#L224-L255 | train |
Alignak-monitoring/alignak | alignak/stats.py | Stats.flush | def flush(self, log=False):
"""Send inner stored metrics to the defined Graphite
Returns False if the sending failed with a warning log if log parameter is set
:return: bool
"""
if not self.my_metrics:
logger.debug("Flushing - no metrics to send")
return... | python | def flush(self, log=False):
"""Send inner stored metrics to the defined Graphite
Returns False if the sending failed with a warning log if log parameter is set
:return: bool
"""
if not self.my_metrics:
logger.debug("Flushing - no metrics to send")
return... | [
"def",
"flush",
"(",
"self",
",",
"log",
"=",
"False",
")",
":",
"if",
"not",
"self",
".",
"my_metrics",
":",
"logger",
".",
"debug",
"(",
"\"Flushing - no metrics to send\"",
")",
"return",
"True",
"now",
"=",
"int",
"(",
"time",
".",
"time",
"(",
")"... | Send inner stored metrics to the defined Graphite
Returns False if the sending failed with a warning log if log parameter is set
:return: bool | [
"Send",
"inner",
"stored",
"metrics",
"to",
"the",
"defined",
"Graphite"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/stats.py#L308-L362 | train |
Alignak-monitoring/alignak | alignak/stats.py | Stats.send_to_graphite | def send_to_graphite(self, metric, value, timestamp=None):
"""
Inner store a new metric and flush to Graphite if the flush threshold is reached.
If no timestamp is provided, get the current time for the metric timestam.
:param metric: metric name in dotted format
:type metric: ... | python | def send_to_graphite(self, metric, value, timestamp=None):
"""
Inner store a new metric and flush to Graphite if the flush threshold is reached.
If no timestamp is provided, get the current time for the metric timestam.
:param metric: metric name in dotted format
:type metric: ... | [
"def",
"send_to_graphite",
"(",
"self",
",",
"metric",
",",
"value",
",",
"timestamp",
"=",
"None",
")",
":",
"if",
"not",
"self",
".",
"statsd_enabled",
"or",
"not",
"self",
".",
"carbon",
":",
"return",
"if",
"timestamp",
"is",
"None",
":",
"timestamp"... | Inner store a new metric and flush to Graphite if the flush threshold is reached.
If no timestamp is provided, get the current time for the metric timestam.
:param metric: metric name in dotted format
:type metric: str
:param value:
:type value: float
:param timestamp: ... | [
"Inner",
"store",
"a",
"new",
"metric",
"and",
"flush",
"to",
"Graphite",
"if",
"the",
"flush",
"threshold",
"is",
"reached",
"."
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/stats.py#L364-L388 | train |
Alignak-monitoring/alignak | alignak/stats.py | Stats.counter | def counter(self, key, value, timestamp=None):
"""Set a counter value
If the inner key does not exist is is created
:param key: counter to update
:type key: str
:param value: counter value
:type value: float
:return: An alignak_stat brok if broks are enabled els... | python | def counter(self, key, value, timestamp=None):
"""Set a counter value
If the inner key does not exist is is created
:param key: counter to update
:type key: str
:param value: counter value
:type value: float
:return: An alignak_stat brok if broks are enabled els... | [
"def",
"counter",
"(",
"self",
",",
"key",
",",
"value",
",",
"timestamp",
"=",
"None",
")",
":",
"_min",
",",
"_max",
",",
"count",
",",
"_sum",
"=",
"self",
".",
"stats",
".",
"get",
"(",
"key",
",",
"(",
"None",
",",
"None",
",",
"0",
",",
... | Set a counter value
If the inner key does not exist is is created
:param key: counter to update
:type key: str
:param value: counter value
:type value: float
:return: An alignak_stat brok if broks are enabled else None | [
"Set",
"a",
"counter",
"value"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/stats.py#L467-L536 | train |
Alignak-monitoring/alignak | alignak/satellite.py | BaseSatellite.get_managed_configurations | def get_managed_configurations(self):
"""Get the configurations managed by this satellite
The configurations managed by a satellite is a list of the configuration attached to
the schedulers related to the satellites. A broker linked to several schedulers
will return the list of the conf... | python | def get_managed_configurations(self):
"""Get the configurations managed by this satellite
The configurations managed by a satellite is a list of the configuration attached to
the schedulers related to the satellites. A broker linked to several schedulers
will return the list of the conf... | [
"def",
"get_managed_configurations",
"(",
"self",
")",
":",
"res",
"=",
"{",
"}",
"for",
"scheduler_link",
"in",
"list",
"(",
"self",
".",
"schedulers",
".",
"values",
"(",
")",
")",
":",
"res",
"[",
"scheduler_link",
".",
"instance_id",
"]",
"=",
"{",
... | Get the configurations managed by this satellite
The configurations managed by a satellite is a list of the configuration attached to
the schedulers related to the satellites. A broker linked to several schedulers
will return the list of the configuration parts of its scheduler links.
... | [
"Get",
"the",
"configurations",
"managed",
"by",
"this",
"satellite"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/satellite.py#L132-L151 | train |
Alignak-monitoring/alignak | alignak/satellite.py | BaseSatellite.get_scheduler_from_hostname | def get_scheduler_from_hostname(self, host_name):
"""Get scheduler linked to the given host_name
:param host_name: host_name we want the scheduler from
:type host_name: str
:return: scheduler with id corresponding to the mapping table
:rtype: dict
"""
scheduler_u... | python | def get_scheduler_from_hostname(self, host_name):
"""Get scheduler linked to the given host_name
:param host_name: host_name we want the scheduler from
:type host_name: str
:return: scheduler with id corresponding to the mapping table
:rtype: dict
"""
scheduler_u... | [
"def",
"get_scheduler_from_hostname",
"(",
"self",
",",
"host_name",
")",
":",
"scheduler_uuid",
"=",
"self",
".",
"hosts_schedulers",
".",
"get",
"(",
"host_name",
",",
"None",
")",
"return",
"self",
".",
"schedulers",
".",
"get",
"(",
"scheduler_uuid",
",",
... | Get scheduler linked to the given host_name
:param host_name: host_name we want the scheduler from
:type host_name: str
:return: scheduler with id corresponding to the mapping table
:rtype: dict | [
"Get",
"scheduler",
"linked",
"to",
"the",
"given",
"host_name"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/satellite.py#L153-L162 | train |
Alignak-monitoring/alignak | alignak/satellite.py | BaseSatellite.get_external_commands | def get_external_commands(self):
"""Get the external commands
:return: External commands list
:rtype: list
"""
res = self.external_commands
logger.debug("Get and clear external commands list: %s", res)
self.external_commands = []
return res | python | def get_external_commands(self):
"""Get the external commands
:return: External commands list
:rtype: list
"""
res = self.external_commands
logger.debug("Get and clear external commands list: %s", res)
self.external_commands = []
return res | [
"def",
"get_external_commands",
"(",
"self",
")",
":",
"res",
"=",
"self",
".",
"external_commands",
"logger",
".",
"debug",
"(",
"\"Get and clear external commands list: %s\"",
",",
"res",
")",
"self",
".",
"external_commands",
"=",
"[",
"]",
"return",
"res"
] | Get the external commands
:return: External commands list
:rtype: list | [
"Get",
"the",
"external",
"commands"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/satellite.py#L164-L173 | train |
Alignak-monitoring/alignak | alignak/satellite.py | BaseSatellite.get_results_from_passive | def get_results_from_passive(self, scheduler_instance_id):
"""Get executed actions results from a passive satellite for a specific scheduler
:param scheduler_instance_id: scheduler id
:type scheduler_instance_id: int
:return: Results list
:rtype: list
"""
# Do I ... | python | def get_results_from_passive(self, scheduler_instance_id):
"""Get executed actions results from a passive satellite for a specific scheduler
:param scheduler_instance_id: scheduler id
:type scheduler_instance_id: int
:return: Results list
:rtype: list
"""
# Do I ... | [
"def",
"get_results_from_passive",
"(",
"self",
",",
"scheduler_instance_id",
")",
":",
"if",
"not",
"self",
".",
"schedulers",
":",
"logger",
".",
"debug",
"(",
"\"I do not have any scheduler: %s\"",
",",
"self",
".",
"schedulers",
")",
"return",
"[",
"]",
"sch... | Get executed actions results from a passive satellite for a specific scheduler
:param scheduler_instance_id: scheduler id
:type scheduler_instance_id: int
:return: Results list
:rtype: list | [
"Get",
"executed",
"actions",
"results",
"from",
"a",
"passive",
"satellite",
"for",
"a",
"specific",
"scheduler"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/satellite.py#L175-L203 | train |
Alignak-monitoring/alignak | alignak/satellite.py | BaseSatellite.get_events | def get_events(self):
"""Get event list from satellite
:return: A copy of the events list
:rtype: list
"""
res = copy.copy(self.events)
del self.events[:]
return res | python | def get_events(self):
"""Get event list from satellite
:return: A copy of the events list
:rtype: list
"""
res = copy.copy(self.events)
del self.events[:]
return res | [
"def",
"get_events",
"(",
"self",
")",
":",
"res",
"=",
"copy",
".",
"copy",
"(",
"self",
".",
"events",
")",
"del",
"self",
".",
"events",
"[",
":",
"]",
"return",
"res"
] | Get event list from satellite
:return: A copy of the events list
:rtype: list | [
"Get",
"event",
"list",
"from",
"satellite"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/satellite.py#L352-L360 | train |
Alignak-monitoring/alignak | alignak/satellite.py | Satellite.manage_action_return | def manage_action_return(self, action):
"""Manage action return from Workers
We just put them into the corresponding sched
and we clean unused properties like my_scheduler
:param action: the action to manage
:type action: alignak.action.Action
:return: None
"""
... | python | def manage_action_return(self, action):
"""Manage action return from Workers
We just put them into the corresponding sched
and we clean unused properties like my_scheduler
:param action: the action to manage
:type action: alignak.action.Action
:return: None
"""
... | [
"def",
"manage_action_return",
"(",
"self",
",",
"action",
")",
":",
"if",
"action",
".",
"__class__",
".",
"my_type",
"not",
"in",
"[",
"'check'",
",",
"'notification'",
",",
"'eventhandler'",
"]",
":",
"self",
".",
"add",
"(",
"action",
")",
"return",
... | Manage action return from Workers
We just put them into the corresponding sched
and we clean unused properties like my_scheduler
:param action: the action to manage
:type action: alignak.action.Action
:return: None | [
"Manage",
"action",
"return",
"from",
"Workers",
"We",
"just",
"put",
"them",
"into",
"the",
"corresponding",
"sched",
"and",
"we",
"clean",
"unused",
"properties",
"like",
"my_scheduler"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/satellite.py#L462-L502 | train |
Alignak-monitoring/alignak | alignak/satellite.py | Satellite.create_and_launch_worker | def create_and_launch_worker(self, module_name='fork'):
"""Create and launch a new worker, and put it into self.workers
It can be mortal or not
:param module_name: the module name related to the worker
default is "fork" for no module
Inde... | python | def create_and_launch_worker(self, module_name='fork'):
"""Create and launch a new worker, and put it into self.workers
It can be mortal or not
:param module_name: the module name related to the worker
default is "fork" for no module
Inde... | [
"def",
"create_and_launch_worker",
"(",
"self",
",",
"module_name",
"=",
"'fork'",
")",
":",
"logger",
".",
"info",
"(",
"\"Allocating new '%s' worker...\"",
",",
"module_name",
")",
"target",
"=",
"None",
"__warned",
"=",
"[",
"]",
"if",
"module_name",
"==",
... | Create and launch a new worker, and put it into self.workers
It can be mortal or not
:param module_name: the module name related to the worker
default is "fork" for no module
Indeed, it is actually the module 'python_name'
:type module_na... | [
"Create",
"and",
"launch",
"a",
"new",
"worker",
"and",
"put",
"it",
"into",
"self",
".",
"workers",
"It",
"can",
"be",
"mortal",
"or",
"not"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/satellite.py#L540-L589 | train |
Alignak-monitoring/alignak | alignak/satellite.py | Satellite.do_stop_workers | def do_stop_workers(self):
"""Stop all workers
:return: None
"""
logger.info("Stopping all workers (%d)", len(self.workers))
for worker in list(self.workers.values()):
try:
logger.info(" - stopping '%s'", worker.get_id())
worker.termin... | python | def do_stop_workers(self):
"""Stop all workers
:return: None
"""
logger.info("Stopping all workers (%d)", len(self.workers))
for worker in list(self.workers.values()):
try:
logger.info(" - stopping '%s'", worker.get_id())
worker.termin... | [
"def",
"do_stop_workers",
"(",
"self",
")",
":",
"logger",
".",
"info",
"(",
"\"Stopping all workers (%d)\"",
",",
"len",
"(",
"self",
".",
"workers",
")",
")",
"for",
"worker",
"in",
"list",
"(",
"self",
".",
"workers",
".",
"values",
"(",
")",
")",
"... | Stop all workers
:return: None | [
"Stop",
"all",
"workers"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/satellite.py#L591-L607 | train |
Alignak-monitoring/alignak | alignak/satellite.py | Satellite.get_broks | def get_broks(self):
"""Get brok list from satellite
:return: A copy of the broks list
:rtype: list
"""
res = copy.copy(self.broks)
del self.broks[:]
return res | python | def get_broks(self):
"""Get brok list from satellite
:return: A copy of the broks list
:rtype: list
"""
res = copy.copy(self.broks)
del self.broks[:]
return res | [
"def",
"get_broks",
"(",
"self",
")",
":",
"res",
"=",
"copy",
".",
"copy",
"(",
"self",
".",
"broks",
")",
"del",
"self",
".",
"broks",
"[",
":",
"]",
"return",
"res"
] | Get brok list from satellite
:return: A copy of the broks list
:rtype: list | [
"Get",
"brok",
"list",
"from",
"satellite"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/satellite.py#L644-L652 | train |
Alignak-monitoring/alignak | alignak/satellite.py | Satellite.check_and_del_zombie_workers | def check_and_del_zombie_workers(self): # pragma: no cover, not with unit tests...
# pylint: disable= not-callable
"""Check if worker are fine and kill them if not.
Dispatch the actions in the worker to another one
TODO: see if unit tests would allow to check this code?
:retur... | python | def check_and_del_zombie_workers(self): # pragma: no cover, not with unit tests...
# pylint: disable= not-callable
"""Check if worker are fine and kill them if not.
Dispatch the actions in the worker to another one
TODO: see if unit tests would allow to check this code?
:retur... | [
"def",
"check_and_del_zombie_workers",
"(",
"self",
")",
":",
"for",
"p",
"in",
"active_children",
"(",
")",
":",
"logger",
".",
"debug",
"(",
"\"got child: %s\"",
",",
"p",
")",
"w_to_del",
"=",
"[",
"]",
"for",
"worker",
"in",
"list",
"(",
"self",
".",... | Check if worker are fine and kill them if not.
Dispatch the actions in the worker to another one
TODO: see if unit tests would allow to check this code?
:return: None | [
"Check",
"if",
"worker",
"are",
"fine",
"and",
"kill",
"them",
"if",
"not",
".",
"Dispatch",
"the",
"actions",
"in",
"the",
"worker",
"to",
"another",
"one"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/satellite.py#L654-L699 | train |
Alignak-monitoring/alignak | alignak/satellite.py | Satellite.adjust_worker_number_by_load | def adjust_worker_number_by_load(self):
"""Try to create the minimum workers specified in the configuration
:return: None
"""
if self.interrupted:
logger.debug("Trying to adjust worker number. Ignoring because we are stopping.")
return
to_del = []
... | python | def adjust_worker_number_by_load(self):
"""Try to create the minimum workers specified in the configuration
:return: None
"""
if self.interrupted:
logger.debug("Trying to adjust worker number. Ignoring because we are stopping.")
return
to_del = []
... | [
"def",
"adjust_worker_number_by_load",
"(",
"self",
")",
":",
"if",
"self",
".",
"interrupted",
":",
"logger",
".",
"debug",
"(",
"\"Trying to adjust worker number. Ignoring because we are stopping.\"",
")",
"return",
"to_del",
"=",
"[",
"]",
"logger",
".",
"debug",
... | Try to create the minimum workers specified in the configuration
:return: None | [
"Try",
"to",
"create",
"the",
"minimum",
"workers",
"specified",
"in",
"the",
"configuration"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/satellite.py#L701-L731 | train |
Alignak-monitoring/alignak | alignak/satellite.py | Satellite._get_queue_for_the_action | def _get_queue_for_the_action(self, action):
"""Find action queue for the action depending on the module.
The id is found with action modulo on action id
:param a: the action that need action queue to be assigned
:type action: object
:return: worker id and queue. (0, None) if no... | python | def _get_queue_for_the_action(self, action):
"""Find action queue for the action depending on the module.
The id is found with action modulo on action id
:param a: the action that need action queue to be assigned
:type action: object
:return: worker id and queue. (0, None) if no... | [
"def",
"_get_queue_for_the_action",
"(",
"self",
",",
"action",
")",
":",
"mod",
"=",
"getattr",
"(",
"action",
",",
"'module_type'",
",",
"'fork'",
")",
"queues",
"=",
"list",
"(",
"self",
".",
"q_by_mod",
"[",
"mod",
"]",
".",
"items",
"(",
")",
")",... | Find action queue for the action depending on the module.
The id is found with action modulo on action id
:param a: the action that need action queue to be assigned
:type action: object
:return: worker id and queue. (0, None) if no queue for the module_type
:rtype: tuple | [
"Find",
"action",
"queue",
"for",
"the",
"action",
"depending",
"on",
"the",
"module",
".",
"The",
"id",
"is",
"found",
"with",
"action",
"modulo",
"on",
"action",
"id"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/satellite.py#L734-L757 | train |
Alignak-monitoring/alignak | alignak/satellite.py | Satellite.add_actions | def add_actions(self, actions_list, scheduler_instance_id):
"""Add a list of actions to the satellite queues
:param actions_list: Actions list to add
:type actions_list: list
:param scheduler_instance_id: sheduler link to assign the actions to
:type scheduler_instance_id: Schedu... | python | def add_actions(self, actions_list, scheduler_instance_id):
"""Add a list of actions to the satellite queues
:param actions_list: Actions list to add
:type actions_list: list
:param scheduler_instance_id: sheduler link to assign the actions to
:type scheduler_instance_id: Schedu... | [
"def",
"add_actions",
"(",
"self",
",",
"actions_list",
",",
"scheduler_instance_id",
")",
":",
"scheduler_link",
"=",
"None",
"for",
"scheduler_id",
"in",
"self",
".",
"schedulers",
":",
"logger",
".",
"debug",
"(",
"\"Trying to add an action, scheduler: %s\"",
","... | Add a list of actions to the satellite queues
:param actions_list: Actions list to add
:type actions_list: list
:param scheduler_instance_id: sheduler link to assign the actions to
:type scheduler_instance_id: SchedulerLink
:return: None | [
"Add",
"a",
"list",
"of",
"actions",
"to",
"the",
"satellite",
"queues"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/satellite.py#L759-L802 | train |
Alignak-monitoring/alignak | alignak/satellite.py | Satellite.assign_to_a_queue | def assign_to_a_queue(self, action):
"""Take an action and put it to a worker actions queue
:param action: action to put
:type action: alignak.action.Action
:return: None
"""
(worker_id, queue) = self._get_queue_for_the_action(action)
if not worker_id:
... | python | def assign_to_a_queue(self, action):
"""Take an action and put it to a worker actions queue
:param action: action to put
:type action: alignak.action.Action
:return: None
"""
(worker_id, queue) = self._get_queue_for_the_action(action)
if not worker_id:
... | [
"def",
"assign_to_a_queue",
"(",
"self",
",",
"action",
")",
":",
"(",
"worker_id",
",",
"queue",
")",
"=",
"self",
".",
"_get_queue_for_the_action",
"(",
"action",
")",
"if",
"not",
"worker_id",
":",
"return",
"action",
".",
"my_worker",
"=",
"worker_id",
... | Take an action and put it to a worker actions queue
:param action: action to put
:type action: alignak.action.Action
:return: None | [
"Take",
"an",
"action",
"and",
"put",
"it",
"to",
"a",
"worker",
"actions",
"queue"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/satellite.py#L804-L822 | train |
Alignak-monitoring/alignak | alignak/satellite.py | Satellite.get_new_actions | def get_new_actions(self):
""" Wrapper function for do_get_new_actions
For stats purpose
:return: None
TODO: Use a decorator for timing this function
"""
try:
_t0 = time.time()
self.do_get_new_actions()
statsmgr.timer('actions.got.time... | python | def get_new_actions(self):
""" Wrapper function for do_get_new_actions
For stats purpose
:return: None
TODO: Use a decorator for timing this function
"""
try:
_t0 = time.time()
self.do_get_new_actions()
statsmgr.timer('actions.got.time... | [
"def",
"get_new_actions",
"(",
"self",
")",
":",
"try",
":",
"_t0",
"=",
"time",
".",
"time",
"(",
")",
"self",
".",
"do_get_new_actions",
"(",
")",
"statsmgr",
".",
"timer",
"(",
"'actions.got.time'",
",",
"time",
".",
"time",
"(",
")",
"-",
"_t0",
... | Wrapper function for do_get_new_actions
For stats purpose
:return: None
TODO: Use a decorator for timing this function | [
"Wrapper",
"function",
"for",
"do_get_new_actions",
"For",
"stats",
"purpose"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/satellite.py#L824-L836 | train |
Alignak-monitoring/alignak | alignak/satellite.py | Satellite.main | def main(self):
"""Main satellite function. Do init and then mainloop
:return: None
"""
try:
# Start the daemon mode
if not self.do_daemon_init_and_start():
self.exit_on_error(message="Daemon initialization error", exit_code=3)
self.d... | python | def main(self):
"""Main satellite function. Do init and then mainloop
:return: None
"""
try:
# Start the daemon mode
if not self.do_daemon_init_and_start():
self.exit_on_error(message="Daemon initialization error", exit_code=3)
self.d... | [
"def",
"main",
"(",
"self",
")",
":",
"try",
":",
"if",
"not",
"self",
".",
"do_daemon_init_and_start",
"(",
")",
":",
"self",
".",
"exit_on_error",
"(",
"message",
"=",
"\"Daemon initialization error\"",
",",
"exit_code",
"=",
"3",
")",
"self",
".",
"do_p... | Main satellite function. Do init and then mainloop
:return: None | [
"Main",
"satellite",
"function",
".",
"Do",
"init",
"and",
"then",
"mainloop"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/satellite.py#L1108-L1136 | train |
Alignak-monitoring/alignak | alignak/contactdowntime.py | ContactDowntime.check_activation | def check_activation(self, contacts):
"""Enter or exit downtime if necessary
:return: None
"""
now = time.time()
was_is_in_effect = self.is_in_effect
self.is_in_effect = (self.start_time <= now <= self.end_time)
# Raise a log entry when we get in the downtime
... | python | def check_activation(self, contacts):
"""Enter or exit downtime if necessary
:return: None
"""
now = time.time()
was_is_in_effect = self.is_in_effect
self.is_in_effect = (self.start_time <= now <= self.end_time)
# Raise a log entry when we get in the downtime
... | [
"def",
"check_activation",
"(",
"self",
",",
"contacts",
")",
":",
"now",
"=",
"time",
".",
"time",
"(",
")",
"was_is_in_effect",
"=",
"self",
".",
"is_in_effect",
"self",
".",
"is_in_effect",
"=",
"(",
"self",
".",
"start_time",
"<=",
"now",
"<=",
"self... | Enter or exit downtime if necessary
:return: None | [
"Enter",
"or",
"exit",
"downtime",
"if",
"necessary"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/contactdowntime.py#L90-L105 | train |
Alignak-monitoring/alignak | alignak/util.py | split_semicolon | def split_semicolon(line, maxsplit=None):
r"""Split a line on semicolons characters but not on the escaped semicolons
:param line: line to split
:type line: str
:param maxsplit: maximal number of split (if None, no limit)
:type maxsplit: None | int
:return: split line
:rtype: list
>>> ... | python | def split_semicolon(line, maxsplit=None):
r"""Split a line on semicolons characters but not on the escaped semicolons
:param line: line to split
:type line: str
:param maxsplit: maximal number of split (if None, no limit)
:type maxsplit: None | int
:return: split line
:rtype: list
>>> ... | [
"def",
"split_semicolon",
"(",
"line",
",",
"maxsplit",
"=",
"None",
")",
":",
"r",
"split_line",
"=",
"line",
".",
"split",
"(",
"';'",
")",
"split_line_size",
"=",
"len",
"(",
"split_line",
")",
"if",
"maxsplit",
"is",
"None",
"or",
"maxsplit",
"<",
... | r"""Split a line on semicolons characters but not on the escaped semicolons
:param line: line to split
:type line: str
:param maxsplit: maximal number of split (if None, no limit)
:type maxsplit: None | int
:return: split line
:rtype: list
>>> split_semicolon('a,b;c;;g')
['a,b', 'c', '... | [
"r",
"Split",
"a",
"line",
"on",
"semicolons",
"characters",
"but",
"not",
"on",
"the",
"escaped",
"semicolons"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/util.py#L110-L165 | train |
Alignak-monitoring/alignak | alignak/util.py | format_t_into_dhms_format | def format_t_into_dhms_format(timestamp):
""" Convert an amount of second into day, hour, min and sec
:param timestamp: seconds
:type timestamp: int
:return: 'Ad Bh Cm Ds'
:rtype: str
>>> format_t_into_dhms_format(456189)
'5d 6h 43m 9s'
>>> format_t_into_dhms_format(3600)
'0d 1h 0... | python | def format_t_into_dhms_format(timestamp):
""" Convert an amount of second into day, hour, min and sec
:param timestamp: seconds
:type timestamp: int
:return: 'Ad Bh Cm Ds'
:rtype: str
>>> format_t_into_dhms_format(456189)
'5d 6h 43m 9s'
>>> format_t_into_dhms_format(3600)
'0d 1h 0... | [
"def",
"format_t_into_dhms_format",
"(",
"timestamp",
")",
":",
"mins",
",",
"timestamp",
"=",
"divmod",
"(",
"timestamp",
",",
"60",
")",
"hour",
",",
"mins",
"=",
"divmod",
"(",
"mins",
",",
"60",
")",
"day",
",",
"hour",
"=",
"divmod",
"(",
"hour",
... | Convert an amount of second into day, hour, min and sec
:param timestamp: seconds
:type timestamp: int
:return: 'Ad Bh Cm Ds'
:rtype: str
>>> format_t_into_dhms_format(456189)
'5d 6h 43m 9s'
>>> format_t_into_dhms_format(3600)
'0d 1h 0m 0s' | [
"Convert",
"an",
"amount",
"of",
"second",
"into",
"day",
"hour",
"min",
"and",
"sec"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/util.py#L230-L248 | train |
Alignak-monitoring/alignak | alignak/util.py | merge_periods | def merge_periods(data):
"""
Merge periods to have better continous periods.
Like 350-450, 400-600 => 350-600
:param data: list of periods
:type data: list
:return: better continous periods
:rtype: list
"""
# sort by start date
newdata = sorted(data, key=lambda drange: drange[0]... | python | def merge_periods(data):
"""
Merge periods to have better continous periods.
Like 350-450, 400-600 => 350-600
:param data: list of periods
:type data: list
:return: better continous periods
:rtype: list
"""
# sort by start date
newdata = sorted(data, key=lambda drange: drange[0]... | [
"def",
"merge_periods",
"(",
"data",
")",
":",
"newdata",
"=",
"sorted",
"(",
"data",
",",
"key",
"=",
"lambda",
"drange",
":",
"drange",
"[",
"0",
"]",
")",
"end",
"=",
"0",
"for",
"period",
"in",
"newdata",
":",
"if",
"period",
"[",
"0",
"]",
"... | Merge periods to have better continous periods.
Like 350-450, 400-600 => 350-600
:param data: list of periods
:type data: list
:return: better continous periods
:rtype: list | [
"Merge",
"periods",
"to",
"have",
"better",
"continous",
"periods",
".",
"Like",
"350",
"-",
"450",
"400",
"-",
"600",
"=",
">",
"350",
"-",
"600"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/util.py#L251-L289 | train |
Alignak-monitoring/alignak | alignak/util.py | list_split | def list_split(val, split_on_comma=True):
"""Try to split each member of a list with comma separator.
If we don't have to split just return val
:param val: value to split
:type val:
:param split_on_comma:
:type split_on_comma: bool
:return: list with members split on comma
:rtype: list
... | python | def list_split(val, split_on_comma=True):
"""Try to split each member of a list with comma separator.
If we don't have to split just return val
:param val: value to split
:type val:
:param split_on_comma:
:type split_on_comma: bool
:return: list with members split on comma
:rtype: list
... | [
"def",
"list_split",
"(",
"val",
",",
"split_on_comma",
"=",
"True",
")",
":",
"if",
"not",
"split_on_comma",
":",
"return",
"val",
"new_val",
"=",
"[",
"]",
"for",
"subval",
"in",
"val",
":",
"if",
"isinstance",
"(",
"subval",
",",
"list",
")",
":",
... | Try to split each member of a list with comma separator.
If we don't have to split just return val
:param val: value to split
:type val:
:param split_on_comma:
:type split_on_comma: bool
:return: list with members split on comma
:rtype: list
>>> list_split(['a,b,c'], False)
['a,b,c... | [
"Try",
"to",
"split",
"each",
"member",
"of",
"a",
"list",
"with",
"comma",
"separator",
".",
"If",
"we",
"don",
"t",
"have",
"to",
"split",
"just",
"return",
"val"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/util.py#L364-L393 | train |
Alignak-monitoring/alignak | alignak/util.py | to_best_int_float | def to_best_int_float(val):
"""Get best type for value between int and float
:param val: value
:type val:
:return: int(float(val)) if int(float(val)) == float(val), else float(val)
:rtype: int | float
>>> to_best_int_float("20.1")
20.1
>>> to_best_int_float("20.0")
20
>>> to_... | python | def to_best_int_float(val):
"""Get best type for value between int and float
:param val: value
:type val:
:return: int(float(val)) if int(float(val)) == float(val), else float(val)
:rtype: int | float
>>> to_best_int_float("20.1")
20.1
>>> to_best_int_float("20.0")
20
>>> to_... | [
"def",
"to_best_int_float",
"(",
"val",
")",
":",
"integer",
"=",
"int",
"(",
"float",
"(",
"val",
")",
")",
"flt",
"=",
"float",
"(",
"val",
")",
"if",
"integer",
"==",
"flt",
":",
"return",
"integer",
"return",
"flt"
] | Get best type for value between int and float
:param val: value
:type val:
:return: int(float(val)) if int(float(val)) == float(val), else float(val)
:rtype: int | float
>>> to_best_int_float("20.1")
20.1
>>> to_best_int_float("20.0")
20
>>> to_best_int_float("20")
20 | [
"Get",
"best",
"type",
"for",
"value",
"between",
"int",
"and",
"float"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/util.py#L396-L419 | train |
Alignak-monitoring/alignak | alignak/util.py | dict_to_serialized_dict | def dict_to_serialized_dict(ref, the_dict):
"""Serialize the list of elements to a dictionary
Used for the retention store
:param ref: Not used
:type ref:
:param the_dict: dictionary to convert
:type the_dict: dict
:return: dict of serialized
:rtype: dict
"""
result = {}
fo... | python | def dict_to_serialized_dict(ref, the_dict):
"""Serialize the list of elements to a dictionary
Used for the retention store
:param ref: Not used
:type ref:
:param the_dict: dictionary to convert
:type the_dict: dict
:return: dict of serialized
:rtype: dict
"""
result = {}
fo... | [
"def",
"dict_to_serialized_dict",
"(",
"ref",
",",
"the_dict",
")",
":",
"result",
"=",
"{",
"}",
"for",
"elt",
"in",
"list",
"(",
"the_dict",
".",
"values",
"(",
")",
")",
":",
"if",
"not",
"getattr",
"(",
"elt",
",",
"'serialize'",
",",
"None",
")"... | Serialize the list of elements to a dictionary
Used for the retention store
:param ref: Not used
:type ref:
:param the_dict: dictionary to convert
:type the_dict: dict
:return: dict of serialized
:rtype: dict | [
"Serialize",
"the",
"list",
"of",
"elements",
"to",
"a",
"dictionary"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/util.py#L587-L604 | train |
Alignak-monitoring/alignak | alignak/util.py | list_to_serialized | def list_to_serialized(ref, the_list):
"""Serialize the list of elements
Used for the retention store
:param ref: Not used
:type ref:
:param the_list: dictionary to convert
:type the_list: dict
:return: dict of serialized
:rtype: dict
"""
result = []
for elt in the_list:
... | python | def list_to_serialized(ref, the_list):
"""Serialize the list of elements
Used for the retention store
:param ref: Not used
:type ref:
:param the_list: dictionary to convert
:type the_list: dict
:return: dict of serialized
:rtype: dict
"""
result = []
for elt in the_list:
... | [
"def",
"list_to_serialized",
"(",
"ref",
",",
"the_list",
")",
":",
"result",
"=",
"[",
"]",
"for",
"elt",
"in",
"the_list",
":",
"if",
"not",
"getattr",
"(",
"elt",
",",
"'serialize'",
",",
"None",
")",
":",
"continue",
"result",
".",
"append",
"(",
... | Serialize the list of elements
Used for the retention store
:param ref: Not used
:type ref:
:param the_list: dictionary to convert
:type the_list: dict
:return: dict of serialized
:rtype: dict | [
"Serialize",
"the",
"list",
"of",
"elements"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/util.py#L607-L624 | train |
Alignak-monitoring/alignak | alignak/util.py | to_hostnames_list | def to_hostnames_list(ref, tab): # pragma: no cover, to be deprecated?
"""Convert Host list into a list of host_name
:param ref: Not used
:type ref:
:param tab: Host list
:type tab: list[alignak.objects.host.Host]
:return: host_name list
:rtype: list
"""
res = []
for host in t... | python | def to_hostnames_list(ref, tab): # pragma: no cover, to be deprecated?
"""Convert Host list into a list of host_name
:param ref: Not used
:type ref:
:param tab: Host list
:type tab: list[alignak.objects.host.Host]
:return: host_name list
:rtype: list
"""
res = []
for host in t... | [
"def",
"to_hostnames_list",
"(",
"ref",
",",
"tab",
")",
":",
"res",
"=",
"[",
"]",
"for",
"host",
"in",
"tab",
":",
"if",
"hasattr",
"(",
"host",
",",
"'host_name'",
")",
":",
"res",
".",
"append",
"(",
"host",
".",
"host_name",
")",
"return",
"re... | Convert Host list into a list of host_name
:param ref: Not used
:type ref:
:param tab: Host list
:type tab: list[alignak.objects.host.Host]
:return: host_name list
:rtype: list | [
"Convert",
"Host",
"list",
"into",
"a",
"list",
"of",
"host_name"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/util.py#L642-L656 | train |
Alignak-monitoring/alignak | alignak/util.py | sort_by_number_values | def sort_by_number_values(x00, y00): # pragma: no cover, looks like not used!
"""Compare x00, y00 base on number of values
:param x00: first elem to compare
:type x00: list
:param y00: second elem to compare
:type y00: list
:return: x00 > y00 (-1) if len(x00) > len(y00), x00 == y00 (0) if id e... | python | def sort_by_number_values(x00, y00): # pragma: no cover, looks like not used!
"""Compare x00, y00 base on number of values
:param x00: first elem to compare
:type x00: list
:param y00: second elem to compare
:type y00: list
:return: x00 > y00 (-1) if len(x00) > len(y00), x00 == y00 (0) if id e... | [
"def",
"sort_by_number_values",
"(",
"x00",
",",
"y00",
")",
":",
"if",
"len",
"(",
"x00",
")",
"<",
"len",
"(",
"y00",
")",
":",
"return",
"1",
"if",
"len",
"(",
"x00",
")",
">",
"len",
"(",
"y00",
")",
":",
"return",
"-",
"1",
"return",
"0"
] | Compare x00, y00 base on number of values
:param x00: first elem to compare
:type x00: list
:param y00: second elem to compare
:type y00: list
:return: x00 > y00 (-1) if len(x00) > len(y00), x00 == y00 (0) if id equals, x00 < y00 (1) else
:rtype: int | [
"Compare",
"x00",
"y00",
"base",
"on",
"number",
"of",
"values"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/util.py#L738-L753 | train |
Alignak-monitoring/alignak | alignak/util.py | strip_and_uniq | def strip_and_uniq(tab):
"""Strip every element of a list and keep a list of ordered unique values
:param tab: list to strip
:type tab: list
:return: stripped list with unique values
:rtype: list
"""
_list = []
for elt in tab:
val = elt.strip()
if val and val not in _lis... | python | def strip_and_uniq(tab):
"""Strip every element of a list and keep a list of ordered unique values
:param tab: list to strip
:type tab: list
:return: stripped list with unique values
:rtype: list
"""
_list = []
for elt in tab:
val = elt.strip()
if val and val not in _lis... | [
"def",
"strip_and_uniq",
"(",
"tab",
")",
":",
"_list",
"=",
"[",
"]",
"for",
"elt",
"in",
"tab",
":",
"val",
"=",
"elt",
".",
"strip",
"(",
")",
"if",
"val",
"and",
"val",
"not",
"in",
"_list",
":",
"_list",
".",
"append",
"(",
"val",
")",
"re... | Strip every element of a list and keep a list of ordered unique values
:param tab: list to strip
:type tab: list
:return: stripped list with unique values
:rtype: list | [
"Strip",
"every",
"element",
"of",
"a",
"list",
"and",
"keep",
"a",
"list",
"of",
"ordered",
"unique",
"values"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/util.py#L777-L790 | train |
Alignak-monitoring/alignak | alignak/util.py | filter_host_by_name | def filter_host_by_name(name):
"""Filter for host
Filter on name
:param name: name to filter
:type name: str
:return: Filter
:rtype: bool
"""
def inner_filter(items):
"""Inner filter for host. Accept if host_name == name"""
host = items["host"]
if host is None:
... | python | def filter_host_by_name(name):
"""Filter for host
Filter on name
:param name: name to filter
:type name: str
:return: Filter
:rtype: bool
"""
def inner_filter(items):
"""Inner filter for host. Accept if host_name == name"""
host = items["host"]
if host is None:
... | [
"def",
"filter_host_by_name",
"(",
"name",
")",
":",
"def",
"inner_filter",
"(",
"items",
")",
":",
"host",
"=",
"items",
"[",
"\"host\"",
"]",
"if",
"host",
"is",
"None",
":",
"return",
"False",
"return",
"host",
".",
"host_name",
"==",
"name",
"return"... | Filter for host
Filter on name
:param name: name to filter
:type name: str
:return: Filter
:rtype: bool | [
"Filter",
"for",
"host",
"Filter",
"on",
"name"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/util.py#L938-L955 | train |
Alignak-monitoring/alignak | alignak/util.py | filter_host_by_regex | def filter_host_by_regex(regex):
"""Filter for host
Filter on regex
:param regex: regex to filter
:type regex: str
:return: Filter
:rtype: bool
"""
host_re = re.compile(regex)
def inner_filter(items):
"""Inner filter for host. Accept if regex match host_name"""
host... | python | def filter_host_by_regex(regex):
"""Filter for host
Filter on regex
:param regex: regex to filter
:type regex: str
:return: Filter
:rtype: bool
"""
host_re = re.compile(regex)
def inner_filter(items):
"""Inner filter for host. Accept if regex match host_name"""
host... | [
"def",
"filter_host_by_regex",
"(",
"regex",
")",
":",
"host_re",
"=",
"re",
".",
"compile",
"(",
"regex",
")",
"def",
"inner_filter",
"(",
"items",
")",
":",
"host",
"=",
"items",
"[",
"\"host\"",
"]",
"if",
"host",
"is",
"None",
":",
"return",
"False... | Filter for host
Filter on regex
:param regex: regex to filter
:type regex: str
:return: Filter
:rtype: bool | [
"Filter",
"for",
"host",
"Filter",
"on",
"regex"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/util.py#L958-L976 | train |
Alignak-monitoring/alignak | alignak/util.py | filter_host_by_group | def filter_host_by_group(group):
"""Filter for host
Filter on group
:param group: group name to filter
:type group: str
:return: Filter
:rtype: bool
"""
def inner_filter(items):
"""Inner filter for host. Accept if group in host.hostgroups"""
host = items["host"]
... | python | def filter_host_by_group(group):
"""Filter for host
Filter on group
:param group: group name to filter
:type group: str
:return: Filter
:rtype: bool
"""
def inner_filter(items):
"""Inner filter for host. Accept if group in host.hostgroups"""
host = items["host"]
... | [
"def",
"filter_host_by_group",
"(",
"group",
")",
":",
"def",
"inner_filter",
"(",
"items",
")",
":",
"host",
"=",
"items",
"[",
"\"host\"",
"]",
"if",
"host",
"is",
"None",
":",
"return",
"False",
"return",
"group",
"in",
"[",
"items",
"[",
"\"hostgroup... | Filter for host
Filter on group
:param group: group name to filter
:type group: str
:return: Filter
:rtype: bool | [
"Filter",
"for",
"host",
"Filter",
"on",
"group"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/util.py#L979-L996 | train |
Alignak-monitoring/alignak | alignak/util.py | filter_host_by_tag | def filter_host_by_tag(tpl):
"""Filter for host
Filter on tag
:param tpl: tag to filter
:type tpl: str
:return: Filter
:rtype: bool
"""
def inner_filter(items):
"""Inner filter for host. Accept if tag in host.tags"""
host = items["host"]
if host is None:
... | python | def filter_host_by_tag(tpl):
"""Filter for host
Filter on tag
:param tpl: tag to filter
:type tpl: str
:return: Filter
:rtype: bool
"""
def inner_filter(items):
"""Inner filter for host. Accept if tag in host.tags"""
host = items["host"]
if host is None:
... | [
"def",
"filter_host_by_tag",
"(",
"tpl",
")",
":",
"def",
"inner_filter",
"(",
"items",
")",
":",
"host",
"=",
"items",
"[",
"\"host\"",
"]",
"if",
"host",
"is",
"None",
":",
"return",
"False",
"return",
"tpl",
"in",
"[",
"t",
".",
"strip",
"(",
")",... | Filter for host
Filter on tag
:param tpl: tag to filter
:type tpl: str
:return: Filter
:rtype: bool | [
"Filter",
"for",
"host",
"Filter",
"on",
"tag"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/util.py#L999-L1016 | train |
Alignak-monitoring/alignak | alignak/util.py | filter_service_by_name | def filter_service_by_name(name):
"""Filter for service
Filter on name
:param name: name to filter
:type name: str
:return: Filter
:rtype: bool
"""
def inner_filter(items):
"""Inner filter for service. Accept if service_description == name"""
service = items["service"]
... | python | def filter_service_by_name(name):
"""Filter for service
Filter on name
:param name: name to filter
:type name: str
:return: Filter
:rtype: bool
"""
def inner_filter(items):
"""Inner filter for service. Accept if service_description == name"""
service = items["service"]
... | [
"def",
"filter_service_by_name",
"(",
"name",
")",
":",
"def",
"inner_filter",
"(",
"items",
")",
":",
"service",
"=",
"items",
"[",
"\"service\"",
"]",
"if",
"service",
"is",
"None",
":",
"return",
"False",
"return",
"service",
".",
"service_description",
"... | Filter for service
Filter on name
:param name: name to filter
:type name: str
:return: Filter
:rtype: bool | [
"Filter",
"for",
"service",
"Filter",
"on",
"name"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/util.py#L1019-L1036 | train |
Alignak-monitoring/alignak | alignak/util.py | filter_service_by_regex_name | def filter_service_by_regex_name(regex):
"""Filter for service
Filter on regex
:param regex: regex to filter
:type regex: str
:return: Filter
:rtype: bool
"""
host_re = re.compile(regex)
def inner_filter(items):
"""Inner filter for service. Accept if regex match service_des... | python | def filter_service_by_regex_name(regex):
"""Filter for service
Filter on regex
:param regex: regex to filter
:type regex: str
:return: Filter
:rtype: bool
"""
host_re = re.compile(regex)
def inner_filter(items):
"""Inner filter for service. Accept if regex match service_des... | [
"def",
"filter_service_by_regex_name",
"(",
"regex",
")",
":",
"host_re",
"=",
"re",
".",
"compile",
"(",
"regex",
")",
"def",
"inner_filter",
"(",
"items",
")",
":",
"service",
"=",
"items",
"[",
"\"service\"",
"]",
"if",
"service",
"is",
"None",
":",
"... | Filter for service
Filter on regex
:param regex: regex to filter
:type regex: str
:return: Filter
:rtype: bool | [
"Filter",
"for",
"service",
"Filter",
"on",
"regex"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/util.py#L1039-L1057 | train |
Alignak-monitoring/alignak | alignak/util.py | filter_service_by_host_name | def filter_service_by_host_name(host_name):
"""Filter for service
Filter on host_name
:param host_name: host_name to filter
:type host_name: str
:return: Filter
:rtype: bool
"""
def inner_filter(items):
"""Inner filter for service. Accept if service.host.host_name == host_name"... | python | def filter_service_by_host_name(host_name):
"""Filter for service
Filter on host_name
:param host_name: host_name to filter
:type host_name: str
:return: Filter
:rtype: bool
"""
def inner_filter(items):
"""Inner filter for service. Accept if service.host.host_name == host_name"... | [
"def",
"filter_service_by_host_name",
"(",
"host_name",
")",
":",
"def",
"inner_filter",
"(",
"items",
")",
":",
"service",
"=",
"items",
"[",
"\"service\"",
"]",
"host",
"=",
"items",
"[",
"\"hosts\"",
"]",
"[",
"service",
".",
"host",
"]",
"if",
"service... | Filter for service
Filter on host_name
:param host_name: host_name to filter
:type host_name: str
:return: Filter
:rtype: bool | [
"Filter",
"for",
"service",
"Filter",
"on",
"host_name"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/util.py#L1060-L1078 | train |
Alignak-monitoring/alignak | alignak/util.py | filter_service_by_regex_host_name | def filter_service_by_regex_host_name(regex):
"""Filter for service
Filter on regex host_name
:param regex: regex to filter
:type regex: str
:return: Filter
:rtype: bool
"""
host_re = re.compile(regex)
def inner_filter(items):
"""Inner filter for service. Accept if regex ma... | python | def filter_service_by_regex_host_name(regex):
"""Filter for service
Filter on regex host_name
:param regex: regex to filter
:type regex: str
:return: Filter
:rtype: bool
"""
host_re = re.compile(regex)
def inner_filter(items):
"""Inner filter for service. Accept if regex ma... | [
"def",
"filter_service_by_regex_host_name",
"(",
"regex",
")",
":",
"host_re",
"=",
"re",
".",
"compile",
"(",
"regex",
")",
"def",
"inner_filter",
"(",
"items",
")",
":",
"service",
"=",
"items",
"[",
"\"service\"",
"]",
"host",
"=",
"items",
"[",
"\"host... | Filter for service
Filter on regex host_name
:param regex: regex to filter
:type regex: str
:return: Filter
:rtype: bool | [
"Filter",
"for",
"service",
"Filter",
"on",
"regex",
"host_name"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/util.py#L1081-L1100 | train |
Alignak-monitoring/alignak | alignak/util.py | filter_service_by_hostgroup_name | def filter_service_by_hostgroup_name(group):
"""Filter for service
Filter on hostgroup
:param group: hostgroup to filter
:type group: str
:return: Filter
:rtype: bool
"""
def inner_filter(items):
"""Inner filter for service. Accept if hostgroup in service.host.hostgroups"""
... | python | def filter_service_by_hostgroup_name(group):
"""Filter for service
Filter on hostgroup
:param group: hostgroup to filter
:type group: str
:return: Filter
:rtype: bool
"""
def inner_filter(items):
"""Inner filter for service. Accept if hostgroup in service.host.hostgroups"""
... | [
"def",
"filter_service_by_hostgroup_name",
"(",
"group",
")",
":",
"def",
"inner_filter",
"(",
"items",
")",
":",
"service",
"=",
"items",
"[",
"\"service\"",
"]",
"host",
"=",
"items",
"[",
"\"hosts\"",
"]",
"[",
"service",
".",
"host",
"]",
"if",
"servic... | Filter for service
Filter on hostgroup
:param group: hostgroup to filter
:type group: str
:return: Filter
:rtype: bool | [
"Filter",
"for",
"service",
"Filter",
"on",
"hostgroup"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/util.py#L1103-L1121 | train |
Alignak-monitoring/alignak | alignak/util.py | filter_service_by_host_tag_name | def filter_service_by_host_tag_name(tpl):
"""Filter for service
Filter on tag
:param tpl: tag to filter
:type tpl: str
:return: Filter
:rtype: bool
"""
def inner_filter(items):
"""Inner filter for service. Accept if tpl in service.host.tags"""
service = items["service"]... | python | def filter_service_by_host_tag_name(tpl):
"""Filter for service
Filter on tag
:param tpl: tag to filter
:type tpl: str
:return: Filter
:rtype: bool
"""
def inner_filter(items):
"""Inner filter for service. Accept if tpl in service.host.tags"""
service = items["service"]... | [
"def",
"filter_service_by_host_tag_name",
"(",
"tpl",
")",
":",
"def",
"inner_filter",
"(",
"items",
")",
":",
"service",
"=",
"items",
"[",
"\"service\"",
"]",
"host",
"=",
"items",
"[",
"\"hosts\"",
"]",
"[",
"service",
".",
"host",
"]",
"if",
"service",... | Filter for service
Filter on tag
:param tpl: tag to filter
:type tpl: str
:return: Filter
:rtype: bool | [
"Filter",
"for",
"service",
"Filter",
"on",
"tag"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/util.py#L1124-L1142 | train |
Alignak-monitoring/alignak | alignak/util.py | filter_service_by_servicegroup_name | def filter_service_by_servicegroup_name(group):
"""Filter for service
Filter on group
:param group: group to filter
:type group: str
:return: Filter
:rtype: bool
"""
def inner_filter(items):
"""Inner filter for service. Accept if group in service.servicegroups"""
servic... | python | def filter_service_by_servicegroup_name(group):
"""Filter for service
Filter on group
:param group: group to filter
:type group: str
:return: Filter
:rtype: bool
"""
def inner_filter(items):
"""Inner filter for service. Accept if group in service.servicegroups"""
servic... | [
"def",
"filter_service_by_servicegroup_name",
"(",
"group",
")",
":",
"def",
"inner_filter",
"(",
"items",
")",
":",
"service",
"=",
"items",
"[",
"\"service\"",
"]",
"if",
"service",
"is",
"None",
":",
"return",
"False",
"return",
"group",
"in",
"[",
"items... | Filter for service
Filter on group
:param group: group to filter
:type group: str
:return: Filter
:rtype: bool | [
"Filter",
"for",
"service",
"Filter",
"on",
"group"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/util.py#L1145-L1162 | train |
Alignak-monitoring/alignak | alignak/util.py | filter_host_by_bp_rule_label | def filter_host_by_bp_rule_label(label):
"""Filter for host
Filter on label
:param label: label to filter
:type label: str
:return: Filter
:rtype: bool
"""
def inner_filter(items):
"""Inner filter for host. Accept if label in host.labels"""
host = items["host"]
... | python | def filter_host_by_bp_rule_label(label):
"""Filter for host
Filter on label
:param label: label to filter
:type label: str
:return: Filter
:rtype: bool
"""
def inner_filter(items):
"""Inner filter for host. Accept if label in host.labels"""
host = items["host"]
... | [
"def",
"filter_host_by_bp_rule_label",
"(",
"label",
")",
":",
"def",
"inner_filter",
"(",
"items",
")",
":",
"host",
"=",
"items",
"[",
"\"host\"",
"]",
"if",
"host",
"is",
"None",
":",
"return",
"False",
"return",
"label",
"in",
"host",
".",
"labels",
... | Filter for host
Filter on label
:param label: label to filter
:type label: str
:return: Filter
:rtype: bool | [
"Filter",
"for",
"host",
"Filter",
"on",
"label"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/util.py#L1165-L1182 | train |
Alignak-monitoring/alignak | alignak/worker.py | Worker.manage_signal | def manage_signal(self, sig, frame): # pylint: disable=unused-argument
"""Manage signals caught by the process but I do not do anything...
our master daemon is managing our termination.
:param sig: signal caught by daemon
:type sig: str
:param frame: current stack frame
... | python | def manage_signal(self, sig, frame): # pylint: disable=unused-argument
"""Manage signals caught by the process but I do not do anything...
our master daemon is managing our termination.
:param sig: signal caught by daemon
:type sig: str
:param frame: current stack frame
... | [
"def",
"manage_signal",
"(",
"self",
",",
"sig",
",",
"frame",
")",
":",
"logger",
".",
"info",
"(",
"\"worker '%s' (pid=%d) received a signal: %s\"",
",",
"self",
".",
"_id",
",",
"os",
".",
"getpid",
"(",
")",
",",
"SIGNALS_TO_NAMES_DICT",
"[",
"sig",
"]",... | Manage signals caught by the process but I do not do anything...
our master daemon is managing our termination.
:param sig: signal caught by daemon
:type sig: str
:param frame: current stack frame
:type frame:
:return: None | [
"Manage",
"signals",
"caught",
"by",
"the",
"process",
"but",
"I",
"do",
"not",
"do",
"anything",
"...",
"our",
"master",
"daemon",
"is",
"managing",
"our",
"termination",
"."
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/worker.py#L183-L196 | train |
Alignak-monitoring/alignak | alignak/worker.py | Worker.check_for_system_time_change | def check_for_system_time_change(self): # pragma: no cover, hardly testable with unit tests...
"""Check if our system time change. If so, change our
:return: 0 if the difference < 900, difference else
:rtype: int
"""
now = time.time()
difference = now - self.t_each_loop... | python | def check_for_system_time_change(self): # pragma: no cover, hardly testable with unit tests...
"""Check if our system time change. If so, change our
:return: 0 if the difference < 900, difference else
:rtype: int
"""
now = time.time()
difference = now - self.t_each_loop... | [
"def",
"check_for_system_time_change",
"(",
"self",
")",
":",
"now",
"=",
"time",
".",
"time",
"(",
")",
"difference",
"=",
"now",
"-",
"self",
".",
"t_each_loop",
"self",
".",
"t_each_loop",
"=",
"now",
"if",
"abs",
"(",
"difference",
")",
">",
"900",
... | Check if our system time change. If so, change our
:return: 0 if the difference < 900, difference else
:rtype: int | [
"Check",
"if",
"our",
"system",
"time",
"change",
".",
"If",
"so",
"change",
"our"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/worker.py#L343-L360 | train |
Alignak-monitoring/alignak | alignak/worker.py | Worker.work | def work(self, actions_queue, returns_queue, control_queue=None): # pragma: no cover
"""Wrapper function for do_work in order to catch the exception
to see the real work, look at do_work
:param actions_queue: Global Queue Master->Slave
:type actions_queue: Queue.Queue
:param re... | python | def work(self, actions_queue, returns_queue, control_queue=None): # pragma: no cover
"""Wrapper function for do_work in order to catch the exception
to see the real work, look at do_work
:param actions_queue: Global Queue Master->Slave
:type actions_queue: Queue.Queue
:param re... | [
"def",
"work",
"(",
"self",
",",
"actions_queue",
",",
"returns_queue",
",",
"control_queue",
"=",
"None",
")",
":",
"try",
":",
"logger",
".",
"info",
"(",
"\"[%s] (pid=%d) starting my job...\"",
",",
"self",
".",
"_id",
",",
"os",
".",
"getpid",
"(",
")"... | Wrapper function for do_work in order to catch the exception
to see the real work, look at do_work
:param actions_queue: Global Queue Master->Slave
:type actions_queue: Queue.Queue
:param returns_queue: queue managed by manager
:type returns_queue: Queue.Queue
:return: N... | [
"Wrapper",
"function",
"for",
"do_work",
"in",
"order",
"to",
"catch",
"the",
"exception",
"to",
"see",
"the",
"real",
"work",
"look",
"at",
"do_work"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/worker.py#L362-L384 | train |
Alignak-monitoring/alignak | setup.py | read_requirements | def read_requirements(filename='requirements.txt'):
"""Reads the list of requirements from given file.
:param filename: Filename to read the requirements from.
Uses ``'requirements.txt'`` by default.
:return: Requirments as list of strings.
"""
# allow for some leeway with the... | python | def read_requirements(filename='requirements.txt'):
"""Reads the list of requirements from given file.
:param filename: Filename to read the requirements from.
Uses ``'requirements.txt'`` by default.
:return: Requirments as list of strings.
"""
# allow for some leeway with the... | [
"def",
"read_requirements",
"(",
"filename",
"=",
"'requirements.txt'",
")",
":",
"if",
"not",
"filename",
".",
"startswith",
"(",
"'requirements'",
")",
":",
"filename",
"=",
"'requirements-'",
"+",
"filename",
"if",
"not",
"os",
".",
"path",
".",
"splitext",... | Reads the list of requirements from given file.
:param filename: Filename to read the requirements from.
Uses ``'requirements.txt'`` by default.
:return: Requirments as list of strings. | [
"Reads",
"the",
"list",
"of",
"requirements",
"from",
"given",
"file",
"."
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/setup.py#L21-L48 | train |
Alignak-monitoring/alignak | alignak/objects/item.py | Item.init_running_properties | def init_running_properties(self):
"""
Initialize the running_properties.
Each instance have own property.
:return: None
"""
for prop, entry in list(self.__class__.running_properties.items()):
val = entry.default
# Make a copy of the value for com... | python | def init_running_properties(self):
"""
Initialize the running_properties.
Each instance have own property.
:return: None
"""
for prop, entry in list(self.__class__.running_properties.items()):
val = entry.default
# Make a copy of the value for com... | [
"def",
"init_running_properties",
"(",
"self",
")",
":",
"for",
"prop",
",",
"entry",
"in",
"list",
"(",
"self",
".",
"__class__",
".",
"running_properties",
".",
"items",
"(",
")",
")",
":",
"val",
"=",
"entry",
".",
"default",
"setattr",
"(",
"self",
... | Initialize the running_properties.
Each instance have own property.
:return: None | [
"Initialize",
"the",
"running_properties",
".",
"Each",
"instance",
"have",
"own",
"property",
"."
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/objects/item.py#L247-L258 | train |
Alignak-monitoring/alignak | alignak/objects/item.py | Item.copy | def copy(self):
"""
Get a copy of this item but with a new id
:return: copy of this object with a new id
:rtype: object
"""
# New dummy item with it's own running properties
copied_item = self.__class__({})
# Now, copy the properties
for prop in s... | python | def copy(self):
"""
Get a copy of this item but with a new id
:return: copy of this object with a new id
:rtype: object
"""
# New dummy item with it's own running properties
copied_item = self.__class__({})
# Now, copy the properties
for prop in s... | [
"def",
"copy",
"(",
"self",
")",
":",
"copied_item",
"=",
"self",
".",
"__class__",
"(",
"{",
"}",
")",
"for",
"prop",
"in",
"self",
".",
"__class__",
".",
"properties",
":",
"if",
"prop",
"in",
"[",
"'uuid'",
"]",
":",
"continue",
"val",
"=",
"get... | Get a copy of this item but with a new id
:return: copy of this object with a new id
:rtype: object | [
"Get",
"a",
"copy",
"of",
"this",
"item",
"but",
"with",
"a",
"new",
"id"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/objects/item.py#L260-L287 | train |
Alignak-monitoring/alignak | alignak/objects/item.py | Item.clean | def clean(self):
"""
Clean properties only needed for initialization and configuration
:return: None
"""
for prop in ('imported_from', 'use', 'plus', 'templates', 'register'):
try:
delattr(self, prop)
except AttributeError:
... | python | def clean(self):
"""
Clean properties only needed for initialization and configuration
:return: None
"""
for prop in ('imported_from', 'use', 'plus', 'templates', 'register'):
try:
delattr(self, prop)
except AttributeError:
... | [
"def",
"clean",
"(",
"self",
")",
":",
"for",
"prop",
"in",
"(",
"'imported_from'",
",",
"'use'",
",",
"'plus'",
",",
"'templates'",
",",
"'register'",
")",
":",
"try",
":",
"delattr",
"(",
"self",
",",
"prop",
")",
"except",
"AttributeError",
":",
"pa... | Clean properties only needed for initialization and configuration
:return: None | [
"Clean",
"properties",
"only",
"needed",
"for",
"initialization",
"and",
"configuration"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/objects/item.py#L289-L305 | train |
Alignak-monitoring/alignak | alignak/objects/item.py | Item.load_global_conf | def load_global_conf(cls, global_configuration):
"""
Apply global Alignak configuration.
Some objects inherit some properties from the global configuration if they do not
define their own value. E.g. the global 'accept_passive_service_checks' is inherited
by the services as 'acc... | python | def load_global_conf(cls, global_configuration):
"""
Apply global Alignak configuration.
Some objects inherit some properties from the global configuration if they do not
define their own value. E.g. the global 'accept_passive_service_checks' is inherited
by the services as 'acc... | [
"def",
"load_global_conf",
"(",
"cls",
",",
"global_configuration",
")",
":",
"logger",
".",
"debug",
"(",
"\"Propagate global parameter for %s:\"",
",",
"cls",
")",
"for",
"prop",
",",
"entry",
"in",
"global_configuration",
".",
"properties",
".",
"items",
"(",
... | Apply global Alignak configuration.
Some objects inherit some properties from the global configuration if they do not
define their own value. E.g. the global 'accept_passive_service_checks' is inherited
by the services as 'accept_passive_checks'
:param cls: parent object
:type ... | [
"Apply",
"global",
"Alignak",
"configuration",
"."
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/objects/item.py#L350-L378 | train |
Alignak-monitoring/alignak | alignak/objects/item.py | Item.get_templates | def get_templates(self):
"""
Get list of templates this object use
:return: list of templates
:rtype: list
"""
use = getattr(self, 'use', '')
if isinstance(use, list):
return [n.strip() for n in use if n.strip()]
return [n.strip() for n in us... | python | def get_templates(self):
"""
Get list of templates this object use
:return: list of templates
:rtype: list
"""
use = getattr(self, 'use', '')
if isinstance(use, list):
return [n.strip() for n in use if n.strip()]
return [n.strip() for n in us... | [
"def",
"get_templates",
"(",
"self",
")",
":",
"use",
"=",
"getattr",
"(",
"self",
",",
"'use'",
",",
"''",
")",
"if",
"isinstance",
"(",
"use",
",",
"list",
")",
":",
"return",
"[",
"n",
".",
"strip",
"(",
")",
"for",
"n",
"in",
"use",
"if",
"... | Get list of templates this object use
:return: list of templates
:rtype: list | [
"Get",
"list",
"of",
"templates",
"this",
"object",
"use"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/objects/item.py#L380-L391 | train |
Alignak-monitoring/alignak | alignak/objects/item.py | Item.get_all_plus_and_delete | def get_all_plus_and_delete(self):
"""
Get all self.plus items of list. We copy it, delete the original and return the copy list
:return: list of self.plus
:rtype: list
"""
res = {}
props = list(self.plus.keys()) # we delete entries, so no for ... in ...
... | python | def get_all_plus_and_delete(self):
"""
Get all self.plus items of list. We copy it, delete the original and return the copy list
:return: list of self.plus
:rtype: list
"""
res = {}
props = list(self.plus.keys()) # we delete entries, so no for ... in ...
... | [
"def",
"get_all_plus_and_delete",
"(",
"self",
")",
":",
"res",
"=",
"{",
"}",
"props",
"=",
"list",
"(",
"self",
".",
"plus",
".",
"keys",
"(",
")",
")",
"for",
"prop",
"in",
"props",
":",
"res",
"[",
"prop",
"]",
"=",
"self",
".",
"get_plus_and_d... | Get all self.plus items of list. We copy it, delete the original and return the copy list
:return: list of self.plus
:rtype: list | [
"Get",
"all",
"self",
".",
"plus",
"items",
"of",
"list",
".",
"We",
"copy",
"it",
"delete",
"the",
"original",
"and",
"return",
"the",
"copy",
"list"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/objects/item.py#L409-L420 | train |
Alignak-monitoring/alignak | alignak/objects/item.py | Item.add_error | def add_error(self, txt):
"""Add a message in the configuration errors list so we can print them
all in one place
Set the object configuration as not correct
:param txt: error message
:type txt: str
:return: None
"""
self.configuration_errors.append(tx... | python | def add_error(self, txt):
"""Add a message in the configuration errors list so we can print them
all in one place
Set the object configuration as not correct
:param txt: error message
:type txt: str
:return: None
"""
self.configuration_errors.append(tx... | [
"def",
"add_error",
"(",
"self",
",",
"txt",
")",
":",
"self",
".",
"configuration_errors",
".",
"append",
"(",
"txt",
")",
"self",
".",
"conf_is_correct",
"=",
"False"
] | Add a message in the configuration errors list so we can print them
all in one place
Set the object configuration as not correct
:param txt: error message
:type txt: str
:return: None | [
"Add",
"a",
"message",
"in",
"the",
"configuration",
"errors",
"list",
"so",
"we",
"can",
"print",
"them",
"all",
"in",
"one",
"place"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/objects/item.py#L436-L447 | train |
Alignak-monitoring/alignak | alignak/objects/item.py | Item.is_correct | def is_correct(self):
"""
Check if this object is correct
This function:
- checks if the required properties are defined, ignoring special_properties if some exist
- logs the previously found warnings and errors
:return: True if it's correct, otherwise False
:rt... | python | def is_correct(self):
"""
Check if this object is correct
This function:
- checks if the required properties are defined, ignoring special_properties if some exist
- logs the previously found warnings and errors
:return: True if it's correct, otherwise False
:rt... | [
"def",
"is_correct",
"(",
"self",
")",
":",
"state",
"=",
"self",
".",
"conf_is_correct",
"properties",
"=",
"self",
".",
"__class__",
".",
"properties",
"for",
"prop",
",",
"entry",
"in",
"list",
"(",
"properties",
".",
"items",
"(",
")",
")",
":",
"i... | Check if this object is correct
This function:
- checks if the required properties are defined, ignoring special_properties if some exist
- logs the previously found warnings and errors
:return: True if it's correct, otherwise False
:rtype: bool | [
"Check",
"if",
"this",
"object",
"is",
"correct"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/objects/item.py#L459-L481 | train |
Alignak-monitoring/alignak | alignak/objects/item.py | Item.old_properties_names_to_new | def old_properties_names_to_new(self):
"""
This function is used by service and hosts to transform Nagios2 parameters to Nagios3
ones, like normal_check_interval to check_interval. There is a old_parameters tab
in Classes that give such modifications to do.
:return: None
... | python | def old_properties_names_to_new(self):
"""
This function is used by service and hosts to transform Nagios2 parameters to Nagios3
ones, like normal_check_interval to check_interval. There is a old_parameters tab
in Classes that give such modifications to do.
:return: None
... | [
"def",
"old_properties_names_to_new",
"(",
"self",
")",
":",
"old_properties",
"=",
"getattr",
"(",
"self",
".",
"__class__",
",",
"\"old_properties\"",
",",
"{",
"}",
")",
"for",
"old_name",
",",
"new_name",
"in",
"list",
"(",
"old_properties",
".",
"items",
... | This function is used by service and hosts to transform Nagios2 parameters to Nagios3
ones, like normal_check_interval to check_interval. There is a old_parameters tab
in Classes that give such modifications to do.
:return: None | [
"This",
"function",
"is",
"used",
"by",
"service",
"and",
"hosts",
"to",
"transform",
"Nagios2",
"parameters",
"to",
"Nagios3",
"ones",
"like",
"normal_check_interval",
"to",
"check_interval",
".",
"There",
"is",
"a",
"old_parameters",
"tab",
"in",
"Classes",
"t... | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/objects/item.py#L483-L498 | train |
Alignak-monitoring/alignak | alignak/objects/item.py | Item.get_raw_import_values | def get_raw_import_values(self): # pragma: no cover, never used
"""
Get properties => values of this object
TODO: never called anywhere, still useful?
:return: dictionary of properties => values
:rtype: dict
"""
res = {}
properties = list(self.__class__... | python | def get_raw_import_values(self): # pragma: no cover, never used
"""
Get properties => values of this object
TODO: never called anywhere, still useful?
:return: dictionary of properties => values
:rtype: dict
"""
res = {}
properties = list(self.__class__... | [
"def",
"get_raw_import_values",
"(",
"self",
")",
":",
"res",
"=",
"{",
"}",
"properties",
"=",
"list",
"(",
"self",
".",
"__class__",
".",
"properties",
".",
"keys",
"(",
")",
")",
"if",
"'register'",
"not",
"in",
"properties",
":",
"properties",
".",
... | Get properties => values of this object
TODO: never called anywhere, still useful?
:return: dictionary of properties => values
:rtype: dict | [
"Get",
"properties",
"=",
">",
"values",
"of",
"this",
"object"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/objects/item.py#L500-L519 | train |
Alignak-monitoring/alignak | alignak/objects/item.py | Item.del_downtime | def del_downtime(self, downtime_id):
"""
Delete a downtime in this object
:param downtime_id: id of the downtime to delete
:type downtime_id: int
:return: None
"""
if downtime_id in self.downtimes:
self.downtimes[downtime_id].can_be_deleted = True
... | python | def del_downtime(self, downtime_id):
"""
Delete a downtime in this object
:param downtime_id: id of the downtime to delete
:type downtime_id: int
:return: None
"""
if downtime_id in self.downtimes:
self.downtimes[downtime_id].can_be_deleted = True
... | [
"def",
"del_downtime",
"(",
"self",
",",
"downtime_id",
")",
":",
"if",
"downtime_id",
"in",
"self",
".",
"downtimes",
":",
"self",
".",
"downtimes",
"[",
"downtime_id",
"]",
".",
"can_be_deleted",
"=",
"True",
"del",
"self",
".",
"downtimes",
"[",
"downti... | Delete a downtime in this object
:param downtime_id: id of the downtime to delete
:type downtime_id: int
:return: None | [
"Delete",
"a",
"downtime",
"in",
"this",
"object"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/objects/item.py#L531-L541 | train |
Alignak-monitoring/alignak | alignak/objects/item.py | Item.get_property_value_for_brok | def get_property_value_for_brok(self, prop, tab):
"""
Get the property of an object and brok_transformation if needed and return the value
:param prop: property name
:type prop: str
:param tab: object with all properties of an object
:type tab: object
:return: va... | python | def get_property_value_for_brok(self, prop, tab):
"""
Get the property of an object and brok_transformation if needed and return the value
:param prop: property name
:type prop: str
:param tab: object with all properties of an object
:type tab: object
:return: va... | [
"def",
"get_property_value_for_brok",
"(",
"self",
",",
"prop",
",",
"tab",
")",
":",
"entry",
"=",
"tab",
"[",
"prop",
"]",
"value",
"=",
"getattr",
"(",
"self",
",",
"prop",
",",
"entry",
".",
"default",
")",
"pre_op",
"=",
"entry",
".",
"brok_transf... | Get the property of an object and brok_transformation if needed and return the value
:param prop: property name
:type prop: str
:param tab: object with all properties of an object
:type tab: object
:return: value of the property original or brok converted
:rtype: str | [
"Get",
"the",
"property",
"of",
"an",
"object",
"and",
"brok_transformation",
"if",
"needed",
"and",
"return",
"the",
"value"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/objects/item.py#L564-L585 | train |
Alignak-monitoring/alignak | alignak/objects/item.py | Item.fill_data_brok_from | def fill_data_brok_from(self, data, brok_type):
"""
Add properties to 'data' parameter with properties of this object when 'brok_type'
parameter is defined in fill_brok of these properties
:param data: object to fill
:type data: object
:param brok_type: name of brok_type... | python | def fill_data_brok_from(self, data, brok_type):
"""
Add properties to 'data' parameter with properties of this object when 'brok_type'
parameter is defined in fill_brok of these properties
:param data: object to fill
:type data: object
:param brok_type: name of brok_type... | [
"def",
"fill_data_brok_from",
"(",
"self",
",",
"data",
",",
"brok_type",
")",
":",
"cls",
"=",
"self",
".",
"__class__",
"for",
"prop",
",",
"entry",
"in",
"list",
"(",
"cls",
".",
"properties",
".",
"items",
"(",
")",
")",
":",
"if",
"brok_type",
"... | Add properties to 'data' parameter with properties of this object when 'brok_type'
parameter is defined in fill_brok of these properties
:param data: object to fill
:type data: object
:param brok_type: name of brok_type
:type brok_type: var
:return: None | [
"Add",
"properties",
"to",
"data",
"parameter",
"with",
"properties",
"of",
"this",
"object",
"when",
"brok_type",
"parameter",
"is",
"defined",
"in",
"fill_brok",
"of",
"these",
"properties"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/objects/item.py#L587-L611 | train |
Alignak-monitoring/alignak | alignak/objects/item.py | Item.get_initial_status_brok | def get_initial_status_brok(self, extra=None):
"""
Create an initial status brok
:param extra: some extra information to be added in the brok data
:type extra: dict
:return: Brok object
:rtype: alignak.Brok
"""
data = {'uuid': self.uuid}
self.fill... | python | def get_initial_status_brok(self, extra=None):
"""
Create an initial status brok
:param extra: some extra information to be added in the brok data
:type extra: dict
:return: Brok object
:rtype: alignak.Brok
"""
data = {'uuid': self.uuid}
self.fill... | [
"def",
"get_initial_status_brok",
"(",
"self",
",",
"extra",
"=",
"None",
")",
":",
"data",
"=",
"{",
"'uuid'",
":",
"self",
".",
"uuid",
"}",
"self",
".",
"fill_data_brok_from",
"(",
"data",
",",
"'full_status'",
")",
"if",
"extra",
":",
"data",
".",
... | Create an initial status brok
:param extra: some extra information to be added in the brok data
:type extra: dict
:return: Brok object
:rtype: alignak.Brok | [
"Create",
"an",
"initial",
"status",
"brok"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/objects/item.py#L613-L626 | train |
Alignak-monitoring/alignak | alignak/objects/item.py | Item.get_update_status_brok | def get_update_status_brok(self):
"""
Create an update item brok
:return: Brok object
:rtype: alignak.Brok
"""
data = {'uuid': self.uuid}
self.fill_data_brok_from(data, 'full_status')
return Brok({'type': 'update_' + self.my_type + '_status', 'data': data... | python | def get_update_status_brok(self):
"""
Create an update item brok
:return: Brok object
:rtype: alignak.Brok
"""
data = {'uuid': self.uuid}
self.fill_data_brok_from(data, 'full_status')
return Brok({'type': 'update_' + self.my_type + '_status', 'data': data... | [
"def",
"get_update_status_brok",
"(",
"self",
")",
":",
"data",
"=",
"{",
"'uuid'",
":",
"self",
".",
"uuid",
"}",
"self",
".",
"fill_data_brok_from",
"(",
"data",
",",
"'full_status'",
")",
"return",
"Brok",
"(",
"{",
"'type'",
":",
"'update_'",
"+",
"s... | Create an update item brok
:return: Brok object
:rtype: alignak.Brok | [
"Create",
"an",
"update",
"item",
"brok"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/objects/item.py#L639-L648 | train |
Alignak-monitoring/alignak | alignak/objects/item.py | Item.get_check_result_brok | def get_check_result_brok(self):
"""
Create check_result brok
:return: Brok object
:rtype: alignak.Brok
"""
data = {'uuid': self.uuid}
self.fill_data_brok_from(data, 'check_result')
return Brok({'type': self.my_type + '_check_result', 'data': data}) | python | def get_check_result_brok(self):
"""
Create check_result brok
:return: Brok object
:rtype: alignak.Brok
"""
data = {'uuid': self.uuid}
self.fill_data_brok_from(data, 'check_result')
return Brok({'type': self.my_type + '_check_result', 'data': data}) | [
"def",
"get_check_result_brok",
"(",
"self",
")",
":",
"data",
"=",
"{",
"'uuid'",
":",
"self",
".",
"uuid",
"}",
"self",
".",
"fill_data_brok_from",
"(",
"data",
",",
"'check_result'",
")",
"return",
"Brok",
"(",
"{",
"'type'",
":",
"self",
".",
"my_typ... | Create check_result brok
:return: Brok object
:rtype: alignak.Brok | [
"Create",
"check_result",
"brok"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/objects/item.py#L650-L659 | train |
Alignak-monitoring/alignak | alignak/objects/item.py | Item.dump | def dump(self, dump_file_name=None): # pragma: no cover, never called
# pylint: disable=unused-argument
"""
Dump Item object properties
:return: dictionary with properties
:rtype: dict
"""
dump = {}
for prop in self.properties:
if not hasattr... | python | def dump(self, dump_file_name=None): # pragma: no cover, never called
# pylint: disable=unused-argument
"""
Dump Item object properties
:return: dictionary with properties
:rtype: dict
"""
dump = {}
for prop in self.properties:
if not hasattr... | [
"def",
"dump",
"(",
"self",
",",
"dump_file_name",
"=",
"None",
")",
":",
"dump",
"=",
"{",
"}",
"for",
"prop",
"in",
"self",
".",
"properties",
":",
"if",
"not",
"hasattr",
"(",
"self",
",",
"prop",
")",
":",
"continue",
"attr",
"=",
"getattr",
"(... | Dump Item object properties
:return: dictionary with properties
:rtype: dict | [
"Dump",
"Item",
"object",
"properties"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/objects/item.py#L692-L711 | train |
Alignak-monitoring/alignak | alignak/objects/item.py | Items.add_items | def add_items(self, items, index_items):
"""
Add items to template if is template, else add in item list
:param items: items list to add
:type items: alignak.objects.item.Items
:param index_items: Flag indicating if the items should be indexed on the fly.
:type index_ite... | python | def add_items(self, items, index_items):
"""
Add items to template if is template, else add in item list
:param items: items list to add
:type items: alignak.objects.item.Items
:param index_items: Flag indicating if the items should be indexed on the fly.
:type index_ite... | [
"def",
"add_items",
"(",
"self",
",",
"items",
",",
"index_items",
")",
":",
"count_templates",
"=",
"0",
"count_items",
"=",
"0",
"generated_items",
"=",
"[",
"]",
"for",
"item",
"in",
"items",
":",
"if",
"item",
".",
"is_tpl",
"(",
")",
":",
"self",
... | Add items to template if is template, else add in item list
:param items: items list to add
:type items: alignak.objects.item.Items
:param index_items: Flag indicating if the items should be indexed on the fly.
:type index_items: bool
:return: None | [
"Add",
"items",
"to",
"template",
"if",
"is",
"template",
"else",
"add",
"in",
"item",
"list"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/objects/item.py#L816-L841 | train |
Alignak-monitoring/alignak | alignak/objects/item.py | Items.manage_conflict | def manage_conflict(self, item, name):
"""
Checks if an object holding the same name already exists in the index.
If so, it compares their definition order: the lowest definition order
is kept. If definition order equal, an error is risen.Item
The method returns the item that s... | python | def manage_conflict(self, item, name):
"""
Checks if an object holding the same name already exists in the index.
If so, it compares their definition order: the lowest definition order
is kept. If definition order equal, an error is risen.Item
The method returns the item that s... | [
"def",
"manage_conflict",
"(",
"self",
",",
"item",
",",
"name",
")",
":",
"if",
"item",
".",
"is_tpl",
"(",
")",
":",
"existing",
"=",
"self",
".",
"name_to_template",
"[",
"name",
"]",
"else",
":",
"existing",
"=",
"self",
".",
"name_to_item",
"[",
... | Checks if an object holding the same name already exists in the index.
If so, it compares their definition order: the lowest definition order
is kept. If definition order equal, an error is risen.Item
The method returns the item that should be added after it has decided
which one shoul... | [
"Checks",
"if",
"an",
"object",
"holding",
"the",
"same",
"name",
"already",
"exists",
"in",
"the",
"index",
"."
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/objects/item.py#L843-L896 | train |
Alignak-monitoring/alignak | alignak/objects/item.py | Items.add_template | def add_template(self, tpl):
"""
Add and index a template into the `templates` container.
:param tpl: The template to add
:type tpl: alignak.objects.item.Item
:return: None
"""
tpl = self.index_template(tpl)
self.templates[tpl.uuid] = tpl | python | def add_template(self, tpl):
"""
Add and index a template into the `templates` container.
:param tpl: The template to add
:type tpl: alignak.objects.item.Item
:return: None
"""
tpl = self.index_template(tpl)
self.templates[tpl.uuid] = tpl | [
"def",
"add_template",
"(",
"self",
",",
"tpl",
")",
":",
"tpl",
"=",
"self",
".",
"index_template",
"(",
"tpl",
")",
"self",
".",
"templates",
"[",
"tpl",
".",
"uuid",
"]",
"=",
"tpl"
] | Add and index a template into the `templates` container.
:param tpl: The template to add
:type tpl: alignak.objects.item.Item
:return: None | [
"Add",
"and",
"index",
"a",
"template",
"into",
"the",
"templates",
"container",
"."
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/objects/item.py#L898-L907 | train |
Alignak-monitoring/alignak | alignak/objects/item.py | Items.index_template | def index_template(self, tpl):
"""
Indexes a template by `name` into the `name_to_template` dictionary.
:param tpl: The template to index
:type tpl: alignak.objects.item.Item
:return: None
"""
objcls = self.inner_class.my_type
name = getattr(tpl, 'name', ... | python | def index_template(self, tpl):
"""
Indexes a template by `name` into the `name_to_template` dictionary.
:param tpl: The template to index
:type tpl: alignak.objects.item.Item
:return: None
"""
objcls = self.inner_class.my_type
name = getattr(tpl, 'name', ... | [
"def",
"index_template",
"(",
"self",
",",
"tpl",
")",
":",
"objcls",
"=",
"self",
".",
"inner_class",
".",
"my_type",
"name",
"=",
"getattr",
"(",
"tpl",
",",
"'name'",
",",
"''",
")",
"if",
"not",
"name",
":",
"mesg",
"=",
"\"a %s template has been def... | Indexes a template by `name` into the `name_to_template` dictionary.
:param tpl: The template to index
:type tpl: alignak.objects.item.Item
:return: None | [
"Indexes",
"a",
"template",
"by",
"name",
"into",
"the",
"name_to_template",
"dictionary",
"."
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/objects/item.py#L909-L928 | train |
Alignak-monitoring/alignak | alignak/objects/item.py | Items.remove_template | def remove_template(self, tpl):
"""
Removes and un-index a template from the `templates` container.
:param tpl: The template to remove
:type tpl: alignak.objects.item.Item
:return: None
"""
try:
del self.templates[tpl.uuid]
except KeyError: #... | python | def remove_template(self, tpl):
"""
Removes and un-index a template from the `templates` container.
:param tpl: The template to remove
:type tpl: alignak.objects.item.Item
:return: None
"""
try:
del self.templates[tpl.uuid]
except KeyError: #... | [
"def",
"remove_template",
"(",
"self",
",",
"tpl",
")",
":",
"try",
":",
"del",
"self",
".",
"templates",
"[",
"tpl",
".",
"uuid",
"]",
"except",
"KeyError",
":",
"pass",
"self",
".",
"unindex_template",
"(",
"tpl",
")"
] | Removes and un-index a template from the `templates` container.
:param tpl: The template to remove
:type tpl: alignak.objects.item.Item
:return: None | [
"Removes",
"and",
"un",
"-",
"index",
"a",
"template",
"from",
"the",
"templates",
"container",
"."
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/objects/item.py#L930-L942 | train |
Alignak-monitoring/alignak | alignak/objects/item.py | Items.unindex_template | def unindex_template(self, tpl):
"""
Unindex a template from the `templates` container.
:param tpl: The template to un-index
:type tpl: alignak.objects.item.Item
:return: None
"""
name = getattr(tpl, 'name', '')
try:
del self.name_to_template[... | python | def unindex_template(self, tpl):
"""
Unindex a template from the `templates` container.
:param tpl: The template to un-index
:type tpl: alignak.objects.item.Item
:return: None
"""
name = getattr(tpl, 'name', '')
try:
del self.name_to_template[... | [
"def",
"unindex_template",
"(",
"self",
",",
"tpl",
")",
":",
"name",
"=",
"getattr",
"(",
"tpl",
",",
"'name'",
",",
"''",
")",
"try",
":",
"del",
"self",
".",
"name_to_template",
"[",
"name",
"]",
"except",
"KeyError",
":",
"pass"
] | Unindex a template from the `templates` container.
:param tpl: The template to un-index
:type tpl: alignak.objects.item.Item
:return: None | [
"Unindex",
"a",
"template",
"from",
"the",
"templates",
"container",
"."
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/objects/item.py#L944-L956 | train |
Alignak-monitoring/alignak | alignak/objects/item.py | Items.add_item | def add_item(self, item, index=True):
# pylint: disable=too-many-branches, too-many-locals, too-many-nested-blocks
"""
Add an item into our containers, and index it depending on the `index` flag.
:param item: object to add
:type item: alignak.objects.item.Item
:param ind... | python | def add_item(self, item, index=True):
# pylint: disable=too-many-branches, too-many-locals, too-many-nested-blocks
"""
Add an item into our containers, and index it depending on the `index` flag.
:param item: object to add
:type item: alignak.objects.item.Item
:param ind... | [
"def",
"add_item",
"(",
"self",
",",
"item",
",",
"index",
"=",
"True",
")",
":",
"name_property",
"=",
"getattr",
"(",
"self",
".",
"__class__",
",",
"\"name_property\"",
",",
"None",
")",
"generated_hosts",
"=",
"[",
"]",
"if",
"name_property",
":",
"n... | Add an item into our containers, and index it depending on the `index` flag.
:param item: object to add
:type item: alignak.objects.item.Item
:param index: Flag indicating if the item should be indexed
:type index: bool
:return: the new items created
:rtype list | [
"Add",
"an",
"item",
"into",
"our",
"containers",
"and",
"index",
"it",
"depending",
"on",
"the",
"index",
"flag",
"."
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/objects/item.py#L958-L1029 | train |
Alignak-monitoring/alignak | alignak/objects/item.py | Items.old_properties_names_to_new | def old_properties_names_to_new(self): # pragma: no cover, never called
"""Convert old Nagios2 names to Nagios3 new names
TODO: still useful?
:return: None
"""
for i in itertools.chain(iter(list(self.items.values())),
iter(list(self.templates.v... | python | def old_properties_names_to_new(self): # pragma: no cover, never called
"""Convert old Nagios2 names to Nagios3 new names
TODO: still useful?
:return: None
"""
for i in itertools.chain(iter(list(self.items.values())),
iter(list(self.templates.v... | [
"def",
"old_properties_names_to_new",
"(",
"self",
")",
":",
"for",
"i",
"in",
"itertools",
".",
"chain",
"(",
"iter",
"(",
"list",
"(",
"self",
".",
"items",
".",
"values",
"(",
")",
")",
")",
",",
"iter",
"(",
"list",
"(",
"self",
".",
"templates",... | Convert old Nagios2 names to Nagios3 new names
TODO: still useful?
:return: None | [
"Convert",
"old",
"Nagios2",
"names",
"to",
"Nagios3",
"new",
"names"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/objects/item.py#L1092-L1101 | train |
Alignak-monitoring/alignak | alignak/objects/item.py | Items.get_all_tags | def get_all_tags(self, item):
"""
Get all tags of an item
:param item: an item
:type item: Item
:return: list of tags
:rtype: list
"""
all_tags = item.get_templates()
for template_id in item.templates:
template = self.templates[templa... | python | def get_all_tags(self, item):
"""
Get all tags of an item
:param item: an item
:type item: Item
:return: list of tags
:rtype: list
"""
all_tags = item.get_templates()
for template_id in item.templates:
template = self.templates[templa... | [
"def",
"get_all_tags",
"(",
"self",
",",
"item",
")",
":",
"all_tags",
"=",
"item",
".",
"get_templates",
"(",
")",
"for",
"template_id",
"in",
"item",
".",
"templates",
":",
"template",
"=",
"self",
".",
"templates",
"[",
"template_id",
"]",
"all_tags",
... | Get all tags of an item
:param item: an item
:type item: Item
:return: list of tags
:rtype: list | [
"Get",
"all",
"tags",
"of",
"an",
"item"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/objects/item.py#L1114-L1129 | train |
Alignak-monitoring/alignak | alignak/objects/item.py | Items.linkify_templates | def linkify_templates(self):
"""
Link all templates, and create the template graph too
:return: None
"""
# First we create a list of all templates
for i in itertools.chain(iter(list(self.items.values())),
iter(list(self.templates.values()... | python | def linkify_templates(self):
"""
Link all templates, and create the template graph too
:return: None
"""
# First we create a list of all templates
for i in itertools.chain(iter(list(self.items.values())),
iter(list(self.templates.values()... | [
"def",
"linkify_templates",
"(",
"self",
")",
":",
"for",
"i",
"in",
"itertools",
".",
"chain",
"(",
"iter",
"(",
"list",
"(",
"self",
".",
"items",
".",
"values",
"(",
")",
")",
")",
",",
"iter",
"(",
"list",
"(",
"self",
".",
"templates",
".",
... | Link all templates, and create the template graph too
:return: None | [
"Link",
"all",
"templates",
"and",
"create",
"the",
"template",
"graph",
"too"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/objects/item.py#L1156-L1167 | train |
Alignak-monitoring/alignak | alignak/objects/item.py | Items.apply_partial_inheritance | def apply_partial_inheritance(self, prop):
"""
Define property with inheritance value of the property
:param prop: property
:type prop: str
:return: None
"""
for i in itertools.chain(iter(list(self.items.values())),
iter(list(self... | python | def apply_partial_inheritance(self, prop):
"""
Define property with inheritance value of the property
:param prop: property
:type prop: str
:return: None
"""
for i in itertools.chain(iter(list(self.items.values())),
iter(list(self... | [
"def",
"apply_partial_inheritance",
"(",
"self",
",",
"prop",
")",
":",
"for",
"i",
"in",
"itertools",
".",
"chain",
"(",
"iter",
"(",
"list",
"(",
"self",
".",
"items",
".",
"values",
"(",
")",
")",
")",
",",
"iter",
"(",
"list",
"(",
"self",
".",... | Define property with inheritance value of the property
:param prop: property
:type prop: str
:return: None | [
"Define",
"property",
"with",
"inheritance",
"value",
"of",
"the",
"property"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/objects/item.py#L1258-L1274 | train |
Alignak-monitoring/alignak | alignak/objects/item.py | Items.linkify_with_contacts | def linkify_with_contacts(self, contacts):
"""
Link items with contacts items
:param contacts: all contacts object
:type contacts: alignak.objects.contact.Contacts
:return: None
"""
for i in self:
if not hasattr(i, 'contacts'):
continu... | python | def linkify_with_contacts(self, contacts):
"""
Link items with contacts items
:param contacts: all contacts object
:type contacts: alignak.objects.contact.Contacts
:return: None
"""
for i in self:
if not hasattr(i, 'contacts'):
continu... | [
"def",
"linkify_with_contacts",
"(",
"self",
",",
"contacts",
")",
":",
"for",
"i",
"in",
"self",
":",
"if",
"not",
"hasattr",
"(",
"i",
",",
"'contacts'",
")",
":",
"continue",
"links_list",
"=",
"strip_and_uniq",
"(",
"i",
".",
"contacts",
")",
"new",
... | Link items with contacts items
:param contacts: all contacts object
:type contacts: alignak.objects.contact.Contacts
:return: None | [
"Link",
"items",
"with",
"contacts",
"items"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/objects/item.py#L1291-L1313 | train |
Alignak-monitoring/alignak | alignak/objects/item.py | Items.linkify_with_escalations | def linkify_with_escalations(self, escalations):
"""
Link with escalations
:param escalations: all escalations object
:type escalations: alignak.objects.escalation.Escalations
:return: None
"""
for i in self:
if not hasattr(i, 'escalations'):
... | python | def linkify_with_escalations(self, escalations):
"""
Link with escalations
:param escalations: all escalations object
:type escalations: alignak.objects.escalation.Escalations
:return: None
"""
for i in self:
if not hasattr(i, 'escalations'):
... | [
"def",
"linkify_with_escalations",
"(",
"self",
",",
"escalations",
")",
":",
"for",
"i",
"in",
"self",
":",
"if",
"not",
"hasattr",
"(",
"i",
",",
"'escalations'",
")",
":",
"continue",
"links_list",
"=",
"strip_and_uniq",
"(",
"i",
".",
"escalations",
")... | Link with escalations
:param escalations: all escalations object
:type escalations: alignak.objects.escalation.Escalations
:return: None | [
"Link",
"with",
"escalations"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/objects/item.py#L1315-L1337 | train |
Alignak-monitoring/alignak | alignak/objects/item.py | Items.explode_contact_groups_into_contacts | def explode_contact_groups_into_contacts(item, contactgroups):
"""
Get all contacts of contact_groups and put them in contacts container
:param item: item where have contact_groups property
:type item: object
:param contactgroups: all contactgroups object
:type contactgr... | python | def explode_contact_groups_into_contacts(item, contactgroups):
"""
Get all contacts of contact_groups and put them in contacts container
:param item: item where have contact_groups property
:type item: object
:param contactgroups: all contactgroups object
:type contactgr... | [
"def",
"explode_contact_groups_into_contacts",
"(",
"item",
",",
"contactgroups",
")",
":",
"if",
"not",
"hasattr",
"(",
"item",
",",
"'contact_groups'",
")",
":",
"return",
"cgnames",
"=",
"''",
"if",
"item",
".",
"contact_groups",
":",
"if",
"isinstance",
"(... | Get all contacts of contact_groups and put them in contacts container
:param item: item where have contact_groups property
:type item: object
:param contactgroups: all contactgroups object
:type contactgroups: alignak.objects.contactgroup.Contactgroups
:return: None | [
"Get",
"all",
"contacts",
"of",
"contact_groups",
"and",
"put",
"them",
"in",
"contacts",
"container"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/objects/item.py#L1390-L1425 | train |
Alignak-monitoring/alignak | alignak/objects/item.py | Items.linkify_with_timeperiods | def linkify_with_timeperiods(self, timeperiods, prop):
"""
Link items with timeperiods items
:param timeperiods: all timeperiods object
:type timeperiods: alignak.objects.timeperiod.Timeperiods
:param prop: property name
:type prop: str
:return: None
"""
... | python | def linkify_with_timeperiods(self, timeperiods, prop):
"""
Link items with timeperiods items
:param timeperiods: all timeperiods object
:type timeperiods: alignak.objects.timeperiod.Timeperiods
:param prop: property name
:type prop: str
:return: None
"""
... | [
"def",
"linkify_with_timeperiods",
"(",
"self",
",",
"timeperiods",
",",
"prop",
")",
":",
"for",
"i",
"in",
"self",
":",
"if",
"not",
"hasattr",
"(",
"i",
",",
"prop",
")",
":",
"continue",
"tpname",
"=",
"getattr",
"(",
"i",
",",
"prop",
")",
".",
... | Link items with timeperiods items
:param timeperiods: all timeperiods object
:type timeperiods: alignak.objects.timeperiod.Timeperiods
:param prop: property name
:type prop: str
:return: None | [
"Link",
"items",
"with",
"timeperiods",
"items"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/objects/item.py#L1427-L1454 | train |
Alignak-monitoring/alignak | alignak/objects/item.py | Items.linkify_with_checkmodulations | def linkify_with_checkmodulations(self, checkmodulations):
"""
Link checkmodulation object
:param checkmodulations: checkmodulations object
:type checkmodulations: alignak.objects.checkmodulation.Checkmodulations
:return: None
"""
for i in self:
if no... | python | def linkify_with_checkmodulations(self, checkmodulations):
"""
Link checkmodulation object
:param checkmodulations: checkmodulations object
:type checkmodulations: alignak.objects.checkmodulation.Checkmodulations
:return: None
"""
for i in self:
if no... | [
"def",
"linkify_with_checkmodulations",
"(",
"self",
",",
"checkmodulations",
")",
":",
"for",
"i",
"in",
"self",
":",
"if",
"not",
"hasattr",
"(",
"i",
",",
"'checkmodulations'",
")",
":",
"continue",
"links_list",
"=",
"strip_and_uniq",
"(",
"i",
".",
"che... | Link checkmodulation object
:param checkmodulations: checkmodulations object
:type checkmodulations: alignak.objects.checkmodulation.Checkmodulations
:return: None | [
"Link",
"checkmodulation",
"object"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/objects/item.py#L1456-L1478 | train |
Alignak-monitoring/alignak | alignak/objects/item.py | Items.linkify_s_by_module | def linkify_s_by_module(self, modules):
"""
Link modules to items
:param modules: Modules object (list of all the modules found in the configuration)
:type modules: alignak.objects.module.Modules
:return: None
"""
for i in self:
links_list = strip_an... | python | def linkify_s_by_module(self, modules):
"""
Link modules to items
:param modules: Modules object (list of all the modules found in the configuration)
:type modules: alignak.objects.module.Modules
:return: None
"""
for i in self:
links_list = strip_an... | [
"def",
"linkify_s_by_module",
"(",
"self",
",",
"modules",
")",
":",
"for",
"i",
"in",
"self",
":",
"links_list",
"=",
"strip_and_uniq",
"(",
"i",
".",
"modules",
")",
"new",
"=",
"[",
"]",
"for",
"name",
"in",
"[",
"e",
"for",
"e",
"in",
"links_list... | Link modules to items
:param modules: Modules object (list of all the modules found in the configuration)
:type modules: alignak.objects.module.Modules
:return: None | [
"Link",
"modules",
"to",
"items"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/objects/item.py#L1504-L1523 | train |
Alignak-monitoring/alignak | alignak/objects/item.py | Items.evaluate_hostgroup_expression | def evaluate_hostgroup_expression(expr, hosts, hostgroups, look_in='hostgroups'):
"""
Evaluate hostgroup expression
:param expr: an expression
:type expr: str
:param hosts: hosts object (all hosts)
:type hosts: alignak.objects.host.Hosts
:param hostgroups: hostgr... | python | def evaluate_hostgroup_expression(expr, hosts, hostgroups, look_in='hostgroups'):
"""
Evaluate hostgroup expression
:param expr: an expression
:type expr: str
:param hosts: hosts object (all hosts)
:type hosts: alignak.objects.host.Hosts
:param hostgroups: hostgr... | [
"def",
"evaluate_hostgroup_expression",
"(",
"expr",
",",
"hosts",
",",
"hostgroups",
",",
"look_in",
"=",
"'hostgroups'",
")",
":",
"if",
"isinstance",
"(",
"expr",
",",
"list",
")",
":",
"expr",
"=",
"'|'",
".",
"join",
"(",
"expr",
")",
"if",
"look_in... | Evaluate hostgroup expression
:param expr: an expression
:type expr: str
:param hosts: hosts object (all hosts)
:type hosts: alignak.objects.host.Hosts
:param hostgroups: hostgroups object (all hostgroups)
:type hostgroups: alignak.objects.hostgroup.Hostgroups
:p... | [
"Evaluate",
"hostgroup",
"expression"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/objects/item.py#L1526-L1553 | train |
Alignak-monitoring/alignak | alignak/objects/item.py | Items.get_hosts_from_hostgroups | def get_hosts_from_hostgroups(hgname, hostgroups):
"""
Get hosts of hostgroups
:param hgname: hostgroup name
:type hgname: str
:param hostgroups: hostgroups object (all hostgroups)
:type hostgroups: alignak.objects.hostgroup.Hostgroups
:return: list of hosts
... | python | def get_hosts_from_hostgroups(hgname, hostgroups):
"""
Get hosts of hostgroups
:param hgname: hostgroup name
:type hgname: str
:param hostgroups: hostgroups object (all hostgroups)
:type hostgroups: alignak.objects.hostgroup.Hostgroups
:return: list of hosts
... | [
"def",
"get_hosts_from_hostgroups",
"(",
"hgname",
",",
"hostgroups",
")",
":",
"if",
"not",
"isinstance",
"(",
"hgname",
",",
"list",
")",
":",
"hgname",
"=",
"[",
"e",
".",
"strip",
"(",
")",
"for",
"e",
"in",
"hgname",
".",
"split",
"(",
"','",
")... | Get hosts of hostgroups
:param hgname: hostgroup name
:type hgname: str
:param hostgroups: hostgroups object (all hostgroups)
:type hostgroups: alignak.objects.hostgroup.Hostgroups
:return: list of hosts
:rtype: list | [
"Get",
"hosts",
"of",
"hostgroups"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/objects/item.py#L1556-L1578 | train |
Alignak-monitoring/alignak | alignak/objects/item.py | Items.explode_host_groups_into_hosts | def explode_host_groups_into_hosts(self, item, hosts, hostgroups):
"""
Get all hosts of hostgroups and add all in host_name container
:param item: the item object
:type item: alignak.objects.item.Item
:param hosts: hosts object
:type hosts: alignak.objects.host.Hosts
... | python | def explode_host_groups_into_hosts(self, item, hosts, hostgroups):
"""
Get all hosts of hostgroups and add all in host_name container
:param item: the item object
:type item: alignak.objects.item.Item
:param hosts: hosts object
:type hosts: alignak.objects.host.Hosts
... | [
"def",
"explode_host_groups_into_hosts",
"(",
"self",
",",
"item",
",",
"hosts",
",",
"hostgroups",
")",
":",
"hnames_list",
"=",
"[",
"]",
"hgnames",
"=",
"getattr",
"(",
"item",
",",
"\"hostgroup_name\"",
",",
"''",
")",
"or",
"''",
"if",
"is_complex_expr"... | Get all hosts of hostgroups and add all in host_name container
:param item: the item object
:type item: alignak.objects.item.Item
:param hosts: hosts object
:type hosts: alignak.objects.host.Hosts
:param hostgroups: hostgroups object
:type hostgroups: alignak.objects.hos... | [
"Get",
"all",
"hosts",
"of",
"hostgroups",
"and",
"add",
"all",
"in",
"host_name",
"container"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/objects/item.py#L1580-L1629 | train |
Alignak-monitoring/alignak | alignak/objects/item.py | Items.get_customs_properties_by_inheritance | def get_customs_properties_by_inheritance(self, obj):
"""
Get custom properties from the templates defined in this object
:param obj: the oject to search the property
:type obj: alignak.objects.item.Item
:return: list of custom properties
:rtype: list
"""
... | python | def get_customs_properties_by_inheritance(self, obj):
"""
Get custom properties from the templates defined in this object
:param obj: the oject to search the property
:type obj: alignak.objects.item.Item
:return: list of custom properties
:rtype: list
"""
... | [
"def",
"get_customs_properties_by_inheritance",
"(",
"self",
",",
"obj",
")",
":",
"for",
"t_id",
"in",
"obj",
".",
"templates",
":",
"template",
"=",
"self",
".",
"templates",
"[",
"t_id",
"]",
"tpl_cv",
"=",
"self",
".",
"get_customs_properties_by_inheritance"... | Get custom properties from the templates defined in this object
:param obj: the oject to search the property
:type obj: alignak.objects.item.Item
:return: list of custom properties
:rtype: list | [
"Get",
"custom",
"properties",
"from",
"the",
"templates",
"defined",
"in",
"this",
"object"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/objects/item.py#L1853-L1886 | train |
Alignak-monitoring/alignak | alignak/graph.py | Graph.add_edge | def add_edge(self, from_node, to_node):
"""Add edge between two node
The edge is oriented
:param from_node: node where edge starts
:type from_node: object
:param to_node: node where edge ends
:type to_node: object
:return: None
"""
# Maybe to_node... | python | def add_edge(self, from_node, to_node):
"""Add edge between two node
The edge is oriented
:param from_node: node where edge starts
:type from_node: object
:param to_node: node where edge ends
:type to_node: object
:return: None
"""
# Maybe to_node... | [
"def",
"add_edge",
"(",
"self",
",",
"from_node",
",",
"to_node",
")",
":",
"if",
"to_node",
"not",
"in",
"self",
".",
"nodes",
":",
"self",
".",
"add_node",
"(",
"to_node",
")",
"try",
":",
"self",
".",
"nodes",
"[",
"from_node",
"]",
"[",
"\"sons\"... | Add edge between two node
The edge is oriented
:param from_node: node where edge starts
:type from_node: object
:param to_node: node where edge ends
:type to_node: object
:return: None | [
"Add",
"edge",
"between",
"two",
"node",
"The",
"edge",
"is",
"oriented"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/graph.py#L81-L99 | train |
Alignak-monitoring/alignak | alignak/graph.py | Graph.loop_check | def loop_check(self):
"""Check if we have a loop in the graph
:return: Nodes in loop
:rtype: list
"""
in_loop = []
# Add the tag for dfs check
for node in list(self.nodes.values()):
node['dfs_loop_status'] = 'DFS_UNCHECKED'
# Now do the job
... | python | def loop_check(self):
"""Check if we have a loop in the graph
:return: Nodes in loop
:rtype: list
"""
in_loop = []
# Add the tag for dfs check
for node in list(self.nodes.values()):
node['dfs_loop_status'] = 'DFS_UNCHECKED'
# Now do the job
... | [
"def",
"loop_check",
"(",
"self",
")",
":",
"in_loop",
"=",
"[",
"]",
"for",
"node",
"in",
"list",
"(",
"self",
".",
"nodes",
".",
"values",
"(",
")",
")",
":",
"node",
"[",
"'dfs_loop_status'",
"]",
"=",
"'DFS_UNCHECKED'",
"for",
"node_id",
",",
"no... | Check if we have a loop in the graph
:return: Nodes in loop
:rtype: list | [
"Check",
"if",
"we",
"have",
"a",
"loop",
"in",
"the",
"graph"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/graph.py#L101-L125 | train |
Alignak-monitoring/alignak | alignak/graph.py | Graph.dfs_loop_search | def dfs_loop_search(self, root):
"""Main algorithm to look for loop.
It tags nodes and find ones stuck in loop.
* Init all nodes with DFS_UNCHECKED value
* DFS_TEMPORARY_CHECKED means we found it once
* DFS_OK : this node (and all sons) are fine
* DFS_NEAR_LOOP : One pro... | python | def dfs_loop_search(self, root):
"""Main algorithm to look for loop.
It tags nodes and find ones stuck in loop.
* Init all nodes with DFS_UNCHECKED value
* DFS_TEMPORARY_CHECKED means we found it once
* DFS_OK : this node (and all sons) are fine
* DFS_NEAR_LOOP : One pro... | [
"def",
"dfs_loop_search",
"(",
"self",
",",
"root",
")",
":",
"self",
".",
"nodes",
"[",
"root",
"]",
"[",
"'dfs_loop_status'",
"]",
"=",
"'DFS_TEMPORARY_CHECKED'",
"for",
"child",
"in",
"self",
".",
"nodes",
"[",
"root",
"]",
"[",
"\"sons\"",
"]",
":",
... | Main algorithm to look for loop.
It tags nodes and find ones stuck in loop.
* Init all nodes with DFS_UNCHECKED value
* DFS_TEMPORARY_CHECKED means we found it once
* DFS_OK : this node (and all sons) are fine
* DFS_NEAR_LOOP : One problem was found in of of the son
* DF... | [
"Main",
"algorithm",
"to",
"look",
"for",
"loop",
".",
"It",
"tags",
"nodes",
"and",
"find",
"ones",
"stuck",
"in",
"loop",
"."
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/graph.py#L127-L170 | train |
Alignak-monitoring/alignak | alignak/graph.py | Graph.dfs_get_all_childs | def dfs_get_all_childs(self, root):
"""Recursively get all sons of this node
:param root: node to get sons
:type root:
:return: sons
:rtype: list
"""
self.nodes[root]['dfs_loop_status'] = 'DFS_CHECKED'
ret = set()
# Me
ret.add(root)
... | python | def dfs_get_all_childs(self, root):
"""Recursively get all sons of this node
:param root: node to get sons
:type root:
:return: sons
:rtype: list
"""
self.nodes[root]['dfs_loop_status'] = 'DFS_CHECKED'
ret = set()
# Me
ret.add(root)
... | [
"def",
"dfs_get_all_childs",
"(",
"self",
",",
"root",
")",
":",
"self",
".",
"nodes",
"[",
"root",
"]",
"[",
"'dfs_loop_status'",
"]",
"=",
"'DFS_CHECKED'",
"ret",
"=",
"set",
"(",
")",
"ret",
".",
"add",
"(",
"root",
")",
"ret",
".",
"update",
"(",... | Recursively get all sons of this node
:param root: node to get sons
:type root:
:return: sons
:rtype: list | [
"Recursively",
"get",
"all",
"sons",
"of",
"this",
"node"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/graph.py#L197-L218 | train |
Alignak-monitoring/alignak | alignak/http/generic_interface.py | GenericInterface.identity | def identity(self):
"""Get the daemon identity
This will return an object containing some properties:
- alignak: the Alignak instance name
- version: the Alignak version
- type: the daemon type
- name: the daemon name
:return: daemon identity
:rtype: dic... | python | def identity(self):
"""Get the daemon identity
This will return an object containing some properties:
- alignak: the Alignak instance name
- version: the Alignak version
- type: the daemon type
- name: the daemon name
:return: daemon identity
:rtype: dic... | [
"def",
"identity",
"(",
"self",
")",
":",
"res",
"=",
"self",
".",
"app",
".",
"get_id",
"(",
")",
"res",
".",
"update",
"(",
"{",
"\"start_time\"",
":",
"self",
".",
"start_time",
"}",
")",
"res",
".",
"update",
"(",
"{",
"\"running_id\"",
":",
"s... | Get the daemon identity
This will return an object containing some properties:
- alignak: the Alignak instance name
- version: the Alignak version
- type: the daemon type
- name: the daemon name
:return: daemon identity
:rtype: dict | [
"Get",
"the",
"daemon",
"identity"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/http/generic_interface.py#L76-L91 | train |
Alignak-monitoring/alignak | alignak/http/generic_interface.py | GenericInterface.api | def api(self):
"""List the methods available on the daemon Web service interface
:return: a list of methods and parameters
:rtype: dict
"""
functions = [x[0]for x in inspect.getmembers(self, predicate=inspect.ismethod)
if not x[0].startswith('_')]
f... | python | def api(self):
"""List the methods available on the daemon Web service interface
:return: a list of methods and parameters
:rtype: dict
"""
functions = [x[0]for x in inspect.getmembers(self, predicate=inspect.ismethod)
if not x[0].startswith('_')]
f... | [
"def",
"api",
"(",
"self",
")",
":",
"functions",
"=",
"[",
"x",
"[",
"0",
"]",
"for",
"x",
"in",
"inspect",
".",
"getmembers",
"(",
"self",
",",
"predicate",
"=",
"inspect",
".",
"ismethod",
")",
"if",
"not",
"x",
"[",
"0",
"]",
".",
"startswith... | List the methods available on the daemon Web service interface
:return: a list of methods and parameters
:rtype: dict | [
"List",
"the",
"methods",
"available",
"on",
"the",
"daemon",
"Web",
"service",
"interface"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/http/generic_interface.py#L95-L138 | train |
Alignak-monitoring/alignak | alignak/http/generic_interface.py | GenericInterface.stop_request | def stop_request(self, stop_now='0'):
"""Request the daemon to stop
If `stop_now` is set to '1' the daemon will stop now. Else, the daemon
will enter the stop wait mode. In this mode the daemon stops its activity and
waits until it receives a new `stop_now` request to stop really.
... | python | def stop_request(self, stop_now='0'):
"""Request the daemon to stop
If `stop_now` is set to '1' the daemon will stop now. Else, the daemon
will enter the stop wait mode. In this mode the daemon stops its activity and
waits until it receives a new `stop_now` request to stop really.
... | [
"def",
"stop_request",
"(",
"self",
",",
"stop_now",
"=",
"'0'",
")",
":",
"self",
".",
"app",
".",
"interrupted",
"=",
"(",
"stop_now",
"==",
"'1'",
")",
"self",
".",
"app",
".",
"will_stop",
"=",
"True",
"return",
"True"
] | Request the daemon to stop
If `stop_now` is set to '1' the daemon will stop now. Else, the daemon
will enter the stop wait mode. In this mode the daemon stops its activity and
waits until it receives a new `stop_now` request to stop really.
:param stop_now: stop now or go to stop wait ... | [
"Request",
"the",
"daemon",
"to",
"stop"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/http/generic_interface.py#L143-L157 | train |
Alignak-monitoring/alignak | alignak/http/generic_interface.py | GenericInterface.get_log_level | def get_log_level(self):
"""Get the current daemon log level
Returns an object with the daemon identity and a `log_level` property.
running_id
:return: current log level
:rtype: str
"""
level_names = {
logging.DEBUG: 'DEBUG', logging.INFO: 'INFO', lo... | python | def get_log_level(self):
"""Get the current daemon log level
Returns an object with the daemon identity and a `log_level` property.
running_id
:return: current log level
:rtype: str
"""
level_names = {
logging.DEBUG: 'DEBUG', logging.INFO: 'INFO', lo... | [
"def",
"get_log_level",
"(",
"self",
")",
":",
"level_names",
"=",
"{",
"logging",
".",
"DEBUG",
":",
"'DEBUG'",
",",
"logging",
".",
"INFO",
":",
"'INFO'",
",",
"logging",
".",
"WARNING",
":",
"'WARNING'",
",",
"logging",
".",
"ERROR",
":",
"'ERROR'",
... | Get the current daemon log level
Returns an object with the daemon identity and a `log_level` property.
running_id
:return: current log level
:rtype: str | [
"Get",
"the",
"current",
"daemon",
"log",
"level"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/http/generic_interface.py#L161-L179 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.