From 39b76d18dce1511f5909d0fb67c375a14eeb5eff Mon Sep 17 00:00:00 2001 From: Curtis Castrapel Date: Wed, 28 Nov 2018 14:41:56 -0800 Subject: [PATCH] add countdown to async call --- lemur/certificates/service.py | 2 +- lemur/plugins/lemur_acme/plugin.py | 13 +------------ 2 files changed, 2 insertions(+), 13 deletions(-) diff --git a/lemur/certificates/service.py b/lemur/certificates/service.py index d965192e..c9a2fa24 100644 --- a/lemur/certificates/service.py +++ b/lemur/certificates/service.py @@ -282,7 +282,7 @@ def create(**kwargs): pending_cert = database.session_query(PendingCertificate).get(cert.id) from lemur.common.celery import fetch_acme_cert if not current_app.config.get("ACME_DISABLE_AUTORESOLVE", False): - fetch_acme_cert.delay(pending_cert.id) + fetch_acme_cert.apply_async((pending_cert.id,), countdown=5) return cert diff --git a/lemur/plugins/lemur_acme/plugin.py b/lemur/plugins/lemur_acme/plugin.py index 53d11935..62e647c4 100644 --- a/lemur/plugins/lemur_acme/plugin.py +++ b/lemur/plugins/lemur_acme/plugin.py @@ -333,12 +333,9 @@ class ACMEIssuerPlugin(IssuerPlugin): def __init__(self, *args, **kwargs): super(ACMEIssuerPlugin, self).__init__(*args, **kwargs) - self.acme = None + self.acme = AcmeHandler() def get_dns_provider(self, type): - if not self.acme: - self.acme = AcmeHandler() - provider_types = { 'cloudflare': cloudflare, 'dyn': dyn, @@ -350,16 +347,12 @@ class ACMEIssuerPlugin(IssuerPlugin): return provider def get_all_zones(self, dns_provider): - if not self.acme: - self.acme = AcmeHandler() dns_provider_options = json.loads(dns_provider.credentials) account_number = dns_provider_options.get("account_id") dns_provider_plugin = self.get_dns_provider(dns_provider.provider_type) return dns_provider_plugin.get_zones(account_number=account_number) def get_ordered_certificate(self, pending_cert): - if not self.acme: - self.acme = AcmeHandler() acme_client, registration = self.acme.setup_acme_client(pending_cert.authority) order_info = authorization_service.get(pending_cert.external_id) if pending_cert.dns_provider_id: @@ -395,8 +388,6 @@ class ACMEIssuerPlugin(IssuerPlugin): return cert def get_ordered_certificates(self, pending_certs): - if not self.acme: - self.acme = AcmeHandler() pending = [] certs = [] for pending_cert in pending_certs: @@ -479,8 +470,6 @@ class ACMEIssuerPlugin(IssuerPlugin): :param issuer_options: :return: :raise Exception: """ - if not self.acme: - self.acme = AcmeHandler() authority = issuer_options.get('authority') create_immediately = issuer_options.get('create_immediately', False) acme_client, registration = self.acme.setup_acme_client(authority)