def serve_networks(): """Start the HIL networking server""" from hil import model, deferred from time import sleep config.setup() server.init() server.register_drivers() server.validate_state() model.init_db() migrations.check_db_schema() # Check if config contains usable sleep_time if (cfg.has_section('network-daemon') and cfg.has_option('network-daemon', 'sleep_time')): try: sleep_time = cfg.getfloat('network-daemon', 'sleep_time') except (ValueError): sys.exit("Error: sleep_time set to non-float value") if sleep_time <= 0 or sleep_time >= 3600: sys.exit("Error: sleep_time not within bounds " "0 < sleep_time < 3600") if sleep_time > 60: logger.warn('sleep_time greater than 1 minute.') else: sleep_time = 2 while True: # Empty the journal until it's empty; then delay so we don't tight # loop. while deferred.apply_networking(): pass sleep(sleep_time)
def run(self): logger = logging.getLogger(__name__) server.init() server.register_drivers() server.validate_state() migrations.check_db_schema() # Check if config contains usable sleep_time if (config.cfg.has_section('network-daemon') and config.cfg.has_option('network-daemon', 'sleep_time')): try: sleep_time = config.cfg.getfloat('network-daemon', 'sleep_time') except (ValueError): sys.exit("Error: sleep_time set to non-float value") if sleep_time <= 0 or sleep_time >= 3600: sys.exit("Error: sleep_time not within bounds " "0 < sleep_time < 3600") if sleep_time > 60: logger.warn('sleep_time greater than 1 minute.') else: sleep_time = 2 while True: # Empty the journal until it's empty; then delay so we don't tight # loop. while deferred.apply_networking(): pass sleep(sleep_time)
def serve(port): """Run a development api server. Don't use this in production.""" try: port = schema.And( schema.Use(int), lambda n: MIN_PORT_NUMBER <= n <= MAX_PORT_NUMBER).validate(port) except schema.SchemaError: raise InvalidAPIArgumentsException( 'Error: Invaid port. Must be in the range 1-65535.') except Exception as e: sys.exit('Unxpected Error!!! \n %s' % e) """Start the HIL API server""" config.setup() 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: # pylint: disable=unused-variable from hil import api, rest server.init() migrations.check_db_schema() server.stop_orphan_consoles() rest.serve(port, debug=debug)
def run(self): logger = logging.getLogger(__name__) server.init() server.register_drivers() server.validate_state() migrations.check_db_schema() # Check if config contains usable sleep_time if (config.cfg.has_section('network-daemon') and config.cfg.has_option('network-daemon', 'sleep_time')): try: sleep_time = config.cfg.getfloat( 'network-daemon', 'sleep_time') except (ValueError): sys.exit("Error: sleep_time set to non-float value") if sleep_time <= 0 or sleep_time >= 3600: sys.exit("Error: sleep_time not within bounds " "0 < sleep_time < 3600") if sleep_time > 60: logger.warn('sleep_time greater than 1 minute.') else: sleep_time = 2 while True: # Empty the journal until it's empty; then delay so we don't tight # loop. while deferred.apply_networking(): pass sleep(sleep_time)
def run(self, port): if config.cfg.has_option('devel', 'debug'): debug = config.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: # pylint: disable=unused-variable from hil import api server.init() migrations.check_db_schema() server.stop_orphan_consoles() rest.serve(port, debug=debug)
def run(self, port): if config.cfg.has_option('devel', 'debug'): debug = config.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: # pylint: disable=unused-variable from hil import api server.init() migrations.check_db_schema() server.stop_orphan_consoles() rest.serve(port, debug=debug)
def create(): """Initialize the database.""" server.init() create_db()
def run(self, obmd_base_url, obmd_admin_token): server.init() with app.app_context(): info = db_extract_ipmi_info() obmd_upload_ipmi_info(obmd_base_url, obmd_admin_token, info) db_add_obmd_info(obmd_base_url, obmd_admin_token)