Die Präsentation wird geladen. Bitte warten

Die Präsentation wird geladen. Bitte warten

A Modular Approach to Configuration Storage Markus Raab Markus Raab xmpp:

Ähnliche Präsentationen


Präsentation zum Thema: "A Modular Approach to Configuration Storage Markus Raab Markus Raab xmpp:"—  Präsentation transkript:

1 http://www.libelektra.org A Modular Approach to Configuration Storage Markus Raab Markus Raab elektra@markus-raab.org xmpp: jabber@markus-raab.org jabber@markus-raab.org Linuxwochen / LGM 2012 Wien 1

2 http://www.libelektra.org What is configuration? Section "InputDevice" Identifier "Mouse0" Driver "mouse" Option "Protocol" "IMPS/2" Option "Device" "/dev/input/mice" Option "ZAxisMapping" "4 5" Option "Emulate3Buttons" "no" EndSection ✔ Readable by humans ✔ Editable by humans ✗ Not easily read and writeable by programs ✔ Settings and options of applications ✔ In a simple hierarchical structure 2

3 http://www.libelektra.org Configuration for every platform? Read and Write access No Access 3

4 http://www.libelektra.org What is Elektra? sh$ ldd /lib/libelektra.so libc.so.6 => /lib/tls/libc.so.6 /lib/ld-linux.so.2 => /lib/ld-linux.so.2 ✔ Access to configuration storage ✔ Portable (ANSI C) ✔ For embedded Systems (small, static) ✔ Security by OS ✔ Supports configuration files ✔ Abstracts configuration 4

5 http://www.libelektra.org What is the Goal? Portable and non-portable software Java, Apache, Samba, KDE, /sbin/init,... FileSystem ConfigFile SingleFile ConfigFile WinReg FileSystem ConfigFile SingleFile FileSystem ConfigFile SingleFile OpenDir FileSystem ConfigFile SingleFile Backends Elektra API :: Abstraction Layer Bindings 5

6 http://www.libelektra.org Key Database Semantik Markus Raab Markus Raab 6

7 http://www.libelektra.org Key Hierachie key/value pairs for system key/value pairs for current user Avi's private keys Luciana's private keys Valeria's private keys system/* hierarchy is stored below /etc/config/ user:$USER/* hierarchy is stored below ~$USER/.config/ user/* hierarchy is for the current user 7

8 http://www.libelektra.org Key Hierachie :: system/... key/value pairs für System Gleichwertig zu /etc/fstab Gleichwertig zu /etc/group Statische gefundene Hardware Gleichwertig zu /etc/inittab Netzwerk Konfiguration Applikationsspezifisches Applikation 1 Applikation 2 Gleichwertig zu /etc/passwd 8

9 http://www.libelektra.org Mounting backends system/ apache / kde/ sw/ apache ini fstab/ fstab ➔ We want whole configuration in one hierarchy, but need support for: Application specific Admin tasks Legacy config files 9 user/ iniC system/sw/apache/site1.com/DocRoot sw/ dump

10 http://www.libelektra.org Bootstrapping sh$ kdb mount.. load default backend.. buildup other backends ✔ Self-Contained Configuration System ✔ eingebautes Default Backend zuerst ✔ Damit eigene Konfiguration einlesen ✔ Backends in globalen Konfigurationsbaum mounten 10

11 http://www.libelektra.org KDB Semantik 1.Wurzel: User und System 2.Keys sind mit Namen eindeutig definiert 3.Löcher werden akzeptiert 4.Keine Ordnungsrelation (Set) 5.Keys sind unabhängig 6.Keine Links, Verstecke Keys o.ä. FS-Semantiken 7.Aber Plugins und Metadaten können 3-6 abändern 11

12 http://www.libelektra.org Elektrifizierung Markus Raab Markus Raab 12

