Merge pull request #2171 from castrapel/letsencrypt_fix
LetsEncrypt Celery Flow
This commit is contained in:
commit
d36a51fabb
|
@ -21,7 +21,10 @@ from lemur.pending_certificates import service as pending_certificate_service
|
||||||
from lemur.plugins.base import plugins
|
from lemur.plugins.base import plugins
|
||||||
from lemur.sources.cli import clean, sync, validate_sources
|
from lemur.sources.cli import clean, sync, validate_sources
|
||||||
|
|
||||||
flask_app = create_app()
|
if current_app:
|
||||||
|
flask_app = current_app
|
||||||
|
else:
|
||||||
|
flask_app = create_app()
|
||||||
|
|
||||||
|
|
||||||
def make_celery(app):
|
def make_celery(app):
|
||||||
|
|
|
@ -23,7 +23,8 @@ class DnsProvider(db.Model):
|
||||||
status = Column(String(length=128), nullable=True)
|
status = Column(String(length=128), nullable=True)
|
||||||
options = Column(JSON, nullable=True)
|
options = Column(JSON, nullable=True)
|
||||||
domains = Column(JSON, nullable=True)
|
domains = Column(JSON, nullable=True)
|
||||||
certificates = relationship("Certificate", backref='dns_provider', foreign_keys='Certificate.dns_provider_id')
|
certificates = relationship("Certificate", backref='dns_provider', foreign_keys='Certificate.dns_provider_id',
|
||||||
|
lazy='dynamic')
|
||||||
|
|
||||||
def __init__(self, name, description, provider_type, credentials):
|
def __init__(self, name, description, provider_type, credentials):
|
||||||
self.name = name
|
self.name = name
|
||||||
|
|
|
@ -333,9 +333,10 @@ 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 = AcmeHandler()
|
|
||||||
|
|
||||||
def get_dns_provider(self, type):
|
def get_dns_provider(self, type):
|
||||||
|
self.acme = AcmeHandler()
|
||||||
|
|
||||||
provider_types = {
|
provider_types = {
|
||||||
'cloudflare': cloudflare,
|
'cloudflare': cloudflare,
|
||||||
'dyn': dyn,
|
'dyn': dyn,
|
||||||
|
@ -347,12 +348,14 @@ class ACMEIssuerPlugin(IssuerPlugin):
|
||||||
return provider
|
return provider
|
||||||
|
|
||||||
def get_all_zones(self, dns_provider):
|
def get_all_zones(self, dns_provider):
|
||||||
|
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):
|
||||||
|
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:
|
||||||
|
@ -388,6 +391,7 @@ class ACMEIssuerPlugin(IssuerPlugin):
|
||||||
return cert
|
return cert
|
||||||
|
|
||||||
def get_ordered_certificates(self, pending_certs):
|
def get_ordered_certificates(self, pending_certs):
|
||||||
|
self.acme = AcmeHandler()
|
||||||
pending = []
|
pending = []
|
||||||
certs = []
|
certs = []
|
||||||
for pending_cert in pending_certs:
|
for pending_cert in pending_certs:
|
||||||
|
@ -470,6 +474,7 @@ class ACMEIssuerPlugin(IssuerPlugin):
|
||||||
:param issuer_options:
|
:param issuer_options:
|
||||||
:return: :raise Exception:
|
:return: :raise Exception:
|
||||||
"""
|
"""
|
||||||
|
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)
|
||||||
|
|
Loading…
Reference in New Issue