예제 #1
0
파일: cli.py 프로젝트: lokI8/haas
def serve(port):
    try:
        port = schema.And(schema.Use(int), lambda n: MIN_PORT_NUMBER <= n <= MAX_PORT_NUMBER).validate(port)
    except schema.SchemaError:
	sys.exit('Error: Invaid port. Must be in the range 1-65535.')
    except Exception as e:
	sys.exit('Unxpected Error!!! \n %s' % e)

    """Start the HaaS API server"""
    if cfg.has_option('devel', 'debug'):
        debug = cfg.getboolean('devel', 'debug')
    else:
        debug = False
    # We need to import api here so that the functions within it get registered
    # (via `rest_call`), though we don't use it directly:
    from haas import model, api, rest
    model.init_db()
    # Stop all orphan console logging processes on startup
    db = model.Session()
    nodes = db.query(model.Node).all()
    for node in nodes:
        node.stop_console()
        node.delete_console()
    # Start server
    rest.serve(port, debug=debug)
예제 #2
0
파일: keystone.py 프로젝트: kylehogan/haas
def launch_server():
    """Launch the haas API server in another thread.

    The keystone client will try to make *real* http requests, so we can't
    just use flask's built-in test fixtures; we need to actually be listening
    on a port.

    Starts the server listening on port 6000. Will not return until the
    server is actually accepting connections.

    We use 6000 instead of the usual 5000, because the latter is used by
    keystone itself.
    """
    # `debug=False` is required because otherwise something in the
    # implementation of werkzeug calls `signal`, and we get a
    # `ValueError` because (apparently) this doesn't work outside of
    # the main thread.
    Thread(target=lambda: rest.serve(port=6000,
                                     debug=False)).start()

    # Poll the server to see if it's accepting connections yet:
    while True:
        try:
            requests.get('http://localhost:6000')
            return
        except requests.exceptions.ConnectionError:
            time.sleep(0.2)
예제 #3
0
def launch_server():
    """Launch the haas API server in another thread.

    The keystone client will try to make *real* http requests, so we can't
    just use flask's built-in test fixtures; we need to actually be listening
    on a port.

    Starts the server listening on port 6000. Will not return until the
    server is actually accepting connections.

    We use 6000 instead of the usual 5000, because the latter is used by
    keystone itself.
    """
    # `debug=False` is required because otherwise something in the
    # implementation of werkzeug calls `signal`, and we get a
    # `ValueError` because (apparently) this doesn't work outside of
    # the main thread.
    Thread(target=lambda: rest.serve(port=6000, debug=False)).start()

    # Poll the server to see if it's accepting connections yet:
    while True:
        try:
            requests.get('http://localhost:6000')
            return
        except requests.exceptions.ConnectionError:
            time.sleep(0.2)
예제 #4
0
def serve():
    """Start the HaaS API server"""
    if cfg.has_option('devel', 'debug'):
        debug = cfg.getboolean('devel', 'debug')
    else:
        debug = False
    # We need to import api here so that the functions within it get registered
    # (via `rest_call`), though we don't use it directly:
    from haas import model, api, rest
    model.init_db()
    # Stop all orphan console logging processes on startup
    db = model.Session()
    nodes = db.query(model.Node).all()
    for node in nodes:
        node.stop_console()
        node.delete_console()
    # Start server
    rest.serve(debug=debug)
예제 #5
0
파일: cli.py 프로젝트: rahulbahal7/haas
def serve(port):
    try:
        port = schema.And(schema.Use(int), lambda n: MIN_PORT_NUMBER <= n <= MAX_PORT_NUMBER).validate(port)
    except schema.SchemaError:
	sys.exit('Error: Invaid port. Must be in the range 1-65535.')
    except Exception as e:
	sys.exit('Unxpected Error!!! \n %s' % e)

    """Start the HaaS API server"""
    if cfg.has_option('devel', 'debug'):
        debug = cfg.getboolean('devel', 'debug')
    else:
        debug = False
    # We need to import api here so that the functions within it get registered
    # (via `rest_call`), though we don't use it directly:
    from haas import model, api, rest
    server.init(stop_consoles=True)
    rest.serve(port, debug=debug)
예제 #6
0
def serve():
    """Start the HaaS API server"""
    if cfg.has_option('devel', 'debug'):
        debug = cfg.getboolean('devel', 'debug')
    else:
        debug = False
    # We need to import api here so that the functions within it get registered
    # (via `rest_call`), though we don't use it directly:
    from haas import model, api, rest
    model.init_db()
    # Stop all orphan console logging processes on startup
    db = model.Session()
    nodes = db.query(model.Node).all()
    for node in nodes:
        node.stop_console()
        node.delete_console()
    # Start server
    rest.serve(debug=debug)
예제 #7
0
def serve(port):
    try:
        port = schema.And(
            schema.Use(int),
            lambda n: MIN_PORT_NUMBER <= n <= MAX_PORT_NUMBER).validate(port)
    except schema.SchemaError:
        sys.exit('Error: Invaid port. Must be in the range 1-65535.')
    except Exception as e:
        sys.exit('Unxpected Error!!! \n %s' % e)
    """Start the HaaS API server"""
    if cfg.has_option('devel', 'debug'):
        debug = cfg.getboolean('devel', 'debug')
    else:
        debug = False
    # We need to import api here so that the functions within it get registered
    # (via `rest_call`), though we don't use it directly:
    from haas import model, api, rest
    server.init(stop_consoles=True)
    rest.serve(port, debug=debug)