Date: Fri, 20 Nov 2015 13:06:16 -0500 From: Allan Jude <allanjude@freebsd.org> To: freebsd-hackers@freebsd.org Subject: Re: libUCL / UCL as FreeBSD config question Message-ID: <564F6118.5030702@freebsd.org> In-Reply-To: <5B598F72-C5DD-48FD-866D-F90E117D646E@rdsor.ro> References: <5B598F72-C5DD-48FD-866D-F90E117D646E@rdsor.ro>
next in thread | previous in thread | raw e-mail | index | archive | help
This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --9I3qhLKErGJfVQgDCDFMlNUEprM7bsUTP Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 2015-11-18 02:55, Dan Partelly wrote: > Hi all, >=20 >=20 > is LibUCL able to read in memory a UCL key-value database , modify it i= n various ways : >=20 > 1. Add a new key-value pair > 2. Modify the value of a value >=20 > and serialise the modified database back to disk ? >=20 > Or it is designed only a one way / read-only configuration mechanism ? = >=20 > The reason Im asking is this:=20 >=20 > if UCL becomes the new config mechanism of FreeBSD, does it brings any = other advantage=20 > than an easy to read and humanly write format ? Would this library/lang= uage be usable in=20 > any other way in system configuration =E2=80=94 apart from autoexec.bat= way =E2=80=94> use command line tool > to read key-vaule , filter it with some tool back to plain **text** an= d feed it to a command line utility > from FreeBSD base ?=20 >=20 > Let=E2=80=99s say one writes a network config daemon to handle network = configuration, and expose network=20 > configuration (like interface management, route management, DHCP bindin= gs and so on), which=20 > exposes all this functionality to the rest of the system through IPC. N= ow, let=E2=80=99s say , a simple client > modifies the IP address of a certain interface, or host name or whateve= r, and in process modifying the > corresponding key-value in memory, in addition to sending the IOCTL to= change ip address for the interface=20 > to the kernel. >=20 > Is lib UCL able to serialise this change back to the file which backups= up the database ? If it is , all is dandy,=20 > If it is not, is is this feature easy to implement in libUCL , without = being a hack, or libUCL design was read only=20 > from start, thing which would make serialisation hard to implement cl= eanly ? >=20 >=20 >=20 >=20 > _______________________________________________ > freebsd-hackers@freebsd.org mailing list > https://lists.freebsd.org/mailman/listinfo/freebsd-hackers > To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@freebsd.o= rg" >=20 Basically, libucl parses the configuration from the file, and creates the in-memory objects. You then have an API to manipulate the objects, like add new key-value pairs, push/pop/shift/append to arrays, merge two sets of key-value pairs with a priority system to decide who wins when there are duplicates, etc. Then, it has an emitter system to serialize those in-memory objects back out to a config file. The API is generic enough that the input and output formats could include some type of database. One flavour that I am looking to add is nvlists, as this appears to be the best way to pass data between modules.= As for the command line tool, this is the intention of uclcmd: If you have /etc/pkg/FreeBSD.conf: FreeBSD: { url: "pkg+http://pkg.FreeBSD.org/${ABI}/latest", mirror_type: "srv", signature_type: "fingerprints", fingerprints: "/usr/share/keys/pkg", enabled: yes } You can do: uclcmd get -f /etc/pkg/FreeBSD.conf FreeBSD.url and the result is: pkg+http://pkg.FreeBSD.org/${ABI}/latest And then you could do: uclcm set -f /etc/pkg/FreeBSD.conf FreeBSD.url http://pkg.mysite.com/${ABI}/custom And it would modify the configuration in place for you. Although some limitation in libucl mean that, if you have a config that has comments in it, the comments are lost, as they are not represented in the in-memory version of the object that then gets serialized for output. If you treat the config files as a database, then this is fine, but if the user expects to still hand edit them with an editor, this is a fairly big POLA violation. --=20 Allan Jude --9I3qhLKErGJfVQgDCDFMlNUEprM7bsUTP Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.22 (MingW32) iQIcBAEBAgAGBQJWT2EfAAoJEBmVNT4SmAt+KD8P/3cNpSAGVU2eCv+wdI1beLhx UFEEUw4DmRV+cyAVKJyXNKPmVCqI64PfJrd+q032noL5Nfekvcf42uwQL2kFqEIt 3+ffOhrKayb5Re3jgT7tOGIaeIA+g6POwzX/EkT5iyfGN/o+BMz+MMVGqIdGWimI SmbkLUGeCqpaQhyuclXen6X0lw9PyyTTpDFpj3vOpXJuaR3Y8lzogAoHdb1HJov0 BDCg3T1Nf1MYY4+juRY5z1B78GQfrsHkYgnF3nx5K9kwcYZqUuCk3sTGDUbICB0/ y4GIaP26tAwiMAFREKmhwMpee/ZaEer4wkKWYfnUz2yefmTH7aGvOsiIBE76WaIY Wr2Xx4QLCb5pk96vKGOurIy7xt0RXFMguO2Zqucw5MKmitQSH3uEH5enXKZvTQiJ BeNC9hv9HRVSkD6kEcmsk7mQ4LiCD0dGThUocJR5/qfWNUfeWlnoC1ZJ3ESH/b7V OiOmHqQ5pjQYgLHE4mGuH6eDmgPop2x3OuuUTD6psqcT/R53T6n/VuB3kaamFhSG DYEL1htlcdGc41gTrwDnbppaFHytSUHs8ETmaE9jlG/9knRTpApMbMPwoWZQ3sOi T/6/gQmI1KZFLUUbwdfO+7jiRyFMmzzJTfgKwN8mn1U2IqdWLOMPO7nQ1012sFgP T1fxqtOinZkUQMkzHy0I =zanl -----END PGP SIGNATURE----- --9I3qhLKErGJfVQgDCDFMlNUEprM7bsUTP--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?564F6118.5030702>