def register(instance_id, instance_type, cs_id, cs_ip, config=None): config = config or get_ngeo_config() assert_instance_id(instance_id, config) assert_instance_type(instance_type) try: with FileLock(get_controller_config_lockfile_path(config)): controller_config_path = get_controller_config_path(config) if not exists(controller_config_path): create_controller_config(controller_config_path, cs_id, cs_ip) else: controller_config = get_controller_config( controller_config_path) assert_controller_id(cs_id, controller_config, "ALREADY_OTHER") assert_controller_ip(cs_ip, controller_config) # IP address and ID are the same, so raise the "ALREADY_SAME" # error. raise ControllerAssertionError( "This browse server is already registered on this " "controller server.", reason="ALREADY_SAME") except LockException: raise ControllerAssertionError( "There is currently another registration in progress.", reason="ALREADY_OTHER")
def register(instance_id, instance_type, cs_id, cs_ip, config=None): config = config or get_ngeo_config() assert_instance_id(instance_id, config) assert_instance_type(instance_type) try: with FileLock(get_controller_config_lockfile_path(config)): controller_config_path = get_controller_config_path(config) if not exists(controller_config_path): create_controller_config(controller_config_path, cs_id, cs_ip) else: controller_config = get_controller_config( controller_config_path ) assert_controller_id(cs_id, controller_config, "ALREADY_OTHER") assert_controller_ip(cs_ip, controller_config) # IP address and ID are the same, so raise the "ALREADY_SAME" # error. raise ControllerAssertionError( "This browse server is already registered on this " "controller server.", reason="ALREADY_SAME" ) except LockException: raise ControllerAssertionError( "There is currently another registration in progress.", reason="ALREADY_OTHER" )
def register(instance_id, instance_type, cs_id, cs_ip, config=None): config = config or get_ngeo_config() assert_instance_id(instance_id, config) assert_instance_type(instance_type) try: with FileLock(get_controller_config_lockfile_path(config)): controller_config_path = get_controller_config_path(config) if not exists(controller_config_path): create_controller_config(controller_config_path, cs_id, cs_ip) else: # TODO: controller server ID was removed? controller_config = get_controller_config(controller_config_path) assert_controller_id(cs_id, controller_config, "ALREADY_OTHER") assert_controller_ip(cs_ip, controller_config) except LockException: raise ControllerAssertionError( "There is currently another registration in progress.", reason="ALREADY_OTHER" )