13 http://www.libelektra.org Elektrifizierung Konfig- uration Konfig- uration App A ✗ Konfiguration ist stark abhängig von der Applikation ✗ Konfiguration wird nicht mit anderer Software geteilt Globale Konfiguration Globale Konfiguration ✔ Konfiguration repräsentiert durch Standards ✔ Verschiedene Programme können Konfigurationen teilen App AApp BApp C Elektrifizierung Konfig- uration Konfig- uration App B Konfig- uration Konfig- uration App C 13

14 http://www.libelektra.org Technische Umsetzung Application /lib/libelektra.s o libelektra-{plugin}.so Pure dynamic (in)dependencyPure dynamic (in)dependency ✔ ✔ Plugin = Shared Library (Linux) ✔ ✔ Nicht sichbar mit ldd ✔ ✔ Je nach Pfad variabel (self- contained durch mounting) Dynamic single dependencyDynamic single dependency ✔ ✔ Sichtbar mit ldd ✔ ✔ libelektra.so versteckt Backends Application process space ✔ Different storages 14

15 http://www.libelektra.org Die API Was ist vorhanden um auf Elektra key/value pairs zuzugreifen? 15

16 http://www.libelektra.org Nur 3 Klassen KDB KeyKeySet Classes 16

17 http://www.libelektra.org Key Eigenschaften ➢ Name ➢ Value system/users/root/shadowPassword = $1$yM93nU user:valeria/env/env2/PATH = $PATH:/usr/sbin 17 ➢ Metaname ➢ Metavalue ➢ Metaname ➢ Metavalue

18 http://www.libelektra.org C API Methods ksNew() ksDel() ksAppendKey() ksAppend() ksNext() ksRewind() ksLookup() ksLookupByName() keyNew() keyDup() keyCopy() keyClear() keyDel() keyIncRef() keyDecRef() keyGetRef() keyRewindMeta() keyNextMeta() keyCurrentMeta() keyGetMeta() keySetMeta() keyGetString() keyGetBinary() keySetBinary() keyValue() kdbOpen() kdbClose() kdbGet() kdbSet() 18

19 http://www.libelektra.org The kdb Command: Perfekt für Skripte $ kdb get system/filesystems/boot/mpoint # kdb set system/sw/xorg/Screen/Display/Modes 1280x1024 $ kdb ls system/sw/myapp $ kdb rm user/env/alias/vnc 19

20 http://www.libelektra.org Modular Approach Markus Raab Markus Raab 20

21 http://www.libelektra.org Desired situation per backend ApplicationApplication LibelektraLibelektra Filter Plugin...... Storage Plugin n Plugins = 1 Backend ➢ Separation of Concerns ➢ Unix philosophy ➢ Can be changed at runtime ➢ Dependencies only to single plugins 21

22 http://www.libelektra.org Resolver Plugin ➢ Erledigt Betriebsystemabhängiges ➢ Ermittelt Dateinamen ➢ Erkennt Konflikte ➢ Erkennt ob Update notwendig 22 ResolverResolver /home/markus/.config/file.ini/home/markus/.config/file.ini /etc/file.ini/etc/file.ini file.inifile.ini Konflikt? Update?

23 http://www.libelektra.org Storage Plugins ksNew( 17, keyNew ("user/fstab/rootfs", KEY_TYPE, KEY_TYPE_STRING, KEY_END), keyNew ("user/fstab/rootfs/device", KEY_VALUE, "LABEL=/", KEY_TYPE, KEY_TYPE_STRING, KEY_END), keyNew ("user/fstab/rootfs/type", KEY_VALUE, "ext3", KEY_TYPE, KEY_TYPE_STRING, KEY_END), KS_END); kdbOpen 1 ksNew 3 keyNew 10 8 user/dumprootkey keyEnd keyNew 15 7 user/dump/key1value1 keyEnd keyNew 15 7 user/dump/key2value2 keyEnd ksEnd ➢ Dump 23 <keyset xmlns="" xsi:schemaLocation="" parent="user/env/alias"> <key basename="ls" type="string" value="ls -Fh" <key basename="vnc" type="string"> vncserver -geometry 900x650 ➢ XML

