-
Notifications
You must be signed in to change notification settings - Fork 317
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
97 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
"""empty message | ||
Revision ID: 368320d26c6c | ||
Revises: 3307381f3b88 | ||
Create Date: 2016-05-27 13:41:47.413694 | ||
""" | ||
|
||
# revision identifiers, used by Alembic. | ||
revision = '368320d26c6c' | ||
down_revision = '3307381f3b88' | ||
|
||
from alembic import op | ||
import sqlalchemy as sa | ||
import sqlalchemy_utils | ||
|
||
|
||
def upgrade(): | ||
### commands auto generated by Alembic - please adjust! ### | ||
op.create_table('endpoints', | ||
sa.Column('id', sa.Integer(), nullable=False), | ||
sa.Column('owner', sa.String(length=128), nullable=True), | ||
sa.Column('name', sa.String(length=128), nullable=True), | ||
sa.Column('dnsname', sa.String(length=256), nullable=True), | ||
sa.Column('type', sa.String(length=128), nullable=True), | ||
sa.Column('active', sa.Boolean(), nullable=True), | ||
sa.Column('port', sa.Integer(), nullable=True), | ||
sa.Column('date_created', sa.DateTime(), server_default=sa.text(u'now()'), nullable=False), | ||
sa.Column('certificate_id', sa.Integer(), nullable=True), | ||
sa.ForeignKeyConstraint(['certificate_id'], ['certificates.id'], ), | ||
sa.PrimaryKeyConstraint('id') | ||
) | ||
op.create_table('policy', | ||
sa.Column('id', sa.Integer(), nullable=False), | ||
sa.Column('endpoint_id', sa.Integer(), nullable=True), | ||
sa.Column('name', sa.String(length=32), nullable=True), | ||
sa.Column('ciphers', sqlalchemy_utils.types.json.JSONType(), nullable=True), | ||
sa.ForeignKeyConstraint(['endpoint_id'], ['endpoints.id'], ), | ||
sa.PrimaryKeyConstraint('id') | ||
) | ||
### end Alembic commands ### | ||
|
||
|
||
def downgrade(): | ||
### commands auto generated by Alembic - please adjust! ### | ||
op.drop_table('policy') | ||
op.drop_table('endpoints') | ||
### end Alembic commands ### |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,8 @@ | |
:license: Apache, see LICENSE for more details. | ||
.. moduleauthor:: Kevin Glisson <[email protected]> | ||
""" | ||
import datetime | ||
|
||
from flask import current_app | ||
|
||
from lemur import database | ||
|
@@ -79,21 +81,25 @@ def sync_endpoints(source): | |
return | ||
|
||
for endpoint in endpoints: | ||
exists = endpoint_service.get_by_name(endpoint['dnsname']) | ||
exists = endpoint_service.get_by_dnsname(endpoint['dnsname']) | ||
|
||
if not exists: | ||
certificate_name = endpoint.pop('certificate_name') | ||
cert = cert_service.get_by_name(certificate_name) | ||
certificate_name = endpoint.pop('certificate_name') | ||
cert = cert_service.get_by_name(certificate_name) | ||
endpoint['certificate'] = cert | ||
|
||
if not cert: | ||
current_app.logger.error("Unable to find associated certificate, be sure that certificates are sync'ed before endpoints") | ||
continue | ||
if not cert: | ||
current_app.logger.error("Unable to find associated certificate, be sure that certificates are sync'ed before endpoints") | ||
continue | ||
|
||
policy = endpoint.pop('policy') | ||
endpoint['policy'] = endpoint_service.create_policy(**policy) | ||
|
||
if not exists: | ||
endpoint_service.create(**endpoint) | ||
new += 1 | ||
|
||
elif len(exists) == 1: | ||
endpoint_service.update(exists[0].id, **endpoint) | ||
else: | ||
endpoint_service.update(exists.id, **endpoint) | ||
updated += 1 | ||
|
||
|
||
|
@@ -138,6 +144,9 @@ def sync(labels=None, type='all'): | |
sync_certificates(source) | ||
sync_endpoints(source) | ||
|
||
source.last_run = datetime.datetime.utcnow() | ||
database.update(source) | ||
|
||
|
||
def create(label, plugin_name, options, description=None): | ||
""" | ||
|