Пример #1
0
def install_provisions(provision, dbhost, clear=False, overwrite=False):
    """Install default provisioning data"""

    hfoslog("Installing HFOS default provisions", emitter='MANAGE')

    # from hfos.logger import verbosity, events
    # verbosity['console'] = verbosity['global'] = events
    from hfos import database
    database.initialize(dbhost)

    from hfos.provisions import provisionstore

    if provision is not None:
        if provision in provisionstore:
            hfoslog("Provisioning ", provision, emitter="MANAGE")
            provisionstore[provision](overwrite=overwrite, clear=clear)
        else:
            hfoslog("Unknown provision: ", provision, "\nValid provisions are",
                    list(provisionstore.keys()),
                    lvl=error,
                    emitter='MANAGE')
    else:
        for provision_name in provisionstore:
            hfoslog("Provisioning " + provision_name, emitter='MANAGE')
            provisionstore[provision_name](overwrite=overwrite, clear=clear)

    hfoslog("Done: Install Provisions")
Пример #2
0
def get_system_configuration():
    from hfos import database
    database.initialize()
    systemconfig = database.objectmodels['systemconfig'].find_one(
        {'active': True})

    return systemconfig
Пример #3
0
def config(ctx, dbhost):
    """Configuration management operations (GROUP)"""

    from hfos import database
    database.initialize(dbhost)
    ctx.obj['db'] = database

    from hfos.schemata.component import ComponentConfigSchemaTemplate
    ctx.obj['col'] = model_factory(ComponentConfigSchemaTemplate)
Пример #4
0
def launch(run=True):
    parser = argparse.ArgumentParser()
    parser.add_argument(
        "-p", "--port", help="Define port for server", type=int, default=80)
    parser.add_argument(
        "--host",
        help="Define hostname for server",
        type=str,
        default='0.0.0.0')
    parser.add_argument(
        "--dbhost",
        help="Define hostname for database server",
        type=str,
        default='127.0.0.1:27017')
    parser.add_argument(
        "--profile", help="Enable profiler", action="store_true")
    parser.add_argument(
        "--opengui",
        help="Launch webbrowser for GUI "
        "inspection after startup",
        action="store_true")
    parser.add_argument(
        "--drawgraph",
        help="Draw a snapshot of the "
        "component graph "
        "after construction",
        action="store_true")
    parser.add_argument(
        "--log", help="Define log level (0-100)", type=int, default=20)

    parser.add_argument(
        "--insecure", help="Keep privileges - INSECURE", action="store_true")

    args = parser.parse_args()
    # pprint(args)

    verbosity['console'] = args.log
    verbosity['global'] = args.log

    hfoslog(
        "Running with Python",
        sys.version.replace("\n", ""),
        sys.platform,
        lvl=debug,
        emitter='CORE')
    hfoslog("Interpreter executable:", sys.executable, emitter='CORE')

    hfoslog("Initializing database access", emitter='CORE')
    initialize(args.dbhost)

    server = construct_graph(args)
    if run:
        server.run()

    return server
Пример #5
0
def launch(run=True, **args):
    verbosity['console'] = args['log'] if not args['quiet'] else 100
    verbosity['global'] = min(args['log'], args['logfileverbosity'])
    verbosity['file'] = args['logfileverbosity'] if args['dolog'] else 100
    set_logfile(args['logfile'])
    print(args['dev'])

    hfoslog("Running with Python", sys.version.replace("\n", ""),
            sys.platform, lvl=debug, emitter='CORE')
    hfoslog("Interpreter executable:", sys.executable, emitter='CORE')
    if args['cert'] is not None:
        hfoslog("Warning! Using SSL without nginx is currently not broken!",
                lvl=critical, emitter='CORE')

    hfoslog("Initializing database access", emitter='CORE')
    initialize(args['dbhost'])

    server = construct_graph(args)
    if run and not args['norun']:
        server.run()

    return server
Пример #6
0
def db(ctx, dbhost):
    """Database management operations (GROUP)"""

    from hfos import database
    database.initialize(dbhost)
    ctx.obj['db'] = database
Пример #7
0
"""
Hackerfleet Operating System - Backend

Test HFOS Launcher
==================


:copyright: (C) 2011-2016 [email protected]
:license: GPLv3 (See LICENSE)

"""

from hfos.database import initialize
from hfos.launcher import Core

__author__ = "Heiko 'riot' Weinen <*****@*****.**>"

initialize()  # Set up database access for testing once


def test_launcher():
    """Tests if the Core Launcher can be instantiated"""

    # Use a non privileged port for testing, until that part can be removed
    # from Core

    core = Core(port=8123)

    assert type(core) == Core
Пример #8
0
        'title': 'Simple Meeting protocol from $DD$MM$YY',
        'slugtemplate': 'protocol-$DD-$MM-$YY',
        'html': 'This would be a protocol template, once the provision have '
                'been fleshed out.'
    },
    {
        'name': 'Todo',
        'uuid': '88ec45e7-7b12-4450-a8f0-290d51290fa3',
        'title': 'Simple Todo item list for $USER',
        'slugtemplate': 'todo-$USER-$DD-$MM-$YY',
        'html': 'This would be a todo template text, once the provision have '
                'been fleshed out.'
    }
]


def provisionPages():
    provisionList(WikiPages, objectmodels['wikipage'])
    hfoslog('WikiPages: Done.', emitter='PROVISIONING')


def provisionTemplates():
    provisionList(WikiTemplates, objectmodels['wikitemplate'])
    hfoslog('WikiTemplates: Done.', emitter='PROVISIONING')


if __name__ == "__main__":
    initialize()
    provisionPages()
    provisionTemplates()
Пример #9
0
Файл: wiki.py Проект: ri0t/hfos
    'been fleshed out.'
}, {
    'name':
    'Todo',
    'uuid':
    '88ec45e7-7b12-4450-a8f0-290d51290fa3',
    'title':
    'Simple Todo item list for $USER',
    'slugtemplate':
    'todo-$USER-$DD-$MM-$YY',
    'html':
    'This would be a todo template text, once the provision have '
    'been fleshed out.'
}]


def provisionPages(**kwargs):
    provisionList(WikiPages, objectmodels['wikipage'], **kwargs)
    hfoslog('WikiPages: Done.', emitter='PROVISIONING')


def provisionTemplates(**kwargs):
    provisionList(WikiTemplates, objectmodels['wikitemplate'], **kwargs)
    hfoslog('WikiTemplates: Done.', emitter='PROVISIONING')


if __name__ == "__main__":
    initialize()
    provisionPages()
    provisionTemplates()
Пример #10
0
#!/usr/bin/env python
# -*- coding: UTF-8 -*-

# HFOS - Hackerfleet Operating System
# ===================================
# Copyright (C) 2011-2017 Heiko 'riot' Weinen <*****@*****.**> and others.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

__author__ = "Heiko 'riot' Weinen"
__license__ = "GPLv3"

from hfos.database import initialize

initialize(database_name='hfos-test')