from bundlewrap.metadata import atomic

defaults = {
    'apt': {
        'packages': {
            'rsyslog': {},
        },
    },
    'icinga2_api': {
        'rsyslog': {
            'services': {
                'RSYSLOGD PROCESS': {
                    'command_on_monitored_host': '/usr/local/share/icinga/plugins/check_systemd_unit rsyslog',
                },
            },
        },
    },
}


@metadata_reactor.provides(
    'firewall/port_rules',
)
def firewall(metadata):
    return {
        'firewall': {
            'port_rules': {
                '514/tcp': atomic(metadata.get('rsyslogd/restrict-to', set())),
                '514/udp': atomic(metadata.get('rsyslogd/restrict-to', set())),
            },
        },
    }
