def main(): """Main, as called from the script instance by pyramid""" args = cmdline() config_path = args.inifile setup_logging(config_path) config.configure_log_level(args) env = bootstrap(config_path) settings, closer = env["registry"].settings, env["closer"] db_url = config.get_db_url(args, settings) engine = create_engine(db_url) models.init_session(engine) delay = int(settings.get("delay", 500)) / 1000 valid = int(settings.get("valid", 3)) delta = datetime.timedelta(days=0, hours=valid) del valid try: ca_cert_path, ca_key_path = config.get_ca_cert_key_path(args, settings) except ValueError as error: error_out(str(error), closer) ca = models.SigningCert.from_files(ca_cert_path, ca_key_path) mainloop(delay, ca, delta)
def setUp(self): self.config = testing.setUp() from sqlalchemy import create_engine engine = create_engine("sqlite://") init_session(engine, create=True) from caramel.models import MyModel with transaction.manager: model = MyModel(name="one", value=55) model.save()
def setUpClass(cls): super(ModelTestCase, cls).setUpClass() # Clear existing session, if any. DBSession.remove() from sqlalchemy import create_engine engine = create_engine("sqlite://") init_session(engine, create=True) with transaction.manager: csr = fixtures.CSRData.initial() csr.save()
def main(): args = cmdline() config_path = args.inifile settings = get_appsettings(config_path) setup_logging(config_path) config.configure_log_level(args) db_url = config.get_db_url(args, settings) engine = create_engine(db_url) init_session(engine, create=True)
def main(): args = cmdline() env = bootstrap(args.inifile) settings, closer = env['registry'].settings, env['closer'] engine = create_engine(settings['sqlalchemy.url']) models.init_session(engine) settings_backdate = asbool(settings.get('backdate', False)) _short = int(settings.get('lifetime.short', 48)) _long = int(settings.get('lifetime.long', 7*24)) life_short = calc_lifetime(relativedelta(hours=_short)) life_long = calc_lifetime(relativedelta(hours=_long)) del _short, _long if not args.sign and not args.refresh and not args.reject: print_list() closer() sys.exit(0) try: with open(settings['ca.cert'], 'rt') as f: ca_cert = f.read() with open(settings['ca.key'], 'rt') as f: ca_key = f.read() except KeyError: error_out("config file needs ca.cert and ca.key properly set") if args.sign and args.refresh: error_out("Only refresh or sign, not both") if args.reject and args.refresh: error_out("Reject doesn't go well with other arguments.") if args.reject and args.sign: error_out("Reject doesn't go well with other arguments.") if life_short > life_long: error_out("Short lived certs ({0}) shouldn't last longer " "than long lived certs ({1})".format(life_short, life_long)) if args.reject: csr_reject(args.reject) if args.sign: if args.long: csr_sign(args.sign, ca_key, ca_cert, life_long, settings_backdate) else: # Never backdate short lived certs csr_sign(args.sign, ca_key, ca_cert, life_short, False) if args.refresh: csr_resign(ca_key, ca_cert, life_short, life_long, settings_backdate)
def main(): args = cmdline() env = bootstrap(args.inifile) settings, closer = env["registry"].settings, env["closer"] db_url = config.get_db_url(args, settings) engine = create_engine(db_url) models.init_session(engine) settings_backdate = asbool(settings.get("backdate", False)) _short = int(settings.get("lifetime.short", 48)) _long = int(settings.get("lifetime.long", 7 * 24)) life_short = calc_lifetime(relativedelta(hours=_short)) life_long = calc_lifetime(relativedelta(hours=_long)) del _short, _long try: ca_cert_path, ca_key_path = config.get_ca_cert_key_path(args, settings) except ValueError as error: error_out(str(error)) ca = models.SigningCert.from_files(ca_cert_path, ca_key_path) if life_short > life_long: error_out( "Short lived certs ({0}) shouldn't last longer " "than long lived certs ({1})".format(life_short, life_long) ) if args.list: print_list() closer() sys.exit(0) if args.reject: csr_reject(args.reject) if args.wipe: error_out("Not implemented yet") if args.clean: error_out("Not implemented yet") if args.cleanall: clean_all() if args.sign: if args.long: csr_sign(args.sign, ca, life_long, settings_backdate) else: # Never backdate short lived certs csr_sign(args.sign, ca, life_short, False) if args.refresh: csr_resign(ca, life_short, life_long, settings_backdate)
def main(): args = cmdline() env = bootstrap(args.inifile) settings, closer = env["registry"].settings, env["closer"] engine = create_engine(settings["sqlalchemy.url"]) models.init_session(engine) settings_backdate = asbool(settings.get("backdate", False)) _short = int(settings.get("lifetime.short", 48)) _long = int(settings.get("lifetime.long", 7 * 24)) life_short = calc_lifetime(relativedelta(hours=_short)) life_long = calc_lifetime(relativedelta(hours=_long)) del _short, _long try: certname = settings["ca.cert"] keyname = settings["ca.key"] except KeyError: error_out("config file needs ca.cert and ca.key properly set") ca = models.SigningCert.from_files(certname, keyname) if life_short > life_long: error_out( "Short lived certs ({0}) shouldn't last longer " "than long lived certs ({1})".format(life_short, life_long) ) if args.list: print_list() closer() sys.exit(0) if args.reject: csr_reject(args.reject) if args.wipe: error_out("Not implemented yet") if args.clean: error_out("Not implemented yet") if args.cleanall: clean_all() if args.sign: if args.long: csr_sign(args.sign, ca, life_long, settings_backdate) else: # Never backdate short lived certs csr_sign(args.sign, ca, life_short, False) if args.refresh: csr_resign(ca, life_short, life_long, settings_backdate)
def main(): """Main, as called from the script instance by pyramid""" logging.basicConfig() logger.setLevel(logging.DEBUG) args = cmdline() env = bootstrap(args.inifile) settings, closer = env['registry'].settings, env['closer'] engine = create_engine(settings['sqlalchemy.url']) models.init_session(engine) delay = int(settings.get('delay', 500)) / 1000 valid = int(settings.get('valid', 3)) delta = datetime.timedelta(days=0, hours=valid) del valid try: certname = settings["ca.cert"] keyname = settings["ca.key"] except KeyError: error_out("config file needs ca.cert and ca.key properly set", closer) ca = models.SigningCert.from_files(certname, keyname) mainloop(delay, ca, delta)