Пример #1
0
class HostExtensions(BaseSchema):
    folder = fields.FolderField(
        description="The folder, in which this host resides.", )
    attributes = fields.attributes_field(
        "host",
        "update",
        description="Attributes of this host.",
        example={"ipaddress": "192.168.0.123"},
    )
    effective_attributes = fields.Dict(
        description=
        "All attributes of this host and all parent folders. Format may change!",
        allow_none=True,
        example={"tag_snmp_ds": None},
    )
    is_cluster = fields.Boolean(
        description=
        "If this is a cluster host, i.e. a container for other hosts.", )
    is_offline = fields.Boolean(description="Whether the host is offline", )
    cluster_nodes = fields.List(
        fields.HostField(),
        allow_none=True,
        missing=None,
        description=
        "In the case this is a cluster host, these are the cluster nodes.",
    )
Пример #2
0
class RuleProperties(base.BaseSchema):
    cast_to_dict = True

    description = fields.String(
        description="A description for this rule to inform other users about its intent.",
        example="This rule is here to foo the bar hosts.",
    )
    comment = fields.String(
        description="Any comment string.",
        example="Created yesterday due to foo hosts behaving weird.",
    )
    documentation_url = fields.URL(
        attribute="docu_url",
        description="An URL (e.g. an internal Wiki entry) which explains this rule.",
        example="http://example.com/wiki/ConfiguringFooBarHosts",
    )
    disabled = fields.Boolean(
        description="When set to False, the rule will be evaluated. Default is False.",
        example=False,
        missing=False,
    )
Пример #3
0
    constructors.collection_href("folder_config"),
    ".../collection",
    method="get",
    query_params=[{
        "parent":
        fields.FolderField(
            description=
            "Show all sub-folders of this folder. The default is the root-folder.",
            example="/servers",
            load_default=watolib.Folder.
            root_folder,  # because we can't load it too early.
        ),
        "recursive":
        fields.Boolean(
            description=
            "List the folder (default: root) and all its sub-folders recursively.",
            example=False,
            load_default=False,
        ),
        "show_hosts":
        fields.Boolean(
            description=
            ("When set, all hosts that are stored in each folder will also be shown. "
             "On large setups this may come at a performance cost, so by default this "
             "is switched off."),
            example=False,
            load_default=False,
        ),
    }],
    response_schema=response_schemas.FolderCollection,
)
def list_folders(params):
Пример #4
0
        host.folder().delete_hosts([host.name()])
    return Response(status=204)


@Endpoint(
    constructors.object_href("host_config", "{host_name}"),
    "cmk/show",
    method="get",
    path_params=[HOST_NAME],
    query_params=[{
        "effective_attributes":
        fields.Boolean(
            missing=False,
            required=False,
            example=False,
            description=
            ("Show all effective attributes, which affect this host, not just the "
             "attributes which were set on this host specifically. This includes "
             "all attributes of all of this host's parent folders."),
        )
    }],
    etag="output",
    convert_response=True,
    response_schema=response_schemas.HostObject,
)
def show_host(params):
    """Show a host"""
    host_name = params["host_name"]
    host: watolib.CREHost = watolib.Host.host(host_name)
    if host is None:
        return problem(
Пример #5
0
)
from cmk.gui.plugins.openapi.restful_objects.parameters import HOST_NAME
from cmk.gui.plugins.openapi.utils import problem
from cmk.gui.plugins.webapi.utils import check_hostname
from cmk.gui.watolib import hosts_and_folders
from cmk.gui.watolib.host_rename import perform_rename_hosts
from cmk.gui.watolib.hosts_and_folders import CREFolder

BAKE_AGENT_PARAM_NAME = "bake_agent"
BAKE_AGENT_PARAM = {
    BAKE_AGENT_PARAM_NAME:
    fields.Boolean(
        load_default=False,
        required=False,
        example=False,
        description=
        ("Tries to bake the agents for the just created hosts. This process is started in the "
         "background after configuring the host. Please note that the backing may take some "
         "time and might block subsequent API calls. "
         "This only works when using the Enterprise Editions."),
    )
}


@Endpoint(
    constructors.collection_href("host_config"),
    "cmk/create",
    method="post",
    etag="output",
    request_schema=request_schemas.CreateHost,
    response_schema=response_schemas.HostConfigSchema,
    query_params=[BAKE_AGENT_PARAM],