Merge pull request #15 from kevgliss/master

General cleanup and hotfixes
This commit is contained in:
kevgliss 2015-07-04 12:57:17 -07:00
commit 737d4d62d4
5 changed files with 63 additions and 36 deletions

View File

@ -100,6 +100,10 @@ used by Lemur to help associate certificates that do not currently have an owner
Lemur has discovered certificates from a third party resource. This is also a default user that can be used to
administer Lemur.
.. code-block:: bash
$ lemur db init
.. code-block:: bash
$ lemur init

View File

@ -62,8 +62,3 @@ def configure_hook(app):
response.status_code = 403
return response

24
lemur/default.conf.py Normal file
View File

@ -0,0 +1,24 @@
# This is just Python which means you can inherit and tweak settings
import os
_basedir = os.path.abspath(os.path.dirname(__file__))
ADMINS = frozenset([''])
THREADS_PER_PAGE = 8
#############
## General ##
#############
# These will need to be set to `True` if you are developing locally
CORS = False
debug = False
#############
## Logging ##
#############
LOG_LEVEL = "DEBUG"
LOG_FILE = "lemur.log"

View File

@ -94,11 +94,10 @@ def configure_app(app, config=None):
except RuntimeError:
if config and config != 'None':
app.config.from_object(from_file(config))
else:
elif os.path.isfile(os.path.expanduser("~/.lemur/lemur.conf.py")):
app.config.from_object(from_file(os.path.expanduser("~/.lemur/lemur.conf.py")))
if not app.config.get('ENCRYPTION_KEY'):
raise NoEncryptionKeyFound
else:
app.config.from_object(from_file(os.path.join(os.path.dirname(os.path.realpath(__file__)), 'default.conf.py')))
def configure_extensions(app):

59
lemur/manage.py Normal file → Executable file
View File

@ -333,14 +333,15 @@ class InitializeApp(Command):
else:
sys.stdout.write("[-] Default user has already been created, skipping...!\n")
for account_name, account_number in current_app.config.get('AWS_ACCOUNT_MAPPINGS').items():
account = account_service.get_by_account_number(account_number)
if current_app.config.get('AWS_ACCOUNT_MAPPINGS'):
for account_name, account_number in current_app.config.get('AWS_ACCOUNT_MAPPINGS').items():
account = account_service.get_by_account_number(account_number)
if not account:
account_service.create(account_number, label=account_name)
sys.stdout.write("[+] Added new account {0}:{1}!\n".format(account_number, account_name))
else:
sys.stdout.write("[-] Account already exists, skipping...!\n")
if not account:
account_service.create(account_number, label=account_name)
sys.stdout.write("[+] Added new account {0}:{1}!\n".format(account_number, account_name))
else:
sys.stdout.write("[-] Account already exists, skipping...!\n")
sys.stdout.write("[/] Done!\n")
@ -439,26 +440,6 @@ class CreateRole(Command):
sys.stdout.write("[+] Created new role: {0}".format(name))
@manager.command
def create_config(config_path=None):
"""
Creates a new configuration file if one does not already exist
"""
if not config_path:
config_path = DEFAULT_CONFIG_PATH
config_path = os.path.expanduser(config_path)
dir = os.path.dirname(config_path)
if not os.path.exists(dir):
os.makedirs(dir)
config = generate_settings()
with open(config_path, 'w') as f:
f.write(config)
sys.stdout.write("Created a new configuration file {0}\n".format(config_path))
class LemurServer(Command):
"""
This is the main Lemur server, it runs the flask app with gunicorn and
@ -494,6 +475,26 @@ class LemurServer(Command):
return app.run()
@manager.command
def create_config(config_path=None):
"""
Creates a new configuration file if one does not already exist
"""
if not config_path:
config_path = DEFAULT_CONFIG_PATH
config_path = os.path.expanduser(config_path)
dir = os.path.dirname(config_path)
if not os.path.exists(dir):
os.makedirs(dir)
config = generate_settings()
with open(config_path, 'w') as f:
f.write(config)
sys.stdout.write("Created a new configuration file {0}\n".format(config_path))
def main():
manager.add_command("start", LemurServer())
manager.add_command("runserver", Server(host='127.0.0.1'))
@ -505,3 +506,7 @@ def main():
manager.add_command('create_role', CreateRole())
manager.add_command("sync", Sync())
manager.run()
if __name__ == "__main__":
main()