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/http/generic_interface.py | GenericInterface.set_log_level | def set_log_level(self, log_level=None):
"""Set the current log level for the daemon
The `log_level` parameter must be in [DEBUG, INFO, WARNING, ERROR, CRITICAL]
In case of any error, this function returns an object containing some properties:
'_status': 'ERR' because of the error
... | python | def set_log_level(self, log_level=None):
"""Set the current log level for the daemon
The `log_level` parameter must be in [DEBUG, INFO, WARNING, ERROR, CRITICAL]
In case of any error, this function returns an object containing some properties:
'_status': 'ERR' because of the error
... | [
"def",
"set_log_level",
"(",
"self",
",",
"log_level",
"=",
"None",
")",
":",
"if",
"log_level",
"is",
"None",
":",
"log_level",
"=",
"cherrypy",
".",
"request",
".",
"json",
"[",
"'log_level'",
"]",
"if",
"log_level",
"not",
"in",
"[",
"'DEBUG'",
",",
... | Set the current log level for the daemon
The `log_level` parameter must be in [DEBUG, INFO, WARNING, ERROR, CRITICAL]
In case of any error, this function returns an object containing some properties:
'_status': 'ERR' because of the error
`_message`: some more explanations about the err... | [
"Set",
"the",
"current",
"log",
"level",
"for",
"the",
"daemon"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/http/generic_interface.py#L184-L209 | train |
Alignak-monitoring/alignak | alignak/http/generic_interface.py | GenericInterface.stats | def stats(self, details=False):
"""Get statistics and information from the daemon
Returns an object with the daemon identity, the daemon start_time
and some extra properties depending upon the daemon type.
All daemons provide these ones:
- program_start: the Alignak start times... | python | def stats(self, details=False):
"""Get statistics and information from the daemon
Returns an object with the daemon identity, the daemon start_time
and some extra properties depending upon the daemon type.
All daemons provide these ones:
- program_start: the Alignak start times... | [
"def",
"stats",
"(",
"self",
",",
"details",
"=",
"False",
")",
":",
"if",
"details",
"is",
"not",
"False",
":",
"details",
"=",
"bool",
"(",
"details",
")",
"res",
"=",
"self",
".",
"identity",
"(",
")",
"res",
".",
"update",
"(",
"self",
".",
"... | Get statistics and information from the daemon
Returns an object with the daemon identity, the daemon start_time
and some extra properties depending upon the daemon type.
All daemons provide these ones:
- program_start: the Alignak start timestamp
- spare: to indicate if the da... | [
"Get",
"statistics",
"and",
"information",
"from",
"the",
"daemon"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/http/generic_interface.py#L240-L263 | train |
Alignak-monitoring/alignak | alignak/http/generic_interface.py | GenericInterface._have_conf | def _have_conf(self, magic_hash=None):
"""Get the daemon current configuration state
If the daemon has received a configuration from its arbiter, this will
return True
If a `magic_hash` is provided it is compared with the one included in the
daemon configuration and this functi... | python | def _have_conf(self, magic_hash=None):
"""Get the daemon current configuration state
If the daemon has received a configuration from its arbiter, this will
return True
If a `magic_hash` is provided it is compared with the one included in the
daemon configuration and this functi... | [
"def",
"_have_conf",
"(",
"self",
",",
"magic_hash",
"=",
"None",
")",
":",
"self",
".",
"app",
".",
"have_conf",
"=",
"getattr",
"(",
"self",
".",
"app",
",",
"'cur_conf'",
",",
"None",
")",
"not",
"in",
"[",
"None",
",",
"{",
"}",
"]",
"if",
"m... | Get the daemon current configuration state
If the daemon has received a configuration from its arbiter, this will
return True
If a `magic_hash` is provided it is compared with the one included in the
daemon configuration and this function returns True only if they match!
:retu... | [
"Get",
"the",
"daemon",
"current",
"configuration",
"state"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/http/generic_interface.py#L310-L329 | train |
Alignak-monitoring/alignak | alignak/http/generic_interface.py | GenericInterface._results | def _results(self, scheduler_instance_id):
"""Get the results of the executed actions for the scheduler which instance id is provided
Calling this method for daemons that are not configured as passive do not make sense.
Indeed, this service should only be exposed on poller and reactionner daemo... | python | def _results(self, scheduler_instance_id):
"""Get the results of the executed actions for the scheduler which instance id is provided
Calling this method for daemons that are not configured as passive do not make sense.
Indeed, this service should only be exposed on poller and reactionner daemo... | [
"def",
"_results",
"(",
"self",
",",
"scheduler_instance_id",
")",
":",
"with",
"self",
".",
"app",
".",
"lock",
":",
"res",
"=",
"self",
".",
"app",
".",
"get_results_from_passive",
"(",
"scheduler_instance_id",
")",
"return",
"serialize",
"(",
"res",
",",
... | Get the results of the executed actions for the scheduler which instance id is provided
Calling this method for daemons that are not configured as passive do not make sense.
Indeed, this service should only be exposed on poller and reactionner daemons.
:param scheduler_instance_id: instance id... | [
"Get",
"the",
"results",
"of",
"the",
"executed",
"actions",
"for",
"the",
"scheduler",
"which",
"instance",
"id",
"is",
"provided"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/http/generic_interface.py#L367-L380 | train |
Alignak-monitoring/alignak | alignak/http/generic_interface.py | GenericInterface._broks | def _broks(self, broker_name): # pylint: disable=unused-argument
"""Get the broks from the daemon
This is used by the brokers to get the broks list of a daemon
:return: Brok list serialized
:rtype: dict
"""
with self.app.broks_lock:
res = self.app.get_broks... | python | def _broks(self, broker_name): # pylint: disable=unused-argument
"""Get the broks from the daemon
This is used by the brokers to get the broks list of a daemon
:return: Brok list serialized
:rtype: dict
"""
with self.app.broks_lock:
res = self.app.get_broks... | [
"def",
"_broks",
"(",
"self",
",",
"broker_name",
")",
":",
"with",
"self",
".",
"app",
".",
"broks_lock",
":",
"res",
"=",
"self",
".",
"app",
".",
"get_broks",
"(",
")",
"return",
"serialize",
"(",
"res",
",",
"True",
")"
] | Get the broks from the daemon
This is used by the brokers to get the broks list of a daemon
:return: Brok list serialized
:rtype: dict | [
"Get",
"the",
"broks",
"from",
"the",
"daemon"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/http/generic_interface.py#L384-L394 | train |
Alignak-monitoring/alignak | alignak/http/generic_interface.py | GenericInterface._events | def _events(self):
"""Get the monitoring events from the daemon
This is used by the arbiter to get the monitoring events from all its satellites
:return: Events list serialized
:rtype: list
"""
with self.app.events_lock:
res = self.app.get_events()
r... | python | def _events(self):
"""Get the monitoring events from the daemon
This is used by the arbiter to get the monitoring events from all its satellites
:return: Events list serialized
:rtype: list
"""
with self.app.events_lock:
res = self.app.get_events()
r... | [
"def",
"_events",
"(",
"self",
")",
":",
"with",
"self",
".",
"app",
".",
"events_lock",
":",
"res",
"=",
"self",
".",
"app",
".",
"get_events",
"(",
")",
"return",
"serialize",
"(",
"res",
",",
"True",
")"
] | Get the monitoring events from the daemon
This is used by the arbiter to get the monitoring events from all its satellites
:return: Events list serialized
:rtype: list | [
"Get",
"the",
"monitoring",
"events",
"from",
"the",
"daemon"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/http/generic_interface.py#L398-L408 | train |
Alignak-monitoring/alignak | alignak/dependencynode.py | DependencyNode.get_state | def get_state(self, hosts, services):
"""Get node state by looking recursively over sons and applying operand
:param hosts: list of available hosts to search for
:param services: list of available services to search for
:return: Node state
:rtype: int
"""
# If we... | python | def get_state(self, hosts, services):
"""Get node state by looking recursively over sons and applying operand
:param hosts: list of available hosts to search for
:param services: list of available services to search for
:return: Node state
:rtype: int
"""
# If we... | [
"def",
"get_state",
"(",
"self",
",",
"hosts",
",",
"services",
")",
":",
"if",
"self",
".",
"operand",
"==",
"'host'",
":",
"host",
"=",
"hosts",
"[",
"self",
".",
"sons",
"[",
"0",
"]",
"]",
"return",
"self",
".",
"get_host_node_state",
"(",
"host"... | Get node state by looking recursively over sons and applying operand
:param hosts: list of available hosts to search for
:param services: list of available services to search for
:return: Node state
:rtype: int | [
"Get",
"node",
"state",
"by",
"looking",
"recursively",
"over",
"sons",
"and",
"applying",
"operand"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/dependencynode.py#L140-L171 | train |
Alignak-monitoring/alignak | alignak/dependencynode.py | DependencyNodeFactory.eval_cor_pattern | def eval_cor_pattern(self, pattern, hosts, services, hostgroups, servicegroups, running=False):
"""Parse and build recursively a tree of DependencyNode from pattern
:param pattern: pattern to parse
:type pattern: str
:param hosts: hosts list, used to find a specific host
:type h... | python | def eval_cor_pattern(self, pattern, hosts, services, hostgroups, servicegroups, running=False):
"""Parse and build recursively a tree of DependencyNode from pattern
:param pattern: pattern to parse
:type pattern: str
:param hosts: hosts list, used to find a specific host
:type h... | [
"def",
"eval_cor_pattern",
"(",
"self",
",",
"pattern",
",",
"hosts",
",",
"services",
",",
"hostgroups",
",",
"servicegroups",
",",
"running",
"=",
"False",
")",
":",
"pattern",
"=",
"pattern",
".",
"strip",
"(",
")",
"complex_node",
"=",
"False",
"for",
... | Parse and build recursively a tree of DependencyNode from pattern
:param pattern: pattern to parse
:type pattern: str
:param hosts: hosts list, used to find a specific host
:type hosts: alignak.objects.host.Host
:param services: services list, used to find a specific service
... | [
"Parse",
"and",
"build",
"recursively",
"a",
"tree",
"of",
"DependencyNode",
"from",
"pattern"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/dependencynode.py#L417-L445 | train |
Alignak-monitoring/alignak | alignak/dependencynode.py | DependencyNodeFactory.eval_complex_cor_pattern | def eval_complex_cor_pattern(self, pattern, hosts, services,
hostgroups, servicegroups, running=False):
# pylint: disable=too-many-branches
"""Parse and build recursively a tree of DependencyNode from a complex pattern
:param pattern: pattern to parse
:t... | python | def eval_complex_cor_pattern(self, pattern, hosts, services,
hostgroups, servicegroups, running=False):
# pylint: disable=too-many-branches
"""Parse and build recursively a tree of DependencyNode from a complex pattern
:param pattern: pattern to parse
:t... | [
"def",
"eval_complex_cor_pattern",
"(",
"self",
",",
"pattern",
",",
"hosts",
",",
"services",
",",
"hostgroups",
",",
"servicegroups",
",",
"running",
"=",
"False",
")",
":",
"node",
"=",
"DependencyNode",
"(",
")",
"pattern",
"=",
"self",
".",
"eval_xof_pa... | Parse and build recursively a tree of DependencyNode from a complex pattern
:param pattern: pattern to parse
:type pattern: str
:param hosts: hosts list, used to find a specific host
:type hosts: alignak.objects.host.Host
:param services: services list, used to find a specific s... | [
"Parse",
"and",
"build",
"recursively",
"a",
"tree",
"of",
"DependencyNode",
"from",
"a",
"complex",
"pattern"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/dependencynode.py#L477-L600 | train |
Alignak-monitoring/alignak | alignak/dependencynode.py | DependencyNodeFactory.eval_simple_cor_pattern | def eval_simple_cor_pattern(self, pattern, hosts, services,
hostgroups, servicegroups, running=False):
"""Parse and build recursively a tree of DependencyNode from a simple pattern
:param pattern: pattern to parse
:type pattern: str
:param hosts: hosts li... | python | def eval_simple_cor_pattern(self, pattern, hosts, services,
hostgroups, servicegroups, running=False):
"""Parse and build recursively a tree of DependencyNode from a simple pattern
:param pattern: pattern to parse
:type pattern: str
:param hosts: hosts li... | [
"def",
"eval_simple_cor_pattern",
"(",
"self",
",",
"pattern",
",",
"hosts",
",",
"services",
",",
"hostgroups",
",",
"servicegroups",
",",
"running",
"=",
"False",
")",
":",
"node",
"=",
"DependencyNode",
"(",
")",
"pattern",
"=",
"self",
".",
"eval_xof_pat... | Parse and build recursively a tree of DependencyNode from a simple pattern
:param pattern: pattern to parse
:type pattern: str
:param hosts: hosts list, used to find a specific host
:type hosts: alignak.objects.host.Host
:param services: services list, used to find a specific se... | [
"Parse",
"and",
"build",
"recursively",
"a",
"tree",
"of",
"DependencyNode",
"from",
"a",
"simple",
"pattern"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/dependencynode.py#L602-L655 | train |
Alignak-monitoring/alignak | alignak/dependencynode.py | DependencyNodeFactory.find_object | def find_object(self, pattern, hosts, services):
"""Find object from pattern
:param pattern: text to search (host1,service1)
:type pattern: str
:param hosts: hosts list, used to find a specific host
:type hosts: alignak.objects.host.Host
:param services: services list, u... | python | def find_object(self, pattern, hosts, services):
"""Find object from pattern
:param pattern: text to search (host1,service1)
:type pattern: str
:param hosts: hosts list, used to find a specific host
:type hosts: alignak.objects.host.Host
:param services: services list, u... | [
"def",
"find_object",
"(",
"self",
",",
"pattern",
",",
"hosts",
",",
"services",
")",
":",
"obj",
"=",
"None",
"error",
"=",
"None",
"is_service",
"=",
"False",
"elts",
"=",
"pattern",
".",
"split",
"(",
"','",
")",
"host_name",
"=",
"elts",
"[",
"0... | Find object from pattern
:param pattern: text to search (host1,service1)
:type pattern: str
:param hosts: hosts list, used to find a specific host
:type hosts: alignak.objects.host.Host
:param services: services list, used to find a specific service
:type services: align... | [
"Find",
"object",
"from",
"pattern"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/dependencynode.py#L657-L691 | train |
Alignak-monitoring/alignak | alignak/objects/timeperiod.py | Timeperiod.is_time_valid | def is_time_valid(self, timestamp):
"""
Check if a time is valid or not
:return: time is valid or not
:rtype: bool
"""
if hasattr(self, 'exclude'):
for daterange in self.exclude:
if daterange.is_time_valid(timestamp):
retur... | python | def is_time_valid(self, timestamp):
"""
Check if a time is valid or not
:return: time is valid or not
:rtype: bool
"""
if hasattr(self, 'exclude'):
for daterange in self.exclude:
if daterange.is_time_valid(timestamp):
retur... | [
"def",
"is_time_valid",
"(",
"self",
",",
"timestamp",
")",
":",
"if",
"hasattr",
"(",
"self",
",",
"'exclude'",
")",
":",
"for",
"daterange",
"in",
"self",
".",
"exclude",
":",
"if",
"daterange",
".",
"is_time_valid",
"(",
"timestamp",
")",
":",
"return... | Check if a time is valid or not
:return: time is valid or not
:rtype: bool | [
"Check",
"if",
"a",
"time",
"is",
"valid",
"or",
"not"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/objects/timeperiod.py#L274-L288 | train |
Alignak-monitoring/alignak | alignak/objects/timeperiod.py | Timeperiod.get_min_from_t | def get_min_from_t(self, timestamp):
"""
Get the first time > timestamp which is valid
:param timestamp: number of seconds
:type timestamp: int
:return: number of seconds
:rtype: int
TODO: not used, so delete it
"""
mins_incl = []
for date... | python | def get_min_from_t(self, timestamp):
"""
Get the first time > timestamp which is valid
:param timestamp: number of seconds
:type timestamp: int
:return: number of seconds
:rtype: int
TODO: not used, so delete it
"""
mins_incl = []
for date... | [
"def",
"get_min_from_t",
"(",
"self",
",",
"timestamp",
")",
":",
"mins_incl",
"=",
"[",
"]",
"for",
"daterange",
"in",
"self",
".",
"dateranges",
":",
"mins_incl",
".",
"append",
"(",
"daterange",
".",
"get_min_from_t",
"(",
"timestamp",
")",
")",
"return... | Get the first time > timestamp which is valid
:param timestamp: number of seconds
:type timestamp: int
:return: number of seconds
:rtype: int
TODO: not used, so delete it | [
"Get",
"the",
"first",
"time",
">",
"timestamp",
"which",
"is",
"valid"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/objects/timeperiod.py#L291-L304 | train |
Alignak-monitoring/alignak | alignak/objects/timeperiod.py | Timeperiod.clean_cache | def clean_cache(self):
"""
Clean cache with entries older than now because not used in future ;)
:return: None
"""
now = int(time.time())
t_to_del = []
for timestamp in self.cache:
if timestamp < now:
t_to_del.append(timestamp)
... | python | def clean_cache(self):
"""
Clean cache with entries older than now because not used in future ;)
:return: None
"""
now = int(time.time())
t_to_del = []
for timestamp in self.cache:
if timestamp < now:
t_to_del.append(timestamp)
... | [
"def",
"clean_cache",
"(",
"self",
")",
":",
"now",
"=",
"int",
"(",
"time",
".",
"time",
"(",
")",
")",
"t_to_del",
"=",
"[",
"]",
"for",
"timestamp",
"in",
"self",
".",
"cache",
":",
"if",
"timestamp",
"<",
"now",
":",
"t_to_del",
".",
"append",
... | Clean cache with entries older than now because not used in future ;)
:return: None | [
"Clean",
"cache",
"with",
"entries",
"older",
"than",
"now",
"because",
"not",
"used",
"in",
"future",
";",
")"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/objects/timeperiod.py#L381-L401 | train |
Alignak-monitoring/alignak | alignak/objects/timeperiod.py | Timeperiod.get_next_valid_time_from_t | def get_next_valid_time_from_t(self, timestamp):
# pylint: disable=too-many-branches
"""
Get next valid time. If it's in cache, get it, otherwise define it.
The limit to find it is 1 year.
:param timestamp: number of seconds
:type timestamp: int or float
:return:... | python | def get_next_valid_time_from_t(self, timestamp):
# pylint: disable=too-many-branches
"""
Get next valid time. If it's in cache, get it, otherwise define it.
The limit to find it is 1 year.
:param timestamp: number of seconds
:type timestamp: int or float
:return:... | [
"def",
"get_next_valid_time_from_t",
"(",
"self",
",",
"timestamp",
")",
":",
"timestamp",
"=",
"int",
"(",
"timestamp",
")",
"original_t",
"=",
"timestamp",
"res_from_cache",
"=",
"self",
".",
"find_next_valid_time_from_cache",
"(",
"timestamp",
")",
"if",
"res_f... | Get next valid time. If it's in cache, get it, otherwise define it.
The limit to find it is 1 year.
:param timestamp: number of seconds
:type timestamp: int or float
:return: Nothing or time in seconds
:rtype: None or int | [
"Get",
"next",
"valid",
"time",
".",
"If",
"it",
"s",
"in",
"cache",
"get",
"it",
"otherwise",
"define",
"it",
".",
"The",
"limit",
"to",
"find",
"it",
"is",
"1",
"year",
"."
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/objects/timeperiod.py#L403-L470 | train |
Alignak-monitoring/alignak | alignak/objects/timeperiod.py | Timeperiod.get_next_invalid_time_from_t | def get_next_invalid_time_from_t(self, timestamp):
# pylint: disable=too-many-branches
"""
Get the next invalid time
:param timestamp: timestamp in seconds (of course)
:type timestamp: int or float
:return: timestamp of next invalid time
:rtype: int or float
... | python | def get_next_invalid_time_from_t(self, timestamp):
# pylint: disable=too-many-branches
"""
Get the next invalid time
:param timestamp: timestamp in seconds (of course)
:type timestamp: int or float
:return: timestamp of next invalid time
:rtype: int or float
... | [
"def",
"get_next_invalid_time_from_t",
"(",
"self",
",",
"timestamp",
")",
":",
"timestamp",
"=",
"int",
"(",
"timestamp",
")",
"original_t",
"=",
"timestamp",
"dr_mins",
"=",
"[",
"]",
"for",
"daterange",
"in",
"self",
".",
"dateranges",
":",
"timestamp",
"... | Get the next invalid time
:param timestamp: timestamp in seconds (of course)
:type timestamp: int or float
:return: timestamp of next invalid time
:rtype: int or float | [
"Get",
"the",
"next",
"invalid",
"time"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/objects/timeperiod.py#L472-L532 | train |
Alignak-monitoring/alignak | alignak/objects/timeperiod.py | Timeperiod.explode | def explode(self):
"""
Try to resolve all unresolved elements
:return: None
"""
for entry in self.unresolved:
self.resolve_daterange(self.dateranges, entry)
self.unresolved = [] | python | def explode(self):
"""
Try to resolve all unresolved elements
:return: None
"""
for entry in self.unresolved:
self.resolve_daterange(self.dateranges, entry)
self.unresolved = [] | [
"def",
"explode",
"(",
"self",
")",
":",
"for",
"entry",
"in",
"self",
".",
"unresolved",
":",
"self",
".",
"resolve_daterange",
"(",
"self",
".",
"dateranges",
",",
"entry",
")",
"self",
".",
"unresolved",
"=",
"[",
"]"
] | Try to resolve all unresolved elements
:return: None | [
"Try",
"to",
"resolve",
"all",
"unresolved",
"elements"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/objects/timeperiod.py#L868-L876 | train |
Alignak-monitoring/alignak | alignak/objects/timeperiod.py | Timeperiod.linkify | def linkify(self, timeperiods):
"""
Will make timeperiod in exclude with id of the timeperiods
:param timeperiods: Timeperiods object
:type timeperiods:
:return: None
"""
new_exclude = []
if hasattr(self, 'exclude') and self.exclude != []:
log... | python | def linkify(self, timeperiods):
"""
Will make timeperiod in exclude with id of the timeperiods
:param timeperiods: Timeperiods object
:type timeperiods:
:return: None
"""
new_exclude = []
if hasattr(self, 'exclude') and self.exclude != []:
log... | [
"def",
"linkify",
"(",
"self",
",",
"timeperiods",
")",
":",
"new_exclude",
"=",
"[",
"]",
"if",
"hasattr",
"(",
"self",
",",
"'exclude'",
")",
"and",
"self",
".",
"exclude",
"!=",
"[",
"]",
":",
"logger",
".",
"debug",
"(",
"\"[timeentry::%s] have exclu... | Will make timeperiod in exclude with id of the timeperiods
:param timeperiods: Timeperiods object
:type timeperiods:
:return: None | [
"Will",
"make",
"timeperiod",
"in",
"exclude",
"with",
"id",
"of",
"the",
"timeperiods"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/objects/timeperiod.py#L878-L897 | train |
Alignak-monitoring/alignak | alignak/objects/timeperiod.py | Timeperiod.check_exclude_rec | def check_exclude_rec(self):
# pylint: disable=access-member-before-definition
"""
Check if this timeperiod is tagged
:return: if tagged return false, if not true
:rtype: bool
"""
if self.rec_tag:
msg = "[timeentry::%s] is in a loop in exclude paramet... | python | def check_exclude_rec(self):
# pylint: disable=access-member-before-definition
"""
Check if this timeperiod is tagged
:return: if tagged return false, if not true
:rtype: bool
"""
if self.rec_tag:
msg = "[timeentry::%s] is in a loop in exclude paramet... | [
"def",
"check_exclude_rec",
"(",
"self",
")",
":",
"if",
"self",
".",
"rec_tag",
":",
"msg",
"=",
"\"[timeentry::%s] is in a loop in exclude parameter\"",
"%",
"(",
"self",
".",
"get_name",
"(",
")",
")",
"self",
".",
"add_error",
"(",
"msg",
")",
"return",
... | Check if this timeperiod is tagged
:return: if tagged return false, if not true
:rtype: bool | [
"Check",
"if",
"this",
"timeperiod",
"is",
"tagged"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/objects/timeperiod.py#L899-L914 | train |
Alignak-monitoring/alignak | alignak/objects/timeperiod.py | Timeperiods.explode | def explode(self):
"""
Try to resolve each timeperiod
:return: None
"""
for t_id in self.items:
timeperiod = self.items[t_id]
timeperiod.explode() | python | def explode(self):
"""
Try to resolve each timeperiod
:return: None
"""
for t_id in self.items:
timeperiod = self.items[t_id]
timeperiod.explode() | [
"def",
"explode",
"(",
"self",
")",
":",
"for",
"t_id",
"in",
"self",
".",
"items",
":",
"timeperiod",
"=",
"self",
".",
"items",
"[",
"t_id",
"]",
"timeperiod",
".",
"explode",
"(",
")"
] | Try to resolve each timeperiod
:return: None | [
"Try",
"to",
"resolve",
"each",
"timeperiod"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/objects/timeperiod.py#L948-L956 | train |
Alignak-monitoring/alignak | alignak/objects/timeperiod.py | Timeperiods.linkify | def linkify(self):
"""
Check exclusion for each timeperiod
:return: None
"""
for t_id in self.items:
timeperiod = self.items[t_id]
timeperiod.linkify(self) | python | def linkify(self):
"""
Check exclusion for each timeperiod
:return: None
"""
for t_id in self.items:
timeperiod = self.items[t_id]
timeperiod.linkify(self) | [
"def",
"linkify",
"(",
"self",
")",
":",
"for",
"t_id",
"in",
"self",
".",
"items",
":",
"timeperiod",
"=",
"self",
".",
"items",
"[",
"t_id",
"]",
"timeperiod",
".",
"linkify",
"(",
"self",
")"
] | Check exclusion for each timeperiod
:return: None | [
"Check",
"exclusion",
"for",
"each",
"timeperiod"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/objects/timeperiod.py#L958-L966 | train |
Alignak-monitoring/alignak | alignak/objects/timeperiod.py | Timeperiods.apply_inheritance | def apply_inheritance(self):
"""
The only interesting property to inherit is exclude
:return: None
"""
self.apply_partial_inheritance('exclude')
for i in self:
self.get_customs_properties_by_inheritance(i)
# And now apply inheritance for unresolved p... | python | def apply_inheritance(self):
"""
The only interesting property to inherit is exclude
:return: None
"""
self.apply_partial_inheritance('exclude')
for i in self:
self.get_customs_properties_by_inheritance(i)
# And now apply inheritance for unresolved p... | [
"def",
"apply_inheritance",
"(",
"self",
")",
":",
"self",
".",
"apply_partial_inheritance",
"(",
"'exclude'",
")",
"for",
"i",
"in",
"self",
":",
"self",
".",
"get_customs_properties_by_inheritance",
"(",
"i",
")",
"for",
"timeperiod",
"in",
"self",
":",
"sel... | The only interesting property to inherit is exclude
:return: None | [
"The",
"only",
"interesting",
"property",
"to",
"inherit",
"is",
"exclude"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/objects/timeperiod.py#L980-L993 | train |
Alignak-monitoring/alignak | alignak/objects/timeperiod.py | Timeperiods.is_correct | def is_correct(self):
"""
check if each properties of timeperiods are valid
:return: True if is correct, otherwise False
:rtype: bool
"""
valid = True
# We do not want a same hg to be explode again and again
# so we tag it
for timeperiod in list(s... | python | def is_correct(self):
"""
check if each properties of timeperiods are valid
:return: True if is correct, otherwise False
:rtype: bool
"""
valid = True
# We do not want a same hg to be explode again and again
# so we tag it
for timeperiod in list(s... | [
"def",
"is_correct",
"(",
"self",
")",
":",
"valid",
"=",
"True",
"for",
"timeperiod",
"in",
"list",
"(",
"self",
".",
"items",
".",
"values",
"(",
")",
")",
":",
"timeperiod",
".",
"rec_tag",
"=",
"False",
"for",
"timeperiod",
"in",
"list",
"(",
"se... | check if each properties of timeperiods are valid
:return: True if is correct, otherwise False
:rtype: bool | [
"check",
"if",
"each",
"properties",
"of",
"timeperiods",
"are",
"valid"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/objects/timeperiod.py#L995-L1033 | train |
Alignak-monitoring/alignak | alignak/dispatcher.py | Dispatcher.check_status_and_get_events | def check_status_and_get_events(self):
# pylint: disable=too-many-branches
"""Get all the daemons status
:return: Dictionary with all the daemons returned information
:rtype: dict
"""
statistics = {}
events = []
for daemon_link in self.all_daemons_links:... | python | def check_status_and_get_events(self):
# pylint: disable=too-many-branches
"""Get all the daemons status
:return: Dictionary with all the daemons returned information
:rtype: dict
"""
statistics = {}
events = []
for daemon_link in self.all_daemons_links:... | [
"def",
"check_status_and_get_events",
"(",
"self",
")",
":",
"statistics",
"=",
"{",
"}",
"events",
"=",
"[",
"]",
"for",
"daemon_link",
"in",
"self",
".",
"all_daemons_links",
":",
"if",
"daemon_link",
"==",
"self",
".",
"arbiter_link",
":",
"continue",
"if... | Get all the daemons status
:return: Dictionary with all the daemons returned information
:rtype: dict | [
"Get",
"all",
"the",
"daemons",
"status"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/dispatcher.py#L299-L337 | train |
Alignak-monitoring/alignak | alignak/dispatcher.py | Dispatcher.get_scheduler_ordered_list | def get_scheduler_ordered_list(self, realm):
"""Get sorted scheduler list for a specific realm
List is ordered as: alive first, then spare (if any), then dead scheduler links
:param realm: realm we want scheduler from
:type realm: alignak.objects.realm.Realm
:return: sorted sch... | python | def get_scheduler_ordered_list(self, realm):
"""Get sorted scheduler list for a specific realm
List is ordered as: alive first, then spare (if any), then dead scheduler links
:param realm: realm we want scheduler from
:type realm: alignak.objects.realm.Realm
:return: sorted sch... | [
"def",
"get_scheduler_ordered_list",
"(",
"self",
",",
"realm",
")",
":",
"scheduler_links",
"=",
"[",
"]",
"for",
"scheduler_link_uuid",
"in",
"realm",
".",
"schedulers",
":",
"scheduler_links",
".",
"append",
"(",
"self",
".",
"schedulers",
"[",
"scheduler_lin... | Get sorted scheduler list for a specific realm
List is ordered as: alive first, then spare (if any), then dead scheduler links
:param realm: realm we want scheduler from
:type realm: alignak.objects.realm.Realm
:return: sorted scheduler list
:rtype: list[alignak.objects.schedul... | [
"Get",
"sorted",
"scheduler",
"list",
"for",
"a",
"specific",
"realm"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/dispatcher.py#L466-L498 | train |
Alignak-monitoring/alignak | alignak/dispatcher.py | Dispatcher.dispatch | def dispatch(self, test=False): # pylint: disable=too-many-branches
"""
Send configuration to satellites
:return: None
"""
if not self.new_to_dispatch:
raise DispatcherError("Dispatcher cannot dispatch, "
"because no configuration i... | python | def dispatch(self, test=False): # pylint: disable=too-many-branches
"""
Send configuration to satellites
:return: None
"""
if not self.new_to_dispatch:
raise DispatcherError("Dispatcher cannot dispatch, "
"because no configuration i... | [
"def",
"dispatch",
"(",
"self",
",",
"test",
"=",
"False",
")",
":",
"if",
"not",
"self",
".",
"new_to_dispatch",
":",
"raise",
"DispatcherError",
"(",
"\"Dispatcher cannot dispatch, \"",
"\"because no configuration is prepared!\"",
")",
"if",
"self",
".",
"first_di... | Send configuration to satellites
:return: None | [
"Send",
"configuration",
"to",
"satellites"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/dispatcher.py#L839-L944 | train |
Alignak-monitoring/alignak | alignak/dispatcher.py | Dispatcher.stop_request | def stop_request(self, stop_now=False):
"""Send a stop request to all the daemons
:param stop_now: stop now or go to stop wait mode
:type stop_now: bool
:return: True if all daemons are reachable
"""
all_ok = True
for daemon_link in self.all_daemons_links:
... | python | def stop_request(self, stop_now=False):
"""Send a stop request to all the daemons
:param stop_now: stop now or go to stop wait mode
:type stop_now: bool
:return: True if all daemons are reachable
"""
all_ok = True
for daemon_link in self.all_daemons_links:
... | [
"def",
"stop_request",
"(",
"self",
",",
"stop_now",
"=",
"False",
")",
":",
"all_ok",
"=",
"True",
"for",
"daemon_link",
"in",
"self",
".",
"all_daemons_links",
":",
"logger",
".",
"debug",
"(",
"\"Stopping: %s (%s)\"",
",",
"daemon_link",
",",
"stop_now",
... | Send a stop request to all the daemons
:param stop_now: stop now or go to stop wait mode
:type stop_now: bool
:return: True if all daemons are reachable | [
"Send",
"a",
"stop",
"request",
"to",
"all",
"the",
"daemons"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/dispatcher.py#L946-L976 | train |
Alignak-monitoring/alignak | alignak/property.py | BoolProp.pythonize | def pythonize(self, val):
"""Convert value into a boolean
:param val: value to convert
:type val: bool, int, str
:return: boolean corresponding to value ::
{'1': True, 'yes': True, 'true': True, 'on': True,
'0': False, 'no': False, 'false': False, 'off': False}
... | python | def pythonize(self, val):
"""Convert value into a boolean
:param val: value to convert
:type val: bool, int, str
:return: boolean corresponding to value ::
{'1': True, 'yes': True, 'true': True, 'on': True,
'0': False, 'no': False, 'false': False, 'off': False}
... | [
"def",
"pythonize",
"(",
"self",
",",
"val",
")",
":",
"__boolean_states__",
"=",
"{",
"'1'",
":",
"True",
",",
"'yes'",
":",
"True",
",",
"'true'",
":",
"True",
",",
"'on'",
":",
"True",
",",
"'0'",
":",
"False",
",",
"'no'",
":",
"False",
",",
... | Convert value into a boolean
:param val: value to convert
:type val: bool, int, str
:return: boolean corresponding to value ::
{'1': True, 'yes': True, 'true': True, 'on': True,
'0': False, 'no': False, 'false': False, 'off': False}
:rtype: bool | [
"Convert",
"value",
"into",
"a",
"boolean"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/property.py#L222-L243 | train |
Alignak-monitoring/alignak | alignak/property.py | ToGuessProp.pythonize | def pythonize(self, val):
"""If value is a single list element just return the element
does nothing otherwise
:param val: value to convert
:type val:
:return: converted value
:rtype:
"""
if isinstance(val, list) and len(set(val)) == 1:
# If we... | python | def pythonize(self, val):
"""If value is a single list element just return the element
does nothing otherwise
:param val: value to convert
:type val:
:return: converted value
:rtype:
"""
if isinstance(val, list) and len(set(val)) == 1:
# If we... | [
"def",
"pythonize",
"(",
"self",
",",
"val",
")",
":",
"if",
"isinstance",
"(",
"val",
",",
"list",
")",
"and",
"len",
"(",
"set",
"(",
"val",
")",
")",
"==",
"1",
":",
"return",
"val",
"[",
"0",
"]",
"return",
"val"
] | If value is a single list element just return the element
does nothing otherwise
:param val: value to convert
:type val:
:return: converted value
:rtype: | [
"If",
"value",
"is",
"a",
"single",
"list",
"element",
"just",
"return",
"the",
"element",
"does",
"nothing",
"otherwise"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/property.py#L471-L485 | train |
Alignak-monitoring/alignak | alignak/monitor.py | MonitorConnection.login | def login(self, username, password):
"""
Log into the WS interface and get the authentication token
if login is:
- accepted, returns True
- refused, returns False
In case of any error, raises a BackendException
:param username: login name
:type username... | python | def login(self, username, password):
"""
Log into the WS interface and get the authentication token
if login is:
- accepted, returns True
- refused, returns False
In case of any error, raises a BackendException
:param username: login name
:type username... | [
"def",
"login",
"(",
"self",
",",
"username",
",",
"password",
")",
":",
"logger",
".",
"debug",
"(",
"\"login for: %s\"",
",",
"username",
")",
"if",
"not",
"username",
"and",
"not",
"password",
":",
"self",
".",
"set_token",
"(",
"token",
"=",
"None",
... | Log into the WS interface and get the authentication token
if login is:
- accepted, returns True
- refused, returns False
In case of any error, raises a BackendException
:param username: login name
:type username: str
:param password: password
:type pas... | [
"Log",
"into",
"the",
"WS",
"interface",
"and",
"get",
"the",
"authentication",
"token"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/monitor.py#L153-L198 | train |
Alignak-monitoring/alignak | alignak/monitor.py | MonitorConnection.logout | def logout(self):
"""
Logout from the backend
:return: return True if logout is successfull, otherwise False
:rtype: bool
"""
logger.debug("request backend logout")
if not self.authenticated:
logger.warning("Unnecessary logout ...")
return... | python | def logout(self):
"""
Logout from the backend
:return: return True if logout is successfull, otherwise False
:rtype: bool
"""
logger.debug("request backend logout")
if not self.authenticated:
logger.warning("Unnecessary logout ...")
return... | [
"def",
"logout",
"(",
"self",
")",
":",
"logger",
".",
"debug",
"(",
"\"request backend logout\"",
")",
"if",
"not",
"self",
".",
"authenticated",
":",
"logger",
".",
"warning",
"(",
"\"Unnecessary logout ...\"",
")",
"return",
"True",
"endpoint",
"=",
"'logou... | Logout from the backend
:return: return True if logout is successfull, otherwise False
:rtype: bool | [
"Logout",
"from",
"the",
"backend"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/monitor.py#L200-L219 | train |
Alignak-monitoring/alignak | alignak/monitor.py | MonitorConnection.get | def get(self, endpoint, params=None):
"""
Get items or item in alignak backend
If an error occurs, a BackendException is raised.
This method builds a response as a dictionary that always contains: _items and _status::
{
u'_items': [
...
... | python | def get(self, endpoint, params=None):
"""
Get items or item in alignak backend
If an error occurs, a BackendException is raised.
This method builds a response as a dictionary that always contains: _items and _status::
{
u'_items': [
...
... | [
"def",
"get",
"(",
"self",
",",
"endpoint",
",",
"params",
"=",
"None",
")",
":",
"response",
"=",
"self",
".",
"get_response",
"(",
"method",
"=",
"'GET'",
",",
"endpoint",
"=",
"endpoint",
",",
"params",
"=",
"params",
")",
"resp",
"=",
"self",
"."... | Get items or item in alignak backend
If an error occurs, a BackendException is raised.
This method builds a response as a dictionary that always contains: _items and _status::
{
u'_items': [
...
],
u'_status': u'OK'
... | [
"Get",
"items",
"or",
"item",
"in",
"alignak",
"backend"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/monitor.py#L221-L249 | train |
Alignak-monitoring/alignak | alignak/monitor.py | MonitorConnection.post | def post(self, endpoint, data, files=None, headers=None):
# pylint: disable=unused-argument
"""
Create a new item
:param endpoint: endpoint (API URL)
:type endpoint: str
:param data: properties of item to create
:type data: dict
:param files: Not used. To... | python | def post(self, endpoint, data, files=None, headers=None):
# pylint: disable=unused-argument
"""
Create a new item
:param endpoint: endpoint (API URL)
:type endpoint: str
:param data: properties of item to create
:type data: dict
:param files: Not used. To... | [
"def",
"post",
"(",
"self",
",",
"endpoint",
",",
"data",
",",
"files",
"=",
"None",
",",
"headers",
"=",
"None",
")",
":",
"response",
"=",
"self",
".",
"get_response",
"(",
"method",
"=",
"'POST'",
",",
"endpoint",
"=",
"endpoint",
",",
"json",
"="... | Create a new item
:param endpoint: endpoint (API URL)
:type endpoint: str
:param data: properties of item to create
:type data: dict
:param files: Not used. To be implemented
:type files: None
:param headers: headers (example: Content-Type)
:type headers:... | [
"Create",
"a",
"new",
"item"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/monitor.py#L251-L272 | train |
Alignak-monitoring/alignak | alignak/monitor.py | MonitorConnection.patch | def patch(self, endpoint, data):
"""
Method to update an item
The headers must include an If-Match containing the object _etag.
headers = {'If-Match': contact_etag}
The data dictionary contain the fields that must be modified.
If the patching fails because the _eta... | python | def patch(self, endpoint, data):
"""
Method to update an item
The headers must include an If-Match containing the object _etag.
headers = {'If-Match': contact_etag}
The data dictionary contain the fields that must be modified.
If the patching fails because the _eta... | [
"def",
"patch",
"(",
"self",
",",
"endpoint",
",",
"data",
")",
":",
"response",
"=",
"self",
".",
"get_response",
"(",
"method",
"=",
"'PATCH'",
",",
"endpoint",
"=",
"endpoint",
",",
"json",
"=",
"data",
",",
"headers",
"=",
"{",
"'Content-Type'",
":... | Method to update an item
The headers must include an If-Match containing the object _etag.
headers = {'If-Match': contact_etag}
The data dictionary contain the fields that must be modified.
If the patching fails because the _etag object do not match with the provided one, a
... | [
"Method",
"to",
"update",
"an",
"item"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/monitor.py#L274-L322 | train |
Alignak-monitoring/alignak | alignak/macroresolver.py | MacroResolver.init | def init(self, conf):
"""Initialize MacroResolver instance with conf.
Must be called at least once.
:param conf: configuration to load
:type conf: alignak.objects.Config
:return: None
"""
# For searching class and elements for on-demand
# we need link to... | python | def init(self, conf):
"""Initialize MacroResolver instance with conf.
Must be called at least once.
:param conf: configuration to load
:type conf: alignak.objects.Config
:return: None
"""
# For searching class and elements for on-demand
# we need link to... | [
"def",
"init",
"(",
"self",
",",
"conf",
")",
":",
"self",
".",
"my_conf",
"=",
"conf",
"self",
".",
"lists_on_demand",
"=",
"[",
"]",
"self",
".",
"hosts",
"=",
"self",
".",
"my_conf",
".",
"hosts",
"self",
".",
"host_class",
"=",
"self",
".",
"ho... | Initialize MacroResolver instance with conf.
Must be called at least once.
:param conf: configuration to load
:type conf: alignak.objects.Config
:return: None | [
"Initialize",
"MacroResolver",
"instance",
"with",
"conf",
".",
"Must",
"be",
"called",
"at",
"least",
"once",
"."
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/macroresolver.py#L146-L174 | train |
Alignak-monitoring/alignak | alignak/macroresolver.py | MacroResolver._get_value_from_element | def _get_value_from_element(self, elt, prop):
# pylint: disable=too-many-return-statements
"""Get value from an element's property.
the property may be a function to call.
If the property is not resolved (because not implemented), this function will return 'n/a'
:param elt: el... | python | def _get_value_from_element(self, elt, prop):
# pylint: disable=too-many-return-statements
"""Get value from an element's property.
the property may be a function to call.
If the property is not resolved (because not implemented), this function will return 'n/a'
:param elt: el... | [
"def",
"_get_value_from_element",
"(",
"self",
",",
"elt",
",",
"prop",
")",
":",
"args",
"=",
"None",
"if",
"isinstance",
"(",
"prop",
",",
"tuple",
")",
":",
"prop",
",",
"args",
"=",
"prop",
"value",
"=",
"getattr",
"(",
"elt",
",",
"prop",
",",
... | Get value from an element's property.
the property may be a function to call.
If the property is not resolved (because not implemented), this function will return 'n/a'
:param elt: element
:type elt: object
:param prop: element property
:type prop: str
:return:... | [
"Get",
"value",
"from",
"an",
"element",
"s",
"property",
"."
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/macroresolver.py#L202-L258 | train |
Alignak-monitoring/alignak | alignak/macroresolver.py | MacroResolver._delete_unwanted_caracters | def _delete_unwanted_caracters(self, chain):
"""Remove not wanted char from chain
unwanted char are illegal_macro_output_chars attribute
:param chain: chain to remove char from
:type chain: str
:return: chain cleaned
:rtype: str
"""
try:
chain... | python | def _delete_unwanted_caracters(self, chain):
"""Remove not wanted char from chain
unwanted char are illegal_macro_output_chars attribute
:param chain: chain to remove char from
:type chain: str
:return: chain cleaned
:rtype: str
"""
try:
chain... | [
"def",
"_delete_unwanted_caracters",
"(",
"self",
",",
"chain",
")",
":",
"try",
":",
"chain",
"=",
"chain",
".",
"decode",
"(",
"'utf8'",
",",
"'replace'",
")",
"except",
"UnicodeEncodeError",
":",
"pass",
"except",
"AttributeError",
":",
"pass",
"for",
"ch... | Remove not wanted char from chain
unwanted char are illegal_macro_output_chars attribute
:param chain: chain to remove char from
:type chain: str
:return: chain cleaned
:rtype: str | [
"Remove",
"not",
"wanted",
"char",
"from",
"chain",
"unwanted",
"char",
"are",
"illegal_macro_output_chars",
"attribute"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/macroresolver.py#L260-L279 | train |
Alignak-monitoring/alignak | alignak/macroresolver.py | MacroResolver.resolve_command | def resolve_command(self, com, data, macromodulations, timeperiods):
"""Resolve command macros with data
:param com: check / event handler or command call object
:type com: object
:param data: objects list, used to search for a specific macro (custom or object related)
:type dat... | python | def resolve_command(self, com, data, macromodulations, timeperiods):
"""Resolve command macros with data
:param com: check / event handler or command call object
:type com: object
:param data: objects list, used to search for a specific macro (custom or object related)
:type dat... | [
"def",
"resolve_command",
"(",
"self",
",",
"com",
",",
"data",
",",
"macromodulations",
",",
"timeperiods",
")",
":",
"logger",
".",
"debug",
"(",
"\"Resolving: macros in: %s, arguments: %s\"",
",",
"com",
".",
"command",
".",
"command_line",
",",
"com",
".",
... | Resolve command macros with data
:param com: check / event handler or command call object
:type com: object
:param data: objects list, used to search for a specific macro (custom or object related)
:type data:
:return: command line with '$MACRO$' replaced with values
:pa... | [
"Resolve",
"command",
"macros",
"with",
"data"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/macroresolver.py#L429-L447 | train |
Alignak-monitoring/alignak | alignak/macroresolver.py | MacroResolver._get_type_of_macro | def _get_type_of_macro(macros, objs):
r"""Set macros types
Example::
ARG\d -> ARGN,
HOSTBLABLA -> class one and set Host in class)
_HOSTTOTO -> HOST CUSTOM MACRO TOTO
SERVICESTATEID:srv-1:Load$ -> MACRO SERVICESTATEID of the service Load of host srv-1
:param ma... | python | def _get_type_of_macro(macros, objs):
r"""Set macros types
Example::
ARG\d -> ARGN,
HOSTBLABLA -> class one and set Host in class)
_HOSTTOTO -> HOST CUSTOM MACRO TOTO
SERVICESTATEID:srv-1:Load$ -> MACRO SERVICESTATEID of the service Load of host srv-1
:param ma... | [
"def",
"_get_type_of_macro",
"(",
"macros",
",",
"objs",
")",
":",
"r",
"for",
"macro",
"in",
"macros",
":",
"if",
"re",
".",
"match",
"(",
"r'ARG\\d'",
",",
"macro",
")",
":",
"macros",
"[",
"macro",
"]",
"[",
"'type'",
"]",
"=",
"'ARGN'",
"continue... | r"""Set macros types
Example::
ARG\d -> ARGN,
HOSTBLABLA -> class one and set Host in class)
_HOSTTOTO -> HOST CUSTOM MACRO TOTO
SERVICESTATEID:srv-1:Load$ -> MACRO SERVICESTATEID of the service Load of host srv-1
:param macros: macros list in a dictionary
:typ... | [
"r",
"Set",
"macros",
"types"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/macroresolver.py#L450-L496 | train |
Alignak-monitoring/alignak | alignak/macroresolver.py | MacroResolver._resolve_ondemand | def _resolve_ondemand(self, macro, data):
# pylint: disable=too-many-locals
"""Get on demand macro value
If the macro cannot be resolved, this function will return 'n/a' rather than
an empty string, this to alert the caller of a potential problem.
:param macro: macro to parse
... | python | def _resolve_ondemand(self, macro, data):
# pylint: disable=too-many-locals
"""Get on demand macro value
If the macro cannot be resolved, this function will return 'n/a' rather than
an empty string, this to alert the caller of a potential problem.
:param macro: macro to parse
... | [
"def",
"_resolve_ondemand",
"(",
"self",
",",
"macro",
",",
"data",
")",
":",
"elts",
"=",
"macro",
".",
"split",
"(",
"':'",
")",
"nb_parts",
"=",
"len",
"(",
"elts",
")",
"macro_name",
"=",
"elts",
"[",
"0",
"]",
"if",
"nb_parts",
"==",
"3",
":",... | Get on demand macro value
If the macro cannot be resolved, this function will return 'n/a' rather than
an empty string, this to alert the caller of a potential problem.
:param macro: macro to parse
:type macro:
:param data: data to get value from
:type data:
:re... | [
"Get",
"on",
"demand",
"macro",
"value"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/macroresolver.py#L523-L581 | train |
Alignak-monitoring/alignak | alignak/macroresolver.py | MacroResolver._tot_hosts_by_state | def _tot_hosts_by_state(self, state=None, state_type=None):
"""Generic function to get the number of host in the specified state
:param state: state to filter on
:type state: str
:param state_type: state type to filter on (HARD, SOFT)
:type state_type: str
:return: numbe... | python | def _tot_hosts_by_state(self, state=None, state_type=None):
"""Generic function to get the number of host in the specified state
:param state: state to filter on
:type state: str
:param state_type: state type to filter on (HARD, SOFT)
:type state_type: str
:return: numbe... | [
"def",
"_tot_hosts_by_state",
"(",
"self",
",",
"state",
"=",
"None",
",",
"state_type",
"=",
"None",
")",
":",
"if",
"state",
"is",
"None",
"and",
"state_type",
"is",
"None",
":",
"return",
"len",
"(",
"self",
".",
"hosts",
")",
"if",
"state_type",
":... | Generic function to get the number of host in the specified state
:param state: state to filter on
:type state: str
:param state_type: state type to filter on (HARD, SOFT)
:type state_type: str
:return: number of host in state *state*
:rtype: int | [
"Generic",
"function",
"to",
"get",
"the",
"number",
"of",
"host",
"in",
"the",
"specified",
"state"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/macroresolver.py#L648-L662 | train |
Alignak-monitoring/alignak | alignak/macroresolver.py | MacroResolver._tot_unhandled_hosts_by_state | def _tot_unhandled_hosts_by_state(self, state):
"""Generic function to get the number of unhandled problem hosts in the specified state
:param state: state to filter on
:type state:
:return: number of host in state *state* and which are not acknowledged problems
:rtype: int
... | python | def _tot_unhandled_hosts_by_state(self, state):
"""Generic function to get the number of unhandled problem hosts in the specified state
:param state: state to filter on
:type state:
:return: number of host in state *state* and which are not acknowledged problems
:rtype: int
... | [
"def",
"_tot_unhandled_hosts_by_state",
"(",
"self",
",",
"state",
")",
":",
"return",
"sum",
"(",
"1",
"for",
"h",
"in",
"self",
".",
"hosts",
"if",
"h",
".",
"state",
"==",
"state",
"and",
"h",
".",
"state_type",
"==",
"u'HARD'",
"and",
"h",
".",
"... | Generic function to get the number of unhandled problem hosts in the specified state
:param state: state to filter on
:type state:
:return: number of host in state *state* and which are not acknowledged problems
:rtype: int | [
"Generic",
"function",
"to",
"get",
"the",
"number",
"of",
"unhandled",
"problem",
"hosts",
"in",
"the",
"specified",
"state"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/macroresolver.py#L664-L673 | train |
Alignak-monitoring/alignak | alignak/macroresolver.py | MacroResolver._tot_services_by_state | def _tot_services_by_state(self, state=None, state_type=None):
"""Generic function to get the number of services in the specified state
:param state: state to filter on
:type state: str
:param state_type: state type to filter on (HARD, SOFT)
:type state_type: str
:return... | python | def _tot_services_by_state(self, state=None, state_type=None):
"""Generic function to get the number of services in the specified state
:param state: state to filter on
:type state: str
:param state_type: state type to filter on (HARD, SOFT)
:type state_type: str
:return... | [
"def",
"_tot_services_by_state",
"(",
"self",
",",
"state",
"=",
"None",
",",
"state_type",
"=",
"None",
")",
":",
"if",
"state",
"is",
"None",
"and",
"state_type",
"is",
"None",
":",
"return",
"len",
"(",
"self",
".",
"services",
")",
"if",
"state_type"... | Generic function to get the number of services in the specified state
:param state: state to filter on
:type state: str
:param state_type: state type to filter on (HARD, SOFT)
:type state_type: str
:return: number of host in state *state*
:rtype: int
TODO: Should... | [
"Generic",
"function",
"to",
"get",
"the",
"number",
"of",
"services",
"in",
"the",
"specified",
"state"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/macroresolver.py#L783-L798 | train |
Alignak-monitoring/alignak | alignak/macroresolver.py | MacroResolver._tot_unhandled_services_by_state | def _tot_unhandled_services_by_state(self, state):
"""Generic function to get the number of unhandled problem services in the specified state
:param state: state to filter on
:type state:
:return: number of service in state *state* and which are not acknowledged problems
:rtype:... | python | def _tot_unhandled_services_by_state(self, state):
"""Generic function to get the number of unhandled problem services in the specified state
:param state: state to filter on
:type state:
:return: number of service in state *state* and which are not acknowledged problems
:rtype:... | [
"def",
"_tot_unhandled_services_by_state",
"(",
"self",
",",
"state",
")",
":",
"return",
"sum",
"(",
"1",
"for",
"s",
"in",
"self",
".",
"services",
"if",
"s",
".",
"state",
"==",
"state",
"and",
"s",
".",
"is_problem",
"and",
"not",
"s",
".",
"proble... | Generic function to get the number of unhandled problem services in the specified state
:param state: state to filter on
:type state:
:return: number of service in state *state* and which are not acknowledged problems
:rtype: int | [
"Generic",
"function",
"to",
"get",
"the",
"number",
"of",
"unhandled",
"problem",
"services",
"in",
"the",
"specified",
"state"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/macroresolver.py#L800-L809 | train |
Alignak-monitoring/alignak | alignak/macroresolver.py | MacroResolver._get_total_services_problems_unhandled | def _get_total_services_problems_unhandled(self):
"""Get the number of services that are a problem and that are not acknowledged
:return: number of problem services which are not acknowledged
:rtype: int
"""
return sum(1 for s in self.services if s.is_problem and not s.problem_h... | python | def _get_total_services_problems_unhandled(self):
"""Get the number of services that are a problem and that are not acknowledged
:return: number of problem services which are not acknowledged
:rtype: int
"""
return sum(1 for s in self.services if s.is_problem and not s.problem_h... | [
"def",
"_get_total_services_problems_unhandled",
"(",
"self",
")",
":",
"return",
"sum",
"(",
"1",
"for",
"s",
"in",
"self",
".",
"services",
"if",
"s",
".",
"is_problem",
"and",
"not",
"s",
".",
"problem_has_been_acknowledged",
")"
] | Get the number of services that are a problem and that are not acknowledged
:return: number of problem services which are not acknowledged
:rtype: int | [
"Get",
"the",
"number",
"of",
"services",
"that",
"are",
"a",
"problem",
"and",
"that",
"are",
"not",
"acknowledged"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/macroresolver.py#L900-L906 | train |
Alignak-monitoring/alignak | alignak/macroresolver.py | MacroResolver._get_total_services_problems_handled | def _get_total_services_problems_handled(self):
"""
Get the number of service problems not handled
:return: Number of services which are problems and not handled
:rtype: int
"""
return sum(1 for s in self.services if s.is_problem and s.problem_has_been_acknowledged) | python | def _get_total_services_problems_handled(self):
"""
Get the number of service problems not handled
:return: Number of services which are problems and not handled
:rtype: int
"""
return sum(1 for s in self.services if s.is_problem and s.problem_has_been_acknowledged) | [
"def",
"_get_total_services_problems_handled",
"(",
"self",
")",
":",
"return",
"sum",
"(",
"1",
"for",
"s",
"in",
"self",
".",
"services",
"if",
"s",
".",
"is_problem",
"and",
"s",
".",
"problem_has_been_acknowledged",
")"
] | Get the number of service problems not handled
:return: Number of services which are problems and not handled
:rtype: int | [
"Get",
"the",
"number",
"of",
"service",
"problems",
"not",
"handled"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/macroresolver.py#L908-L915 | train |
Alignak-monitoring/alignak | alignak/misc/carboniface.py | CarbonIface.add_data | def add_data(self, metric, value, ts=None):
"""
Add data to queue
:param metric: the metric name
:type metric: str
:param value: the value of data
:type value: int
:param ts: the timestamp
:type ts: int | None
:return: True if added successfully, ... | python | def add_data(self, metric, value, ts=None):
"""
Add data to queue
:param metric: the metric name
:type metric: str
:param value: the value of data
:type value: int
:param ts: the timestamp
:type ts: int | None
:return: True if added successfully, ... | [
"def",
"add_data",
"(",
"self",
",",
"metric",
",",
"value",
",",
"ts",
"=",
"None",
")",
":",
"if",
"not",
"ts",
":",
"ts",
"=",
"time",
".",
"time",
"(",
")",
"if",
"self",
".",
"__data_lock",
".",
"acquire",
"(",
")",
":",
"self",
".",
"__da... | Add data to queue
:param metric: the metric name
:type metric: str
:param value: the value of data
:type value: int
:param ts: the timestamp
:type ts: int | None
:return: True if added successfully, otherwise False
:rtype: bool | [
"Add",
"data",
"to",
"queue"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/misc/carboniface.py#L40-L59 | train |
Alignak-monitoring/alignak | alignak/modulesmanager.py | ModulesManager.set_daemon_name | def set_daemon_name(self, daemon_name):
"""Set the daemon name of the daemon which this manager is attached to
and propagate this daemon name to our managed modules
:param daemon_name:
:return:
"""
self.daemon_name = daemon_name
for instance in self.instances:
... | python | def set_daemon_name(self, daemon_name):
"""Set the daemon name of the daemon which this manager is attached to
and propagate this daemon name to our managed modules
:param daemon_name:
:return:
"""
self.daemon_name = daemon_name
for instance in self.instances:
... | [
"def",
"set_daemon_name",
"(",
"self",
",",
"daemon_name",
")",
":",
"self",
".",
"daemon_name",
"=",
"daemon_name",
"for",
"instance",
"in",
"self",
".",
"instances",
":",
"instance",
".",
"set_loaded_into",
"(",
"daemon_name",
")"
] | Set the daemon name of the daemon which this manager is attached to
and propagate this daemon name to our managed modules
:param daemon_name:
:return: | [
"Set",
"the",
"daemon",
"name",
"of",
"the",
"daemon",
"which",
"this",
"manager",
"is",
"attached",
"to",
"and",
"propagate",
"this",
"daemon",
"name",
"to",
"our",
"managed",
"modules"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/modulesmanager.py#L90-L99 | train |
Alignak-monitoring/alignak | alignak/modulesmanager.py | ModulesManager.load_and_init | def load_and_init(self, modules):
"""Import, instantiate & "init" the modules we manage
:param modules: list of the managed modules
:return: True if no errors
"""
self.load(modules)
self.get_instances()
return len(self.configuration_errors) == 0 | python | def load_and_init(self, modules):
"""Import, instantiate & "init" the modules we manage
:param modules: list of the managed modules
:return: True if no errors
"""
self.load(modules)
self.get_instances()
return len(self.configuration_errors) == 0 | [
"def",
"load_and_init",
"(",
"self",
",",
"modules",
")",
":",
"self",
".",
"load",
"(",
"modules",
")",
"self",
".",
"get_instances",
"(",
")",
"return",
"len",
"(",
"self",
".",
"configuration_errors",
")",
"==",
"0"
] | Import, instantiate & "init" the modules we manage
:param modules: list of the managed modules
:return: True if no errors | [
"Import",
"instantiate",
"&",
"init",
"the",
"modules",
"we",
"manage"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/modulesmanager.py#L101-L110 | train |
Alignak-monitoring/alignak | alignak/modulesmanager.py | ModulesManager.load | def load(self, modules):
"""Load Python modules and check their usability
:param modules: list of the modules that must be loaded
:return:
"""
self.modules_assoc = []
for module in modules:
if not module.enabled:
logger.info("Module %s is decl... | python | def load(self, modules):
"""Load Python modules and check their usability
:param modules: list of the modules that must be loaded
:return:
"""
self.modules_assoc = []
for module in modules:
if not module.enabled:
logger.info("Module %s is decl... | [
"def",
"load",
"(",
"self",
",",
"modules",
")",
":",
"self",
".",
"modules_assoc",
"=",
"[",
"]",
"for",
"module",
"in",
"modules",
":",
"if",
"not",
"module",
".",
"enabled",
":",
"logger",
".",
"info",
"(",
"\"Module %s is declared but not enabled\"",
"... | Load Python modules and check their usability
:param modules: list of the modules that must be loaded
:return: | [
"Load",
"Python",
"modules",
"and",
"check",
"their",
"usability"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/modulesmanager.py#L112-L158 | train |
Alignak-monitoring/alignak | alignak/modulesmanager.py | ModulesManager.try_instance_init | def try_instance_init(self, instance, late_start=False):
"""Try to "initialize" the given module instance.
:param instance: instance to init
:type instance: object
:param late_start: If late_start, don't look for last_init_try
:type late_start: bool
:return: True on succ... | python | def try_instance_init(self, instance, late_start=False):
"""Try to "initialize" the given module instance.
:param instance: instance to init
:type instance: object
:param late_start: If late_start, don't look for last_init_try
:type late_start: bool
:return: True on succ... | [
"def",
"try_instance_init",
"(",
"self",
",",
"instance",
",",
"late_start",
"=",
"False",
")",
":",
"try",
":",
"instance",
".",
"init_try",
"+=",
"1",
"if",
"not",
"late_start",
"and",
"instance",
".",
"init_try",
">",
"1",
":",
"if",
"instance",
".",
... | Try to "initialize" the given module instance.
:param instance: instance to init
:type instance: object
:param late_start: If late_start, don't look for last_init_try
:type late_start: bool
:return: True on successful init. False if instance init method raised any Exception.
... | [
"Try",
"to",
"initialize",
"the",
"given",
"module",
"instance",
"."
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/modulesmanager.py#L160-L202 | train |
Alignak-monitoring/alignak | alignak/modulesmanager.py | ModulesManager.clear_instances | def clear_instances(self, instances=None):
"""Request to "remove" the given instances list or all if not provided
:param instances: instances to remove (all instances are removed if None)
:type instances:
:return: None
"""
if instances is None:
instances = se... | python | def clear_instances(self, instances=None):
"""Request to "remove" the given instances list or all if not provided
:param instances: instances to remove (all instances are removed if None)
:type instances:
:return: None
"""
if instances is None:
instances = se... | [
"def",
"clear_instances",
"(",
"self",
",",
"instances",
"=",
"None",
")",
":",
"if",
"instances",
"is",
"None",
":",
"instances",
"=",
"self",
".",
"instances",
"[",
":",
"]",
"for",
"instance",
"in",
"instances",
":",
"self",
".",
"remove_instance",
"(... | Request to "remove" the given instances list or all if not provided
:param instances: instances to remove (all instances are removed if None)
:type instances:
:return: None | [
"Request",
"to",
"remove",
"the",
"given",
"instances",
"list",
"or",
"all",
"if",
"not",
"provided"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/modulesmanager.py#L204-L214 | train |
Alignak-monitoring/alignak | alignak/modulesmanager.py | ModulesManager.set_to_restart | def set_to_restart(self, instance):
"""Put an instance to the restart queue
:param instance: instance to restart
:type instance: object
:return: None
"""
self.to_restart.append(instance)
if instance.is_external:
instance.proc = None | python | def set_to_restart(self, instance):
"""Put an instance to the restart queue
:param instance: instance to restart
:type instance: object
:return: None
"""
self.to_restart.append(instance)
if instance.is_external:
instance.proc = None | [
"def",
"set_to_restart",
"(",
"self",
",",
"instance",
")",
":",
"self",
".",
"to_restart",
".",
"append",
"(",
"instance",
")",
"if",
"instance",
".",
"is_external",
":",
"instance",
".",
"proc",
"=",
"None"
] | Put an instance to the restart queue
:param instance: instance to restart
:type instance: object
:return: None | [
"Put",
"an",
"instance",
"to",
"the",
"restart",
"queue"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/modulesmanager.py#L216-L225 | train |
Alignak-monitoring/alignak | alignak/modulesmanager.py | ModulesManager.get_instances | def get_instances(self):
"""Create, init and then returns the list of module instances that the caller needs.
This method is called once the Python modules are loaded to initialize the modules.
If an instance can't be created or initialized then only log is doneand that
instance is ski... | python | def get_instances(self):
"""Create, init and then returns the list of module instances that the caller needs.
This method is called once the Python modules are loaded to initialize the modules.
If an instance can't be created or initialized then only log is doneand that
instance is ski... | [
"def",
"get_instances",
"(",
"self",
")",
":",
"self",
".",
"clear_instances",
"(",
")",
"for",
"(",
"alignak_module",
",",
"python_module",
")",
"in",
"self",
".",
"modules_assoc",
":",
"alignak_module",
".",
"properties",
"=",
"python_module",
".",
"properti... | Create, init and then returns the list of module instances that the caller needs.
This method is called once the Python modules are loaded to initialize the modules.
If an instance can't be created or initialized then only log is doneand that
instance is skipped. The previous modules instance(... | [
"Create",
"init",
"and",
"then",
"returns",
"the",
"list",
"of",
"module",
"instances",
"that",
"the",
"caller",
"needs",
"."
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/modulesmanager.py#L227-L281 | train |
Alignak-monitoring/alignak | alignak/modulesmanager.py | ModulesManager.start_external_instances | def start_external_instances(self, late_start=False):
"""Launch external instances that are load correctly
:param late_start: If late_start, don't look for last_init_try
:type late_start: bool
:return: None
"""
for instance in [i for i in self.instances if i.is_external]... | python | def start_external_instances(self, late_start=False):
"""Launch external instances that are load correctly
:param late_start: If late_start, don't look for last_init_try
:type late_start: bool
:return: None
"""
for instance in [i for i in self.instances if i.is_external]... | [
"def",
"start_external_instances",
"(",
"self",
",",
"late_start",
"=",
"False",
")",
":",
"for",
"instance",
"in",
"[",
"i",
"for",
"i",
"in",
"self",
".",
"instances",
"if",
"i",
".",
"is_external",
"]",
":",
"if",
"not",
"self",
".",
"try_instance_ini... | Launch external instances that are load correctly
:param late_start: If late_start, don't look for last_init_try
:type late_start: bool
:return: None | [
"Launch",
"external",
"instances",
"that",
"are",
"load",
"correctly"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/modulesmanager.py#L283-L300 | train |
Alignak-monitoring/alignak | alignak/modulesmanager.py | ModulesManager.remove_instance | def remove_instance(self, instance):
"""Request to cleanly remove the given instance.
If instance is external also shutdown it cleanly
:param instance: instance to remove
:type instance: object
:return: None
"""
# External instances need to be close before (proce... | python | def remove_instance(self, instance):
"""Request to cleanly remove the given instance.
If instance is external also shutdown it cleanly
:param instance: instance to remove
:type instance: object
:return: None
"""
# External instances need to be close before (proce... | [
"def",
"remove_instance",
"(",
"self",
",",
"instance",
")",
":",
"if",
"instance",
".",
"is_external",
":",
"logger",
".",
"info",
"(",
"\"Request external process to stop for %s\"",
",",
"instance",
".",
"name",
")",
"instance",
".",
"stop_process",
"(",
")",
... | Request to cleanly remove the given instance.
If instance is external also shutdown it cleanly
:param instance: instance to remove
:type instance: object
:return: None | [
"Request",
"to",
"cleanly",
"remove",
"the",
"given",
"instance",
".",
"If",
"instance",
"is",
"external",
"also",
"shutdown",
"it",
"cleanly"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/modulesmanager.py#L302-L319 | train |
Alignak-monitoring/alignak | alignak/modulesmanager.py | ModulesManager.check_alive_instances | def check_alive_instances(self):
"""Check alive instances.
If not, log error and try to restart it
:return: None
"""
# Only for external
for instance in self.instances:
if instance in self.to_restart:
continue
if instance.is_exter... | python | def check_alive_instances(self):
"""Check alive instances.
If not, log error and try to restart it
:return: None
"""
# Only for external
for instance in self.instances:
if instance in self.to_restart:
continue
if instance.is_exter... | [
"def",
"check_alive_instances",
"(",
"self",
")",
":",
"for",
"instance",
"in",
"self",
".",
"instances",
":",
"if",
"instance",
"in",
"self",
".",
"to_restart",
":",
"continue",
"if",
"instance",
".",
"is_external",
"and",
"instance",
".",
"process",
"and",... | Check alive instances.
If not, log error and try to restart it
:return: None | [
"Check",
"alive",
"instances",
".",
"If",
"not",
"log",
"error",
"and",
"try",
"to",
"restart",
"it"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/modulesmanager.py#L321-L359 | train |
Alignak-monitoring/alignak | alignak/modulesmanager.py | ModulesManager.try_to_restart_deads | def try_to_restart_deads(self):
"""Try to reinit and restart dead instances
:return: None
"""
to_restart = self.to_restart[:]
del self.to_restart[:]
for instance in to_restart:
logger.warning("Trying to restart module: %s", instance.name)
if sel... | python | def try_to_restart_deads(self):
"""Try to reinit and restart dead instances
:return: None
"""
to_restart = self.to_restart[:]
del self.to_restart[:]
for instance in to_restart:
logger.warning("Trying to restart module: %s", instance.name)
if sel... | [
"def",
"try_to_restart_deads",
"(",
"self",
")",
":",
"to_restart",
"=",
"self",
".",
"to_restart",
"[",
":",
"]",
"del",
"self",
".",
"to_restart",
"[",
":",
"]",
"for",
"instance",
"in",
"to_restart",
":",
"logger",
".",
"warning",
"(",
"\"Trying to rest... | Try to reinit and restart dead instances
:return: None | [
"Try",
"to",
"reinit",
"and",
"restart",
"dead",
"instances"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/modulesmanager.py#L361-L381 | train |
Alignak-monitoring/alignak | alignak/modulesmanager.py | ModulesManager.stop_all | def stop_all(self):
"""Stop all module instances
:return: None
"""
logger.info('Shutting down modules...')
# Ask internal to quit if they can
for instance in self.get_internal_instances():
if hasattr(instance, 'quit') and isinstance(instance.quit, collections... | python | def stop_all(self):
"""Stop all module instances
:return: None
"""
logger.info('Shutting down modules...')
# Ask internal to quit if they can
for instance in self.get_internal_instances():
if hasattr(instance, 'quit') and isinstance(instance.quit, collections... | [
"def",
"stop_all",
"(",
"self",
")",
":",
"logger",
".",
"info",
"(",
"'Shutting down modules...'",
")",
"for",
"instance",
"in",
"self",
".",
"get_internal_instances",
"(",
")",
":",
"if",
"hasattr",
"(",
"instance",
",",
"'quit'",
")",
"and",
"isinstance",... | Stop all module instances
:return: None | [
"Stop",
"all",
"module",
"instances"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/modulesmanager.py#L417-L428 | train |
Alignak-monitoring/alignak | alignak/bin/alignak_environment.py | AlignakConfigParser.parse | def parse(self):
# pylint: disable=too-many-branches
"""
Check if some extra configuration files are existing in an `alignak.d` sub directory
near the found configuration file.
Parse the Alignak configuration file(s)
Exit the script if some errors are encountered.
... | python | def parse(self):
# pylint: disable=too-many-branches
"""
Check if some extra configuration files are existing in an `alignak.d` sub directory
near the found configuration file.
Parse the Alignak configuration file(s)
Exit the script if some errors are encountered.
... | [
"def",
"parse",
"(",
"self",
")",
":",
"sub_directory",
"=",
"'alignak.d'",
"dir_name",
"=",
"os",
".",
"path",
".",
"dirname",
"(",
"self",
".",
"configuration_file",
")",
"dir_name",
"=",
"os",
".",
"path",
".",
"join",
"(",
"dir_name",
",",
"sub_direc... | Check if some extra configuration files are existing in an `alignak.d` sub directory
near the found configuration file.
Parse the Alignak configuration file(s)
Exit the script if some errors are encountered.
:return: True/False | [
"Check",
"if",
"some",
"extra",
"configuration",
"files",
"are",
"existing",
"in",
"an",
"alignak",
".",
"d",
"sub",
"directory",
"near",
"the",
"found",
"configuration",
"file",
"."
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/bin/alignak_environment.py#L172-L242 | train |
Alignak-monitoring/alignak | alignak/bin/alignak_environment.py | AlignakConfigParser.write | def write(self, env_file):
"""
Write the Alignak configuration to a file
:param env_file: file name to dump the configuration
:type env_file: str
:return: True/False
"""
try:
with open(env_file, "w") as out_file:
self.config.write(out_... | python | def write(self, env_file):
"""
Write the Alignak configuration to a file
:param env_file: file name to dump the configuration
:type env_file: str
:return: True/False
"""
try:
with open(env_file, "w") as out_file:
self.config.write(out_... | [
"def",
"write",
"(",
"self",
",",
"env_file",
")",
":",
"try",
":",
"with",
"open",
"(",
"env_file",
",",
"\"w\"",
")",
"as",
"out_file",
":",
"self",
".",
"config",
".",
"write",
"(",
"out_file",
")",
"except",
"Exception",
"as",
"exp",
":",
"print"... | Write the Alignak configuration to a file
:param env_file: file name to dump the configuration
:type env_file: str
:return: True/False | [
"Write",
"the",
"Alignak",
"configuration",
"to",
"a",
"file"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/bin/alignak_environment.py#L244-L256 | train |
Alignak-monitoring/alignak | alignak/bin/alignak_environment.py | AlignakConfigParser.get_alignak_macros | def get_alignak_macros(self):
"""
Get the Alignak macros.
:return: a dict containing the Alignak macros
"""
macros = self.get_alignak_configuration(macros=True)
sections = self._search_sections('pack.')
for name, _ in list(sections.items()):
section_... | python | def get_alignak_macros(self):
"""
Get the Alignak macros.
:return: a dict containing the Alignak macros
"""
macros = self.get_alignak_configuration(macros=True)
sections = self._search_sections('pack.')
for name, _ in list(sections.items()):
section_... | [
"def",
"get_alignak_macros",
"(",
"self",
")",
":",
"macros",
"=",
"self",
".",
"get_alignak_configuration",
"(",
"macros",
"=",
"True",
")",
"sections",
"=",
"self",
".",
"_search_sections",
"(",
"'pack.'",
")",
"for",
"name",
",",
"_",
"in",
"list",
"(",... | Get the Alignak macros.
:return: a dict containing the Alignak macros | [
"Get",
"the",
"Alignak",
"macros",
"."
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/bin/alignak_environment.py#L292-L304 | train |
Alignak-monitoring/alignak | alignak/bin/alignak_environment.py | AlignakConfigParser.get_alignak_configuration | def get_alignak_configuration(self, section=SECTION_CONFIGURATION,
legacy_cfg=False, macros=False):
"""
Get the Alignak configuration parameters. All the variables included in
the SECTION_CONFIGURATION section except the variables starting with 'cfg'
and... | python | def get_alignak_configuration(self, section=SECTION_CONFIGURATION,
legacy_cfg=False, macros=False):
"""
Get the Alignak configuration parameters. All the variables included in
the SECTION_CONFIGURATION section except the variables starting with 'cfg'
and... | [
"def",
"get_alignak_configuration",
"(",
"self",
",",
"section",
"=",
"SECTION_CONFIGURATION",
",",
"legacy_cfg",
"=",
"False",
",",
"macros",
"=",
"False",
")",
":",
"configuration",
"=",
"self",
".",
"_search_sections",
"(",
"section",
")",
"if",
"section",
... | Get the Alignak configuration parameters. All the variables included in
the SECTION_CONFIGURATION section except the variables starting with 'cfg'
and the macros.
If `lecagy_cfg` is True, this function only returns the variables included in
the SECTION_CONFIGURATION section except the v... | [
"Get",
"the",
"Alignak",
"configuration",
"parameters",
".",
"All",
"the",
"variables",
"included",
"in",
"the",
"SECTION_CONFIGURATION",
"section",
"except",
"the",
"variables",
"starting",
"with",
"cfg",
"and",
"the",
"macros",
"."
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/bin/alignak_environment.py#L306-L345 | train |
Alignak-monitoring/alignak | alignak/bin/alignak_environment.py | AlignakConfigParser.get_daemons | def get_daemons(self, daemon_name=None, daemon_type=None):
"""
Get the daemons configuration parameters
If name is provided, get the configuration for this daemon, else,
If type is provided, get the configuration for all the daemons of this type, else
get the configuration of al... | python | def get_daemons(self, daemon_name=None, daemon_type=None):
"""
Get the daemons configuration parameters
If name is provided, get the configuration for this daemon, else,
If type is provided, get the configuration for all the daemons of this type, else
get the configuration of al... | [
"def",
"get_daemons",
"(",
"self",
",",
"daemon_name",
"=",
"None",
",",
"daemon_type",
"=",
"None",
")",
":",
"if",
"daemon_name",
"is",
"not",
"None",
":",
"sections",
"=",
"self",
".",
"_search_sections",
"(",
"'daemon.%s'",
"%",
"daemon_name",
")",
"if... | Get the daemons configuration parameters
If name is provided, get the configuration for this daemon, else,
If type is provided, get the configuration for all the daemons of this type, else
get the configuration of all the daemons.
:param daemon_name: the searched daemon name
:p... | [
"Get",
"the",
"daemons",
"configuration",
"parameters"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/bin/alignak_environment.py#L347-L372 | train |
Alignak-monitoring/alignak | alignak/bin/alignak_environment.py | AlignakConfigParser.get_modules | def get_modules(self, name=None, daemon_name=None, names_only=True):
"""
Get the modules configuration parameters
If name is provided, get the configuration for this module, else,
If daemon_name is provided, get the configuration for all the modules of this daemon, else
get the ... | python | def get_modules(self, name=None, daemon_name=None, names_only=True):
"""
Get the modules configuration parameters
If name is provided, get the configuration for this module, else,
If daemon_name is provided, get the configuration for all the modules of this daemon, else
get the ... | [
"def",
"get_modules",
"(",
"self",
",",
"name",
"=",
"None",
",",
"daemon_name",
"=",
"None",
",",
"names_only",
"=",
"True",
")",
":",
"if",
"name",
"is",
"not",
"None",
":",
"sections",
"=",
"self",
".",
"_search_sections",
"(",
"'module.'",
"+",
"na... | Get the modules configuration parameters
If name is provided, get the configuration for this module, else,
If daemon_name is provided, get the configuration for all the modules of this daemon, else
get the configuration of all the modules.
:param name: the searched module name
... | [
"Get",
"the",
"modules",
"configuration",
"parameters"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/bin/alignak_environment.py#L374-L405 | train |
Alignak-monitoring/alignak | alignak/objects/itemgroup.py | Itemgroup.copy_shell | def copy_shell(self):
"""
Copy the group properties EXCEPT the members.
Members need to be filled after manually
:return: Itemgroup object
:rtype: alignak.objects.itemgroup.Itemgroup
:return: None
"""
cls = self.__class__
new_i = cls() # create a... | python | def copy_shell(self):
"""
Copy the group properties EXCEPT the members.
Members need to be filled after manually
:return: Itemgroup object
:rtype: alignak.objects.itemgroup.Itemgroup
:return: None
"""
cls = self.__class__
new_i = cls() # create a... | [
"def",
"copy_shell",
"(",
"self",
")",
":",
"cls",
"=",
"self",
".",
"__class__",
"new_i",
"=",
"cls",
"(",
")",
"new_i",
".",
"uuid",
"=",
"self",
".",
"uuid",
"for",
"prop",
"in",
"cls",
".",
"properties",
":",
"if",
"hasattr",
"(",
"self",
",",
... | Copy the group properties EXCEPT the members.
Members need to be filled after manually
:return: Itemgroup object
:rtype: alignak.objects.itemgroup.Itemgroup
:return: None | [
"Copy",
"the",
"group",
"properties",
"EXCEPT",
"the",
"members",
".",
"Members",
"need",
"to",
"be",
"filled",
"after",
"manually"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/objects/itemgroup.py#L100-L121 | train |
Alignak-monitoring/alignak | alignak/objects/itemgroup.py | Itemgroup.add_members | def add_members(self, members):
"""Add a new member to the members list
:param members: member name
:type members: str
:return: None
"""
if not isinstance(members, list):
members = [members]
if not getattr(self, 'members', None):
self.mem... | python | def add_members(self, members):
"""Add a new member to the members list
:param members: member name
:type members: str
:return: None
"""
if not isinstance(members, list):
members = [members]
if not getattr(self, 'members', None):
self.mem... | [
"def",
"add_members",
"(",
"self",
",",
"members",
")",
":",
"if",
"not",
"isinstance",
"(",
"members",
",",
"list",
")",
":",
"members",
"=",
"[",
"members",
"]",
"if",
"not",
"getattr",
"(",
"self",
",",
"'members'",
",",
"None",
")",
":",
"self",
... | Add a new member to the members list
:param members: member name
:type members: str
:return: None | [
"Add",
"a",
"new",
"member",
"to",
"the",
"members",
"list"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/objects/itemgroup.py#L144-L157 | train |
Alignak-monitoring/alignak | alignak/objects/itemgroup.py | Itemgroup.add_unknown_members | def add_unknown_members(self, members):
"""Add a new member to the unknown members list
:param member: member name
:type member: str
:return: None
"""
if not isinstance(members, list):
members = [members]
if not hasattr(self, 'unknown_members'):
... | python | def add_unknown_members(self, members):
"""Add a new member to the unknown members list
:param member: member name
:type member: str
:return: None
"""
if not isinstance(members, list):
members = [members]
if not hasattr(self, 'unknown_members'):
... | [
"def",
"add_unknown_members",
"(",
"self",
",",
"members",
")",
":",
"if",
"not",
"isinstance",
"(",
"members",
",",
"list",
")",
":",
"members",
"=",
"[",
"members",
"]",
"if",
"not",
"hasattr",
"(",
"self",
",",
"'unknown_members'",
")",
":",
"self",
... | Add a new member to the unknown members list
:param member: member name
:type member: str
:return: None | [
"Add",
"a",
"new",
"member",
"to",
"the",
"unknown",
"members",
"list"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/objects/itemgroup.py#L159-L172 | train |
Alignak-monitoring/alignak | alignak/objects/itemgroup.py | Itemgroup.is_correct | def is_correct(self):
"""
Check if a group is valid.
Valid mean all members exists, so list of unknown_members is empty
:return: True if group is correct, otherwise False
:rtype: bool
"""
state = True
# Make members unique, remove duplicates
if s... | python | def is_correct(self):
"""
Check if a group is valid.
Valid mean all members exists, so list of unknown_members is empty
:return: True if group is correct, otherwise False
:rtype: bool
"""
state = True
# Make members unique, remove duplicates
if s... | [
"def",
"is_correct",
"(",
"self",
")",
":",
"state",
"=",
"True",
"if",
"self",
".",
"members",
":",
"self",
".",
"members",
"=",
"list",
"(",
"set",
"(",
"self",
".",
"members",
")",
")",
"if",
"self",
".",
"unknown_members",
":",
"for",
"member",
... | Check if a group is valid.
Valid mean all members exists, so list of unknown_members is empty
:return: True if group is correct, otherwise False
:rtype: bool | [
"Check",
"if",
"a",
"group",
"is",
"valid",
".",
"Valid",
"mean",
"all",
"members",
"exists",
"so",
"list",
"of",
"unknown_members",
"is",
"empty"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/objects/itemgroup.py#L174-L196 | train |
Alignak-monitoring/alignak | alignak/objects/itemgroup.py | Itemgroup.get_initial_status_brok | def get_initial_status_brok(self, extra=None):
"""
Get a brok with the group properties
`members` contains a list of uuid which we must provide the names. Thus we will replace
the default provided uuid with the members short name. The `extra` parameter, if present,
is containin... | python | def get_initial_status_brok(self, extra=None):
"""
Get a brok with the group properties
`members` contains a list of uuid which we must provide the names. Thus we will replace
the default provided uuid with the members short name. The `extra` parameter, if present,
is containin... | [
"def",
"get_initial_status_brok",
"(",
"self",
",",
"extra",
"=",
"None",
")",
":",
"if",
"extra",
"and",
"isinstance",
"(",
"extra",
",",
"Items",
")",
":",
"members",
"=",
"[",
"]",
"for",
"member_id",
"in",
"self",
".",
"members",
":",
"member",
"="... | Get a brok with the group properties
`members` contains a list of uuid which we must provide the names. Thus we will replace
the default provided uuid with the members short name. The `extra` parameter, if present,
is containing the Items to search for...
:param extra: monitoring item... | [
"Get",
"a",
"brok",
"with",
"the",
"group",
"properties"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/objects/itemgroup.py#L198-L219 | train |
Alignak-monitoring/alignak | alignak/daemon.py | Daemon.check_dir | def check_dir(self, dirname):
"""Check and create directory
:param dirname: file name
:type dirname; str
:return: None
"""
try:
os.makedirs(dirname)
dir_stat = os.stat(dirname)
print("Created the directory: %s, stat: %s" % (dirname, d... | python | def check_dir(self, dirname):
"""Check and create directory
:param dirname: file name
:type dirname; str
:return: None
"""
try:
os.makedirs(dirname)
dir_stat = os.stat(dirname)
print("Created the directory: %s, stat: %s" % (dirname, d... | [
"def",
"check_dir",
"(",
"self",
",",
"dirname",
")",
":",
"try",
":",
"os",
".",
"makedirs",
"(",
"dirname",
")",
"dir_stat",
"=",
"os",
".",
"stat",
"(",
"dirname",
")",
"print",
"(",
"\"Created the directory: %s, stat: %s\"",
"%",
"(",
"dirname",
",",
... | Check and create directory
:param dirname: file name
:type dirname; str
:return: None | [
"Check",
"and",
"create",
"directory"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/daemon.py#L789-L828 | train |
Alignak-monitoring/alignak | alignak/daemon.py | Daemon.request_stop | def request_stop(self, message='', exit_code=0):
"""Remove pid and stop daemon
:return: None
"""
# Log an error message if exit code is not 0
# Force output to stderr
if exit_code:
if message:
logger.error(message)
try:
... | python | def request_stop(self, message='', exit_code=0):
"""Remove pid and stop daemon
:return: None
"""
# Log an error message if exit code is not 0
# Force output to stderr
if exit_code:
if message:
logger.error(message)
try:
... | [
"def",
"request_stop",
"(",
"self",
",",
"message",
"=",
"''",
",",
"exit_code",
"=",
"0",
")",
":",
"if",
"exit_code",
":",
"if",
"message",
":",
"logger",
".",
"error",
"(",
"message",
")",
"try",
":",
"sys",
".",
"stderr",
".",
"write",
"(",
"me... | Remove pid and stop daemon
:return: None | [
"Remove",
"pid",
"and",
"stop",
"daemon"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/daemon.py#L874-L901 | train |
Alignak-monitoring/alignak | alignak/daemon.py | Daemon.daemon_connection_init | def daemon_connection_init(self, s_link, set_wait_new_conf=False):
"""Initialize a connection with the daemon for the provided satellite link
Initialize the connection (HTTP client) to the daemon and get its running identifier.
Returns True if it succeeds else if any error occur or the daemon i... | python | def daemon_connection_init(self, s_link, set_wait_new_conf=False):
"""Initialize a connection with the daemon for the provided satellite link
Initialize the connection (HTTP client) to the daemon and get its running identifier.
Returns True if it succeeds else if any error occur or the daemon i... | [
"def",
"daemon_connection_init",
"(",
"self",
",",
"s_link",
",",
"set_wait_new_conf",
"=",
"False",
")",
":",
"logger",
".",
"debug",
"(",
"\"Daemon connection initialization: %s %s\"",
",",
"s_link",
".",
"type",
",",
"s_link",
".",
"name",
")",
"if",
"not",
... | Initialize a connection with the daemon for the provided satellite link
Initialize the connection (HTTP client) to the daemon and get its running identifier.
Returns True if it succeeds else if any error occur or the daemon is inactive
it returns False.
Assume the daemon should be reac... | [
"Initialize",
"a",
"connection",
"with",
"the",
"daemon",
"for",
"the",
"provided",
"satellite",
"link"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/daemon.py#L937-L987 | train |
Alignak-monitoring/alignak | alignak/daemon.py | Daemon.do_load_modules | def do_load_modules(self, modules):
"""Wrapper for calling load_and_init method of modules_manager attribute
:param modules: list of modules that should be loaded by the daemon
:return: None
"""
_ts = time.time()
logger.info("Loading modules...")
if self.modules... | python | def do_load_modules(self, modules):
"""Wrapper for calling load_and_init method of modules_manager attribute
:param modules: list of modules that should be loaded by the daemon
:return: None
"""
_ts = time.time()
logger.info("Loading modules...")
if self.modules... | [
"def",
"do_load_modules",
"(",
"self",
",",
"modules",
")",
":",
"_ts",
"=",
"time",
".",
"time",
"(",
")",
"logger",
".",
"info",
"(",
"\"Loading modules...\"",
")",
"if",
"self",
".",
"modules_manager",
".",
"load_and_init",
"(",
"modules",
")",
":",
"... | Wrapper for calling load_and_init method of modules_manager attribute
:param modules: list of modules that should be loaded by the daemon
:return: None | [
"Wrapper",
"for",
"calling",
"load_and_init",
"method",
"of",
"modules_manager",
"attribute"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/daemon.py#L1179-L1203 | train |
Alignak-monitoring/alignak | alignak/daemon.py | Daemon.dump_environment | def dump_environment(self):
""" Try to dump memory
Not currently implemented feature
:return: None
"""
# Dump the Alignak configuration to a temporary ini file
path = os.path.join(tempfile.gettempdir(),
'dump-env-%s-%s-%d.ini' % (self.type, s... | python | def dump_environment(self):
""" Try to dump memory
Not currently implemented feature
:return: None
"""
# Dump the Alignak configuration to a temporary ini file
path = os.path.join(tempfile.gettempdir(),
'dump-env-%s-%s-%d.ini' % (self.type, s... | [
"def",
"dump_environment",
"(",
"self",
")",
":",
"path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"tempfile",
".",
"gettempdir",
"(",
")",
",",
"'dump-env-%s-%s-%d.ini'",
"%",
"(",
"self",
".",
"type",
",",
"self",
".",
"name",
",",
"int",
"(",
"ti... | Try to dump memory
Not currently implemented feature
:return: None | [
"Try",
"to",
"dump",
"memory"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/daemon.py#L1215-L1230 | train |
Alignak-monitoring/alignak | alignak/daemon.py | Daemon.change_to_workdir | def change_to_workdir(self):
"""Change working directory to working attribute
:return: None
"""
logger.info("Changing working directory to: %s", self.workdir)
self.check_dir(self.workdir)
try:
os.chdir(self.workdir)
except OSError as exp:
... | python | def change_to_workdir(self):
"""Change working directory to working attribute
:return: None
"""
logger.info("Changing working directory to: %s", self.workdir)
self.check_dir(self.workdir)
try:
os.chdir(self.workdir)
except OSError as exp:
... | [
"def",
"change_to_workdir",
"(",
"self",
")",
":",
"logger",
".",
"info",
"(",
"\"Changing working directory to: %s\"",
",",
"self",
".",
"workdir",
")",
"self",
".",
"check_dir",
"(",
"self",
".",
"workdir",
")",
"try",
":",
"os",
".",
"chdir",
"(",
"self... | Change working directory to working attribute
:return: None | [
"Change",
"working",
"directory",
"to",
"working",
"attribute"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/daemon.py#L1243-L1259 | train |
Alignak-monitoring/alignak | alignak/daemon.py | Daemon.unlink | def unlink(self):
"""Remove the daemon's pid file
:return: None
"""
logger.debug("Unlinking %s", self.pid_filename)
try:
os.unlink(self.pid_filename)
except OSError as exp:
logger.debug("Got an error unlinking our pid file: %s", exp) | python | def unlink(self):
"""Remove the daemon's pid file
:return: None
"""
logger.debug("Unlinking %s", self.pid_filename)
try:
os.unlink(self.pid_filename)
except OSError as exp:
logger.debug("Got an error unlinking our pid file: %s", exp) | [
"def",
"unlink",
"(",
"self",
")",
":",
"logger",
".",
"debug",
"(",
"\"Unlinking %s\"",
",",
"self",
".",
"pid_filename",
")",
"try",
":",
"os",
".",
"unlink",
"(",
"self",
".",
"pid_filename",
")",
"except",
"OSError",
"as",
"exp",
":",
"logger",
"."... | Remove the daemon's pid file
:return: None | [
"Remove",
"the",
"daemon",
"s",
"pid",
"file"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/daemon.py#L1261-L1270 | train |
Alignak-monitoring/alignak | alignak/daemon.py | Daemon.__open_pidfile | def __open_pidfile(self, write=False):
"""Open pid file in read or write mod
:param write: boolean to open file in write mod (true = write)
:type write: bool
:return: None
"""
# if problem on opening or creating file it'll be raised to the caller:
try:
... | python | def __open_pidfile(self, write=False):
"""Open pid file in read or write mod
:param write: boolean to open file in write mod (true = write)
:type write: bool
:return: None
"""
# if problem on opening or creating file it'll be raised to the caller:
try:
... | [
"def",
"__open_pidfile",
"(",
"self",
",",
"write",
"=",
"False",
")",
":",
"try",
":",
"self",
".",
"pre_log",
".",
"append",
"(",
"(",
"\"DEBUG\"",
",",
"\"Opening %s pid file: %s\"",
"%",
"(",
"'existing'",
"if",
"os",
".",
"path",
".",
"exists",
"(",... | Open pid file in read or write mod
:param write: boolean to open file in write mod (true = write)
:type write: bool
:return: None | [
"Open",
"pid",
"file",
"in",
"read",
"or",
"write",
"mod"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/daemon.py#L1290-L1313 | train |
Alignak-monitoring/alignak | alignak/daemon.py | Daemon.write_pid | def write_pid(self, pid):
""" Write pid to the pid file
:param pid: pid of the process
:type pid: None | int
:return: None
"""
self.fpid.seek(0)
self.fpid.truncate()
self.fpid.write("%d" % pid)
self.fpid.close()
del self.fpid | python | def write_pid(self, pid):
""" Write pid to the pid file
:param pid: pid of the process
:type pid: None | int
:return: None
"""
self.fpid.seek(0)
self.fpid.truncate()
self.fpid.write("%d" % pid)
self.fpid.close()
del self.fpid | [
"def",
"write_pid",
"(",
"self",
",",
"pid",
")",
":",
"self",
".",
"fpid",
".",
"seek",
"(",
"0",
")",
"self",
".",
"fpid",
".",
"truncate",
"(",
")",
"self",
".",
"fpid",
".",
"write",
"(",
"\"%d\"",
"%",
"pid",
")",
"self",
".",
"fpid",
".",... | Write pid to the pid file
:param pid: pid of the process
:type pid: None | int
:return: None | [
"Write",
"pid",
"to",
"the",
"pid",
"file"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/daemon.py#L1378-L1389 | train |
Alignak-monitoring/alignak | alignak/daemon.py | Daemon.close_fds | def close_fds(self, skip_close_fds): # pragma: no cover, not with unit tests...
"""Close all the process file descriptors.
Skip the descriptors present in the skip_close_fds list
:param skip_close_fds: list of file descriptor to preserve from closing
:type skip_close_fds: list
... | python | def close_fds(self, skip_close_fds): # pragma: no cover, not with unit tests...
"""Close all the process file descriptors.
Skip the descriptors present in the skip_close_fds list
:param skip_close_fds: list of file descriptor to preserve from closing
:type skip_close_fds: list
... | [
"def",
"close_fds",
"(",
"self",
",",
"skip_close_fds",
")",
":",
"max_fds",
"=",
"resource",
".",
"getrlimit",
"(",
"resource",
".",
"RLIMIT_NOFILE",
")",
"[",
"1",
"]",
"if",
"max_fds",
"==",
"resource",
".",
"RLIM_INFINITY",
":",
"max_fds",
"=",
"1024",... | Close all the process file descriptors.
Skip the descriptors present in the skip_close_fds list
:param skip_close_fds: list of file descriptor to preserve from closing
:type skip_close_fds: list
:return: None | [
"Close",
"all",
"the",
"process",
"file",
"descriptors",
".",
"Skip",
"the",
"descriptors",
"present",
"in",
"the",
"skip_close_fds",
"list"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/daemon.py#L1391-L1414 | train |
Alignak-monitoring/alignak | alignak/daemon.py | Daemon.do_daemon_init_and_start | def do_daemon_init_and_start(self, set_proc_title=True):
"""Main daemon function.
Clean, allocates, initializes and starts all necessary resources to go in daemon mode.
The set_proc_title parameter is mainly useful for the Alignak unit tests.
This to avoid changing the test process name... | python | def do_daemon_init_and_start(self, set_proc_title=True):
"""Main daemon function.
Clean, allocates, initializes and starts all necessary resources to go in daemon mode.
The set_proc_title parameter is mainly useful for the Alignak unit tests.
This to avoid changing the test process name... | [
"def",
"do_daemon_init_and_start",
"(",
"self",
",",
"set_proc_title",
"=",
"True",
")",
":",
"if",
"set_proc_title",
":",
"self",
".",
"set_proctitle",
"(",
"self",
".",
"name",
")",
"self",
".",
"change_to_user_group",
"(",
")",
"self",
".",
"change_to_workd... | Main daemon function.
Clean, allocates, initializes and starts all necessary resources to go in daemon mode.
The set_proc_title parameter is mainly useful for the Alignak unit tests.
This to avoid changing the test process name!
:param set_proc_title: if set (default), the process titl... | [
"Main",
"daemon",
"function",
".",
"Clean",
"allocates",
"initializes",
"and",
"starts",
"all",
"necessary",
"resources",
"to",
"go",
"in",
"daemon",
"mode",
"."
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/daemon.py#L1481-L1551 | train |
Alignak-monitoring/alignak | alignak/daemon.py | Daemon.setup_communication_daemon | def setup_communication_daemon(self):
# pylint: disable=no-member
""" Setup HTTP server daemon to listen
for incoming HTTP requests from other Alignak daemons
:return: True if initialization is ok, else False
"""
ca_cert = ssl_cert = ssl_key = server_dh = None
#... | python | def setup_communication_daemon(self):
# pylint: disable=no-member
""" Setup HTTP server daemon to listen
for incoming HTTP requests from other Alignak daemons
:return: True if initialization is ok, else False
"""
ca_cert = ssl_cert = ssl_key = server_dh = None
#... | [
"def",
"setup_communication_daemon",
"(",
"self",
")",
":",
"ca_cert",
"=",
"ssl_cert",
"=",
"ssl_key",
"=",
"server_dh",
"=",
"None",
"if",
"self",
".",
"use_ssl",
":",
"ssl_cert",
"=",
"os",
".",
"path",
".",
"abspath",
"(",
"self",
".",
"server_cert",
... | Setup HTTP server daemon to listen
for incoming HTTP requests from other Alignak daemons
:return: True if initialization is ok, else False | [
"Setup",
"HTTP",
"server",
"daemon",
"to",
"listen",
"for",
"incoming",
"HTTP",
"requests",
"from",
"other",
"Alignak",
"daemons"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/daemon.py#L1553-L1607 | train |
Alignak-monitoring/alignak | alignak/daemon.py | Daemon.set_proctitle | def set_proctitle(self, daemon_name=None):
"""Set the proctitle of the daemon
:param daemon_name: daemon instance name (eg. arbiter-master). If not provided, only the
daemon type (eg. arbiter) will be used for the process title
:type daemon_name: str
:return: None
"""
... | python | def set_proctitle(self, daemon_name=None):
"""Set the proctitle of the daemon
:param daemon_name: daemon instance name (eg. arbiter-master). If not provided, only the
daemon type (eg. arbiter) will be used for the process title
:type daemon_name: str
:return: None
"""
... | [
"def",
"set_proctitle",
"(",
"self",
",",
"daemon_name",
"=",
"None",
")",
":",
"logger",
".",
"debug",
"(",
"\"Setting my process name: %s\"",
",",
"daemon_name",
")",
"if",
"daemon_name",
":",
"setproctitle",
"(",
"\"alignak-%s %s\"",
"%",
"(",
"self",
".",
... | Set the proctitle of the daemon
:param daemon_name: daemon instance name (eg. arbiter-master). If not provided, only the
daemon type (eg. arbiter) will be used for the process title
:type daemon_name: str
:return: None | [
"Set",
"the",
"proctitle",
"of",
"the",
"daemon"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/daemon.py#L1734-L1748 | train |
Alignak-monitoring/alignak | alignak/daemon.py | Daemon.http_daemon_thread | def http_daemon_thread(self):
"""Main function of the http daemon thread will loop forever unless we stop the root daemon
The main thing is to have a pool of X concurrent requests for the http_daemon,
so "no_lock" calls can always be directly answer without having a "locked" version to
... | python | def http_daemon_thread(self):
"""Main function of the http daemon thread will loop forever unless we stop the root daemon
The main thing is to have a pool of X concurrent requests for the http_daemon,
so "no_lock" calls can always be directly answer without having a "locked" version to
... | [
"def",
"http_daemon_thread",
"(",
"self",
")",
":",
"logger",
".",
"debug",
"(",
"\"HTTP thread running\"",
")",
"try",
":",
"self",
".",
"http_daemon",
".",
"run",
"(",
")",
"except",
"PortNotFree",
"as",
"exp",
":",
"logger",
".",
"exception",
"(",
"'The... | Main function of the http daemon thread will loop forever unless we stop the root daemon
The main thing is to have a pool of X concurrent requests for the http_daemon,
so "no_lock" calls can always be directly answer without having a "locked" version to
finish. This is achieved thanks to the Ch... | [
"Main",
"function",
"of",
"the",
"http",
"daemon",
"thread",
"will",
"loop",
"forever",
"unless",
"we",
"stop",
"the",
"root",
"daemon"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/daemon.py#L1781-L1801 | train |
Alignak-monitoring/alignak | alignak/daemon.py | Daemon.make_a_pause | def make_a_pause(self, timeout=0.0001, check_time_change=True):
""" Wait up to timeout and check for system time change.
This function checks if the system time changed since the last call. If so,
the difference is returned to the caller.
The duration of this call is removed from the ti... | python | def make_a_pause(self, timeout=0.0001, check_time_change=True):
""" Wait up to timeout and check for system time change.
This function checks if the system time changed since the last call. If so,
the difference is returned to the caller.
The duration of this call is removed from the ti... | [
"def",
"make_a_pause",
"(",
"self",
",",
"timeout",
"=",
"0.0001",
",",
"check_time_change",
"=",
"True",
")",
":",
"if",
"timeout",
"==",
"0",
":",
"timeout",
"=",
"0.0001",
"if",
"not",
"check_time_change",
":",
"time",
".",
"sleep",
"(",
"timeout",
")... | Wait up to timeout and check for system time change.
This function checks if the system time changed since the last call. If so,
the difference is returned to the caller.
The duration of this call is removed from the timeout. If this duration is
greater than the required timeout, no sle... | [
"Wait",
"up",
"to",
"timeout",
"and",
"check",
"for",
"system",
"time",
"change",
"."
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/daemon.py#L1803-L1851 | train |
Alignak-monitoring/alignak | alignak/daemon.py | Daemon.wait_for_initial_conf | def wait_for_initial_conf(self, timeout=1.0):
"""Wait initial configuration from the arbiter.
Basically sleep 1.0 and check if new_conf is here
:param timeout: timeout to wait
:type timeout: int
:return: None
"""
logger.info("Waiting for initial configuration")
... | python | def wait_for_initial_conf(self, timeout=1.0):
"""Wait initial configuration from the arbiter.
Basically sleep 1.0 and check if new_conf is here
:param timeout: timeout to wait
:type timeout: int
:return: None
"""
logger.info("Waiting for initial configuration")
... | [
"def",
"wait_for_initial_conf",
"(",
"self",
",",
"timeout",
"=",
"1.0",
")",
":",
"logger",
".",
"info",
"(",
"\"Waiting for initial configuration\"",
")",
"_ts",
"=",
"time",
".",
"time",
"(",
")",
"while",
"not",
"self",
".",
"new_conf",
"and",
"not",
"... | Wait initial configuration from the arbiter.
Basically sleep 1.0 and check if new_conf is here
:param timeout: timeout to wait
:type timeout: int
:return: None | [
"Wait",
"initial",
"configuration",
"from",
"the",
"arbiter",
".",
"Basically",
"sleep",
"1",
".",
"0",
"and",
"check",
"if",
"new_conf",
"is",
"here"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/daemon.py#L1885-L1904 | train |
Alignak-monitoring/alignak | alignak/daemon.py | Daemon.watch_for_new_conf | def watch_for_new_conf(self, timeout=0):
"""Check if a new configuration was sent to the daemon
This function is called on each daemon loop turn. Basically it is a sleep...
If a new configuration was posted, this function returns True
:param timeout: timeout to wait. Default is no wai... | python | def watch_for_new_conf(self, timeout=0):
"""Check if a new configuration was sent to the daemon
This function is called on each daemon loop turn. Basically it is a sleep...
If a new configuration was posted, this function returns True
:param timeout: timeout to wait. Default is no wai... | [
"def",
"watch_for_new_conf",
"(",
"self",
",",
"timeout",
"=",
"0",
")",
":",
"logger",
".",
"debug",
"(",
"\"Watching for a new configuration, timeout: %s\"",
",",
"timeout",
")",
"self",
".",
"make_a_pause",
"(",
"timeout",
"=",
"timeout",
",",
"check_time_chang... | Check if a new configuration was sent to the daemon
This function is called on each daemon loop turn. Basically it is a sleep...
If a new configuration was posted, this function returns True
:param timeout: timeout to wait. Default is no wait time.
:type timeout: float
:return... | [
"Check",
"if",
"a",
"new",
"configuration",
"was",
"sent",
"to",
"the",
"daemon"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/daemon.py#L1927-L1940 | train |
Alignak-monitoring/alignak | alignak/daemon.py | Daemon.hook_point | def hook_point(self, hook_name, handle=None):
"""Used to call module function that may define a hook function for hook_name
Available hook points:
- `tick`, called on each daemon loop turn
- `save_retention`; called by the scheduler when live state
saving is to be done
... | python | def hook_point(self, hook_name, handle=None):
"""Used to call module function that may define a hook function for hook_name
Available hook points:
- `tick`, called on each daemon loop turn
- `save_retention`; called by the scheduler when live state
saving is to be done
... | [
"def",
"hook_point",
"(",
"self",
",",
"hook_name",
",",
"handle",
"=",
"None",
")",
":",
"full_hook_name",
"=",
"'hook_'",
"+",
"hook_name",
"for",
"module",
"in",
"self",
".",
"modules_manager",
".",
"instances",
":",
"_ts",
"=",
"time",
".",
"time",
"... | Used to call module function that may define a hook function for hook_name
Available hook points:
- `tick`, called on each daemon loop turn
- `save_retention`; called by the scheduler when live state
saving is to be done
- `load_retention`; called by the scheduler when live ... | [
"Used",
"to",
"call",
"module",
"function",
"that",
"may",
"define",
"a",
"hook",
"function",
"for",
"hook_name"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/daemon.py#L1942-L1982 | train |
Alignak-monitoring/alignak | alignak/daemon.py | Daemon.get_id | def get_id(self, details=False): # pylint: disable=unused-argument
"""Get daemon identification information
:return: A dict with the following structure
::
{
"alignak": selfAlignak instance name
"type": daemon type
"name": daemon name... | python | def get_id(self, details=False): # pylint: disable=unused-argument
"""Get daemon identification information
:return: A dict with the following structure
::
{
"alignak": selfAlignak instance name
"type": daemon type
"name": daemon name... | [
"def",
"get_id",
"(",
"self",
",",
"details",
"=",
"False",
")",
":",
"res",
"=",
"{",
"\"alignak\"",
":",
"getattr",
"(",
"self",
",",
"'alignak_name'",
",",
"'unknown'",
")",
",",
"\"type\"",
":",
"getattr",
"(",
"self",
",",
"'type'",
",",
"'unknown... | Get daemon identification information
:return: A dict with the following structure
::
{
"alignak": selfAlignak instance name
"type": daemon type
"name": daemon name
"version": Alignak version
}
:rtype: dict | [
"Get",
"daemon",
"identification",
"information"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/daemon.py#L2005-L2026 | train |
Alignak-monitoring/alignak | alignak/daemon.py | Daemon.exit_ok | def exit_ok(self, message, exit_code=None):
"""Log a message and exit
:param exit_code: if not None, exit with the provided value as exit code
:type exit_code: int
:param message: message for the exit reason
:type message: str
:return: None
"""
logger.inf... | python | def exit_ok(self, message, exit_code=None):
"""Log a message and exit
:param exit_code: if not None, exit with the provided value as exit code
:type exit_code: int
:param message: message for the exit reason
:type message: str
:return: None
"""
logger.inf... | [
"def",
"exit_ok",
"(",
"self",
",",
"message",
",",
"exit_code",
"=",
"None",
")",
":",
"logger",
".",
"info",
"(",
"\"Exiting...\"",
")",
"if",
"message",
":",
"logger",
".",
"info",
"(",
"\"-----\"",
")",
"logger",
".",
"error",
"(",
"\"Exit message: %... | Log a message and exit
:param exit_code: if not None, exit with the provided value as exit code
:type exit_code: int
:param message: message for the exit reason
:type message: str
:return: None | [
"Log",
"a",
"message",
"and",
"exit"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/daemon.py#L2075-L2093 | train |
Alignak-monitoring/alignak | alignak/daemon.py | Daemon.exit_on_error | def exit_on_error(self, message, exit_code=1):
# pylint: disable=no-self-use
"""Log generic message when getting an error and exit
:param exit_code: if not None, exit with the provided value as exit code
:type exit_code: int
:param message: message for the exit reason
:t... | python | def exit_on_error(self, message, exit_code=1):
# pylint: disable=no-self-use
"""Log generic message when getting an error and exit
:param exit_code: if not None, exit with the provided value as exit code
:type exit_code: int
:param message: message for the exit reason
:t... | [
"def",
"exit_on_error",
"(",
"self",
",",
"message",
",",
"exit_code",
"=",
"1",
")",
":",
"log",
"=",
"\"I got an unrecoverable error. I have to exit.\"",
"if",
"message",
":",
"log",
"+=",
"\"\\n-----\\nError message: %s\"",
"%",
"message",
"print",
"(",
"\"Error ... | Log generic message when getting an error and exit
:param exit_code: if not None, exit with the provided value as exit code
:type exit_code: int
:param message: message for the exit reason
:type message: str
:return: None | [
"Log",
"generic",
"message",
"when",
"getting",
"an",
"error",
"and",
"exit"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/daemon.py#L2095-L2114 | train |
Alignak-monitoring/alignak | alignak/daemon.py | Daemon.exit_on_exception | def exit_on_exception(self, raised_exception, message='', exit_code=99):
"""Log generic message when getting an unrecoverable error
:param raised_exception: raised Exception
:type raised_exception: Exception
:param message: message for the exit reason
:type message: str
... | python | def exit_on_exception(self, raised_exception, message='', exit_code=99):
"""Log generic message when getting an unrecoverable error
:param raised_exception: raised Exception
:type raised_exception: Exception
:param message: message for the exit reason
:type message: str
... | [
"def",
"exit_on_exception",
"(",
"self",
",",
"raised_exception",
",",
"message",
"=",
"''",
",",
"exit_code",
"=",
"99",
")",
":",
"self",
".",
"exit_on_error",
"(",
"message",
"=",
"message",
",",
"exit_code",
"=",
"None",
")",
"logger",
".",
"critical",... | Log generic message when getting an unrecoverable error
:param raised_exception: raised Exception
:type raised_exception: Exception
:param message: message for the exit reason
:type message: str
:param exit_code: exit with the provided value as exit code
:type exit_code:... | [
"Log",
"generic",
"message",
"when",
"getting",
"an",
"unrecoverable",
"error"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/daemon.py#L2116-L2132 | train |
Alignak-monitoring/alignak | alignak/daemon.py | Daemon.get_objects_from_from_queues | def get_objects_from_from_queues(self):
""" Get objects from "from" queues and add them.
:return: True if we got something in the queue, False otherwise.
:rtype: bool
"""
_t0 = time.time()
had_some_objects = False
for module in self.modules_manager.get_external_i... | python | def get_objects_from_from_queues(self):
""" Get objects from "from" queues and add them.
:return: True if we got something in the queue, False otherwise.
:rtype: bool
"""
_t0 = time.time()
had_some_objects = False
for module in self.modules_manager.get_external_i... | [
"def",
"get_objects_from_from_queues",
"(",
"self",
")",
":",
"_t0",
"=",
"time",
".",
"time",
"(",
")",
"had_some_objects",
"=",
"False",
"for",
"module",
"in",
"self",
".",
"modules_manager",
".",
"get_external_instances",
"(",
")",
":",
"queue",
"=",
"mod... | Get objects from "from" queues and add them.
:return: True if we got something in the queue, False otherwise.
:rtype: bool | [
"Get",
"objects",
"from",
"from",
"queues",
"and",
"add",
"them",
"."
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/daemon.py#L2134-L2166 | train |
Alignak-monitoring/alignak | alignak/downtime.py | Downtime.add_automatic_comment | def add_automatic_comment(self, ref):
"""Add comment on ref for downtime
:param ref: the host/service we want to link a comment to
:type ref: alignak.objects.schedulingitem.SchedulingItem
:return: None
"""
if self.fixed is True:
text = (DOWNTIME_FIXED_MESSAG... | python | def add_automatic_comment(self, ref):
"""Add comment on ref for downtime
:param ref: the host/service we want to link a comment to
:type ref: alignak.objects.schedulingitem.SchedulingItem
:return: None
"""
if self.fixed is True:
text = (DOWNTIME_FIXED_MESSAG... | [
"def",
"add_automatic_comment",
"(",
"self",
",",
"ref",
")",
":",
"if",
"self",
".",
"fixed",
"is",
"True",
":",
"text",
"=",
"(",
"DOWNTIME_FIXED_MESSAGE",
"%",
"(",
"ref",
".",
"my_type",
",",
"time",
".",
"strftime",
"(",
"\"%Y-%m-%d %H:%M:%S\"",
",",
... | Add comment on ref for downtime
:param ref: the host/service we want to link a comment to
:type ref: alignak.objects.schedulingitem.SchedulingItem
:return: None | [
"Add",
"comment",
"on",
"ref",
"for",
"downtime"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/downtime.py#L313-L349 | train |
Alignak-monitoring/alignak | alignak/downtime.py | Downtime.get_raise_brok | def get_raise_brok(self, host_name, service_name=''):
"""Get a start downtime brok
:param host_name: host concerned by the downtime
:type host_name
:param service_name: service concerned by the downtime
:type service_name
:return: brok with wanted data
:rtype: al... | python | def get_raise_brok(self, host_name, service_name=''):
"""Get a start downtime brok
:param host_name: host concerned by the downtime
:type host_name
:param service_name: service concerned by the downtime
:type service_name
:return: brok with wanted data
:rtype: al... | [
"def",
"get_raise_brok",
"(",
"self",
",",
"host_name",
",",
"service_name",
"=",
"''",
")",
":",
"data",
"=",
"self",
".",
"serialize",
"(",
")",
"data",
"[",
"'host'",
"]",
"=",
"host_name",
"if",
"service_name",
"!=",
"''",
":",
"data",
"[",
"'servi... | Get a start downtime brok
:param host_name: host concerned by the downtime
:type host_name
:param service_name: service concerned by the downtime
:type service_name
:return: brok with wanted data
:rtype: alignak.brok.Brok | [
"Get",
"a",
"start",
"downtime",
"brok"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/downtime.py#L379-L394 | train |
Alignak-monitoring/alignak | alignak/downtime.py | Downtime.get_expire_brok | def get_expire_brok(self, host_name, service_name=''):
"""Get an expire downtime brok
:param host_name: host concerned by the downtime
:type host_name
:param service_name: service concerned by the downtime
:type service_name
:return: brok with wanted data
:rtype:... | python | def get_expire_brok(self, host_name, service_name=''):
"""Get an expire downtime brok
:param host_name: host concerned by the downtime
:type host_name
:param service_name: service concerned by the downtime
:type service_name
:return: brok with wanted data
:rtype:... | [
"def",
"get_expire_brok",
"(",
"self",
",",
"host_name",
",",
"service_name",
"=",
"''",
")",
":",
"data",
"=",
"self",
".",
"serialize",
"(",
")",
"data",
"[",
"'host'",
"]",
"=",
"host_name",
"if",
"service_name",
"!=",
"''",
":",
"data",
"[",
"'serv... | Get an expire downtime brok
:param host_name: host concerned by the downtime
:type host_name
:param service_name: service concerned by the downtime
:type service_name
:return: brok with wanted data
:rtype: alignak.brok.Brok | [
"Get",
"an",
"expire",
"downtime",
"brok"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/downtime.py#L396-L411 | train |
Alignak-monitoring/alignak | alignak/objects/command.py | Command.fill_data_brok_from | def fill_data_brok_from(self, data, brok_type):
"""
Add properties to data if fill_brok of these class properties
is same as brok_type
:param data: dictionnary of this command
:type data: dict
:param brok_type: type of brok
:type brok_type: str
:return: N... | python | def fill_data_brok_from(self, data, brok_type):
"""
Add properties to data if fill_brok of these class properties
is same as brok_type
:param data: dictionnary of this command
:type data: dict
:param brok_type: type of brok
:type brok_type: str
:return: N... | [
"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 if fill_brok of these class properties
is same as brok_type
:param data: dictionnary of this command
:type data: dict
:param brok_type: type of brok
:type brok_type: str
:return: None | [
"Add",
"properties",
"to",
"data",
"if",
"fill_brok",
"of",
"these",
"class",
"properties",
"is",
"same",
"as",
"brok_type"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/objects/command.py#L126-L144 | train |
Alignak-monitoring/alignak | alignak/objects/servicedependency.py | Servicedependency.get_name | def get_name(self):
"""Get name based on 4 class attributes
Each attribute is substituted by '' if attribute does not exist
:return: dependent_host_name/dependent_service_description..host_name/service_description
:rtype: str
TODO: Clean this function (use format for string)
... | python | def get_name(self):
"""Get name based on 4 class attributes
Each attribute is substituted by '' if attribute does not exist
:return: dependent_host_name/dependent_service_description..host_name/service_description
:rtype: str
TODO: Clean this function (use format for string)
... | [
"def",
"get_name",
"(",
"self",
")",
":",
"return",
"getattr",
"(",
"self",
",",
"'dependent_host_name'",
",",
"''",
")",
"+",
"'/'",
"+",
"getattr",
"(",
"self",
",",
"'dependent_service_description'",
",",
"''",
")",
"+",
"'..'",
"+",
"getattr",
"(",
"... | Get name based on 4 class attributes
Each attribute is substituted by '' if attribute does not exist
:return: dependent_host_name/dependent_service_description..host_name/service_description
:rtype: str
TODO: Clean this function (use format for string) | [
"Get",
"name",
"based",
"on",
"4",
"class",
"attributes",
"Each",
"attribute",
"is",
"substituted",
"by",
"if",
"attribute",
"does",
"not",
"exist"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/objects/servicedependency.py#L108-L119 | train |
Alignak-monitoring/alignak | alignak/objects/servicedependency.py | Servicedependencies.explode_hostgroup | def explode_hostgroup(self, svc_dep, hostgroups):
# pylint: disable=too-many-locals
"""Explode a service dependency for each member of hostgroup
:param svc_dep: service dependency to explode
:type svc_dep: alignak.objects.servicedependency.Servicedependency
:param hostgroups: us... | python | def explode_hostgroup(self, svc_dep, hostgroups):
# pylint: disable=too-many-locals
"""Explode a service dependency for each member of hostgroup
:param svc_dep: service dependency to explode
:type svc_dep: alignak.objects.servicedependency.Servicedependency
:param hostgroups: us... | [
"def",
"explode_hostgroup",
"(",
"self",
",",
"svc_dep",
",",
"hostgroups",
")",
":",
"snames",
"=",
"[",
"d",
".",
"strip",
"(",
")",
"for",
"d",
"in",
"svc_dep",
".",
"service_description",
".",
"split",
"(",
"','",
")",
"]",
"dep_snames",
"=",
"[",
... | Explode a service dependency for each member of hostgroup
:param svc_dep: service dependency to explode
:type svc_dep: alignak.objects.servicedependency.Servicedependency
:param hostgroups: used to find hostgroup objects
:type hostgroups: alignak.objects.hostgroup.Hostgroups
:re... | [
"Explode",
"a",
"service",
"dependency",
"for",
"each",
"member",
"of",
"hostgroup"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/objects/servicedependency.py#L168-L204 | train |
Alignak-monitoring/alignak | alignak/objects/servicedependency.py | Servicedependencies.linkify_sd_by_s | def linkify_sd_by_s(self, hosts, services):
"""Replace dependent_service_description and service_description
in service dependency by the real object
:param hosts: host list, used to look for a specific one
:type hosts: alignak.objects.host.Hosts
:param services: service list to... | python | def linkify_sd_by_s(self, hosts, services):
"""Replace dependent_service_description and service_description
in service dependency by the real object
:param hosts: host list, used to look for a specific one
:type hosts: alignak.objects.host.Hosts
:param services: service list to... | [
"def",
"linkify_sd_by_s",
"(",
"self",
",",
"hosts",
",",
"services",
")",
":",
"to_del",
"=",
"[",
"]",
"errors",
"=",
"self",
".",
"configuration_errors",
"warns",
"=",
"self",
".",
"configuration_warnings",
"for",
"servicedep",
"in",
"self",
":",
"try",
... | Replace dependent_service_description and service_description
in service dependency by the real object
:param hosts: host list, used to look for a specific one
:type hosts: alignak.objects.host.Hosts
:param services: service list to look for a specific one
:type services: aligna... | [
"Replace",
"dependent_service_description",
"and",
"service_description",
"in",
"service",
"dependency",
"by",
"the",
"real",
"object"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/objects/servicedependency.py#L324-L379 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.