add countdown to async call

This commit is contained in:
Curtis Castrapel 2018-11-28 14:41:56 -08:00
parent e074a14ee9
commit 39b76d18dc
2 changed files with 2 additions and 13 deletions

View File

@ -282,7 +282,7 @@ def create(**kwargs):
pending_cert = database.session_query(PendingCertificate).get(cert.id) pending_cert = database.session_query(PendingCertificate).get(cert.id)
from lemur.common.celery import fetch_acme_cert from lemur.common.celery import fetch_acme_cert
if not current_app.config.get("ACME_DISABLE_AUTORESOLVE", False): 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 return cert

View File

@ -333,12 +333,9 @@ class ACMEIssuerPlugin(IssuerPlugin):
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
super(ACMEIssuerPlugin, self).__init__(*args, **kwargs) super(ACMEIssuerPlugin, self).__init__(*args, **kwargs)
self.acme = None self.acme = AcmeHandler()
def get_dns_provider(self, type): def get_dns_provider(self, type):
if not self.acme:
self.acme = AcmeHandler()
provider_types = { provider_types = {
'cloudflare': cloudflare, 'cloudflare': cloudflare,
'dyn': dyn, 'dyn': dyn,
@ -350,16 +347,12 @@ class ACMEIssuerPlugin(IssuerPlugin):
return provider return provider
def get_all_zones(self, dns_provider): def get_all_zones(self, dns_provider):
if not self.acme:
self.acme = AcmeHandler()
dns_provider_options = json.loads(dns_provider.credentials) dns_provider_options = json.loads(dns_provider.credentials)
account_number = dns_provider_options.get("account_id") account_number = dns_provider_options.get("account_id")
dns_provider_plugin = self.get_dns_provider(dns_provider.provider_type) dns_provider_plugin = self.get_dns_provider(dns_provider.provider_type)
return dns_provider_plugin.get_zones(account_number=account_number) return dns_provider_plugin.get_zones(account_number=account_number)
def get_ordered_certificate(self, pending_cert): 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) acme_client, registration = self.acme.setup_acme_client(pending_cert.authority)
order_info = authorization_service.get(pending_cert.external_id) order_info = authorization_service.get(pending_cert.external_id)
if pending_cert.dns_provider_id: if pending_cert.dns_provider_id:
@ -395,8 +388,6 @@ class ACMEIssuerPlugin(IssuerPlugin):
return cert return cert
def get_ordered_certificates(self, pending_certs): def get_ordered_certificates(self, pending_certs):
if not self.acme:
self.acme = AcmeHandler()
pending = [] pending = []
certs = [] certs = []
for pending_cert in pending_certs: for pending_cert in pending_certs:
@ -479,8 +470,6 @@ class ACMEIssuerPlugin(IssuerPlugin):
:param issuer_options: :param issuer_options:
:return: :raise Exception: :return: :raise Exception:
""" """
if not self.acme:
self.acme = AcmeHandler()
authority = issuer_options.get('authority') authority = issuer_options.get('authority')
create_immediately = issuer_options.get('create_immediately', False) create_immediately = issuer_options.get('create_immediately', False)
acme_client, registration = self.acme.setup_acme_client(authority) acme_client, registration = self.acme.setup_acme_client(authority)