Loading cloudcontrol/node/hypervisor/jobs.py +2 −15 Original line number Diff line number Diff line Loading @@ -14,7 +14,7 @@ import pyev from cloudcontrol.node.exc import TunnelError, DRBDAllocationError, DRBDError from cloudcontrol.node.jobs import BaseThreadedJob from cloudcontrol.node.utils import SocketBuffer, subproc_call from cloudcontrol.node.utils import SocketBuffer, subproc_call, Singleton logger = logging.getLogger(__name__) Loading Loading @@ -573,23 +573,10 @@ class TCPTunnel(object): # logger.debug('Proccessed write event') class Meta(type): """DRBDAllocator metaclass used for singleton implementation.""" def __init__(cls, name, bases, dict): super(Meta, cls).__init__(cls, bases, dict) cls._instance = None def __call__(cls, *args, **kwargs): if cls._instance is None: cls._instance = super(Meta, cls).__call__(*args, **kwargs) return cls._instance class DRBDAllocator(object): """Keeps a list of allocated DRBD devices.""" __metaclass__ = Meta __metaclass__ = Singleton RMMOD = '/sbin/rmmod' MODPROBE = '/sbin/modprobe' Loading cloudcontrol/node/utils.py +13 −0 Original line number Diff line number Diff line Loading @@ -81,3 +81,16 @@ class SocketBuffer(deque): def is_empty(self): return self.current_len == 0 class Singleton(type): """Singleton metaclass.""" def __init__(cls, name, bases, dict): super(Singleton, cls).__init__(cls, bases, dict) cls._instance = None def __call__(cls, *args, **kwargs): if cls._instance is None: cls._instance = super(Singleton, cls).__call__(*args, **kwargs) return cls._instance Loading
cloudcontrol/node/hypervisor/jobs.py +2 −15 Original line number Diff line number Diff line Loading @@ -14,7 +14,7 @@ import pyev from cloudcontrol.node.exc import TunnelError, DRBDAllocationError, DRBDError from cloudcontrol.node.jobs import BaseThreadedJob from cloudcontrol.node.utils import SocketBuffer, subproc_call from cloudcontrol.node.utils import SocketBuffer, subproc_call, Singleton logger = logging.getLogger(__name__) Loading Loading @@ -573,23 +573,10 @@ class TCPTunnel(object): # logger.debug('Proccessed write event') class Meta(type): """DRBDAllocator metaclass used for singleton implementation.""" def __init__(cls, name, bases, dict): super(Meta, cls).__init__(cls, bases, dict) cls._instance = None def __call__(cls, *args, **kwargs): if cls._instance is None: cls._instance = super(Meta, cls).__call__(*args, **kwargs) return cls._instance class DRBDAllocator(object): """Keeps a list of allocated DRBD devices.""" __metaclass__ = Meta __metaclass__ = Singleton RMMOD = '/sbin/rmmod' MODPROBE = '/sbin/modprobe' Loading
cloudcontrol/node/utils.py +13 −0 Original line number Diff line number Diff line Loading @@ -81,3 +81,16 @@ class SocketBuffer(deque): def is_empty(self): return self.current_len == 0 class Singleton(type): """Singleton metaclass.""" def __init__(cls, name, bases, dict): super(Singleton, cls).__init__(cls, bases, dict) cls._instance = None def __call__(cls, *args, **kwargs): if cls._instance is None: cls._instance = super(Singleton, cls).__call__(*args, **kwargs) return cls._instance