예제 #1
0
from cmk.gui import sites
from cmk.gui.plugins.openapi.livestatus_helpers.queries import Query
from cmk.gui.plugins.openapi.livestatus_helpers.tables import Services
from cmk.gui.plugins.openapi.restful_objects.parameters import HOST_NAME
from cmk.gui.plugins.openapi.restful_objects import (
    endpoint_schema,
    constructors,
    response_schemas,
    ParamDict,
)

PARAMETERS = [
    ParamDict.create(
        'host_alias',
        'query',
        example="example",
        required=False,
        schema_type='string',
    ),
    ParamDict.create(
        'acknowledged',
        'query',
        example="0",
        required=False,
        schema_type='boolean',
    ),
    ParamDict.create(
        'in_downtime',
        'query',
        example="1",
        required=False,
예제 #2
0
    "clustered_undecided": "clustered_new",
    "clustered_vanished": "clustered_vanished",
    "clustered_ignored": "clustered_ignored",
    "active_ignored": "active_ignored",
    "custom_ignored": "custom_ignored",
    "legacy": "legacy",
    "legacy_ignored": "legacy_ignored"
}

DISCOVERY_ACTION = {"tabula-rasa": "refresh", "full-scan": "refresh"}

DISCOVERY_HOST = ParamDict.create(
    'host',
    'query',
    schema_string_pattern="[a-zA-Z][a-zA-Z0-9_-]+",
    description=(
        'Optionally the hostname for which a certain agent has '
        'been configured. If omitted you may only download this agent if you '
        'have the rights for all agents.'),
    example='example.com',
    required=True)

DISCOVERY_SOURCE_STATE = ParamDict.create(
    'discovery_state',
    'query',
    description=(
        'The discovery state of the services. May be one of the following: ' +
        ', '.join(sorted(SERVICE_DISCOVERY_STATES.keys()))),
    schema_string_pattern='|'.join(sorted(SERVICE_DISCOVERY_STATES.keys())),
    example='monitored',
    required=True)
예제 #3
0
# conditions defined in the file COPYING, which is part of this source code package.
"""Activate changes"""
from cmk.gui import watolib
from cmk.gui.globals import request
from cmk.gui.http import Response
from cmk.gui.plugins.openapi.restful_objects import (
    constructors,
    endpoint_schema,
    response_schemas,
    ParamDict,
)

ACTIVATION_ID = ParamDict.create(
    'activation_id',
    'path',
    description='The activation-id.',
    required=True,
    schema_type='string',
    example='d3b07384d113e0ec49eaa6238ad5ff00',
)


@endpoint_schema(constructors.domain_type_action_href('activation_run',
                                                      'activate-changes'),
                 'cmk/activate',
                 method='post',
                 response_schema=response_schemas.DomainObject)
def activate_changes(params):
    """Activate pending changes."""
    body = params.get('body', {})
    sites = body.get('sites', [])
    activation_id = watolib.activate_changes_start(sites)
예제 #4
0
from cmk.gui.plugins.openapi.endpoints.utils import add_if_missing, verify_columns
from cmk.gui.plugins.openapi.livestatus_helpers.queries import Query
from cmk.gui.plugins.openapi.livestatus_helpers.tables import Services
from cmk.gui.plugins.openapi.restful_objects.parameters import HOST_NAME
from cmk.gui.plugins.openapi.restful_objects import (
    endpoint_schema,
    constructors,
    response_schemas,
    ParamDict,
)

PARAMETERS = [
    ParamDict.create(
        'host_alias',
        'query',
        example="example",
        required=False,
        schema_type='string',
    ),
    ParamDict.create(
        'acknowledged',
        'query',
        example="0",
        required=False,
        schema_type='boolean',
    ),
    ParamDict.create(
        'in_downtime',
        'query',
        example="1",
        required=False,
예제 #5
0
파일: downtime.py 프로젝트: majma24/checkmk
from cmk.gui.plugins.openapi.livestatus_helpers.tables.downtimes import Downtimes
from cmk.gui.plugins.openapi.restful_objects import (
    endpoint_schema,
    request_schemas,
    constructors,
    response_schemas,
    ParamDict,
)
from cmk.gui.watolib.downtime import (
    execute_livestatus_command,
    remove_downtime_command,
)

DOWNTIME_ID = ParamDict.create('downtime_id',
                               'path',
                               description='The id of the downtime',
                               example='54',
                               required=True)

DowntimeType = Literal['host', 'service', 'hostgroup', 'servicegroup']


@endpoint_schema(constructors.collection_href('downtime'),
                 'cmk/create',
                 method='post',
                 request_schema=request_schemas.CreateDowntime,
                 output_empty=True)
def create_downtime(params):
    """Create downtime"""
    body = params['body']
    downtime_type: DowntimeType = body['downtime_type']
예제 #6
0
        persistent=bool(params.get('persistent')),
        user=_user_id(),
        comment=params.get('comment', 'Acknowledged'),
    )
    return http.Response(status=204)


@endpoint_schema(constructors.object_action_href('hostgroup',
                                                 '{hostgroup_name}',
                                                 'acknowledge'),
                 'cmk/create',
                 method='post',
                 parameters=[
                     ParamDict.create('hostgroup_name',
                                      'path',
                                      description='The name of the host group',
                                      example='samples',
                                      required=True),
                 ],
                 request_schema=request_schemas.AcknowledgeHostProblem,
                 output_empty=True)
def set_acknowledgement_on_hostgroup(params):
    """Acknowledge problems for hosts of a host group"""
    body = params['body']
    acknowledge_hostgroup_problem(
        sites.live(),
        params['hostgroup_name'],
        sticky=body['sticky'],
        notify=body['notify'],
        persistent=body['persistent'],
        user=config.user.ident,
예제 #7
0
from cmk.gui.plugins.openapi.restful_objects.parameters import HOST_NAME


@endpoint_schema(constructors.collection_href('host'),
                 '.../collection',
                 method='get',
                 parameters=[
                     HOST_NAME(
                         location='query',
                         required=False,
                         description=Hosts.name.__doc__,
                     ),
                     ParamDict.create(
                         'host_alias',
                         'query',
                         required=False,
                         description=Hosts.alias.__doc__,
                         schema_type='string',
                     ),
                     ParamDict.create(
                         'acknowledged',
                         'query',
                         required=False,
                         example='1',
                         description=Hosts.acknowledged.__doc__,
                         schema_type='boolean',
                     ),
                     ParamDict.create(
                         'in_downtime',
                         'query',
                         required=False,
예제 #8
0
파일: host.py 프로젝트: majma24/checkmk

@endpoint_schema(
    constructors.collection_href('host'),
    '.../collection',
    method='get',
    parameters=[
        HOST_NAME(
            location='query',
            required=False,
            description=Hosts.name.__doc__,
        ),
        ParamDict.create(
            'host_alias',
            'query',
            required=False,
            description=Hosts.alias.__doc__,
            schema_type='string',
        ),
        ParamDict.create(
            'acknowledged',
            'query',
            required=False,
            example='1',
            description=Hosts.acknowledged.__doc__,
            schema_type='boolean',
        ),
        ParamDict.create(
            'in_downtime',
            'query',
            required=False,
예제 #9
0
                                                     constructors,
                                                     response_schemas)

RECURRING_OPTIONS = {
    "hour": 1,
    "day": 2,
    "week": 3,
    "second week": 4,
    "fourth week": 5,
    "same weekday": 6,
    "same day of the month": 7
}

DOWNTIME_ID = ParamDict.create('downtime_id',
                               'path',
                               description='The id of the downtime',
                               example='54',
                               required=True)


@endpoint_schema(constructors.collection_href('downtime'),
                 'cmk/create',
                 method='post',
                 request_schema=request_schemas.CreateDowntime,
                 output_empty=True)
def create_downtime(params):
    body = params['body']
    host_name = body['host_name']
    start_dt = _time_dt(body['start_time'])
    end_dt = _time_dt(body['end_time'])
    delayed_duration = body.get("delayed_duration", 0)