24 http://www.libelektra.org Reihenfolge von Plugins Get Configuration ResolverResolver Storage Plugin............ 24 Set Configuration ResolverResolver...... Storage Plugin Resolver (Commit)

25 http://www.libelektra.org Fehlerbehandlung ErrorError............ Resolver (Rollback)...... 25 Set Configuration ResolverResolver...... Storage Plugin Resolver (Commit)

26 http://www.libelektra.org signal sender=:1.9 -> path=/org/libelektra/configuration; interface=org.libelektra; member=changed Aug 31 10:25:05 markusbyte elektra[4149]: committed configuration user/syslog with 1 keys Aug 31 10:25:14 markusbyte elektra[4150]: committed configuration user/syslog with 2 keys Cross-Cutting-Concerns ✔ Notification (D-Bus) ✔ Logging (Syslog) 26

27 http://www.libelektra.org keyNew ("system/elektra/modules/hosts/config/needs/glob/#1", KEY_VALUE, "/*", KEY_META, "check/ipaddr", "", KEY_META, "validation/regex", "^[0-9.:]+$", KEY_END), Metadaten ✔ Daten über Konfiguration ✔ Globbing 27

28 http://www.libelektra.org # kdb set system/sw/xorg/Screen/Display/Modes 12y80x1024 Could not validate “12y80x1024”, needed [0-9]+x[0-9]+ $ kdb set user/hosts/hostname 192.168.0.x Value of key is not a valid IP Address Name or service not known Basic Checker ✔ Validation ✔ Network 28 $ kdb set user/fstab/rootfs/device /dev/none Warning: No such file or directory from key: user/fstab/rootfs/device with path: /dev/none ✔ Filename

29 http://www.libelektra.org LABEL=stable /jfsdefaults,errors=remount-ro 0 1 proc /proc procdefaults 0 0 LABEL=swap none swapsw 0 0 LABEL=home/homejfsrw,suid,dev,exec,auto,nouser 0 2 Struct Checker 29 ÄnderungenÄnderungen Struct list list Struct FStab struct FStab { string device; string mpoint; FSType type; string options; unsigned_short dumpfreq; unsigned_short passno; }; ✗ Bestimmte Einträge müssen /dürfen nicht vorhanden sein

30 http://www.libelektra.org FSType enum FSType {fat,ntfs,ext2,jfs,proc,swap}; string unsigned_short [5..20] LABEL=stable /jfsdefaults,errors=remount-ro 0 1 proc /proc procdefaults 0 0 LABEL=swap none swapsw 0 0 LABEL=home/homejfsrw,suid,dev,exec,auto,nouser 0 2 ✗ /etc/fstab akzeptiert nicht beliebiges Type Checker 30 ➢ Checks value of an key ➢ Basic CORBA Typesystem ➢ Min/Max

31 http://www.libelektra.org More Storage ➢ TCL ➢ Nickel 31 { {system/hosts="" {file=/etc/hosts} {mode=644} {ctime=1273165467} } multi="line inside quotes" ; with comments after escapes=\\\a\r\n\x11\b\056\t\\t\ xj \==\; not a comment \[not a section\]=yeah loooooooog=truncated Ni_node current = NULL; while ((current = Ni_GetNextChild(root, current)) != NULL) { Key *k = keyNew(0); keySetName (k, Ni_GetName(current, NULL)); keySetString (k, Ni_GetValue (current, NULL)); ksAppendKey (returned, k); } query = '{' >> pair >> *(pair) > '}'; pair = '{' >> key > '=' >> val >> *('{' >> metakey > '=' >> metaval > '}') > '}';

32 http://www.libelektra.org Limited Storage ➢ Hosts ➢ Simpleini 32 #/etc/hosts file # a new comment 192.168.0.23first_entry 192.168.0.24second_entry alias2 alias3 alias4 alias5 192.22.22.3third_entry # Markus follows 192.168.1.55markus ✔ Kommentare erhalten ✔ Reihenfolge erhalten user/simpleini/example1 = @NULL user/simpleini/example_empty_string = @EMPTY user/simpleini/example_null_value = @NULL user/simpleini/example_text = @@text user/simpleini/equal = %3Dequal%3D ➢ Null Values? ➢ Special Characters?

