_id stringlengths 2 7 | title stringlengths 1 88 | partition stringclasses 3
values | text stringlengths 75 19.8k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q236100 | MacroResolver._tot_hosts_by_state | train | 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 | {
"resource": ""
} |
q236101 | MacroResolver._tot_unhandled_hosts_by_state | train | 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 | {
"resource": ""
} |
q236102 | MacroResolver._tot_services_by_state | train | 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 | {
"resource": ""
} |
q236103 | MacroResolver._tot_unhandled_services_by_state | train | 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 | {
"resource": ""
} |
q236104 | MacroResolver._get_total_services_problems_unhandled | train | 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 | {
"resource": ""
} |
q236105 | MacroResolver._get_total_services_problems_handled | train | 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 | {
"resource": ""
} |
q236106 | CarbonIface.add_data | train | 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 | {
"resource": ""
} |
q236107 | ModulesManager.set_daemon_name | train | 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 | {
"resource": ""
} |
q236108 | ModulesManager.load_and_init | train | 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 | {
"resource": ""
} |
q236109 | ModulesManager.load | train | 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 | {
"resource": ""
} |
q236110 | ModulesManager.try_instance_init | train | 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 | {
"resource": ""
} |
q236111 | ModulesManager.clear_instances | train | 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 | {
"resource": ""
} |
q236112 | ModulesManager.set_to_restart | train | 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 | {
"resource": ""
} |
q236113 | ModulesManager.get_instances | train | 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 | {
"resource": ""
} |
q236114 | ModulesManager.start_external_instances | train | 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 | {
"resource": ""
} |
q236115 | ModulesManager.remove_instance | train | 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 | {
"resource": ""
} |
q236116 | ModulesManager.check_alive_instances | train | 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 | {
"resource": ""
} |
q236117 | ModulesManager.try_to_restart_deads | train | 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 | {
"resource": ""
} |
q236118 | ModulesManager.stop_all | train | 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 | {
"resource": ""
} |
q236119 | AlignakConfigParser.parse | train | 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 | {
"resource": ""
} |
q236120 | AlignakConfigParser.write | train | 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 | {
"resource": ""
} |
q236121 | AlignakConfigParser.get_alignak_macros | train | 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 | {
"resource": ""
} |
q236122 | AlignakConfigParser.get_alignak_configuration | train | 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 | {
"resource": ""
} |
q236123 | AlignakConfigParser.get_daemons | train | 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 | {
"resource": ""
} |
q236124 | AlignakConfigParser.get_modules | train | 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 | {
"resource": ""
} |
q236125 | Itemgroup.copy_shell | train | 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 | {
"resource": ""
} |
q236126 | Itemgroup.add_members | train | 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 | {
"resource": ""
} |
q236127 | Itemgroup.add_unknown_members | train | 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 | {
"resource": ""
} |
q236128 | Itemgroup.is_correct | train | 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 | {
"resource": ""
} |
q236129 | Itemgroup.get_initial_status_brok | train | 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 | {
"resource": ""
} |
q236130 | Daemon.check_dir | train | 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 | {
"resource": ""
} |
q236131 | Daemon.request_stop | train | 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 | {
"resource": ""
} |
q236132 | Daemon.daemon_connection_init | train | 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 | {
"resource": ""
} |
q236133 | Daemon.do_load_modules | train | 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 | {
"resource": ""
} |
q236134 | Daemon.dump_environment | train | 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 | {
"resource": ""
} |
q236135 | Daemon.change_to_workdir | train | 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 | {
"resource": ""
} |
q236136 | Daemon.unlink | train | 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 | {
"resource": ""
} |
q236137 | Daemon.__open_pidfile | train | 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 | {
"resource": ""
} |
q236138 | Daemon.write_pid | train | 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 | {
"resource": ""
} |
q236139 | Daemon.close_fds | train | 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 | {
"resource": ""
} |
q236140 | Daemon.do_daemon_init_and_start | train | 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 | {
"resource": ""
} |
q236141 | Daemon.setup_communication_daemon | train | 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 | {
"resource": ""
} |
q236142 | Daemon.set_proctitle | train | 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 | {
"resource": ""
} |
q236143 | Daemon.http_daemon_thread | train | 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 | {
"resource": ""
} |
q236144 | Daemon.make_a_pause | train | 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 | {
"resource": ""
} |
q236145 | Daemon.wait_for_initial_conf | train | 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 | {
"resource": ""
} |
q236146 | Daemon.watch_for_new_conf | train | 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 | {
"resource": ""
} |
q236147 | Daemon.hook_point | train | 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 | {
"resource": ""
} |
q236148 | Daemon.get_id | train | 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 | {
"resource": ""
} |
q236149 | Daemon.exit_ok | train | 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 | {
"resource": ""
} |
q236150 | Daemon.exit_on_error | train | 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 | {
"resource": ""
} |
q236151 | Daemon.exit_on_exception | train | 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 | {
"resource": ""
} |
q236152 | Daemon.get_objects_from_from_queues | train | 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 | {
"resource": ""
} |
q236153 | Downtime.add_automatic_comment | train | 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 | {
"resource": ""
} |
q236154 | Downtime.get_raise_brok | train | 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 | {
"resource": ""
} |
q236155 | Downtime.get_expire_brok | train | 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 | {
"resource": ""
} |
q236156 | Command.fill_data_brok_from | train | 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 | {
"resource": ""
} |
q236157 | Servicedependency.get_name | train | 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 | {
"resource": ""
} |
q236158 | Servicedependencies.explode_hostgroup | train | 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 | {
"resource": ""
} |
q236159 | Servicedependencies.linkify_sd_by_s | train | 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 | {
"resource": ""
} |
q236160 | Servicedependencies.linkify_sd_by_tp | train | def linkify_sd_by_tp(self, timeperiods):
"""Replace dependency_period by a real object in service dependency
:param timeperiods: list of timeperiod, used to look for a specific one
:type timeperiods: alignak.objects.timeperiod.Timeperiods
:return: None
"""
for servicedep... | python | {
"resource": ""
} |
q236161 | Servicedependencies.linkify_s_by_sd | train | def linkify_s_by_sd(self, services):
"""Add dependency in service objects
:return: None
"""
for servicedep in self:
# Only used for debugging purpose when loops are detected
setattr(servicedep, "service_description_string", "undefined")
setattr(servic... | python | {
"resource": ""
} |
q236162 | InnerMetrics.init | train | def init(self): # pylint: disable=too-many-branches
"""Called by the daemon broker to initialize the module"""
if not self.enabled:
logger.info(" the module is disabled.")
return True
try:
connections = self.test_connection()
except Exception as exp:... | python | {
"resource": ""
} |
q236163 | InnerMetrics.get_metrics_from_perfdata | train | def get_metrics_from_perfdata(self, service, perf_data):
"""Decode the performance data to build a metrics list"""
result = []
metrics = PerfDatas(perf_data)
for metric in metrics:
logger.debug("service: %s, metric: %s (%s)", service, metric, metric.__dict__)
if... | python | {
"resource": ""
} |
q236164 | InnerMetrics.send_to_tsdb | train | def send_to_tsdb(self, realm, host, service, metrics, ts, path):
"""Send performance data to time series database
Indeed this function stores metrics in the internal cache and checks if the flushing
is necessary and then flushes.
:param realm: concerned realm
:type: string
... | python | {
"resource": ""
} |
q236165 | InnerMetrics.manage_initial_service_status_brok | train | def manage_initial_service_status_brok(self, b):
"""Prepare the known services cache"""
host_name = b.data['host_name']
service_description = b.data['service_description']
service_id = host_name+"/"+service_description
logger.debug("got initial service status: %s", service_id)
... | python | {
"resource": ""
} |
q236166 | InnerMetrics.manage_initial_host_status_brok | train | def manage_initial_host_status_brok(self, b):
"""Prepare the known hosts cache"""
host_name = b.data['host_name']
logger.debug("got initial host status: %s", host_name)
self.hosts_cache[host_name] = {
'realm_name':
sanitize_name(b.data.get('realm_name', b.dat... | python | {
"resource": ""
} |
q236167 | InnerMetrics.manage_service_check_result_brok | train | def manage_service_check_result_brok(self, b): # pylint: disable=too-many-branches
"""A service check result brok has just arrived ..."""
host_name = b.data.get('host_name', None)
service_description = b.data.get('service_description', None)
if not host_name or not service_description:
... | python | {
"resource": ""
} |
q236168 | InnerMetrics.manage_host_check_result_brok | train | def manage_host_check_result_brok(self, b): # pylint: disable=too-many-branches
"""An host check result brok has just arrived..."""
host_name = b.data.get('host_name', None)
if not host_name:
return
logger.debug("host check result: %s", host_name)
# If host initial ... | python | {
"resource": ""
} |
q236169 | Comment.get_comment_brok | train | def get_comment_brok(self, host_name, service_name=''):
"""Get a comment brok
:param host_name:
:param service_name:
:return: brok with wanted data
:rtype: alignak.brok.Brok
"""
data = self.serialize()
data['host'] = host_name
if service_name:
... | python | {
"resource": ""
} |
q236170 | NotificationWays.new_inner_member | train | def new_inner_member(self, name, params):
"""Create new instance of NotificationWay with given name and parameters
and add it to the item list
:param name: notification way name
:type name: str
:param params: notification wat parameters
:type params: dict
:return... | python | {
"resource": ""
} |
q236171 | serialize | train | def serialize(obj, no_dump=False):
"""
Serialize an object.
Returns a dict containing an `_error` property if a MemoryError happens during the
object serialization. See #369.
:param obj: the object to serialize
:type obj: alignak.objects.item.Item | dict | list | str
:param no_dump: if Tru... | python | {
"resource": ""
} |
q236172 | Brok.get_event | train | def get_event(self):
"""This function returns an Event from a Brok
If the type is monitoring_log then the Brok contains a monitoring event
(alert, notification, ...) information. This function will return a tuple
with the creation time, the level and message information
:return... | python | {
"resource": ""
} |
q236173 | Brok.prepare | train | def prepare(self):
"""Un-serialize data from data attribute and add instance_id key if necessary
:return: None
"""
# Maybe the Brok is a old daemon one or was already prepared
# if so, the data is already ok
if hasattr(self, 'prepared') and not self.prepared:
... | python | {
"resource": ""
} |
q236174 | ComplexExpressionNode.resolve_elements | train | def resolve_elements(self):
"""Get element of this node recursively
Compute rules with OR or AND rule then NOT rules.
:return: set of element
:rtype: set
"""
# If it's a leaf, we just need to dump a set with the content of the node
if self.leaf:
if no... | python | {
"resource": ""
} |
q236175 | ComplexExpressionFactory.eval_cor_pattern | train | def eval_cor_pattern(self, pattern): # pylint:disable=too-many-branches
"""Parse and build recursively a tree of ComplexExpressionNode from pattern
:param pattern: pattern to parse
:type pattern: str
:return: root node of parsed tree
:type: alignak.complexexpression.ComplexExpr... | python | {
"resource": ""
} |
q236176 | ComplexExpressionFactory.find_object | train | def find_object(self, pattern):
"""Get a list of host corresponding to the pattern regarding the context
:param pattern: pattern to find
:type pattern: str
:return: Host list matching pattern (hostgroup name, template, all)
:rtype: list[alignak.objects.host.Host]
"""
... | python | {
"resource": ""
} |
q236177 | Scheduler.all_my_hosts_and_services | train | def all_my_hosts_and_services(self):
"""Create an iterator for all my known hosts and services
:return: None
"""
for what in (self.hosts, self.services):
for item in what:
yield item | python | {
"resource": ""
} |
q236178 | Scheduler.load_conf | train | def load_conf(self, instance_id, instance_name, conf):
"""Load configuration received from Arbiter and pushed by our Scheduler daemon
:param instance_name: scheduler instance name
:type instance_name: str
:param instance_id: scheduler instance id
:type instance_id: str
:... | python | {
"resource": ""
} |
q236179 | Scheduler.update_recurrent_works_tick | train | def update_recurrent_works_tick(self, conf):
"""Modify the tick value for the scheduler recurrent work
A tick is an amount of loop of the scheduler before executing the recurrent work
The provided configuration may contain some tick-function_name keys that contain
a tick value to be up... | python | {
"resource": ""
} |
q236180 | Scheduler.dump_config | train | def dump_config(self):
"""Dump scheduler configuration into a temporary file
The dumped content is JSON formatted
:return: None
"""
path = os.path.join(tempfile.gettempdir(),
'dump-cfg-scheduler-%s-%d.json' % (self.name, int(time.time())))
t... | python | {
"resource": ""
} |
q236181 | Scheduler.add_notification | train | def add_notification(self, notification):
"""Add a notification into actions list
:param notification: notification to add
:type notification: alignak.notification.Notification
:return: None
"""
if notification.uuid in self.actions:
logger.warning("Already ex... | python | {
"resource": ""
} |
q236182 | Scheduler.add_check | train | def add_check(self, check):
"""Add a check into the scheduler checks list
:param check: check to add
:type check: alignak.check.Check
:return: None
"""
if check is None:
return
if check.uuid in self.checks:
logger.debug("Already existing c... | python | {
"resource": ""
} |
q236183 | Scheduler.add_event_handler | train | def add_event_handler(self, action):
"""Add a event handler into actions list
:param action: event handler to add
:type action: alignak.eventhandler.EventHandler
:return: None
"""
if action.uuid in self.actions:
logger.info("Already existing event handler: %s... | python | {
"resource": ""
} |
q236184 | Scheduler.hook_point | train | def hook_point(self, hook_name):
"""Generic function to call modules methods if such method is avalaible
:param hook_name: function name to call
:type hook_name: str
:return:None
"""
self.my_daemon.hook_point(hook_name=hook_name, handle=self) | python | {
"resource": ""
} |
q236185 | Scheduler.clean_queues | train | def clean_queues(self):
# pylint: disable=too-many-locals
"""Reduces internal list size to max allowed
* checks and broks : 5 * length of hosts + services
* actions : 5 * length of hosts + services + contacts
:return: None
"""
# If we set the interval at 0, we b... | python | {
"resource": ""
} |
q236186 | Scheduler.update_business_values | train | def update_business_values(self):
"""Iter over host and service and update business_impact
:return: None
"""
for elt in self.all_my_hosts_and_services():
if not elt.is_problem:
was = elt.business_impact
elt.update_business_impact_value(self.ho... | python | {
"resource": ""
} |
q236187 | Scheduler.scatter_master_notifications | train | def scatter_master_notifications(self):
"""Generate children notifications from a master notification
Also update notification number
Master notification are raised when a notification must be sent out. They are not
launched by reactionners (only children are) but they are used to build... | python | {
"resource": ""
} |
q236188 | Scheduler.manage_internal_checks | train | def manage_internal_checks(self):
"""Run internal checks
:return: None
"""
if os.getenv('ALIGNAK_MANAGE_INTERNAL', '1') != '1':
return
now = time.time()
for chk in list(self.checks.values()):
if not chk.internal:
# Exclude checks t... | python | {
"resource": ""
} |
q236189 | Scheduler.reset_topology_change_flag | train | def reset_topology_change_flag(self):
"""Set topology_change attribute to False in all hosts and services
:return: None
"""
for i in self.hosts:
i.topology_change = False
for i in self.services:
i.topology_change = False | python | {
"resource": ""
} |
q236190 | Scheduler.log_initial_states | train | def log_initial_states(self):
"""Raise hosts and services initial status logs
First, raise hosts status and then services. This to allow the events log
to be a little sorted.
:return: None
"""
# Raise hosts initial status broks
for elt in self.hosts:
... | python | {
"resource": ""
} |
q236191 | Scheduler.get_retention_data | train | def get_retention_data(self): # pylint: disable=too-many-branches,too-many-statements
# pylint: disable=too-many-locals
"""Get all hosts and services data to be sent to the retention storage.
This function only prepares the data because a module is in charge of making
the data survive ... | python | {
"resource": ""
} |
q236192 | Scheduler.restore_retention_data | train | def restore_retention_data(self, data):
"""Restore retention data
Data coming from retention will override data coming from configuration
It is kinda confusing when you modify an attribute (external command) and it get saved
by retention
:param data: data from retention
... | python | {
"resource": ""
} |
q236193 | Scheduler.restore_retention_data_item | train | def restore_retention_data_item(self, data, item):
# pylint: disable=too-many-branches, too-many-locals
"""
Restore data in item
:param data: retention data of the item
:type data: dict
:param item: host or service item
:type item: alignak.objects.host.Host | ali... | python | {
"resource": ""
} |
q236194 | Scheduler.fill_initial_broks | train | def fill_initial_broks(self, broker_name):
# pylint: disable=too-many-branches
"""Create initial broks for a specific broker
:param broker_name: broker name
:type broker_name: str
:return: number of created broks
"""
broker_uuid = None
logger.debug("My br... | python | {
"resource": ""
} |
q236195 | Scheduler.get_program_status_brok | train | def get_program_status_brok(self, brok_type='program_status'):
"""Create a program status brok
Initially builds the running properties and then, if initial status brok,
get the properties from the Config class where an entry exist for the brok
'full_status'
:return: Brok with p... | python | {
"resource": ""
} |
q236196 | Scheduler.consume_results | train | def consume_results(self): # pylint: disable=too-many-branches
"""Handle results waiting in waiting_results list.
Check ref will call consume result and update their status
:return: None
"""
# All results are in self.waiting_results
# We need to get them first
q... | python | {
"resource": ""
} |
q236197 | Scheduler.get_new_actions | train | def get_new_actions(self):
"""Call 'get_new_actions' hook point
Iter over all hosts and services to add new actions in internal lists
:return: None
"""
_t0 = time.time()
self.hook_point('get_new_actions')
statsmgr.timer('hook.get-new-actions', time.time() - _t0)
... | python | {
"resource": ""
} |
q236198 | Scheduler.get_new_broks | train | def get_new_broks(self):
"""Iter over all hosts and services to add new broks in internal lists
:return: None
"""
# ask for service and hosts their broks waiting
# be eaten
for elt in self.all_my_hosts_and_services():
for brok in elt.broks:
se... | python | {
"resource": ""
} |
q236199 | Scheduler.send_broks_to_modules | train | def send_broks_to_modules(self):
"""Put broks into module queues
Only broks without sent_to_externals to True are sent
Only modules that ask for broks will get some
:return: None
"""
t00 = time.time()
nb_sent = 0
broks = []
for broker_link in list... | python | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.