def __init__(self, irs, log, scheduler): """ Initialize the (single) clientIF instance :param irs: a Dispatcher object to be used as this object's irs. :type irs: :class:`vdsm.storage.dispatcher.Dispatcher` :param log: a log object to be used for this object's logging. :type log: :class:`logging.Logger` """ self.vmContainerLock = threading.Lock() self._networkSemaphore = threading.Semaphore() self._shutdownSemaphore = threading.Semaphore() self.irs = irs if self.irs: self._contEIOVmsCB = partial(clientIF.contEIOVms, proxy(self)) self.irs.registerDomainStateChangeCallback(self._contEIOVmsCB) self.log = log self._recovery = True # TODO: The guest agent related code spreads around too much. There is # QemuGuestAgentPoller and ChannelListner here and then many instances # of GuestAgent per VM in vm.py. This should be refactored and # operated by single object. Idealy the distinction between what is # served by QEMU-GA and what is server by oVirt GA should not be # visible to the rest of the code. self.channelListener = Listener(self.log) self.qga_poller = QemuGuestAgentPoller(self, log, scheduler) self.mom = None self.servers = {} self._broker_client = None self._subscriptions = defaultdict(list) self._scheduler = scheduler self._unknown_vm_ids = set() if _glusterEnabled: self.gluster = gapi.GlusterApi() else: self.gluster = None try: self.vmContainer = {} self.lastRemoteAccess = 0 self._enabled = True self._netConfigDirty = False self.mom = MomClient(config.get("mom", "socket_path")) self.mom.connect() secret.clear() concurrent.thread(self._recoverThread, name='vmrecovery').start() self.channelListener.settimeout( config.getint('vars', 'guest_agent_timeout')) self.channelListener.start() self.qga_poller.start() self.threadLocal = threading.local() self.threadLocal.client = '' host = config.get('addresses', 'management_ip') port = config.getint('addresses', 'management_port') # When IPv6 is not enabled, fallback to listen on IPv4 address try: self._createAcceptor(host, port) except socket.error as e: if e.errno == errno.EAFNOSUPPORT and host in ('::', '::1'): fallback_host = '0.0.0.0' self._createAcceptor(fallback_host, port) else: raise self._prepareHttpServer() self._prepareJSONRPCServer() self._connectToBroker() except: self.log.error('failed to init clientIF, ' 'shutting down storage dispatcher') if self.irs: self.irs.prepareForShutdown() raise
def __init__(self, irs, log, scheduler): """ Initialize the (single) clientIF instance :param irs: a Dispatcher object to be used as this object's irs. :type irs: :class:`vdsm.storage.dispatcher.Dispatcher` :param log: a log object to be used for this object's logging. :type log: :class:`logging.Logger` """ self.vmContainerLock = threading.Lock() self._networkSemaphore = threading.Semaphore() self._shutdownSemaphore = threading.Semaphore() self.irs = irs if self.irs: self._contEIOVmsCB = partial(clientIF.contEIOVms, proxy(self)) self.irs.registerDomainStateChangeCallback(self._contEIOVmsCB) self.log = log self._recovery = True self.channelListener = Listener(self.log) self.mom = None self.servers = {} self._broker_client = None self._subscriptions = defaultdict(list) self._scheduler = scheduler self._unknown_vm_ids = set() if _glusterEnabled: self.gluster = gapi.GlusterApi() else: self.gluster = None try: self.vmContainer = {} self.lastRemoteAccess = 0 self._enabled = True self._netConfigDirty = False self._prepareMOM() secret.clear() concurrent.thread(self._recoverThread, name='vmrecovery').start() self.channelListener.settimeout( config.getint('vars', 'guest_agent_timeout')) self.channelListener.start() self.threadLocal = threading.local() self.threadLocal.client = '' host = config.get('addresses', 'management_ip') port = config.getint('addresses', 'management_port') # When IPv6 is not enabled, fallback to listen on IPv4 address try: self._createAcceptor(host, port) except socket.error as e: if e.errno == errno.EAFNOSUPPORT and host in ('::', '::1'): fallback_host = '0.0.0.0' self._createAcceptor(fallback_host, port) else: raise self._prepareHttpServer() self._prepareJSONRPCServer() self._connectToBroker() except: self.log.error('failed to init clientIF, ' 'shutting down storage dispatcher') if self.irs: self.irs.prepareForShutdown() raise