33 http://www.libelektra.org Filter Plugins 33 kdb set set user/ccode/key "'val x'" in storage: \'val\tx\' kdb set user/hexcode/key value=abc xyz in storage: value%3Dabc%20xyz ✔ Character Reduction ✔ Application Specific Concerns HiddenKeysHiddenKeys ✔ Iconv

34 http://www.libelektra.org Plugins Übersicht 34

35 http://www.libelektra.org Kontrakte Plugin 0 Plugin 1 Plugin n...... ➢ Wer garantiert das? ➢ Richtigen Plugins? ➢ Richtige Reihenfolge? Quelle: haldimandcountyhydro.ca 35 Plugin 2 Benötigt:ProviderBenötigt:Provider Reihenfolge: Vor Provider Reihenfolge: Bietet an: Provider Provider

36 http://www.libelektra.org Demo 36

37 http://www.libelektra.org Who uses Elektra? ✔ Cross Plattform Software 37 ✔ Embedded Systems Oyranos ✔ Administrators

38 http://www.libelektra.org Ende Vielen Dank für Deine Aufmerksamkeit! 38 Markus Raab Markus Raab elektra@markus-raab.org

39 http://www.libelektra.org Errors and Warnings 39 ✔ Volle Unterstützung von Fehlermeldungen ✔ Mittels Metadaten beliebige Texte ✔ Zentrale Datenbank ✔ (“Don't repeat yourself”) ✔ Unterstützung von Exceptions usw.

40 http://www.libelektra.org Import, Export and Convert (TODO) $ kdb export user/env/alias > file.xml $ kdb import file.xml $ kdb convert file.xml file.ini <keyset xmlns="http://www.libelektra.org" xsi:schemaLocation="http://www.libelektra.org elektra.xsd" parent="user/env/alias"> <key basename="ls" type="string" uid="aviram" gid="aviram" mode="0664" value="ls -Fh --color=auto" Make 'ls' command more cleaver <key basename="vnc" type="string" uid="aviram" gid="aviram" mode="0664"> vncserver -geometry 900x650 Instant creation of a VNC server 40

41 http://www.libelektra.org kdbedit: The Elektra GUI Edit (TODO) auch für Beginner auch für Beginner Hierachische Struktur Hierachische Struktur Alle Funktionen Alle Funktionen Exportieren und Importieren Exportieren und Importieren Wenn alles versagt hast du hoffentlich das richtige Backend gewählt. 41

42 http://www.libelektra.org Resources ➢ Homepage: http://www.libelektra.org http://www.libelektra.org ➢ Bugs: http://bugs.libelektra.org http://bugs.libelektra.org ➢ Svn: http://svn.libelektra.org http://svn.libelektra.org ➢ API: http://www.libelektra.org/elektra-api/ http://www.libelektra.org/elektra-api/ ➢ elektra@markus-raab.org elektra@markus-raab.org ➢ Mailing Liste: registry-list@sf.net registry-list@sf.net 42

43 http://www.libelektra.org Einsatz von Elektra ✔ Cross Plattform Software 43 ✔ Embedded Systems Oyranos ✔ In Debian

44 http://www.libelektra.org Key Hierachie :: system/... key/value pairs für System Gleichwertig zu /etc/fstab Gleichwertig zu /etc/group Statische gefundene Hardware Gleichwertig zu /etc/inittab Netzwerk Konfiguration Applikationsspezifisches Applikation 1 Applikation 2 Gleichwertig zu /etc/passwd 44

45 http://www.libelektra.org Administration mit Elektra Markus Raab Markus Raab 45

