diff --git a/lemur/migrations/versions/5ae0ecefb01f_.py b/lemur/migrations/versions/5ae0ecefb01f_.py new file mode 100644 index 00000000..a471c4bf --- /dev/null +++ b/lemur/migrations/versions/5ae0ecefb01f_.py @@ -0,0 +1,32 @@ +"""Convert pending cert status field to text + +Revision ID: 5ae0ecefb01f +Revises: 1db4f82bc780 +Create Date: 2018-08-14 08:16:43.329316 + +""" + +# revision identifiers, used by Alembic. +revision = '5ae0ecefb01f' +down_revision = '1db4f82bc780' + +from alembic import op +import sqlalchemy as sa + + +def upgrade(): + op.alter_column( + table_name='pending_certs', + column_name='status', + nullable=True, + type_=sa.TEXT() + ) + + +def downgrade(): + op.alter_column( + table_name='pending_certs', + column_name='status', + nullable=True, + type_=sa.VARCHAR(128) + ) diff --git a/lemur/pending_certificates/cli.py b/lemur/pending_certificates/cli.py index 0deeaf68..cbce700d 100644 --- a/lemur/pending_certificates/cli.py +++ b/lemur/pending_certificates/cli.py @@ -107,12 +107,12 @@ def fetch_all_acme(): if pending_cert.number_attempts > 4: error_log["message"] = "Deleting pending certificate" send_pending_failure_notification(pending_cert, notify_owner=pending_cert.notify) - pending_certificate_service.delete_by_id(pending_cert.id) + pending_certificate_service.delete(pending_certificate_service.cancel(pending_cert)) else: pending_certificate_service.increment_attempt(pending_cert) pending_certificate_service.update( cert.get("pending_cert").id, - status=str(cert.get("last_error"))[0:128] + status=str(cert.get("last_error")) ) current_app.logger.error(error_log) log_data["message"] = "Complete" diff --git a/lemur/pending_certificates/models.py b/lemur/pending_certificates/models.py index a43834d4..bd516f67 100644 --- a/lemur/pending_certificates/models.py +++ b/lemur/pending_certificates/models.py @@ -39,7 +39,7 @@ class PendingCertificate(db.Model): date_created = Column(ArrowType, PassiveDefault(func.now()), nullable=False) dns_provider_id = Column(Integer, ForeignKey('dns_providers.id', ondelete="CASCADE")) - status = Column(String(128)) + status = Column(Text(), nullable=True) rotation = Column(Boolean, default=False) user_id = Column(Integer, ForeignKey('users.id')) diff --git a/lemur/plugins/lemur_acme/plugin.py b/lemur/plugins/lemur_acme/plugin.py index 7c04ca44..926035c4 100644 --- a/lemur/plugins/lemur_acme/plugin.py +++ b/lemur/plugins/lemur_acme/plugin.py @@ -215,7 +215,7 @@ class AcmeHandler(object): if not dns_provider.domains: continue for name in dns_provider.domains: - if domain.endswith(name): + if domain.endswith("." + name): self.dns_providers_for_domain[domain].append(dns_provider) return self.dns_providers_for_domain @@ -477,7 +477,8 @@ class ACMEIssuerPlugin(IssuerPlugin): current_app.logger.debug("Using DNS provider: {0}".format(dns_provider.provider_type)) dns_provider_plugin = __import__(dns_provider.provider_type, globals(), locals(), [], 1) account_number = credentials.get("account_id") - if dns_provider.provider_type == 'route53' and not account_number: + provider_type = dns_provider.provider_type + if provider_type == "route53" and not account_number: error = "Route53 DNS Provider {} does not have an account number configured.".format(dns_provider.name) current_app.logger.error(error) raise InvalidConfiguration(error) @@ -485,6 +486,7 @@ class ACMEIssuerPlugin(IssuerPlugin): dns_provider = {} dns_provider_options = None account_number = None + provider_type = None domains = self.acme.get_domains(issuer_options) if not create_immediately: @@ -497,7 +499,7 @@ class ACMEIssuerPlugin(IssuerPlugin): authz_domains.append(d.value) dns_authorization = authorization_service.create(account_number, authz_domains, - dns_provider.get("provider_type")) + provider_type) # Return id of the DNS Authorization return None, None, dns_authorization.id diff --git a/lemur/static/app/angular/pending_certificates/view/view.tpl.html b/lemur/static/app/angular/pending_certificates/view/view.tpl.html index d480cc2d..1f028793 100644 --- a/lemur/static/app/angular/pending_certificates/view/view.tpl.html +++ b/lemur/static/app/angular/pending_certificates/view/view.tpl.html @@ -82,7 +82,7 @@
  • Latest Status - + {{ pendingCertificate.status }}