Blame SOURCES/cobbler-concurrency.patch

1070a0
diff -rupN cobbler-2.0.7-orig/cobbler/collection_distros.py cobbler-2.0.7/cobbler/collection_distros.py
1070a0
--- cobbler-2.0.7-orig/cobbler/collection_distros.py	2013-10-21 14:11:29.327459462 -0400
1070a0
+++ cobbler-2.0.7/cobbler/collection_distros.py	2013-10-22 08:22:48.727270516 -0400
1070a0
@@ -68,7 +68,11 @@ class Distros(collection.Collection):
1070a0
                 if with_sync:
1070a0
                     lite_sync = action_litesync.BootLiteSync(self.config, logger=logger)
1070a0
                     lite_sync.remove_single_distro(name)
1070a0
-            del self.listing[name]
1070a0
+            self.lock.acquire()
1070a0
+            try:
1070a0
+                del self.listing[name]
1070a0
+            finally:
1070a0
+                self.lock.release()
1070a0
 
1070a0
             self.config.serialize_delete(self, obj)
1070a0
 
1070a0
diff -rupN cobbler-2.0.7-orig/cobbler/collection_images.py cobbler-2.0.7/cobbler/collection_images.py
1070a0
--- cobbler-2.0.7-orig/cobbler/collection_images.py	2013-10-21 14:11:29.327459462 -0400
1070a0
+++ cobbler-2.0.7/cobbler/collection_images.py	2013-10-22 08:23:16.008462783 -0400
1070a0
@@ -65,7 +65,11 @@ class Images(collection.Collection):
1070a0
                     lite_sync = action_litesync.BootLiteSync(self.config, logger=logger)
1070a0
                     lite_sync.remove_single_image(name)
1070a0
 
1070a0
-            del self.listing[name]
1070a0
+            self.lock.acquire()
1070a0
+            try:
1070a0
+                del self.listing[name]
1070a0
+            finally:
1070a0
+                self.lock.release()
1070a0
             self.config.serialize_delete(self, obj)
1070a0
 
1070a0
             if with_delete:
1070a0
diff -rupN cobbler-2.0.7-orig/cobbler/collection_profiles.py cobbler-2.0.7/cobbler/collection_profiles.py
1070a0
--- cobbler-2.0.7-orig/cobbler/collection_profiles.py	2013-10-21 14:11:29.326459455 -0400
1070a0
+++ cobbler-2.0.7/cobbler/collection_profiles.py	2013-10-22 08:35:28.586626217 -0400
1070a0
@@ -68,7 +68,11 @@ class Profiles(collection.Collection):
1070a0
             if with_delete:
1070a0
                 if with_triggers: 
1070a0
                     utils.run_triggers(self.config.api, obj, "/var/lib/cobbler/triggers/delete/profile/pre/*", [], logger)
1070a0
-            del self.listing[name]
1070a0
+            self.lock.acquire()
1070a0
+            try:
1070a0
+                del self.listing[name]
1070a0
+            finally:
1070a0
+                self.lock.release()
1070a0
             self.config.serialize_delete(self, obj)
1070a0
             if with_delete:
1070a0
                 if with_triggers: 
1070a0
diff -rupN cobbler-2.0.7-orig/cobbler/collection.py cobbler-2.0.7/cobbler/collection.py
1070a0
--- cobbler-2.0.7-orig/cobbler/collection.py	2013-10-21 14:11:29.331459490 -0400
1070a0
+++ cobbler-2.0.7/cobbler/collection.py	2013-10-22 08:32:46.137481152 -0400
1070a0
@@ -26,6 +26,7 @@ import utils
1070a0
 import glob
1070a0
 import time
1070a0
 import random
1070a0
+from threading import Lock
1070a0
 
1070a0
 import action_litesync
1070a0
 import item_system
1070a0
@@ -45,6 +46,7 @@ class Collection:
1070a0
         self.clear()
1070a0
         self.api = self.config.api
1070a0
         self.lite_sync = None
1070a0
+        self.lock = Lock()
1070a0
 
1070a0
     def factory_produce(self,config,seed_data):
