More pep8 fixes.
This commit is contained in:
parent
0a0f5f6e84
commit
b494661ad8
@ -104,7 +104,7 @@ class Authority(object):
|
|||||||
class UserCerts(object):
|
class UserCerts(object):
|
||||||
@falcon.before(validate)
|
@falcon.before(validate)
|
||||||
def on_post(self, req, resp):
|
def on_post(self, req, resp):
|
||||||
# TODO: validation
|
# TODO(pino): validation
|
||||||
try:
|
try:
|
||||||
user = db.createUserCert(
|
user = db.createUserCert(
|
||||||
self.session,
|
self.session,
|
||||||
|
@ -11,10 +11,8 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import falcon
|
import falcon
|
||||||
import os
|
|
||||||
import sqlalchemy as sa
|
import sqlalchemy as sa
|
||||||
import sshpubkeys
|
import sshpubkeys
|
||||||
import uuid
|
|
||||||
from Crypto.PublicKey import RSA
|
from Crypto.PublicKey import RSA
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from sqlalchemy.exc import IntegrityError
|
from sqlalchemy.exc import IntegrityError
|
||||||
@ -125,7 +123,7 @@ def createToken(session, host_id, auth_id, hostname):
|
|||||||
token = session.query(Token).filter(Token.host_id == host_id).one()
|
token = session.query(Token).filter(Token.host_id == host_id).one()
|
||||||
if token is not None:
|
if token is not None:
|
||||||
return token
|
return token
|
||||||
except:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
token = Token(host_id=host_id,
|
token = Token(host_id=host_id,
|
||||||
@ -164,12 +162,12 @@ def createHostCert(session, token_id, host_id, pub):
|
|||||||
if token.used:
|
if token.used:
|
||||||
if token.fingerprint_used != fingerprint:
|
if token.fingerprint_used != fingerprint:
|
||||||
raise falcon.HTTPConflict(
|
raise falcon.HTTPConflict(
|
||||||
description='The token was previously used with a different public key')
|
description='Token already signed a different public key')
|
||||||
# The token was already used for same host and pub key. Return record.
|
# The token was already used for same host and pub key. Return record.
|
||||||
host = session.query(HostCert).get([host_id, fingerprint])
|
host = session.query(HostCert).get([host_id, fingerprint])
|
||||||
if host is None:
|
if host is None:
|
||||||
raise falcon.HTTPInternalServerError(
|
raise falcon.HTTPInternalServerError(
|
||||||
description='The token was used, but no corresponding Host record was found.')
|
description='Token already used, but Host record not found.')
|
||||||
if host.token_id == token_id:
|
if host.token_id == token_id:
|
||||||
return host
|
return host
|
||||||
raise falcon.HTTPConflict(
|
raise falcon.HTTPConflict(
|
||||||
|
@ -22,7 +22,7 @@ def get_url():
|
|||||||
# return os.getenv("DATABASE_URL", "sqlite:///:memory:")
|
# return os.getenv("DATABASE_URL", "sqlite:///:memory:")
|
||||||
|
|
||||||
|
|
||||||
class SQLAlchemySessionManager:
|
class SQLAlchemySessionManager(object):
|
||||||
"""
|
"""
|
||||||
Create scoped session for every request and close it when the request ends
|
Create scoped session for every request and close it when the request ends
|
||||||
"""
|
"""
|
||||||
|
@ -11,7 +11,6 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import json
|
import json
|
||||||
import os
|
|
||||||
import requests
|
import requests
|
||||||
import sshpubkeys
|
import sshpubkeys
|
||||||
import uuid
|
import uuid
|
||||||
|
@ -18,7 +18,7 @@ from oslo_config import cfg
|
|||||||
from oslo_log import log as logging
|
from oslo_log import log as logging
|
||||||
from oslo_serialization import jsonutils
|
from oslo_serialization import jsonutils
|
||||||
from sqlalchemy import create_engine
|
from sqlalchemy import create_engine
|
||||||
from sqlalchemy.orm import sessionmaker, scoped_session
|
from sqlalchemy.orm import scoped_session, sessionmaker
|
||||||
|
|
||||||
from tatu.db.models import createAuthority
|
from tatu.db.models import createAuthority
|
||||||
from tatu.db.persistence import get_url
|
from tatu.db.persistence import get_url
|
||||||
@ -64,9 +64,9 @@ class NotificationEndpoint(object):
|
|||||||
|
|
||||||
def main():
|
def main():
|
||||||
logging.register_options(CONF)
|
logging.register_options(CONF)
|
||||||
extra_log_level_defaults = ['tatu=DEBUG', '__main__=DEBUG']
|
log_levels = logging.get_default_log_levels() + \
|
||||||
logging.set_defaults(default_log_levels=logging.get_default_log_levels() +
|
['tatu=DEBUG', '__main__=DEBUG']
|
||||||
extra_log_level_defaults)
|
logging.set_defaults(default_log_levels=log_levels)
|
||||||
logging.setup(CONF, DOMAIN)
|
logging.setup(CONF, DOMAIN)
|
||||||
|
|
||||||
transport = oslo_messaging.get_notification_transport(CONF)
|
transport = oslo_messaging.get_notification_transport(CONF)
|
||||||
|
@ -46,14 +46,14 @@ def generateCert(auth_key, entity_key, hostname=None, principals='root'):
|
|||||||
cert = ''
|
cert = ''
|
||||||
with open(cert_file, 'r') as text_file:
|
with open(cert_file, 'r') as text_file:
|
||||||
cert = text_file.read()
|
cert = text_file.read()
|
||||||
except Exception as e:
|
#except Exception as e:
|
||||||
print e
|
# print e
|
||||||
finally:
|
finally:
|
||||||
# Delete temporary files
|
# Delete temporary files
|
||||||
for file in [ca_file, pub_file, cert_file]:
|
for file in [ca_file, pub_file, cert_file]:
|
||||||
try:
|
try:
|
||||||
os.remove(file)
|
os.remove(file)
|
||||||
pass
|
pass
|
||||||
except:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
return cert
|
return cert
|
||||||
|
Loading…
x
Reference in New Issue
Block a user