コード例 #1
0
ファイル: backend.py プロジェクト: Tvaske/sponge
 def authenticate(self, username, password=None):
     """ authenticate a user """
     try:
         self.server.set_basic_auth_credentials(username, password)
         logging.info("Successfully logged in with password")
         cert = self.userapi.admin_certificate()
         bundle = SpongeBundle(username)
         bundle.write(cert)
         self.server = get_pulp_server(new=True)
         self.server.set_ssl_credentials(bundle.crtpath())
         udata = self.userapi.user(username)
         logger.info("%s logged in successfully" % username)
     except server.ServerRequestError, err:
         logger.warning("Login failure for %s: %s" % (username, err[1]))
         return None
コード例 #2
0
ファイル: rebalanceschedule.py プロジェクト: Tvaske/sponge
    def setup_pulp(self):
        """ instantiate pulp server object and log in """
        config = ConsumerConfig()
        userapi = UserAPI()
        serveropts = config.server
        pulpserver = server.PulpServer(serveropts['host'],
                                       int(serveropts['port']),
                                       serveropts['scheme'],
                                       serveropts['path'])
        server.set_active_server(pulpserver)

        bundle = SpongeBundle(SpongeConfig.get("scheduler_username"))
        try:
            server.active_server.set_basic_auth_credentials(SpongeConfig.get("scheduler_username"),
                                                            SpongeConfig.get("scheduler_password"))
            crt = userapi.admin_certificate()
            bundle.write(crt)
        except server.ServerRequestError, err:
            self.stderr.write("Could not authenticate to Pulp: %s\n" % err[1])
            self.stderr.write("Ensure that the scheduler username and password are set properly in Sponge\n")
            raise SystemExit(1)