NAME

App::Netdisco::Util::ManagedConfig - ACL Manager data loaded into the config

DESCRIPTION

The config_version table holds one counter per scope. The acl counter goes up by one every time the ACL Manager writes, so a process can tell whether its copy is stale with one cheap read.

Only writes made through "acl_txn_do( $coderef )" bump it, so after editing the ACL tables by hand restart netdisco-web and netdisco-backend, or run:

UPDATE config_version SET version = version + 1 WHERE scope = 'acl';

EXPORT_OK

tenant_key

Returns the current tenant, or netdisco for the default tenant.

acl_txn_do( $coderef )

Runs $coderef in a transaction on the current tenant's database, then bumps the acl counter in that same transaction. Returns nothing. If $coderef dies nothing is bumped and the error propagates.

load_managed_config

Brings the current tenant's ACL Manager roles and named groups into portctl_by_role and host_groups, reading the ACL tables only if the counter moved since the last load. The first call in a process takes the clean YAML copy (see "capture_yaml_settings").

A failed database read never makes it die. It can die only while taking the YAML copy, if one of the two settings is a hash holding something Storable can't copy, such as a code reference, which YAML can't express. A value of either setting that isn't a hash at all counts as empty.

capture_yaml_settings

Takes the clean copy of the YAML values that the ACL Manager adds to, replacing any copy taken before. A value that isn't a hash is taken as an empty hash.

"load_managed_config" and "yaml_setting( $name )" call this themselves the first time either runs in a process, so nothing else needs to. Tests call it again after setting new YAML values.

It is taken then, not as this module loads, so that site web plugins (which Web.pm loads later) and values a test sets before its first request or job are in the copy.

yaml_setting( $name )

Returns the clean YAML copy of portctl_by_role or host_groups, without anything from the ACL Manager. Takes the copy first if this process hasn't yet.

is_reserved_group_name( $name )

True for a name a host ACL may not take, because it would replace a group Netdisco relies on: the __NAME__ groups such as __ANY__ that share/config.yml ships, and the synthesized_group_ names this module makes for each ACL row.