_id stringlengths 2 7 | title stringlengths 1 88 | partition stringclasses 3
values | text stringlengths 75 19.8k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q236000 | filter_host_by_group | train | def filter_host_by_group(group):
"""Filter for host
Filter on group
:param group: group name to filter
:type group: str
:return: Filter
:rtype: bool
"""
def inner_filter(items):
"""Inner filter for host. Accept if group in host.hostgroups"""
host = items["host"]
... | python | {
"resource": ""
} |
q236001 | filter_host_by_tag | train | def filter_host_by_tag(tpl):
"""Filter for host
Filter on tag
:param tpl: tag to filter
:type tpl: str
:return: Filter
:rtype: bool
"""
def inner_filter(items):
"""Inner filter for host. Accept if tag in host.tags"""
host = items["host"]
if host is None:
... | python | {
"resource": ""
} |
q236002 | filter_service_by_name | train | def filter_service_by_name(name):
"""Filter for service
Filter on name
:param name: name to filter
:type name: str
:return: Filter
:rtype: bool
"""
def inner_filter(items):
"""Inner filter for service. Accept if service_description == name"""
service = items["service"]
... | python | {
"resource": ""
} |
q236003 | filter_service_by_regex_name | train | def filter_service_by_regex_name(regex):
"""Filter for service
Filter on regex
:param regex: regex to filter
:type regex: str
:return: Filter
:rtype: bool
"""
host_re = re.compile(regex)
def inner_filter(items):
"""Inner filter for service. Accept if regex match service_des... | python | {
"resource": ""
} |
q236004 | filter_service_by_host_name | train | def filter_service_by_host_name(host_name):
"""Filter for service
Filter on host_name
:param host_name: host_name to filter
:type host_name: str
:return: Filter
:rtype: bool
"""
def inner_filter(items):
"""Inner filter for service. Accept if service.host.host_name == host_name"... | python | {
"resource": ""
} |
q236005 | filter_service_by_regex_host_name | train | def filter_service_by_regex_host_name(regex):
"""Filter for service
Filter on regex host_name
:param regex: regex to filter
:type regex: str
:return: Filter
:rtype: bool
"""
host_re = re.compile(regex)
def inner_filter(items):
"""Inner filter for service. Accept if regex ma... | python | {
"resource": ""
} |
q236006 | filter_service_by_hostgroup_name | train | def filter_service_by_hostgroup_name(group):
"""Filter for service
Filter on hostgroup
:param group: hostgroup to filter
:type group: str
:return: Filter
:rtype: bool
"""
def inner_filter(items):
"""Inner filter for service. Accept if hostgroup in service.host.hostgroups"""
... | python | {
"resource": ""
} |
q236007 | filter_service_by_host_tag_name | train | def filter_service_by_host_tag_name(tpl):
"""Filter for service
Filter on tag
:param tpl: tag to filter
:type tpl: str
:return: Filter
:rtype: bool
"""
def inner_filter(items):
"""Inner filter for service. Accept if tpl in service.host.tags"""
service = items["service"]... | python | {
"resource": ""
} |
q236008 | filter_service_by_servicegroup_name | train | def filter_service_by_servicegroup_name(group):
"""Filter for service
Filter on group
:param group: group to filter
:type group: str
:return: Filter
:rtype: bool
"""
def inner_filter(items):
"""Inner filter for service. Accept if group in service.servicegroups"""
servic... | python | {
"resource": ""
} |
q236009 | filter_host_by_bp_rule_label | train | def filter_host_by_bp_rule_label(label):
"""Filter for host
Filter on label
:param label: label to filter
:type label: str
:return: Filter
:rtype: bool
"""
def inner_filter(items):
"""Inner filter for host. Accept if label in host.labels"""
host = items["host"]
... | python | {
"resource": ""
} |
q236010 | Worker.manage_signal | train | def manage_signal(self, sig, frame): # pylint: disable=unused-argument
"""Manage signals caught by the process but I do not do anything...
our master daemon is managing our termination.
:param sig: signal caught by daemon
:type sig: str
:param frame: current stack frame
... | python | {
"resource": ""
} |
q236011 | Worker.check_for_system_time_change | train | def check_for_system_time_change(self): # pragma: no cover, hardly testable with unit tests...
"""Check if our system time change. If so, change our
:return: 0 if the difference < 900, difference else
:rtype: int
"""
now = time.time()
difference = now - self.t_each_loop... | python | {
"resource": ""
} |
q236012 | Worker.work | train | def work(self, actions_queue, returns_queue, control_queue=None): # pragma: no cover
"""Wrapper function for do_work in order to catch the exception
to see the real work, look at do_work
:param actions_queue: Global Queue Master->Slave
:type actions_queue: Queue.Queue
:param re... | python | {
"resource": ""
} |
q236013 | read_requirements | train | def read_requirements(filename='requirements.txt'):
"""Reads the list of requirements from given file.
:param filename: Filename to read the requirements from.
Uses ``'requirements.txt'`` by default.
:return: Requirments as list of strings.
"""
# allow for some leeway with the... | python | {
"resource": ""
} |
q236014 | Item.init_running_properties | train | def init_running_properties(self):
"""
Initialize the running_properties.
Each instance have own property.
:return: None
"""
for prop, entry in list(self.__class__.running_properties.items()):
val = entry.default
# Make a copy of the value for com... | python | {
"resource": ""
} |
q236015 | Item.copy | train | def copy(self):
"""
Get a copy of this item but with a new id
:return: copy of this object with a new id
:rtype: object
"""
# New dummy item with it's own running properties
copied_item = self.__class__({})
# Now, copy the properties
for prop in s... | python | {
"resource": ""
} |
q236016 | Item.clean | train | def clean(self):
"""
Clean properties only needed for initialization and configuration
:return: None
"""
for prop in ('imported_from', 'use', 'plus', 'templates', 'register'):
try:
delattr(self, prop)
except AttributeError:
... | python | {
"resource": ""
} |
q236017 | Item.load_global_conf | train | def load_global_conf(cls, global_configuration):
"""
Apply global Alignak configuration.
Some objects inherit some properties from the global configuration if they do not
define their own value. E.g. the global 'accept_passive_service_checks' is inherited
by the services as 'acc... | python | {
"resource": ""
} |
q236018 | Item.get_templates | train | def get_templates(self):
"""
Get list of templates this object use
:return: list of templates
:rtype: list
"""
use = getattr(self, 'use', '')
if isinstance(use, list):
return [n.strip() for n in use if n.strip()]
return [n.strip() for n in us... | python | {
"resource": ""
} |
q236019 | Item.get_all_plus_and_delete | train | def get_all_plus_and_delete(self):
"""
Get all self.plus items of list. We copy it, delete the original and return the copy list
:return: list of self.plus
:rtype: list
"""
res = {}
props = list(self.plus.keys()) # we delete entries, so no for ... in ...
... | python | {
"resource": ""
} |
q236020 | Item.add_error | train | def add_error(self, txt):
"""Add a message in the configuration errors list so we can print them
all in one place
Set the object configuration as not correct
:param txt: error message
:type txt: str
:return: None
"""
self.configuration_errors.append(tx... | python | {
"resource": ""
} |
q236021 | Item.is_correct | train | def is_correct(self):
"""
Check if this object is correct
This function:
- checks if the required properties are defined, ignoring special_properties if some exist
- logs the previously found warnings and errors
:return: True if it's correct, otherwise False
:rt... | python | {
"resource": ""
} |
q236022 | Item.old_properties_names_to_new | train | def old_properties_names_to_new(self):
"""
This function is used by service and hosts to transform Nagios2 parameters to Nagios3
ones, like normal_check_interval to check_interval. There is a old_parameters tab
in Classes that give such modifications to do.
:return: None
... | python | {
"resource": ""
} |
q236023 | Item.get_raw_import_values | train | def get_raw_import_values(self): # pragma: no cover, never used
"""
Get properties => values of this object
TODO: never called anywhere, still useful?
:return: dictionary of properties => values
:rtype: dict
"""
res = {}
properties = list(self.__class__... | python | {
"resource": ""
} |
q236024 | Item.del_downtime | train | def del_downtime(self, downtime_id):
"""
Delete a downtime in this object
:param downtime_id: id of the downtime to delete
:type downtime_id: int
:return: None
"""
if downtime_id in self.downtimes:
self.downtimes[downtime_id].can_be_deleted = True
... | python | {
"resource": ""
} |
q236025 | Item.get_property_value_for_brok | train | def get_property_value_for_brok(self, prop, tab):
"""
Get the property of an object and brok_transformation if needed and return the value
:param prop: property name
:type prop: str
:param tab: object with all properties of an object
:type tab: object
:return: va... | python | {
"resource": ""
} |
q236026 | Item.fill_data_brok_from | train | def fill_data_brok_from(self, data, brok_type):
"""
Add properties to 'data' parameter with properties of this object when 'brok_type'
parameter is defined in fill_brok of these properties
:param data: object to fill
:type data: object
:param brok_type: name of brok_type... | python | {
"resource": ""
} |
q236027 | Item.get_initial_status_brok | train | def get_initial_status_brok(self, extra=None):
"""
Create an initial status brok
:param extra: some extra information to be added in the brok data
:type extra: dict
:return: Brok object
:rtype: alignak.Brok
"""
data = {'uuid': self.uuid}
self.fill... | python | {
"resource": ""
} |
q236028 | Item.get_update_status_brok | train | def get_update_status_brok(self):
"""
Create an update item brok
:return: Brok object
:rtype: alignak.Brok
"""
data = {'uuid': self.uuid}
self.fill_data_brok_from(data, 'full_status')
return Brok({'type': 'update_' + self.my_type + '_status', 'data': data... | python | {
"resource": ""
} |
q236029 | Item.get_check_result_brok | train | def get_check_result_brok(self):
"""
Create check_result brok
:return: Brok object
:rtype: alignak.Brok
"""
data = {'uuid': self.uuid}
self.fill_data_brok_from(data, 'check_result')
return Brok({'type': self.my_type + '_check_result', 'data': data}) | python | {
"resource": ""
} |
q236030 | Item.dump | train | def dump(self, dump_file_name=None): # pragma: no cover, never called
# pylint: disable=unused-argument
"""
Dump Item object properties
:return: dictionary with properties
:rtype: dict
"""
dump = {}
for prop in self.properties:
if not hasattr... | python | {
"resource": ""
} |
q236031 | Items.add_items | train | def add_items(self, items, index_items):
"""
Add items to template if is template, else add in item list
:param items: items list to add
:type items: alignak.objects.item.Items
:param index_items: Flag indicating if the items should be indexed on the fly.
:type index_ite... | python | {
"resource": ""
} |
q236032 | Items.manage_conflict | train | def manage_conflict(self, item, name):
"""
Checks if an object holding the same name already exists in the index.
If so, it compares their definition order: the lowest definition order
is kept. If definition order equal, an error is risen.Item
The method returns the item that s... | python | {
"resource": ""
} |
q236033 | Items.add_template | train | def add_template(self, tpl):
"""
Add and index a template into the `templates` container.
:param tpl: The template to add
:type tpl: alignak.objects.item.Item
:return: None
"""
tpl = self.index_template(tpl)
self.templates[tpl.uuid] = tpl | python | {
"resource": ""
} |
q236034 | Items.index_template | train | def index_template(self, tpl):
"""
Indexes a template by `name` into the `name_to_template` dictionary.
:param tpl: The template to index
:type tpl: alignak.objects.item.Item
:return: None
"""
objcls = self.inner_class.my_type
name = getattr(tpl, 'name', ... | python | {
"resource": ""
} |
q236035 | Items.remove_template | train | def remove_template(self, tpl):
"""
Removes and un-index a template from the `templates` container.
:param tpl: The template to remove
:type tpl: alignak.objects.item.Item
:return: None
"""
try:
del self.templates[tpl.uuid]
except KeyError: #... | python | {
"resource": ""
} |
q236036 | Items.unindex_template | train | def unindex_template(self, tpl):
"""
Unindex a template from the `templates` container.
:param tpl: The template to un-index
:type tpl: alignak.objects.item.Item
:return: None
"""
name = getattr(tpl, 'name', '')
try:
del self.name_to_template[... | python | {
"resource": ""
} |
q236037 | Items.add_item | train | def add_item(self, item, index=True):
# pylint: disable=too-many-branches, too-many-locals, too-many-nested-blocks
"""
Add an item into our containers, and index it depending on the `index` flag.
:param item: object to add
:type item: alignak.objects.item.Item
:param ind... | python | {
"resource": ""
} |
q236038 | Items.old_properties_names_to_new | train | def old_properties_names_to_new(self): # pragma: no cover, never called
"""Convert old Nagios2 names to Nagios3 new names
TODO: still useful?
:return: None
"""
for i in itertools.chain(iter(list(self.items.values())),
iter(list(self.templates.v... | python | {
"resource": ""
} |
q236039 | Items.get_all_tags | train | def get_all_tags(self, item):
"""
Get all tags of an item
:param item: an item
:type item: Item
:return: list of tags
:rtype: list
"""
all_tags = item.get_templates()
for template_id in item.templates:
template = self.templates[templa... | python | {
"resource": ""
} |
q236040 | Items.linkify_templates | train | def linkify_templates(self):
"""
Link all templates, and create the template graph too
:return: None
"""
# First we create a list of all templates
for i in itertools.chain(iter(list(self.items.values())),
iter(list(self.templates.values()... | python | {
"resource": ""
} |
q236041 | Items.apply_partial_inheritance | train | def apply_partial_inheritance(self, prop):
"""
Define property with inheritance value of the property
:param prop: property
:type prop: str
:return: None
"""
for i in itertools.chain(iter(list(self.items.values())),
iter(list(self... | python | {
"resource": ""
} |
q236042 | Items.linkify_with_contacts | train | def linkify_with_contacts(self, contacts):
"""
Link items with contacts items
:param contacts: all contacts object
:type contacts: alignak.objects.contact.Contacts
:return: None
"""
for i in self:
if not hasattr(i, 'contacts'):
continu... | python | {
"resource": ""
} |
q236043 | Items.linkify_with_escalations | train | def linkify_with_escalations(self, escalations):
"""
Link with escalations
:param escalations: all escalations object
:type escalations: alignak.objects.escalation.Escalations
:return: None
"""
for i in self:
if not hasattr(i, 'escalations'):
... | python | {
"resource": ""
} |
q236044 | Items.explode_contact_groups_into_contacts | train | def explode_contact_groups_into_contacts(item, contactgroups):
"""
Get all contacts of contact_groups and put them in contacts container
:param item: item where have contact_groups property
:type item: object
:param contactgroups: all contactgroups object
:type contactgr... | python | {
"resource": ""
} |
q236045 | Items.linkify_with_timeperiods | train | def linkify_with_timeperiods(self, timeperiods, prop):
"""
Link items with timeperiods items
:param timeperiods: all timeperiods object
:type timeperiods: alignak.objects.timeperiod.Timeperiods
:param prop: property name
:type prop: str
:return: None
"""
... | python | {
"resource": ""
} |
q236046 | Items.linkify_with_checkmodulations | train | def linkify_with_checkmodulations(self, checkmodulations):
"""
Link checkmodulation object
:param checkmodulations: checkmodulations object
:type checkmodulations: alignak.objects.checkmodulation.Checkmodulations
:return: None
"""
for i in self:
if no... | python | {
"resource": ""
} |
q236047 | Items.linkify_s_by_module | train | def linkify_s_by_module(self, modules):
"""
Link modules to items
:param modules: Modules object (list of all the modules found in the configuration)
:type modules: alignak.objects.module.Modules
:return: None
"""
for i in self:
links_list = strip_an... | python | {
"resource": ""
} |
q236048 | Items.evaluate_hostgroup_expression | train | def evaluate_hostgroup_expression(expr, hosts, hostgroups, look_in='hostgroups'):
"""
Evaluate hostgroup expression
:param expr: an expression
:type expr: str
:param hosts: hosts object (all hosts)
:type hosts: alignak.objects.host.Hosts
:param hostgroups: hostgr... | python | {
"resource": ""
} |
q236049 | Items.get_hosts_from_hostgroups | train | def get_hosts_from_hostgroups(hgname, hostgroups):
"""
Get hosts of hostgroups
:param hgname: hostgroup name
:type hgname: str
:param hostgroups: hostgroups object (all hostgroups)
:type hostgroups: alignak.objects.hostgroup.Hostgroups
:return: list of hosts
... | python | {
"resource": ""
} |
q236050 | Items.explode_host_groups_into_hosts | train | def explode_host_groups_into_hosts(self, item, hosts, hostgroups):
"""
Get all hosts of hostgroups and add all in host_name container
:param item: the item object
:type item: alignak.objects.item.Item
:param hosts: hosts object
:type hosts: alignak.objects.host.Hosts
... | python | {
"resource": ""
} |
q236051 | Items.get_customs_properties_by_inheritance | train | def get_customs_properties_by_inheritance(self, obj):
"""
Get custom properties from the templates defined in this object
:param obj: the oject to search the property
:type obj: alignak.objects.item.Item
:return: list of custom properties
:rtype: list
"""
... | python | {
"resource": ""
} |
q236052 | Graph.add_edge | train | def add_edge(self, from_node, to_node):
"""Add edge between two node
The edge is oriented
:param from_node: node where edge starts
:type from_node: object
:param to_node: node where edge ends
:type to_node: object
:return: None
"""
# Maybe to_node... | python | {
"resource": ""
} |
q236053 | Graph.loop_check | train | def loop_check(self):
"""Check if we have a loop in the graph
:return: Nodes in loop
:rtype: list
"""
in_loop = []
# Add the tag for dfs check
for node in list(self.nodes.values()):
node['dfs_loop_status'] = 'DFS_UNCHECKED'
# Now do the job
... | python | {
"resource": ""
} |
q236054 | Graph.dfs_loop_search | train | def dfs_loop_search(self, root):
"""Main algorithm to look for loop.
It tags nodes and find ones stuck in loop.
* Init all nodes with DFS_UNCHECKED value
* DFS_TEMPORARY_CHECKED means we found it once
* DFS_OK : this node (and all sons) are fine
* DFS_NEAR_LOOP : One pro... | python | {
"resource": ""
} |
q236055 | Graph.dfs_get_all_childs | train | def dfs_get_all_childs(self, root):
"""Recursively get all sons of this node
:param root: node to get sons
:type root:
:return: sons
:rtype: list
"""
self.nodes[root]['dfs_loop_status'] = 'DFS_CHECKED'
ret = set()
# Me
ret.add(root)
... | python | {
"resource": ""
} |
q236056 | GenericInterface.identity | train | def identity(self):
"""Get the daemon identity
This will return an object containing some properties:
- alignak: the Alignak instance name
- version: the Alignak version
- type: the daemon type
- name: the daemon name
:return: daemon identity
:rtype: dic... | python | {
"resource": ""
} |
q236057 | GenericInterface.api | train | def api(self):
"""List the methods available on the daemon Web service interface
:return: a list of methods and parameters
:rtype: dict
"""
functions = [x[0]for x in inspect.getmembers(self, predicate=inspect.ismethod)
if not x[0].startswith('_')]
f... | python | {
"resource": ""
} |
q236058 | GenericInterface.stop_request | train | def stop_request(self, stop_now='0'):
"""Request the daemon to stop
If `stop_now` is set to '1' the daemon will stop now. Else, the daemon
will enter the stop wait mode. In this mode the daemon stops its activity and
waits until it receives a new `stop_now` request to stop really.
... | python | {
"resource": ""
} |
q236059 | GenericInterface.get_log_level | train | def get_log_level(self):
"""Get the current daemon log level
Returns an object with the daemon identity and a `log_level` property.
running_id
:return: current log level
:rtype: str
"""
level_names = {
logging.DEBUG: 'DEBUG', logging.INFO: 'INFO', lo... | python | {
"resource": ""
} |
q236060 | GenericInterface.set_log_level | train | 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 | {
"resource": ""
} |
q236061 | GenericInterface.stats | train | 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 | {
"resource": ""
} |
q236062 | GenericInterface._have_conf | train | 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 | {
"resource": ""
} |
q236063 | GenericInterface._results | train | 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 | {
"resource": ""
} |
q236064 | GenericInterface._broks | train | 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 | {
"resource": ""
} |
q236065 | GenericInterface._events | train | 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 | {
"resource": ""
} |
q236066 | DependencyNode.get_state | train | 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 | {
"resource": ""
} |
q236067 | DependencyNodeFactory.eval_cor_pattern | train | 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 | {
"resource": ""
} |
q236068 | DependencyNodeFactory.eval_complex_cor_pattern | train | 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 | {
"resource": ""
} |
q236069 | DependencyNodeFactory.eval_simple_cor_pattern | train | 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 | {
"resource": ""
} |
q236070 | DependencyNodeFactory.find_object | train | 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 | {
"resource": ""
} |
q236071 | Timeperiod.is_time_valid | train | 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 | {
"resource": ""
} |
q236072 | Timeperiod.get_min_from_t | train | 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 | {
"resource": ""
} |
q236073 | Timeperiod.clean_cache | train | 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 | {
"resource": ""
} |
q236074 | Timeperiod.get_next_valid_time_from_t | train | 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 | {
"resource": ""
} |
q236075 | Timeperiod.get_next_invalid_time_from_t | train | 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 | {
"resource": ""
} |
q236076 | Timeperiod.explode | train | 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 | {
"resource": ""
} |
q236077 | Timeperiod.linkify | train | 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 | {
"resource": ""
} |
q236078 | Timeperiod.check_exclude_rec | train | 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 | {
"resource": ""
} |
q236079 | Timeperiods.explode | train | def explode(self):
"""
Try to resolve each timeperiod
:return: None
"""
for t_id in self.items:
timeperiod = self.items[t_id]
timeperiod.explode() | python | {
"resource": ""
} |
q236080 | Timeperiods.linkify | train | 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 | {
"resource": ""
} |
q236081 | Timeperiods.apply_inheritance | train | 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 | {
"resource": ""
} |
q236082 | Timeperiods.is_correct | train | 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 | {
"resource": ""
} |
q236083 | Dispatcher.check_status_and_get_events | train | 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 | {
"resource": ""
} |
q236084 | Dispatcher.get_scheduler_ordered_list | train | 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 | {
"resource": ""
} |
q236085 | Dispatcher.dispatch | train | 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 | {
"resource": ""
} |
q236086 | Dispatcher.stop_request | train | 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 | {
"resource": ""
} |
q236087 | BoolProp.pythonize | train | 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 | {
"resource": ""
} |
q236088 | ToGuessProp.pythonize | train | 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 | {
"resource": ""
} |
q236089 | MonitorConnection.login | train | 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 | {
"resource": ""
} |
q236090 | MonitorConnection.logout | train | 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 | {
"resource": ""
} |
q236091 | MonitorConnection.get | train | 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 | {
"resource": ""
} |
q236092 | MonitorConnection.post | train | 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 | {
"resource": ""
} |
q236093 | MonitorConnection.patch | train | 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 | {
"resource": ""
} |
q236094 | MacroResolver.init | train | 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 | {
"resource": ""
} |
q236095 | MacroResolver._get_value_from_element | train | 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 | {
"resource": ""
} |
q236096 | MacroResolver._delete_unwanted_caracters | train | 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 | {
"resource": ""
} |
q236097 | MacroResolver.resolve_command | train | 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 | {
"resource": ""
} |
q236098 | MacroResolver._get_type_of_macro | train | 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 | {
"resource": ""
} |
q236099 | MacroResolver._resolve_ondemand | train | 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 | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.