def run(url, consumer_name, reporting, polling_frequency, key_file, pulp_url, register): from gevent import monkey monkey.patch_all(select=False, thread=False) if not pulp_url: # use http://admin:admin@<host part from amqp url>/" amqp_url = urllib3.util.parse_url(url) pulp_url = 'https://*****:*****@' + amqp_url.host + '/' rsa = None pem = "" if key_file: # load rsa and set-up authentication rsa = RSA.load_key(key_file) bio_fd = BIO.MemoryBuffer() rsa.save_pub_key_bio(bio_fd) pem = bio_fd.getvalue() pulp = Pulp(pulp_url) consumer = None if register: consumer = Consumer.register(pulp, consumer_name, rsa_pub=pem) log.info("registered: " + str(consumer)) qh = QpidHandle(url, consumer_name, authenticator=Authenticator(signing_key=rsa, verifying_key=pulp.pubkey)) a = Agent(pulp_auto.handler, PROFILE=PROFILE) ### try: with a.catching(reporting), a.running(qh): while True: try: time.sleep(1.0/polling_frequency) except KeyboardInterrupt: if consumer: log.info("unregistered: " + str(consumer.delete(pulp))) break except Exception as e: pass