Пример #1
0
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")
Пример #2
0
def unregister(instance_id, cs_id, cs_ip, config=None):
    config = config or get_ngeo_config()
    assert_instance_id(instance_id, config)

    try:
        with FileLock(get_controller_config_lockfile_path(config)):
            controller_config_path = get_controller_config_path(config)
            if not exists(controller_config_path):
                raise ControllerAssertionError(
                    "This Browse Server instance was not yet registered.",
                    reason="UNBOUND"
                )

            # TODO: controller server ID was removed?
            controller_config = get_controller_config(controller_config_path)
            assert_controller_id(cs_id, controller_config, "CONTROLLER_OTHER")
            assert_controller_ip(cs_ip, controller_config)
            
            # remove the controller configuration to complete unregistration
            os.remove(controller_config_path)

    except LockException:
        raise ControllerAssertionError(
            "There is currently another registration in progress.",
            reason="CONTROLLER_OTHER"
        )
Пример #3
0
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"
        )
Пример #4
0
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"
        )
Пример #5
0
def unregister(instance_id, cs_id, cs_ip, config=None):
    config = config or get_ngeo_config()
    assert_instance_id(instance_id, config)

    try:
        with FileLock(get_controller_config_lockfile_path(config)):
            controller_config_path = get_controller_config_path(config)
            if not exists(controller_config_path):
                raise ControllerAssertionError(
                    "This Browse Server instance was not yet registered.",
                    reason="UNBOUND")

            controller_config = get_controller_config(controller_config_path)
            assert_controller_id(cs_id, controller_config, "CONTROLLER_OTHER")
            assert_controller_ip(cs_ip, controller_config)

            # remove the controller configuration to complete unregistration
            os.remove(controller_config_path)

    except LockException:
        raise ControllerAssertionError(
            "There is currently another registration in progress.",
            reason="CONTROLLER_OTHER")