mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-01-31 06:39:11 +00:00
98_configDBwrap - added commandref, sorted into helper modules
git-svn-id: https://svn.fhem.de/fhem/trunk@5165 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
aae0f2e90a
commit
196ebb3182
@ -19,8 +19,9 @@ sub configDBwrap_Define($$) {
|
||||
my ($hash, $def) = @_;
|
||||
my @a = split("[ \t][ \t]*", $def);
|
||||
return "Wrong syntax: use define <name> configDB" if(int(@a) != 2);
|
||||
my @version = split(/ /,cfgDB_svnId);
|
||||
readingsSingleUpdate($hash, 'version', "$version[3] - $version[4]", 0);
|
||||
readingsSingleUpdate($hash, 'state', 'active', 0);
|
||||
readingsSingleUpdate($hash, 'version', cfgDB_svnId, 0);
|
||||
return undef;
|
||||
}
|
||||
|
||||
@ -55,7 +56,7 @@ sub configDBwrap_Get($@) {
|
||||
|
||||
my ($hash, @a) = @_;
|
||||
my $name = $hash->{NAME};
|
||||
my $usage = "Unknown argument, choose one of diff info:noArg list";
|
||||
my $usage = "Unknown argument, choose one of diff info:noArg list uuid";
|
||||
return $usage if(int(@a) < 2);
|
||||
my $ret;
|
||||
|
||||
@ -75,6 +76,10 @@ sub configDBwrap_Get($@) {
|
||||
$ret = cfgDB_Diff($a[2],$a[3]);
|
||||
}
|
||||
|
||||
when ('uuid') {
|
||||
$ret = _cfgDB_Uuid;
|
||||
}
|
||||
|
||||
default { $ret = $usage; }
|
||||
|
||||
}
|
||||
@ -83,3 +88,249 @@ sub configDBwrap_Get($@) {
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
=pod
|
||||
=begin html
|
||||
|
||||
<a name="configDBwrap"></a>
|
||||
<h3>configDBwrap</h3>
|
||||
<ul>
|
||||
This module is a wrapper to support set and get compatibility <br/>
|
||||
for additional functions provided by configDB.<br/>
|
||||
<br/>
|
||||
<a name="GDSdefine"></a>
|
||||
<b>Define</b>
|
||||
<ul>
|
||||
<br/>
|
||||
<code>define configDB configDBwrap</code>
|
||||
<br/><br/>
|
||||
Important: the name <b>must</b> be configDB!
|
||||
</ul>
|
||||
<br/>
|
||||
<br/>
|
||||
<a name="GDSset"></a>
|
||||
<b>Set-Commands</b><br/>
|
||||
<br/>
|
||||
<ul>
|
||||
<li><code>set configDB reorg [keep]</code></li><br/>
|
||||
Deletes all stored versions with version number higher than [keep].<br/>
|
||||
Default value for optional parameter keep = 3.<br/>
|
||||
This function can be used to create a nightly running job for<br/>
|
||||
database reorganisation when called from an at-Definition.<br/>
|
||||
<br/>
|
||||
|
||||
<li><code>set configDB recover <version></code></li><br/>
|
||||
Restores an older version from database archive.<br/>
|
||||
<code>set configDB recover 3</code> will <b>copy</b> version #3 from database
|
||||
to version #0.<br/>
|
||||
Original version #0 will be lost.<br/><br/>
|
||||
<b>Important!</b><br/>
|
||||
The restored version will <b>NOT</b> be activated automatically!<br/>
|
||||
You must do a <code>rereadcfg</code> or - even better - <code>shutdown restart</code> yourself.<br/>
|
||||
</ul>
|
||||
<br/>
|
||||
<br/>
|
||||
<a name="GDSget"></a>
|
||||
<b>Get-Commands</b><br/>
|
||||
<br/>
|
||||
<ul>
|
||||
<li><code>get configDB info</code></li><br/>
|
||||
Returns some database statistics<br/>
|
||||
<pre>
|
||||
--------------------------------------------------------------------------------
|
||||
configDB Database Information
|
||||
--------------------------------------------------------------------------------
|
||||
dbconn: SQLite:dbname=/opt/fhem/configDB.db
|
||||
dbuser:
|
||||
dbpass:
|
||||
dbtype: SQLITE
|
||||
--------------------------------------------------------------------------------
|
||||
fhemconfig: 7707 entries
|
||||
|
||||
Ver 0 saved: Sat Mar 1 11:37:00 2014 def: 293 attr: 1248
|
||||
Ver 1 saved: Fri Feb 28 23:55:13 2014 def: 293 attr: 1248
|
||||
Ver 2 saved: Fri Feb 28 23:49:01 2014 def: 293 attr: 1248
|
||||
Ver 3 saved: Fri Feb 28 22:24:40 2014 def: 293 attr: 1247
|
||||
Ver 4 saved: Fri Feb 28 22:14:03 2014 def: 293 attr: 1246
|
||||
--------------------------------------------------------------------------------
|
||||
fhemstate: 1890 entries saved: Sat Mar 1 12:05:00 2014
|
||||
--------------------------------------------------------------------------------
|
||||
</pre>
|
||||
Ver 0 always indicates the currently running configuration.<br/>
|
||||
<br/>
|
||||
|
||||
<li><code>get configDB list [device] [version]</code></li><br/>
|
||||
Search for device named [device] in configuration version [version]<br/>
|
||||
in database archive.<br/>
|
||||
Default value for [device] = % to show all devices.<br/>
|
||||
Default value for [version] = 0 to show devices from current version.<br/>
|
||||
Examples for valid requests:<br/>
|
||||
<br/>
|
||||
<code>get configDB list</code><br/>
|
||||
<code>get configDB list global</code><br/>
|
||||
<code>get configDB list '' 1</code><br/>
|
||||
<code>get configDB list global 1</code><br/>
|
||||
<br/>
|
||||
|
||||
<li><code>get configDB diff <device> <version></code></li><br/>
|
||||
Compare configuration dataset for device <device>
|
||||
from current version 0 with version <version><br/>
|
||||
Example for valid request:<br/>
|
||||
<br/>
|
||||
<code>get configDB telnetPort 1</code><br/>
|
||||
<br/>
|
||||
will show a result like this:
|
||||
<pre>
|
||||
compare device: telnetPort in current version 0 (left) to version: 1 (right)
|
||||
+--+--------------------------------------+--+--------------------------------------+
|
||||
| 1|define telnetPort telnet 7072 global | 1|define telnetPort telnet 7072 global |
|
||||
* 2|attr telnetPort room telnet * | |
|
||||
+--+--------------------------------------+--+--------------------------------------+</pre>
|
||||
|
||||
<li><code>get configDB uuid</code></li><br/>
|
||||
Returns a uuid that can be used for own purposes.<br/>
|
||||
</ul>
|
||||
<br/>
|
||||
<a name="GDSattr"></a>
|
||||
<b>Attributes</b><br/>
|
||||
<br/>
|
||||
<ul>
|
||||
<li><code>private <1|0></code></li><br/>
|
||||
If set to 1 user and password info will not be shown in get ... info.<br/>
|
||||
</ul>
|
||||
<br/>
|
||||
<b>Author's notes</b><br/>
|
||||
<br/>
|
||||
<ul>
|
||||
<li>You may need to install perl package Text::Diff to use the diff-function.</li>
|
||||
<br/>
|
||||
<li>There still will be some more (planned) development to this extension.</li>
|
||||
<br/>
|
||||
<li>Have fun!</li>
|
||||
</ul>
|
||||
</ul>
|
||||
|
||||
=end html
|
||||
|
||||
=begin html_DE
|
||||
|
||||
<a name="configDBwrap"></a>
|
||||
<h3>configDBwrap</h3>
|
||||
<ul>
|
||||
Ein Wrapper-Modul, um die von configDB bereitgestellten Zusatzfunktionen<br/>
|
||||
mit regulären set und get Befehlen nutzen zu können.<br/>
|
||||
<br/>
|
||||
<a name="GDSdefine"></a>
|
||||
<b>Define</b>
|
||||
<ul>
|
||||
<br/>
|
||||
<code>define configDB configDBwrap</code>
|
||||
<br/><br/>
|
||||
Wichtig: der Name <b>muss</b> configDB lauten!
|
||||
</ul>
|
||||
<br/>
|
||||
<br/>
|
||||
<a name="GDSset"></a>
|
||||
<b>Set-Befehle</b><br/>
|
||||
<br/>
|
||||
<ul>
|
||||
<li><code>set configDB reorg [keep]</code></li><br/>
|
||||
Löscht alle gespeicherten Konfigurationen mit Versionsnummern größer als [keep].<br/>
|
||||
Standardwert für den optionalen Parameter keep = 3.<br/>
|
||||
Mit dieser Funktion läßt sich eine nächtliche Reorganisation per at umsetzen.<br/>
|
||||
<br/>
|
||||
|
||||
<li><code>set configDB recover <version></code></li><br/>
|
||||
Stellt eine ältere Version aus dem Datenbankarchiv wieder her.<br/>
|
||||
<code>set configDB recover 3</code> <b>kopiert</b> die Version #3 aus der Datenbank
|
||||
zur Version #0.<br/>
|
||||
Die ursprüngliche Version #0 wird dabei gelöscht.<br/><br/>
|
||||
<b>Wichtig!</b><br/>
|
||||
Die zurückgeholte Version wird <b>NICHT</b> automatisch aktiviert!<br/>
|
||||
Ein <code>rereadcfg</code> oder - besser - <code>shutdown restart</code> muss manuell erfolgen.<br/>
|
||||
</ul>
|
||||
<br/>
|
||||
<br/>
|
||||
<a name="GDSget"></a>
|
||||
<b>Get-Befehle</b><br/>
|
||||
<br/>
|
||||
<ul>
|
||||
<li><code>get configDB info</code></li><br/>
|
||||
Liefert eine Datenbankstatistik<br/>
|
||||
<pre>
|
||||
--------------------------------------------------------------------------------
|
||||
configDB Database Information
|
||||
--------------------------------------------------------------------------------
|
||||
dbconn: SQLite:dbname=/opt/fhem/configDB.db
|
||||
dbuser:
|
||||
dbpass:
|
||||
dbtype: SQLITE
|
||||
--------------------------------------------------------------------------------
|
||||
fhemconfig: 7707 entries
|
||||
|
||||
Ver 0 saved: Sat Mar 1 11:37:00 2014 def: 293 attr: 1248
|
||||
Ver 1 saved: Fri Feb 28 23:55:13 2014 def: 293 attr: 1248
|
||||
Ver 2 saved: Fri Feb 28 23:49:01 2014 def: 293 attr: 1248
|
||||
Ver 3 saved: Fri Feb 28 22:24:40 2014 def: 293 attr: 1247
|
||||
Ver 4 saved: Fri Feb 28 22:14:03 2014 def: 293 attr: 1246
|
||||
--------------------------------------------------------------------------------
|
||||
fhemstate: 1890 entries saved: Sat Mar 1 12:05:00 2014
|
||||
--------------------------------------------------------------------------------
|
||||
</pre>
|
||||
Ver 0 bezeichnet immer die aktuell verwendete Konfiguration.<br/>
|
||||
<br/>
|
||||
|
||||
<li><code>get configDB list [device] [version]</code></li><br/>
|
||||
Sucht das Gerät [device] in der Konfiguration der Version [version]<br/>
|
||||
in der Datenbank.<br/>
|
||||
Standardwert für [device] = % um alle Geräte anzuzeigen<br/>
|
||||
Standardwert für [version] = 0 um Geräte in der aktuellen Version anzuzeigen.<br/>
|
||||
Beispiele für gültige Aufrufe:<br/>
|
||||
<br/>
|
||||
<code>get configDB list</code><br/>
|
||||
<code>get configDB list global</code><br/>
|
||||
<code>get configDB list '' 1</code><br/>
|
||||
<code>get configDB list global 1</code><br/>
|
||||
<br/>
|
||||
|
||||
<li><code>get configDB diff <device> <version></code></li><br/>
|
||||
Vergleicht die Konfigurationsdaten des Gerätes <device> aus der aktuellen Version 0 mit den Daten aus Version <version><br/>
|
||||
Beispielaufruf:<br/>
|
||||
<br/>
|
||||
<code>get configDB diff telnetPort 1</code><br/>
|
||||
<br/>
|
||||
liefert ein Ergebnis ähnlich dieser Ausgabe:
|
||||
<pre>
|
||||
compare device: telnetPort in current version 0 (left) to version: 1 (right)
|
||||
+--+--------------------------------------+--+--------------------------------------+
|
||||
| 1|define telnetPort telnet 7072 global | 1|define telnetPort telnet 7072 global |
|
||||
* 2|attr telnetPort room telnet * | |
|
||||
+--+--------------------------------------+--+--------------------------------------+</pre>
|
||||
|
||||
<li><code>get configDB uuid</code></li><br/>
|
||||
Liefert eine uuid, die man für eigene Zwecke verwenden kann.<br/>
|
||||
</ul>
|
||||
<br/>
|
||||
<a name="GDSattr"></a>
|
||||
<b>Attribute</b><br/>
|
||||
<br/>
|
||||
<ul>
|
||||
<li><code>private <1|0></code></li><br/>
|
||||
Benutzername und Passwort werden in get ... info nicht angezeigt, wenn private auf 1 gesetzt wird.<br/>
|
||||
</ul>
|
||||
<br/>
|
||||
<b>Hinweise:</b><br/>
|
||||
<br/>
|
||||
<ul>
|
||||
<br/>
|
||||
<li>Für die Nutzung von get ... diff wird das perl Paket Text::Diff benötigt.</li>
|
||||
<br/>
|
||||
<li>Diese Erweiterung wird laufend weiterentwickelt.</li>
|
||||
<br/>
|
||||
<li>Viel Spass!</li>
|
||||
</ul>
|
||||
</ul>
|
||||
|
||||
=end html_DE
|
||||
|
||||
=cut
|
||||
|
@ -88,6 +88,7 @@
|
||||
<a href="#average">average</a>
|
||||
<a href="#Calendar">Calendar</a>
|
||||
<a href="#configDB">configDB</a>
|
||||
<a href="#configDBwrap">configDBwrap</a>
|
||||
<a href="#Dashboard">Dashboard</a>
|
||||
<a href="#DbLog">DbLog</a>
|
||||
<a href="#dewpoint">dewpoint</a>
|
||||
|
@ -87,6 +87,7 @@
|
||||
<a href="#average">average</a>
|
||||
<a href="#Calendar">Calendar</a>
|
||||
<a href="#configDB">configDB</a>
|
||||
<a href="#configDBwrap">configDBwrap</a>
|
||||
<a href="#Dashboard">Dashboard</a>
|
||||
<a href="#DbLog">DbLog</a>
|
||||
<a href="#dewpoint">dewpoint</a>
|
||||
|
Loading…
Reference in New Issue
Block a user