Bug 26819 - Transaktionen für UCR bzw. Handling von UCR-Variablenlisten
Transaktionen für UCR bzw. Handling von UCR-Variablenlisten
Status: CLOSED DUPLICATE of bug 32544
Product: UCS
Classification: Unclassified
Component: UCR
UCS 3.0
Other Linux
: P4 enhancement (vote)
: UCS 3.2
Assigned To: Philipp Hahn
Felix Botner
: interim-2
: 27077 (view as bug list)
Depends on:
Blocks: 29764
  Show dependency treegraph
 
Reported: 2012-04-17 17:21 CEST by Alexander Kläser
Modified: 2013-11-19 06:41 CET (History)
4 users (show)

See Also:
What kind of report is it?: ---
What type of bug is this?: ---
Who will be affected by this bug?: ---
How will those affected feel about the bug?: ---
User Pain:
Enterprise Customer affected?:
School Customer affected?:
ISV affected?:
Waiting Support:
Flags outvoted (downgraded) after PO Review:
Ticket number:
Bug group (optional):
Max CVSS v3 score:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Alexander Kläser univentionstaff 2012-04-17 17:21:47 CEST
In einigen Fällen gibt es Listen von UCR-Variablen, bspw:

  proxy/filter/setting/Wikipedia/domain/whitelisted/1: wikipedia.org
  proxy/filter/setting/Wikipedia/domain/whitelisted/2: wikipedia.de
  ...

oder

  interfaces/eth0/...
  interfaces/eth1/...
  ...

Das Handling dieser Listen ist unpraktisch, wenn ein Array von Einträgen (bspw. im ersten Fall eine Liste von Domains, im zweiten eine Liste von Netzwerkgeräteeinstellungen) wieder auf die UCR-Variablen übertragen werden soll. 

Hilfreich wäre bereits bspw. ein Transaktionsmechanismus, mit dem alle Variablen gelöscht und dann neu gesetzt werden können. Nur der Diff würde dann als Commit übertragen werden und die Dateien würden nur bei Bedarf neu generiert. Ggf. sind auch andere Vorgehensweise möglich.
Comment 1 Sönke Schwardt-Krummrich univentionstaff 2012-04-17 18:01:53 CEST
API-Vorschlag:

ucr = univention.config_registry.ConfigRegistry()
ucr.load()
ucr.begin_transaction()
ucr['foo'] = '123'
ucr['hostname'] = 'myhost'
del ucr['some/var']
ucr.end_transaction()
Comment 2 Philipp Hahn univentionstaff 2012-04-17 18:15:40 CEST
(In reply to comment #1)
> API-Vorschlag:
...
> ucr.end_transaction()

Als alter Datenbankler wenn überhaupt bitte 'commit()' und 'abort()' (±Prefix/Suffix); 'end' enthält für mein Geschmäckle zu wenig Semantik.
Comment 3 Alexander Kläser univentionstaff 2012-12-12 10:19:12 CET
Wieder aufgefallen im App-Center (siehe auch Bug 29764), dort wird ebenfalls ein Transaktionsmechanismus benötigt. Hilfreich wäre auch eine Erweiterung, die mit yield arbeitet (ähnlich zu set_save_commit_load() in appcenter/util.py).

(In reply to comment #2)
> (In reply to comment #1)
> > API-Vorschlag:
> ...
> > ucr.end_transaction()
> 
> Als alter Datenbankler wenn überhaupt bitte 'commit()' und 'abort()'
> (±Prefix/Suffix); 'end' enthält für mein Geschmäckle zu wenig Semantik.

Gute Idee!
Comment 4 Stefan Gohmann univentionstaff 2012-12-21 22:15:15 CET
Das sollte aber nur eine Ergänzung der vorhandenen einfachen API sein und nicht die vorhandene API ersetzen.
Comment 5 Alexander Kläser univentionstaff 2013-04-23 14:05:21 CEST
*** Bug 27077 has been marked as a duplicate of this bug. ***
Comment 6 Philipp Hahn univentionstaff 2013-09-20 08:34:51 CEST
r43987 | Bug #32544: UCR: Add context wrapper

UCR now implements the Python context interface:
  with ConfigRegistry() as ucr:
    ucr['foo'] = '123'
    ucr['hostname'] = 'myhost'
    del ucr['some/var']
This will NOT run the handlers (AKA commit)!

For that use
  from univention.config_registry import ConfigRegistry
  from univention.config_registry.frontend import ucr_update
  ucr = ConfigRegistry()
  # no ucr.load() required, unless you need old values
  ucr_update(ucr, {
    'foo': '123',
    'hostname': 'myhost',
    'some/var': None,
  })
Do not mix those, as ucr_update() uses the above internally, which would create a self-deadlock.

*** This bug has been marked as a duplicate of bug 32544 ***
Comment 7 Felix Botner univentionstaff 2013-09-20 10:50:18 CEST
(In reply to Philipp Hahn from comment #6)
> ... 
> *** This bug has been marked as a duplicate of bug 32544 ***

OK
Comment 8 Stefan Gohmann univentionstaff 2013-11-19 06:41:46 CET
UCS 3.2 has been released:
 http://docs.univention.de/release-notes-3.2-en.html
 http://docs.univention.de/release-notes-3.2-de.html

If this error occurs again, please use "Clone This Bug".