% for monitored_node in sorted(monitored_nodes):
object Host "${monitored_node.name}" {
    import "generic-host"

    address = "${monitored_node.metadata.get('icinga_options/hostname', monitored_node.hostname)}"

    # used for determining service groups
    vars.bw_groups = [ "${'", "'.join(sorted({group.name for group in monitored_node.groups}))}" ]
    vars.location = "${monitored_node.metadata.get('location', 'unknown')}"
    vars.os = "${monitored_node.os}"

    # used for status page
    vars.pretty_name = "${monitored_node.metadata.get('icinga_options/pretty_name', monitored_node.name)}"

    vars.period = "${sla_info[monitored_node.metadata.get('sla', '24x7')]}"
    vars.sla = "${monitored_node.metadata.get('sla', '24x7')}"

    vars.notification.sms = ${str(monitored_node.metadata.get('icinga_options/vars.notification.sms', True)).lower()}
    vars.notification.mail = true
}
%   for depends_on_host in sorted(monitored_node.metadata.get('icinga_options/also_affected_by', set())):
object Dependency "${monitored_node.name}_depends_on_${depends_on_host}" {
    parent_host_name = "${depends_on_host}"
    child_host_name = "${monitored_node.name}"
    states = [ Up ]
    disable_checks = true
    disable_notifications = true
    ignore_soft_states = true
}
%   endfor
% endfor

apply Dependency "disable-service-checks-on-host-down" to Service {
    disable_checks = true
    ignore_soft_states = true
    assign where true
}