46 http://www.libelektra.org Qualität ➢ Genaue Doku! ➢ Testfälle ➢ API: http://www.libelektra.org/elektra-api/ http://www.libelektra.org/elektra-api/ ➢ Testing Framework ➢ ➢ 2769 Zusicherungen ➢ Bug Database ➢ Stable Policy 46

47 http://www.libelektra.org The API is Fully Documented! http://doc.libelektra.org/api/0.7/ ✔ API doc in Doxygen ✔ API man pages ✔ Viele Code Beispiele ✔ Programing Tutorial 47

48 http://www.libelektra.org GConf ist fett und dependent... bash$ ldd /usr/lib/libgconf-2.so.4 libgobject-2.0.so.0 => /usr/lib/libgobject-2.0.so.0 libORBit-2.so.0 => /usr/lib/libORBit-2.so.0 libm.so.6 => /lib/tls/libm.so.6 libgmodule-2.0.so.0 => /usr/lib/libgmodule-2.0.so.0 libdl.so.2 => /lib/libdl.so.2 libgthread-2.0.so.0 => /usr/lib/libgthread-2.0.so.0 libglib-2.0.so.0 => /usr/lib/libglib-2.0.so.0 libpthread.so.0 => /lib/tls/libpthread.so.0 libc.so.6 => /lib/tls/libc.so.6 libpopt.so.0 => /usr/lib/libpopt.so.0 /lib/ld-linux.so.2 48

49 http://www.libelektra.org Elektra ist leicht... bash$ ldd /lib/libelektra.so libc.so.6 => /lib/tls/libc.so.6 /lib/ld-linux.so.2 => /lib/ld-linux.so.2 ✔ Verwendbar bei Restriktionen (kein Netzwerk, kein /usr), sogar bei /sbin/init ✔ Auch ohne Dämon verwendbar No single point of failure Kein Kommunikationsprotokol notwendig Keine Sicherheitslöcher möglich Sicherheit über OS Einfach und sauber 49

50 http://www.libelektra.org Ecosystem 50

51 http://www.libelektra.org Elektra als Bibliothek ➢ Bücher: Key (Titel/Inhalt) ➢ Regale: KeySet ➢ Bibliothekar: Backend 51

52 http://www.libelektra.org fstype enum fstype {fat,ntfs,ext2,jfs,proc,swap}; fstabEntry struct fstabEntry { string device; path mpoint; fstype type; string options; unsigned short dumpfreq; unsigned short passno; }; LABEL=stable /jfsdefaults,errors=remount-ro 0 1 proc /proc procdefaults 0 0 LABEL=swap none swapsw 0 0 LABEL=home/homejfsrw,suid,dev,exec,auto,nouser 0 2 ✗ z.b. /etc/fstab akzeptiert nicht beliebiges Offene Fragen (2) ✗ Bestimmte Einträge müssen vorhanden sein ➢ Wie kann man obigen Typ beschreiben? ➢ Können Plugins dadurch beschreiben was sie akzeptieren? 52

53 http://www.libelektra.org Related Work ➢ Elektra with Mounting ➢ Uniconf (with Daemon) ➢ Debconf (supports stacking) ➢ Augeas (Linux Configuration Files only) ➢ Pam (Error Conditions) ➢ Puppet 53

54 http://www.libelektra.org Warum Mounting? service saft { socket_type = stream protocol = tcp wait = no user = root server = /usr/sbin/sendfiled port = 487 disable = no } ✔ Unterschiedliche Bedürfnisse ✔ Identität von Software 54 #inetd.conf Identstreamtcpwaitidentd/usr/sbin/identdidentd saftstreamtcpnowaitroot/usr/sbin/tcpd/usr/sbin/sendfiled fingerstreamtcpnowaitnobody/usr/sbin/tcpdin.fingerd 54

