Search in sources :

Example 11 with EventMessage

use of com.vmware.flowgate.common.model.redis.message.EventMessage in project flowgate by vmware.

the class RedisMessageReceiver method receiveMessage.

@Override
public void receiveMessage(String message) {
    try {
        EventMessage eventMessage = mapper.readValue(message, EventMessageImpl.class);
        asyncService.executeAsync(eventMessage);
    } catch (IOException e) {
        logger.error("Failed prase message ", e);
    }
}
Also used : EventMessage(com.vmware.flowgate.common.model.redis.message.EventMessage) IOException(java.io.IOException)

Example 12 with EventMessage

use of com.vmware.flowgate.common.model.redis.message.EventMessage in project flowgate by vmware.

the class JobsController method generateTempHumidityMapping.

@ResponseStatus(HttpStatus.CREATED)
@RequestMapping(value = "/temphumiditymapping/fullsync/{fullsync}", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE)
public void generateTempHumidityMapping(@PathVariable boolean fullsync) {
    try {
        String command = fullsync ? EventMessageUtil.FullSyncTemperatureAndHumiditySensors : EventMessageUtil.SyncTemperatureAndHumiditySensors;
        EventMessage eventMessage = EventMessageUtil.createEventMessage(EventType.Aggregator, command, "");
        String message = EventMessageUtil.convertEventMessageAsString(eventMessage);
        publisher.publish(EventMessageUtil.AggregatorTopic, message);
    } catch (IOException e) {
        log.error("Failed to create event message", e);
        throw new WormholeRequestException("Failed to create event message");
    }
}
Also used : WormholeRequestException(com.vmware.flowgate.exception.WormholeRequestException) EventMessage(com.vmware.flowgate.common.model.redis.message.EventMessage) IOException(java.io.IOException) ResponseStatus(org.springframework.web.bind.annotation.ResponseStatus) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 13 with EventMessage

use of com.vmware.flowgate.common.model.redis.message.EventMessage in project flowgate by vmware.

the class JobsController method syncHostnameByIp.

@ResponseStatus(HttpStatus.CREATED)
@RequestMapping(value = "/synchostnamebyip/{ip:.+}", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE)
public void syncHostnameByIp(@PathVariable("ip") String ip) {
    if (IPAddressUtil.isValidIp(ip)) {
        EventMessage eventMessage = EventMessageUtil.createEventMessage(EventType.InfoBlox, null, ip);
        try {
            String message = EventMessageUtil.convertEventMessageAsString(eventMessage);
            publisher.publish(EventMessageUtil.InfobloxTopic, message);
        } catch (IOException e) {
            log.error("Failed to create event message", e);
            throw new WormholeRequestException("Failed to create event message for query hostname.");
        }
    } else {
        throw new WormholeRequestException(String.format("Invalid Ip: %s", ip));
    }
}
Also used : WormholeRequestException(com.vmware.flowgate.exception.WormholeRequestException) EventMessage(com.vmware.flowgate.common.model.redis.message.EventMessage) IOException(java.io.IOException) ResponseStatus(org.springframework.web.bind.annotation.ResponseStatus) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 14 with EventMessage

use of com.vmware.flowgate.common.model.redis.message.EventMessage in project flowgate by vmware.

the class JobsController method generateServerPDUMapping.

@ResponseStatus(HttpStatus.CREATED)
@RequestMapping(value = "/pduservermapping", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE)
public void generateServerPDUMapping() {
    try {
        EventMessage eventMessage = EventMessageUtil.createEventMessage(EventType.Aggregator, EventMessageUtil.PDUServerMappingCommand, "");
        String message = EventMessageUtil.convertEventMessageAsString(eventMessage);
        publisher.publish(EventMessageUtil.AggregatorTopic, message);
    } catch (IOException e) {
        log.error("Failed to create event message", e);
        throw new WormholeRequestException("Failed to create event message");
    }
}
Also used : WormholeRequestException(com.vmware.flowgate.exception.WormholeRequestException) EventMessage(com.vmware.flowgate.common.model.redis.message.EventMessage) IOException(java.io.IOException) ResponseStatus(org.springframework.web.bind.annotation.ResponseStatus) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 15 with EventMessage

use of com.vmware.flowgate.common.model.redis.message.EventMessage in project flowgate by vmware.

the class MessageProcessingTest method testVC.

@Test
public void testVC() throws Exception {
    ObjectMapper mapper = new ObjectMapper();
    SDDCSoftwareConfig vc = new SDDCSoftwareConfig();
    vc.setDescription("good vc");
    vc.setName("Test VC");
    vc.setServerURL("10.10.10.10");
    vc.setPassword("fake password");
    vc.setType(SoftwareType.VCENTER);
    String payload = mapper.writeValueAsString(vc);
    // EventMessage message =
    // EventMessageUtil.createEventMessage(EventType.VCenter, EventMessageUtil.VCENTER_SyncCustomerAttrs, payload);
    EventMessage message = EventMessageUtil.createEventMessage(EventType.VCenter, EventMessageUtil.VCENTER_SyncData, "");
    System.out.println(mapper.writeValueAsString(message));
}
Also used : SDDCSoftwareConfig(com.vmware.flowgate.common.model.SDDCSoftwareConfig) EventMessage(com.vmware.flowgate.common.model.redis.message.EventMessage) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) Test(org.junit.Test)

Aggregations

EventMessage (com.vmware.flowgate.common.model.redis.message.EventMessage)33 IOException (java.io.IOException)24 EventUser (com.vmware.flowgate.common.model.redis.message.EventUser)8 EventMessageImpl (com.vmware.flowgate.common.model.redis.message.impl.EventMessageImpl)8 FacilitySoftwareConfig (com.vmware.flowgate.common.model.FacilitySoftwareConfig)7 Test (org.junit.Test)6 SDDCSoftwareConfig (com.vmware.flowgate.common.model.SDDCSoftwareConfig)5 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)5 Asset (com.vmware.flowgate.common.model.Asset)4 WormholeRequestException (com.vmware.flowgate.exception.WormholeRequestException)4 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)4 ResponseStatus (org.springframework.web.bind.annotation.ResponseStatus)4 ArrayList (java.util.ArrayList)3 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)3 Async (org.springframework.scheduling.annotation.Async)3 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)2 AssetIPMapping (com.vmware.flowgate.common.model.AssetIPMapping)2 Date (java.util.Date)2 AdapterJobCommand (com.vmware.flowgate.common.model.AdapterJobCommand)1 IntegrationStatus (com.vmware.flowgate.common.model.IntegrationStatus)1