def serialize_host(host: watolib.CREHost, effective_attributes: bool): extensions = { "folder": host.folder().path(), "attributes": host.attributes(), "effective_attributes": host.effective_attributes() if effective_attributes else None, "is_cluster": host.is_cluster(), "is_offline": host.is_offline(), "cluster_nodes": host.cluster_nodes(), } agent_links = [] if not cmk_version.is_raw_edition(): import cmk.gui.cee.agent_bakery as agent_bakery # pylint: disable=no-name-in-module for agent_type in sorted(agent_bakery.agent_package_types().keys()): agent_links.append( constructors.link_rel( rel="cmk/download", href="{}?{}".format( constructors.domain_type_action_href( "agent", "download"), urlencode({ "os_type": agent_type, "host_name": host.id() }), ), method="get", title=f"Download the {agent_type} agent of the host.", )) return constructors.domain_object( domain_type="host_config", identifier=host.id(), title=host.alias() or host.name(), links=[ constructors.link_rel( rel="cmk/folder_config", href=constructors.object_href("folder_config", folder_slug(host.folder())), method="get", title="The folder config of the host.", ), ] + agent_links, extensions=extensions, )
def serialize_host(host: watolib.CREHost, effective_attributes: bool): extensions = { "folder": host.folder().path(), "attributes": host.attributes(), "effective_attributes": host.effective_attributes() if effective_attributes else None, "is_cluster": host.is_cluster(), "is_offline": host.is_offline(), "cluster_nodes": host.cluster_nodes(), } return constructors.domain_object( domain_type="host_config", identifier=host.id(), title=host.alias() or host.name(), links=[ constructors.link_rel( rel="cmk/folder_config", href=constructors.object_href("folder_config", folder_slug(host.folder())), method="get", title="The folder config of the host.", ), ], extensions=extensions, )
def serialize_host(host: watolib.CREHost, effective_attributes: bool): if effective_attributes: attributes = host.effective_attributes() else: attributes = host.attributes() if 'meta_data' in attributes: attributes = attributes.copy() del attributes['meta_data'] return constructors.domain_object( domain_type='host_config', identifier=host.id(), title=host.alias(), links=[ constructors.link_rel( rel='cmk/folder_config', href=constructors.object_href('folder_config', folder_slug(host.folder())), method='get', title='The folder config of the host.', ), ], extensions={ 'attributes': attributes, 'is_cluster': host.is_cluster(), 'is_offline': host.is_offline(), 'cluster_nodes': host.cluster_nodes(), }, )
def serialize_host(host: watolib.CREHost, effective_attributes: bool): extensions = { 'folder': host.folder().path(), 'attributes': host.attributes(), 'effective_attributes': host.effective_attributes() if effective_attributes else None, 'is_cluster': host.is_cluster(), 'is_offline': host.is_offline(), 'cluster_nodes': host.cluster_nodes(), } return constructors.domain_object( domain_type='host_config', identifier=host.id(), title=host.alias() or host.name(), links=[ constructors.link_rel( rel='cmk/folder_config', href=constructors.object_href('folder_config', folder_slug(host.folder())), method='get', title='The folder config of the host.', ), ], extensions=extensions, )