class HostExtensions(BaseSchema): folder = gui_fields.FolderField( description="The folder, in which this host resides.", ) attributes = gui_fields.attributes_field( "host", "view", 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( gui_fields.HostField(), allow_none=True, load_default=None, description="In the case this is a cluster host, these are the cluster nodes.", )
"links": [ constructors.link_rel("self", constructors.collection_href("host_config")) ], } return constructors.serve_json(_hosts) @Endpoint( constructors.object_property_href("host_config", "{host_name}", "nodes"), ".../property", method="put", path_params=[{ "host_name": gui_fields.HostField( description="A cluster host.", should_be_cluster=True, ), }], etag="both", request_schema=request_schemas.UpdateNodes, response_schema=response_schemas.ObjectProperty, permissions_required=permissions.Perm("wato.all_folders"), ) def update_nodes(params): """Update the nodes of a cluster host""" host_name = params["host_name"] body = params["body"] nodes = body["nodes"] host: watolib.CREHost = watolib.Host.load_host(host_name) _require_host_etag(host) host.edit(host.attributes(), nodes)
"fix_all": "fixall", "refresh": "refresh", "only_host_labels": "only-host-labels", } @Endpoint(collection_href("service", "services"), '.../collection', method='get', response_schema=response_schemas.DomainObject, tag_group='Setup', query_params=[{ 'host_name': fields.HostField( description='The host of the discovered services.', example='example.com', required=True, ), 'discovery_phase': fields.String( description='The discovery phase of the services.', enum=sorted(SERVICE_DISCOVERY_PHASES.keys()), example='monitored', required=True, ), }]) def show_services(params): """Show all services of specific phase""" host = watolib.Host.host(params["host_name"]) discovery_request = StartDiscoveryRequest( host=host,
"refresh": "refresh", "only_host_labels": "only-host-labels", } @Endpoint( collection_href("service", "services"), ".../collection", method="get", response_schema=response_schemas.DomainObject, tag_group="Setup", query_params=[{ "host_name": gui_fields.HostField( description="The host of the discovered services.", example="example.com", required=True, ), "discovery_phase": fields.String( description="The discovery phase of the services.", enum=sorted(SERVICE_DISCOVERY_PHASES.keys()), example="monitored", required=True, ), }], ) def show_services(params) -> Response: """Show all services of specific phase""" host = Host.load_host(params["host_name"]) discovery_request = StartDiscoveryRequest(
def openapi_field(self) -> fields.Field: return fields.List( fields.HostField(should_exist=True), description="A list of parents of this host.", )
"host", "service", "hostgroup", "servicegroup", "host_by_query", "service_by_query" ] SERVICE_DESCRIPTION_SHOW = { "service_description": fields.String( description="The service description. No exception is raised when the specified service " "description does not exist", example="Memory", required=False, ) } HOST_NAME_SHOW = { "host_name": fields.HostField( description="The host name. No exception is raised when the specified host name does not exist", should_exist=None, # we do not care example="example.com", required=False, ) } class DowntimeParameter(BaseSchema): query = fields.query_field(Downtimes, required=False) @Endpoint( constructors.collection_href("downtime", "host"), "cmk/create_host", method="post", tag_group="Monitoring", skip_locking=True,