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 Linuxwochenende 2010 Metalab 1

2 http://www.libelektra.org Was ist Konfiguration? Section "InputDevice" Identifier "Mouse0" Driver "mouse" Option "Protocol" "IMPS/2" Option "Device" "/dev/input/mice" Option "ZAxisMapping" "4 5" Option "Emulate3Buttons" "no" EndSection ✔ Für Menschen lesbar ✔ Für Menschen editierbar ✗ Nicht für alle Programme einfach lesbar/editierbar ✔ Einstellungen und Optionen von Programmen ✔ Einfache hierarchische Struktur 2

3 http://www.libelektra.org Konfiguration für jede Platform? Lesen und Schreiben Kein Zugang 3

4 http://www.libelektra.org Was ist Elektra? sh$ ldd /lib/libelektra.so libc.so.6 => /lib/tls/libc.so.6 /lib/ld-linux.so.2 => /lib/ld-linux.so.2 ✔ Bibliothek um Konfiguration zu speichern ✔ Klein und portabel ✔ Während Diplomarbeit erweitert ✔ Sicherheit über OS ✔ Konfigurationsdateien ✔ Abstraktion von Konfiguration 4

5 http://www.libelektra.org Was ist das Ziel? Portable und nicht 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 Linuxwochenende Wien 2010 6

7 http://www.libelektra.org Key Hierachie key/value pairs für System key/value pairs für aktuellen User Avi's persönliche keys Luciana's persönliche keys Valeria's persönliche keys Die system/* Hierachie ist gespeichert unter /etc/ Die user:$USER/* Hierachie unter ~$USER/.config/ Die user/* Hierachie ist eine Abkürzung für aktuellen 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 Backends mounten system/ apache / kde/ sw/ apache ini fstab/ fstab ➔ Gesamte Konfiguration in einer Hierachie, ABER: verschiedene Bedürfnisse Performance alte Konfigurations- dateien 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 Linuxwochenende Wien 2010 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 (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 Modularer Ansatz Markus Raab Markus Raab Linuxwochende 2010 19

20 http://www.libelektra.org Erwünschte Situation ApplicationApplication LibelektraLibelektra Filter Plugin...... Storage Plugin n Plugins = 1 Backend ➢ Separation of Concerns ➢ Unix Philosophie ➢ Flexibles Laufzeitverhalten ➢ Dependencies 20

21 http://www.libelektra.org Plugins Markus Raab Markus Raab Linuxwochende 2010 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 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 26

27 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) 27

28 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 28

29 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 29 $ 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

30 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 30 Ä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

31 http://www.libelektra.org FSType enum FSType {fat,ntfs,ext2,jfs,proc,swap}; string unsigned_short 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 31 ➢ Überprüfung der Typen ➢ Basic CORBA Typsystem

32 http://www.libelektra.org More Storage ➢ TCL ➢ Nickel 32 { {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 > '}') > '}';

33 http://www.libelektra.org Limited Storage ➢ Hosts ➢ Simpleini 33 #/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?

34 http://www.libelektra.org Filter Plugins 34 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

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

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

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

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

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

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

41 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 41

42 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. 42

43 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 43

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

45 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 45

46 http://www.libelektra.org Administration mit Elektra Markus Raab Markus Raab Linuxwochende 2010 46

47 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 47

48 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 48

49 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 49

50 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 50

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

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

53 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? 53

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

55 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 55 #inetd.conf Identstreamtcpwaitidentd/usr/sbin/identdidentd saftstreamtcpnowaitroot/usr/sbin/tcpd/usr/sbin/sendfiled fingerstreamtcpnowaitnobody/usr/sbin/tcpdin.fingerd 55

56 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. 56

57 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 57

58 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. 58

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

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

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

62 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 62

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

64 http://www.libelektra.org Modulare Backends für Elektra Markus Raab Markus Raab Linuxwochende 2010 64

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

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

67 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 67

68 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 68

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


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

Ähnliche Präsentationen


Google-Anzeigen