import accounts
import logger
import tools
+from threading import BoundedSemaphore
+
+globalsem = BoundedSemaphore()
# special constant that tells vserver to keep its existing settings
KEEP_LIMIT = vserver.VC_LIM_KEEP
SHELL = '/bin/vsh'
TYPE = 'sliver.VServer'
- _init_disk_info_sem = tools.NMLock("/var/run/nm-disk-info.lock")
+ _init_disk_info_sem = globalsem
def __init__(self, rec):
logger.verbose ('initing Sliver_VS with name=%s'%rec['name'])
class NMLock:
def __init__(self, file):
+ logger.log("Lock %s initialized." % file, 2)
self.fd = os.open(file, os.O_RDWR|os.O_CREAT, 0600)
flags = fcntl.fcntl(self.fd, fcntl.F_GETFD)
flags |= fcntl.FD_CLOEXEC
def __del__(self):
os.close(self.fd)
def acquire(self):
- fcntl.lockf(self.fd, fcntl.LOCK_EX)
+ logger.log("Lock acquired.", 2)
+ fcntl.lockf(self.fd, fcntl.LOCK_SH)
def release(self):
+ logger.log("Lock released.", 2)
fcntl.lockf(self.fd, fcntl.LOCK_UN)