55 http://www.libelektra.org State-of-the-Art ➢ M. Lackner, A. Krall, and F. Puntigam. Supporting design by contract in Java. Journal of Object Technology, 1(3):57–76, 2002. ➢ C. Andreae, J. Noble, S. Markstrum, and T. Millstein. A framework for implementing pluggable type systems. ACM SIGPLAN Notices, 41(10):74, 2006. ➢ Markus Raab and Patrick Sabin. Implementation of Multiple Key Databases for Shared Configuration. ftp://www.markus-raab.org/elektra.pdf, March 2008. 55

56 http://www.libelektra.org Dämon Architektur Application /lib/libelektra.s o libelektra-daemon.so Server Protokol über unix domain sockets ➔ Client-Server Architecture Kommunikation zum Server über libelektra-daemon.so Der Server selber verwendet auch libelektra.so um key/value zu speichern. single point of failure Application's space Server's 56

57 http://www.libelektra.org Editieren von key/value pairs (0.7) Beliebiger Editor um XML Datei zu editieren Beliebiger Editor um XML Datei zu editieren Neu hinzugefügte werden, kommen hinzu. Neu hinzugefügte werden, kommen hinzu. Veränderte werden übertragen. Veränderte werden übertragen. Auch löschen funktioniert. Auch löschen funktioniert. 57

58 http://www.libelektra.org Key Data Base ➢ Abstrahiert Zugriff auf permanente Keys ➢ Liest oder schreibt Keysets auf die Festplatte 58

59 http://www.libelektra.org Keyset Eigenschaften ➢ Container für Keys ➢ Menge ➢ Effiziente übergabe vieler Keys ➢ Schnelles Suchen nach Namen 59

60 http://www.libelektra.org Fertig um jetzt benutzt zu werden. ➢ Vorhanden ✔ ✔ C ✔ ✔ C++ ✔ ✔ Shell ✔ ✔ XML ➢ War mal da... ✔ ✔ Python ✔ ✔ Scheme ✔ ✔ Ruby ✔ ✔ Java 60

61 http://www.libelektra.org The Elektra Initiative needs YOU ! ➢ Avi Alkalay ➢ Avi Alkalay ➢ Markus Raab ➢ Markus Raab ➢ Yannick Lecaillez ➢ Yannick Lecaillez ➢ Jens Andersen ➢ Jens Andersen ➢ Patrick Sabin ➢ Patrick Sabin ➢ Pier Luigi Fiorini ➢ Pier Luigi Fiorini ➢ Rèmi ➢ Rèmi ➢ Studio-HB ➢ Studio-HB 61

62 http://www.libelektra.org Related Work ➢ Elektra with Mounting ➢ Uniconf (with Daemon) ➢ Debconf (supports stacking) ➢ Augeas (Linux Configuration Files only) ➢ Pam (Error Conditions) 62

63 http://www.libelektra.org Modulare Backends für Elektra Markus Raab Markus Raab 63

64 http://www.libelektra.org ApplicationApplication Vorige Situation LibelektraLibelektra ➢ Duplizierter Code ➢ Fehlende Flexibilität ➢ Reimplementierung von Features ➢ Capabilites Modularität in Backends? BackendBackend 64

65 http://www.libelektra.org Key Namen Dieser kleiner Punkt macht die ganze Hierachie inaktiv? 65

66 http://www.libelektra.org Key Hierachie :: system/... key/value pairs für System Gleichwertig zu /etc/fstab Gleichwertig zu /etc/group Statische gefundene Hardware Gleichwertig zu /etc/inittab Netzwerk Konfiguration Applikationsspezifisches Applikation 1 Applikation 2 Gleichwertig zu /etc/passwd 66

67 http://www.libelektra.org Key Hierachie :: user/... key/value pairs für aktuellen User User's environment (statt ~/.bashrc) User's aliases Erste env var Zweite env var $PATH setzen Drittes environment key/value pairs für Applikationen Temporäre key/value pairs 67

68 http://www.libelektra.org Kaskading Durch diesen Slash wird der richtige Schlüssel automatisch gesucht 68


Herunterladen ppt "A Modular Approach to Configuration Storage Markus Raab Markus Raab xmpp:"

Ähnliche Präsentationen


Google-Anzeigen