1070a0
         """
1070a0
@@ -89,9 +91,13 @@ class Collection:
1070a0
         if len(kargs) == 1 and kargs.has_key("name") and not return_list:
1070a0
             return self.listing.get(kargs["name"].lower(), None)
1070a0
 
1070a0
-        for (name, obj) in self.listing.iteritems():
1070a0
-            if obj.find_match(kargs, no_errors=no_errors):
1070a0
-                matches.append(obj)
1070a0
+        self.lock.acquire()
1070a0
+        try:
1070a0
+            for (name, obj) in self.listing.iteritems():
1070a0
+                if obj.find_match(kargs, no_errors=no_errors):
1070a0
+                    matches.append(obj)
1070a0
+        finally:
1070a0
+            self.lock.release()
1070a0
 
1070a0
         if not return_list:
1070a0
             if len(matches) == 0:
1070a0
@@ -266,14 +272,22 @@ class Collection:
1070a0
 
1070a0
         if not save:
1070a0
             # don't need to run triggers, so add it already ...
1070a0
-            self.listing[ref.name.lower()] = ref
1070a0
+            self.lock.acquire()
1070a0
+            try:
1070a0
+                self.listing[ref.name.lower()] = ref
1070a0
+            finally:
1070a0
+                self.lock.release()
1070a0
 
1070a0
         # perform filesystem operations
1070a0
         if save:
1070a0
             # failure of a pre trigger will prevent the object from being added
1070a0
             if with_triggers:
1070a0
                 utils.run_triggers(self.api, ref,"/var/lib/cobbler/triggers/add/%s/pre/*" % self.collection_type(), [], logger)
1070a0
-            self.listing[ref.name.lower()] = ref
1070a0
+            self.lock.acquire()
1070a0
+            try:
1070a0
+                self.listing[ref.name.lower()] = ref
1070a0
+            finally:
1070a0
+                self.lock.release()
1070a0
 
1070a0
             # save just this item if possible, if not, save
1070a0
             # the whole collection
1070a0
diff -rupN cobbler-2.0.7-orig/cobbler/collection_repos.py cobbler-2.0.7/cobbler/collection_repos.py
1070a0
--- cobbler-2.0.7-orig/cobbler/collection_repos.py	2013-10-21 14:11:29.324459441 -0400
1070a0
+++ cobbler-2.0.7/cobbler/collection_repos.py	2013-10-22 08:24:23.448938085 -0400
1070a0
@@ -58,7 +58,11 @@ class Repos(collection.Collection):
1070a0
                 if with_triggers: 
1070a0
                     utils.run_triggers(self.config.api, obj, "/var/lib/cobbler/triggers/delete/repo/pre/*", [], logger)
1070a0
 
1070a0
-            del self.listing[name]
1070a0
+            self.lock.acquire()
1070a0
+            try:
1070a0
+                del self.listing[name]
1070a0
+            finally:
1070a0
+                self.lock.release()
1070a0
             self.config.serialize_delete(self, obj)
1070a0
 
1070a0
             if with_delete:
1070a0
diff -rupN cobbler-2.0.7-orig/cobbler/collection_systems.py cobbler-2.0.7/cobbler/collection_systems.py
1070a0
--- cobbler-2.0.7-orig/cobbler/collection_systems.py	2013-10-21 14:11:29.324459441 -0400
1070a0
+++ cobbler-2.0.7/cobbler/collection_systems.py	2013-10-22 08:24:36.502030081 -0400
1070a0
@@ -56,7 +56,11 @@ class Systems(collection.Collection):
1070a0
                 if with_sync:
1070a0
                     lite_sync = action_litesync.BootLiteSync(self.config, logger=logger)
1070a0
                     lite_sync.remove_single_system(name)
1070a0
-            del self.listing[name]
1070a0
+            self.lock.acquire()
1070a0
+            try:
1070a0
+                del self.listing[name]
1070a0
+            finally:
1070a0
+                self.lock.release()
1070a0
             self.config.serialize_delete(self, obj)
1070a0
             if with_delete:
1070a0
                 if with_triggers: