[type/__uci*] Remove public-facing transaction "interface"

This commit is contained in:
Dennis Camera 2020-10-25 11:13:06 +01:00
parent a6c37095f1
commit c1ae3ccb2f
3 changed files with 10 additions and 22 deletions

View file

@ -11,8 +11,6 @@ DESCRIPTION
This cdist type can be used to alter configuration options in OpenWrt's This cdist type can be used to alter configuration options in OpenWrt's
Unified Configuration Interface (UCI) system. Unified Configuration Interface (UCI) system.
Options can be applied in batches if the ``--transaction`` parameter is used.
REQUIRED PARAMETERS REQUIRED PARAMETERS
------------------- -------------------
@ -30,9 +28,6 @@ OPTIONAL PARAMETERS
------------------- -------------------
state state
``present`` or ``absent``, defaults to ``present``. ``present`` or ``absent``, defaults to ``present``.
transaction
The name of the transaction this option belongs to.
If none is given: ``default`` is used.
type type
If the type should generate an option or a list. If the type should generate an option or a list.
One of: ``option`` or ``list``. One of: ``option`` or ``list``.
@ -55,10 +50,10 @@ EXAMPLES
# Set DHCP option 252: tell DHCP clients to not ask for proxy information. # Set DHCP option 252: tell DHCP clients to not ask for proxy information.
__uci dhcp.lan.dhcp_option --type list --value '252,"\n"' __uci dhcp.lan.dhcp_option --type list --value '252,"\n"'
# Enable NTP and NTPd (in one transaction) # Enable NTP and NTPd (each is applied individually)
__uci system.ntp.enabled --value 1 --transaction ntp __uci system.ntp.enabled --value 1
__uci system.ntp.enable_server --value 1 --transaction ntp __uci system.ntp.enable_server --value 1
__uci system.ntp.server --type list --transaction ntp \ __uci system.ntp.server --type list \
--value '0.openwrt.pool.ntp.org' \ --value '0.openwrt.pool.ntp.org' \
--value '1.openwrt.pool.ntp.org' \ --value '1.openwrt.pool.ntp.org' \
--value '2.openwrt.pool.ntp.org' \ --value '2.openwrt.pool.ntp.org' \

View file

@ -53,9 +53,6 @@ option
shell argument. shell argument.
state state
``present`` or ``absent``, defaults to ``present``. ``present`` or ``absent``, defaults to ``present``.
transaction
The name of the transaction this option belongs to.
The value will be forwarded to :strong:`cdist-type__uci`\ (7).
type type
The type of the section in the format: ``<config>.<section-type>`` The type of the section in the format: ``<config>.<section-type>``
@ -71,13 +68,13 @@ EXAMPLES
.. code-block:: sh .. code-block:: sh
# Configure the dropbear daemon # Configure the dropbear daemon
__uci_section dropbear --type dropbear.dropbear --transaction sshd \ __uci_section dropbear --type dropbear.dropbear \
--match Port=22 --option Port=22 \ --match Port=22 --option Port=22 \
--option PasswordAuth=off \ --option PasswordAuth=off \
--option RootPasswordAuth=off --option RootPasswordAuth=off
# Define a firewall zone comprised of lan and wlan networks # Define a firewall zone comprised of lan and wlan networks
__uci_section firewall.internal --type firewall.zone --transaction fw \ __uci_section firewall.internal --type firewall.zone \
--option name='internal' \ --option name='internal' \
--list network='lan' \ --list network='lan' \
--list network='wlan' \ --list network='wlan' \
@ -87,7 +84,6 @@ EXAMPLES
# Block SSH access from the guest network # Block SSH access from the guest network
__uci_section firewall.block_ssh_from_guest --type firewall.rule \ __uci_section firewall.block_ssh_from_guest --type firewall.rule \
--transaction fwrules \
--option name='Block-SSH-Access-from-Guest' \ --option name='Block-SSH-Access-from-Guest' \
--option src='guest' \ --option src='guest' \
--option proto='tcp' \ --option proto='tcp' \
@ -96,7 +92,6 @@ EXAMPLES
# Configure a Wi-Fi access point # Configure a Wi-Fi access point
__uci_section wireless.default_radio0 --type wireless.wifi-iface \ __uci_section wireless.default_radio0 --type wireless.wifi-iface \
--transaction wifi \
--option device='radio0' \ --option device='radio0' \
--option mode='ap' \ --option mode='ap' \
--option network='wlan' \ --option network='wlan' \

View file

@ -46,7 +46,6 @@ esac
section=$(cat "${__object:?}/explorer/match") section=$(cat "${__object:?}/explorer/match")
state_should=$(cat "${__object:?}/parameter/state") state_should=$(cat "${__object:?}/parameter/state")
transaction_name=$(cat "${__object:?}/parameter/transaction")
case $state_should case $state_should
in in
@ -106,8 +105,7 @@ in
fi fi
# Make sure the section itself is present # Make sure the section itself is present
__uci "${section}" --state present --transaction "${transaction_name}" \ __uci "${section}" --state present --value "${sect_type}"
--value "${sect_type}"
export require=__uci/"${section}" export require=__uci/"${section}"
# Delete options/lists not in "should" # Delete options/lists not in "should"
@ -115,7 +113,7 @@ in
| while read -r optname | while read -r optname
do do
grep_line "${optname}" "${listnames_should}" "${optnames_should}" || { grep_line "${optname}" "${listnames_should}" "${optnames_should}" || {
__uci "${section}.${optname}" --state absent --transaction "${transaction_name}" __uci "${section}.${optname}" --state absent
} </dev/null } </dev/null
done done
@ -130,14 +128,14 @@ in
| unquote_lines \ | unquote_lines \
| append_values \ | append_values \
__uci "${section}.${_optname}" --state present \ __uci "${section}.${_optname}" --state present \
--type "${_type}" --transaction "${transaction_name}" --type "${_type}"
done done
;; ;;
(absent) (absent)
# if explorer found no section there is nothing to delete # if explorer found no section there is nothing to delete
test -n "${section}" || exit 0 test -n "${section}" || exit 0
__uci "${section}" --state absent --transaction "${transaction_name}" __uci "${section}" --state absent
;; ;;
(*) (*)
printf 'Invalid --state: %s\n' "${state_should}" >&2 printf 'Invalid --state: %s\n' "${state_should}" >&2