Пример #1
0
    def setUpClass(cls):
        super(ConsumerAgentPulpTest, cls).setUpClass()
        cls.ROLES = ROLES
        cls.PROFILE = PROFILE
        from conf.facade.yum import YumRepo
        repo_role = [repo for repo in ROLES.repos if repo.type == 'rpm'][0]
        cls.repo, cls.importer, [
            cls.distributor
        ] = YumRepo.from_role(repo_role).create(cls.pulp)

        cls.rsa = RSA.load_key('./tests/data/fake-consumer.pem')
        bio_fd = BIO.MemoryBuffer()
        cls.rsa.save_pub_key_bio(bio_fd)
        cls.rsa_pub_pem = bio_fd.getvalue()
        cls.consumer = Consumer.register(cls.pulp,
                                         cls.__name__ + '_consumer',
                                         rsa_pub=cls.rsa_pub_pem)
        #cls.binding_data = {'repo_id': cls.repo.id, 'distributor_id': cls.distributor.id}
        cls.log.info('instantiating agent')
        cls.agent = Agent(pulp_auto.handler,
                          PROFILE=pulp_auto.handler.profile.PROFILE)
        cls.log.info('instantiating qpid handle')
        cls.qpid_handle = QpidHandle(ROLES.qpid.url,
                                     cls.consumer.id,
                                     auth=Authenticator(
                                         signing_key=cls.rsa,
                                         verifying_key=cls.pulp.pubkey))
 def setUpClass(cls):
     super(ConsumerAuthTest, cls).setUpClass()
     cls.ROLES = ROLES
     cls.PROFILE = PROFILE
     cls.rsa_primary = RSA.load_key(
         '/usr/share/pulp_auto/tests/data/fake-consumer.pem')
     cls.rsa_secondary = RSA.load_key(
         '/usr/share/pulp_auto/tests/data/fake-consumer-secondary.pem')
     bio_fd = BIO.MemoryBuffer()
     cls.rsa_primary.save_pub_key_bio(bio_fd)
     cls.pub_pem_primary = bio_fd.getvalue()
     bio_fd = BIO.MemoryBuffer()
     cls.rsa_secondary.save_pub_key_bio(bio_fd)
     cls.pub_pem_secondary = bio_fd.getvalue()
     cls.repo, cls.importer, cls.distributor = create_yum_repo(
         cls.pulp,
         **[repo for repo in cls.ROLES.repos if repo.type == 'rpm'][0])
     cls.consumer = Consumer.register(cls.pulp,
                                      cls.__name__ + '_consumer',
                                      rsa_pub=cls.pub_pem_primary)
     cls.agent = Agent(pulp_auto.handler,
                       PROFILE=pulp_auto.handler.profile.PROFILE)
     cls.qpid_handle = QpidHandle(cls.ROLES.qpid.url,
                                  cls.consumer.id,
                                  auth=Authenticator(
                                      signing_key=cls.rsa_primary,
                                      verifying_key=cls.pulp.pubkey))
Пример #3
0
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