ETC_MASK_EVENTS_TO_WATCH = pyinotify.IN_CLOSE_WRITE | \ pyinotify.IN_CREATE | \ pyinotify.IN_DELETE | \ pyinotify.IN_MODIFY | \ pyinotify.IN_MOVED_FROM | \ pyinotify.IN_MOVED_TO | \ pyinotify.IN_UNMOUNT RUN_MASK_EVENTS_TO_WATCH = pyinotify.IN_DELETE | \ pyinotify.IN_MOVED_TO notifier = pyinotify.ThreadedNotifier(wm, Kxp()) notifier.start() _ = wm.add_watch(KVM_ETC, ETC_MASK_EVENTS_TO_WATCH, rec=True) logger.info('Watching {0}...'.format(KVM_ETC), print_msg=True) _ = wm.add_watch(KVM_RUN, RUN_MASK_EVENTS_TO_WATCH, rec=True) logger.info('Watching {0}...'.format(KVM_RUN), print_msg=True) logger.info('KVM xml processor active...', print_msg=True) if run_event_consumer(): # Load mapping mapping = {} path = os.path.join(os.path.dirname(__file__), 'mappings') for filename in os.listdir(path): if os.path.isfile(os.path.join( path, filename)) and filename.endswith('.py'): name = filename.replace('.py', '') module = imp.load_source(name, os.path.join(path, filename)) for member in inspect.getmembers(module):
except Exception, ex: logger.exception('Unexpected error processing tasks: {0}'.format(ex)) raise if 'interval' in return_data: interval = return_data['interval'] if interval != self.interval: self.interval = interval self._update_config('interval', str(interval)) self.interval = return_data['interval'] if __name__ == '__main__': try: if int(Configuration.get('ovs.support.enabled')) == 0: print 'Support not enabled' sys.exit(0) logger.info('Starting up') client = SupportAgent() while True: try: client.run() time.sleep(client.interval) except KeyboardInterrupt: raise except Exception, exception: logger.exception('Unexpected error during run: {0}'.format(exception)) time.sleep(10) except KeyboardInterrupt: print 'Aborting...' logger.info('Stopping (keyboard interrupt)')
pyinotify.IN_CLOSE_WRITE | pyinotify.IN_CREATE | pyinotify.IN_DELETE | pyinotify.IN_MODIFY | pyinotify.IN_MOVED_FROM | pyinotify.IN_MOVED_TO | pyinotify.IN_UNMOUNT ) RUN_MASK_EVENTS_TO_WATCH = pyinotify.IN_DELETE | pyinotify.IN_MOVED_TO notifier = pyinotify.ThreadedNotifier(wm, Kxp()) notifier.start() _ = wm.add_watch(KVM_ETC, ETC_MASK_EVENTS_TO_WATCH, rec=True) logger.info("Watching {0}...".format(KVM_ETC), print_msg=True) _ = wm.add_watch(KVM_RUN, RUN_MASK_EVENTS_TO_WATCH, rec=True) logger.info("Watching {0}...".format(KVM_RUN), print_msg=True) logger.info("KVM xml processor active...", print_msg=True) if run_event_consumer(): # Load mapping mapping = {} path = os.path.join(os.path.dirname(__file__), "mappings") for filename in os.listdir(path): if os.path.isfile(os.path.join(path, filename)) and filename.endswith(".py"): name = filename.replace(".py", "") module = imp.load_source(name, os.path.join(path, filename)) for member in inspect.getmembers(module): if ( inspect.isclass(member[1])