Пример #1
0
# Reading config
conf_file='/etc/pkgevent.ini'
try:
    config = configparser.ConfigParser()
    config.read(conf_file)
    zmq_host=config.get('common', 'zmq_host')
    pub_port=config.get('common', 'pub_port')
    events_logfile=config.get('common', 'events_logfile')
    response_topic=config.get('common', 'response_topic')
except Exception as err:
    e = sys.exc_info()[0]
    print ('Error while reading configfile - %s ' % conf_file)
    print (sys.exc_info())
    sys.exit(2)

pkgutils.get_logger('events_logger', events_logfile)
events_logger = logging.getLogger('events_logger')


# Create socket to talk to server
context = zmq.Context()
socket = context.socket(zmq.SUB)
socket.connect ("tcp://%s:%s" % (zmq_host, pub_port))
socket.setsockopt(zmq.SUBSCRIBE, response_topic)

events_logger.info("Starting pkgevent_listener")

if __name__ == '__main__':
    while True:
        string = socket.recv()
        if string:
Пример #2
0
    zmq_host = config.get('common', 'zmq_host')
    yum_master = config.get('common', 'yum_master')
    pub_port = config.get('common', 'pub_port')
    sub_port = config.get('common', 'sub_port')
    events_logfile = config.get('common', 'events_logfile')
    action_logfile = config.get('common', 'action_logfile')
    request_topic = config.get('common', 'request_topic')
    response_topic = config.get('common', 'response_topic')
except Exception as err:
    e = sys.exc_info()[0]
    print('Error while reading configfile - %s ' % conf_file)
    print(sys.exc_info())
    sys.exit(2)

send_from = os.uname()[1]
pkgutils.get_logger('events_logger', events_logfile)
pkgutils.get_logger('action_logger', action_logfile)
events_logger = logging.getLogger('events_logger')
action_logger = logging.getLogger('action_logger')

#events_logger=pkgutils.get_logger(events_logfile)
#action_logger=pkgutils.get_logger(action_logfile)

# Create socket to subcribe to "Request" queue from the zeroMQ server
context = zmq.Context()
socket = context.socket(zmq.SUB)
events_logger.info("Listening for events from %s" % zmq_host)
socket.connect("tcp://%s:%s" % (zmq_host, pub_port))
socket.setsockopt(zmq.SUBSCRIBE, request_topic)

Пример #3
0
    zmq_host=config.get('common', 'zmq_host')
    yum_master=config.get('common', 'yum_master')
    pub_port=config.get('common', 'pub_port')
    sub_port=config.get('common', 'sub_port')
    events_logfile=config.get('common', 'events_logfile')
    action_logfile=config.get('common', 'action_logfile')
    request_topic=config.get('common', 'request_topic')
    response_topic=config.get('common', 'response_topic')
except Exception as err:
    e = sys.exc_info()[0]
    print ('Error while reading configfile - %s ' % conf_file)
    print (sys.exc_info())
    sys.exit(2)

send_from=os.uname()[1]
pkgutils.get_logger('events_logger', events_logfile)
pkgutils.get_logger('action_logger', action_logfile)
events_logger = logging.getLogger('events_logger')
action_logger = logging.getLogger('action_logger')

#events_logger=pkgutils.get_logger(events_logfile)
#action_logger=pkgutils.get_logger(action_logfile)

# Create socket to subcribe to "Request" queue from the zeroMQ server
context = zmq.Context()
socket = context.socket(zmq.SUB)
events_logger.info("Listening for events from %s" % zmq_host)
socket.connect ("tcp://%s:%s" % (zmq_host, pub_port))
socket.setsockopt(zmq.SUBSCRIBE, request_topic)

Пример #4
0
    pub_port=config.get('common', 'pub_port')
    events_logfile=config.get('common', 'events_logfile')
    request_topic=config.get('common', 'request_topic')
    response_topic=config.get('common', 'response_topic')
    transport=config.get('common', 'transport')
    saltmaster=config.get('salt', 'saltmaster')

    config.read(packagebuilder_ini)
    my_mirrors=config.get('misc', 'my_mirrors')
except Exception as err:
    e = sys.exc_info()[0]
    print ('Error while reading configfile - %s ' % conf_file)
    print (sys.exc_info())
    sys.exit(2)

pkgutils.get_logger('events_logger', events_logfile)
events_logger = logging.getLogger('events_logger')
my_mirrors = my_mirrors.split()

def listen_to_response(sec=5):
    '''
    This function will listen to reponse topic for 5 seconds by default and print out the response result
    '''
    # Create socket to talk to server
    con = zmq.Context()
    socket = con.socket(zmq.SUB)
    socket.connect ("tcp://%s:%s" % (zmq_host, pub_port))
    socket.setsockopt(zmq.SUBSCRIBE, response_topic)
    hosts_responded = []
    count = 0
    timer = sec * 10