예제 #1
0
    def get_instance(self, arguments=None):
        """
        Return an instance of the backend with either the default arguments or the one provided as an argument.

        :param arguments: If defined, use these arguments when calling the __init__ method.
        """
        cl = ClassLoader(self.module, self.klass, self.arguments)
        return cl.get_instance(arguments)
예제 #2
0
파일: models.py 프로젝트: michigraber/coco
    def get_instance(self, arguments=None):
        """
        Return an instance of the backend with either the default arguments or the one provided as an argument.

        :param arguments: If defined, use these arguments when calling the __init__ method.
        """
        cl = ClassLoader(self.module, self.klass, self.arguments)
        return cl.get_instance(arguments)
예제 #3
0
파일: helpers.py 프로젝트: michigraber/coco
def get_internal_ldap():
    """
    Return an instance of the internal LDAP backend.
    """
    global _INTERNAL_LDAP
    if _INTERNAL_LDAP is None:
        module, klass = ClassLoader.split(str(config.INTERNAL_LDAP_CLASS))
        _INTERNAL_LDAP = ClassLoader(module, klass, config.INTERNAL_LDAP_ARGS)
    return _INTERNAL_LDAP.get_instance()
예제 #4
0
파일: helpers.py 프로젝트: michigraber/coco
def get_user_backend():
    """
    Return an instance of the external user backend.
    """
    global _USER_BACKEND
    if _USER_BACKEND is None:
        module, klass = ClassLoader.split(str(config.USER_BACKEND_CLASS))
        _USER_BACKEND = ClassLoader(module, klass, config.USER_BACKEND_ARGS)
    return _USER_BACKEND.get_instance()
예제 #5
0
파일: helpers.py 프로젝트: michigraber/coco
def get_storage_backend():
    """
    Return the singleton instance of the storage backend in use.
    """
    global _STORAGE_BACKEND
    if _STORAGE_BACKEND is None:
        module, klass = ClassLoader.split(str(config.STORAGE_BACKEND_CLASS))
        cl = ClassLoader(module, klass, config.STORAGE_BACKEND_ARGS)
        _STORAGE_BACKEND = cl.get_instance()
    return _STORAGE_BACKEND
예제 #6
0
파일: helpers.py 프로젝트: michigraber/coco
def get_server_selection_algorithm():
    """
    Return the server selection algorithm instance that is used to pick a container host.
    """
    global _SERVER_SELECTION_ALGORITHM
    if _SERVER_SELECTION_ALGORITHM is None:
        module, klass = ClassLoader.split(
            str(config.SERVER_SELECTION_ALGORITHM_CLASS))
        cl = ClassLoader(module, klass)
        _SERVER_SELECTION_ALGORITHM = cl.get_instance()
    return _SERVER_SELECTION_ALGORITHM
예제 #7
0
def main():
    """
    coco host API command-line interface entry point.
    """
    # define available arguments
    parser = argparse.ArgumentParser(description='coco host API CLI tool')
    parser.add_argument('-d', '--debug', help='run in debug mode',
                        action='store_true', default=False, dest='debug')
    parser.add_argument('-l', '--listen', help='the address to listen on (default: 0.0.0.0)',
                        action='store', type=str, default='0.0.0.0', dest='address')
    parser.add_argument('-p', '--port', help='the port to bind to (default: 8080)',
                        action='store', type=int, default=8080, dest='port')
    parser.add_argument('--container-backend', help='absolute name of the container backend class to load (default: coco.backends.container_backends.Docker)',
                        action='store', type=str, default='coco.backends.container_backends.Docker', dest='container_backend')
    parser.add_argument('--container-backend-args', help='arguments to pass to the container backend upon initialization (default: { "version": "auto" })',
                        action='store', type=str, default='{ "version": "auto" }', dest='container_backend_args')
    args = parser.parse_args()

    # set configuration values
    config.debug = args.debug

    try:
        module, klass = ClassLoader.split(args.container_backend)
        backend = ClassLoader(module=module, klass=klass, args=args.container_backend_args)
        config.container_backend = backend.get_instance()
    except Exception as ex:
        if config.debug:
            raise ex
        else:
            print """Initializing the container backend failed.
Turn on debug mode (-d. --debug) to get more information about the error."""
            sys.exit(1)

    # bootstrap the application and add our routes
    app = Flask(__name__)
    app.register_blueprint(containers_blueprint)
    app.register_blueprint(core_blueprint)

    # run the application / HTTP REST API
    app.run(
        debug=config.debug,
        host=args.address,
        port=args.port
        # processes=4
    )
예제 #8
0
def main():
    """
    coco host API command-line interface entry point.
    """
    # define available arguments
    parser = argparse.ArgumentParser(description='coco host API CLI tool')
    parser.add_argument('-d',
                        '--debug',
                        help='run in debug mode',
                        action='store_true',
                        default=False,
                        dest='debug')
    parser.add_argument('-l',
                        '--listen',
                        help='the address to listen on (default: 0.0.0.0)',
                        action='store',
                        type=str,
                        default='0.0.0.0',
                        dest='address')
    parser.add_argument('-p',
                        '--port',
                        help='the port to bind to (default: 8080)',
                        action='store',
                        type=int,
                        default=8080,
                        dest='port')
    parser.add_argument(
        '--container-backend',
        help=
        'absolute name of the container backend class to load (default: coco.backends.container_backends.Docker)',
        action='store',
        type=str,
        default='coco.backends.container_backends.Docker',
        dest='container_backend')
    parser.add_argument(
        '--container-backend-args',
        help=
        'arguments to pass to the container backend upon initialization (default: { "version": "auto" })',
        action='store',
        type=str,
        default='{ "version": "auto" }',
        dest='container_backend_args')
    args = parser.parse_args()

    # set configuration values
    config.debug = args.debug

    try:
        module, klass = ClassLoader.split(args.container_backend)
        backend = ClassLoader(module=module,
                              klass=klass,
                              args=args.container_backend_args)
        config.container_backend = backend.get_instance()
    except Exception as ex:
        if config.debug:
            raise ex
        else:
            print """Initializing the container backend failed.
Turn on debug mode (-d. --debug) to get more information about the error."""
            sys.exit(1)

    # bootstrap the application and add our routes
    app = Flask(__name__)
    app.register_blueprint(containers_blueprint)
    app.register_blueprint(core_blueprint)

    # run the application / HTTP REST API
    app.run(debug=config.debug,
            host=args.address,
            port=args.port
            # processes=4
            )