diff options
Diffstat (limited to 'src/lib/Bcfg2/Server')
-rw-r--r-- | src/lib/Bcfg2/Server/Admin.py | 4 | ||||
-rwxr-xr-x | src/lib/Bcfg2/Server/Encryption.py | 6 | ||||
-rw-r--r-- | src/lib/Bcfg2/Server/Reports/reports/models.py | 10 |
3 files changed, 11 insertions, 9 deletions
diff --git a/src/lib/Bcfg2/Server/Admin.py b/src/lib/Bcfg2/Server/Admin.py index 6a56657cf..207106596 100644 --- a/src/lib/Bcfg2/Server/Admin.py +++ b/src/lib/Bcfg2/Server/Admin.py @@ -912,8 +912,8 @@ if HAS_REPORTS: # Bcfg2.DBSettings has been populated, Django gets a null # configuration, and subsequent updates to # Bcfg2.DBSettings won't help. - from django.db.transaction import commit_on_success - self.run = commit_on_success(self.run) + from Bcfg2.Reporting.Compat import transaction + self.run = transaction.atomic(self.run) def run(self, _): # pylint: disable=E0202 # Cleanup unused entries diff --git a/src/lib/Bcfg2/Server/Encryption.py b/src/lib/Bcfg2/Server/Encryption.py index f30144d13..f8b602d90 100755 --- a/src/lib/Bcfg2/Server/Encryption.py +++ b/src/lib/Bcfg2/Server/Encryption.py @@ -444,7 +444,7 @@ class PropertiesDecryptor(Decryptor, PropertiesCryptoMixin): default_xpath = '//*[@encrypted]' def decrypt(self): - decrypted = False + decrypted_any = False xdata = lxml.etree.XML(self.data, parser=XMLParser) for elt in self._get_elements(xdata): try: @@ -456,7 +456,7 @@ class PropertiesDecryptor(Decryptor, PropertiesCryptoMixin): decrypted = ssl_decrypt(elt.text, passphrase).strip() elt.text = decrypted.encode('ascii', 'xmlcharrefreplace') elt.set("encrypted", pname) - decrypted = True + decrypted_any = True except (EVPError, TypeError): self.logger.error("Could not decrypt %s, skipping" % print_xml(elt)) @@ -468,7 +468,7 @@ class PropertiesDecryptor(Decryptor, PropertiesCryptoMixin): # a different key, and wound up with gibberish. self.logger.warning("Decrypted %s to gibberish, skipping" % elt.tag) - if decrypted: + if decrypted_any: return xdata else: raise DecryptError("Failed to decrypt any data in %s" % diff --git a/src/lib/Bcfg2/Server/Reports/reports/models.py b/src/lib/Bcfg2/Server/Reports/reports/models.py index c7105fdd9..ac4c8eac4 100644 --- a/src/lib/Bcfg2/Server/Reports/reports/models.py +++ b/src/lib/Bcfg2/Server/Reports/reports/models.py @@ -9,11 +9,13 @@ except ImproperlyConfigured: print("Reports: unable to import django models: %s" % e) sys.exit(1) -from django.db import connection, transaction +from django.db import connection from django.db.models import Q from datetime import datetime, timedelta from time import strptime +from Bcfg2.Reporting.Compat import transaction + KIND_CHOICES = ( #These are the kinds of config elements ('Package', 'Package'), @@ -294,7 +296,7 @@ class Reason(models.Model): return rv @staticmethod - @transaction.commit_on_success + @transaction.atomic def prune_orphans(): '''Prune oprhaned rows... no good way to use the ORM''' cursor = connection.cursor() @@ -311,7 +313,7 @@ class Entries(models.Model): return self.name @staticmethod - @transaction.commit_on_success + @transaction.atomic def prune_orphans(): '''Prune oprhaned rows... no good way to use the ORM''' cursor = connection.cursor() @@ -340,7 +342,7 @@ class Performance(models.Model): return self.metric @staticmethod - @transaction.commit_on_success + @transaction.atomic def prune_orphans(): '''Prune oprhaned rows... no good way to use the ORM''' cursor = connection.cursor() |