def clock(): LOG = logging.getLogger(__name__) LOG.debug("At %s heartbeat once" % time.asctime()) cn.heartbeat() time.sleep(CONF.heartbeat_interval) #TODO: the max depth of recursion clock()
import threading #try: # from brick.openstack.common import log as logging #except ImportError: from vmthunder.openstack.common import log as logging LOG = logging.getLogger(__name__) def synchronized(name): """Synchronization decorator. Decorating a method like so:: @synchronized('mylock') def foo(self, *args): ... ensures that only one thread will execute the foo method at a time. Different methods can share the same lock:: @synchronized('mylock') def foo(self, *args): ... @synchronized('mylock') def bar(self, *args): ...
def clock(): LOG = logging.getLogger(__name__) LOG.debug("At %s heartbeat once" % time.asctime()) cn.heartbeat() time.sleep(int(CONF.heartbeat_interval, 10)) clock()
from vmthunder.openstack.common import log as logging LOG = logging.getLogger(__name__) def reform_connections(connections): """ :param connections: a tuple or list """ if not (isinstance(connections, list) or isinstance(connections, tuple)): raise Exception( 'VMThunder: Unknown connections type: connection: {0:s}, type: {1:s}' .format(connections, type(connections))) new_connections = [] for connection in connections: new_connections.append(reform_connection(connection)) return new_connections def reform_connection(connection): """ :return new_connection: a list includes 'target_portal', 'target_iqn' and 'target_lun'. """ LOG.debug("old connection is :") LOG.debug(connection) if isinstance(connection, dict): new_connection = { 'target_portal': connection['target_portal'], 'target_iqn': connection['target_iqn'], 'target_lun': connection['target_lun'], }