Provide API for auto assignment check for specific device (#1262)

* Extend the auto assign executor to execute a auto assignment check for a specific device.

Signed-off-by: Michael Herdt <Michael.Herdt@bosch.io>

* add tests and handle exceptions

Signed-off-by: Stefan Klotz <stefan.klotz@bosch.io>

* add unit test

Signed-off-by: Stefan Klotz <stefan.klotz@bosch.io>

* add Copyright header

Signed-off-by: Stefan Klotz <stefan.klotz@bosch.io>

* fix Copyright header

Signed-off-by: Stefan Klotz <stefan.klotz@bosch.io>

* add authorization

Signed-off-by: Stefan Klotz <stefan.klotz@bosch.io>

* fix exception handling and authorization

Signed-off-by: Stefan Klotz <stefan.klotz@bosch.io>

* renaming

Signed-off-by: Stefan Klotz <stefan.klotz@bosch.io>

* Rename auto assignment functions

Signed-off-by: Michael Herdt <Michael.Herdt@bosch.io>

Co-authored-by: Stefan Klotz <stefan.klotz@bosch.io>
This commit is contained in:
Michael Herdt
2022-07-12 15:47:38 +02:00
committed by GitHub
parent 1ec5eb6ede
commit 5c95c4ce28
8 changed files with 647 additions and 334 deletions

View File

@@ -800,6 +800,25 @@ public interface TargetManagement {
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
boolean existsByControllerId(@NotEmpty String controllerId);
/**
* Verify if a target matches a specific target filter query, does not have
* a specific DS already assigned and is compatible with it.
*
* @param controllerId
* of the {@link org.eclipse.hawkbit.repository.model.Target} to
* check
* @param distributionSetId
* of the
* {@link org.eclipse.hawkbit.repository.model.DistributionSet}
* to consider
* @param targetFilterQuery
* to execute
* @return true if it matches
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY_AND_READ_TARGET)
boolean isTargetMatchingQueryAndDSNotAssignedAndCompatible(@NotNull String controllerId, long distributionSetId,
@NotNull String targetFilterQuery);
/**
* Creates a list of target meta data entries.
*

View File

@@ -12,7 +12,6 @@ package org.eclipse.hawkbit.repository.autoassign;
* An interface declaration which contains the check for the auto assignment
* logic.
*/
@FunctionalInterface
public interface AutoAssignExecutor {
/**
@@ -20,6 +19,14 @@ public interface AutoAssignExecutor {
* triggers the check and assignment to targets that don't have the design DS
* yet
*/
void check();
void checkAllTargets();
/**
* Method performs an auto assign check for a specific device only
*
* @param controllerId
* of the device to check
*/
void checkSingleTarget(String controllerId);
}