Target attributes update can be (re-)triggered by management API (#690)
* extend Management API with attribute `requestAttributes` * introduce new DMF Event Topic `REQUEST_ATTRIBUTES_UPDATE` * enhance REST documentation by new functionality * add tests for: * Management API * Amqp Message Dispatcher Service * Repository (Target Management) Signed-off-by: Jeroen Jan Laverman (INST/ESY3) <jeroen.laverman@bosch-si.com>
This commit is contained in:
committed by
Dominic Schabel
parent
f4340098d9
commit
ecfe774e53
@@ -36,6 +36,7 @@ import org.eclipse.hawkbit.repository.SystemManagement;
|
||||
import org.eclipse.hawkbit.repository.TargetManagement;
|
||||
import org.eclipse.hawkbit.repository.event.remote.TargetAssignDistributionSetEvent;
|
||||
import org.eclipse.hawkbit.repository.event.remote.TargetDeletedEvent;
|
||||
import org.eclipse.hawkbit.repository.event.remote.TargetAttributesRequestedEvent;
|
||||
import org.eclipse.hawkbit.repository.event.remote.entity.CancelTargetAssignmentEvent;
|
||||
import org.eclipse.hawkbit.repository.model.Artifact;
|
||||
import org.eclipse.hawkbit.repository.model.SoftwareModule;
|
||||
@@ -157,8 +158,8 @@ public class AmqpMessageDispatcherService extends BaseAmqpService {
|
||||
* window available, the topic {@link EventTopic#DOWNLOAD_AND_INSTALL} is
|
||||
* returned else {@link EventTopic#DOWNLOAD} is returned.
|
||||
*
|
||||
* @param target
|
||||
* for which to find the event type
|
||||
* @param maintenanceWindowAvailable
|
||||
* valid maintenance window or not.
|
||||
*
|
||||
* @return {@link EventTopic} to use for message.
|
||||
*/
|
||||
@@ -199,6 +200,12 @@ public class AmqpMessageDispatcherService extends BaseAmqpService {
|
||||
sendDeleteMessage(deleteEvent.getTenant(), deleteEvent.getControllerId(), deleteEvent.getTargetAddress());
|
||||
}
|
||||
|
||||
@EventListener(classes = TargetAttributesRequestedEvent.class)
|
||||
protected void targetTriggerUpdateAttributes(final TargetAttributesRequestedEvent updateAttributesEvent) {
|
||||
sendUpdateAttributesMessageToTarget(updateAttributesEvent.getTenant(), updateAttributesEvent.getControllerId(),
|
||||
updateAttributesEvent.getTargetAddress());
|
||||
}
|
||||
|
||||
protected void sendUpdateMessageToTarget(final String tenant, final Target target, final Long actionId,
|
||||
final Map<SoftwareModule, List<SoftwareModuleMetadata>> modules, final boolean maintenanceWindowAvailable) {
|
||||
|
||||
@@ -270,6 +277,18 @@ public class AmqpMessageDispatcherService extends BaseAmqpService {
|
||||
|
||||
}
|
||||
|
||||
protected void sendUpdateAttributesMessageToTarget(final String tenant, final String controllerId,
|
||||
final String targetAddress) {
|
||||
if (!hasValidAddress(targetAddress)) {
|
||||
return;
|
||||
}
|
||||
|
||||
final Message message = new Message(null,
|
||||
createConnectorMessagePropertiesEvent(tenant, controllerId, EventTopic.REQUEST_ATTRIBUTES_UPDATE));
|
||||
|
||||
amqpSenderService.sendMessage(message, URI.create(targetAddress));
|
||||
}
|
||||
|
||||
private static MessageProperties createConnectorMessagePropertiesEvent(final String tenant,
|
||||
final String controllerId, final EventTopic topic) {
|
||||
final MessageProperties messageProperties = createConnectorMessageProperties(tenant, controllerId);
|
||||
|
||||
Reference in New Issue
Block a user