private static void publishOnMessageBus(String eventCategory, String eventType, String details, Event.State state) { if (state != com.cloud.event.Event.State.Completed) { return; } try { s_eventBus = ComponentContext.getComponent(EventBus.class); } catch (NoSuchBeanDefinitionException nbe) { return; // no provider is configured to provide events bus, so just return } org.apache.cloudstack.framework.events.Event event = new org.apache.cloudstack.framework.events.Event(ManagementService.Name, eventCategory, eventType, EventTypes.getEntityForEvent(eventType), null); Map<String, String> eventDescription = new HashMap<String, String>(); eventDescription.put("event", eventType); eventDescription.put("status", state.toString()); eventDescription.put("details", details); event.setDescription(eventDescription); try { s_eventBus.publish(event); } catch (EventBusException evx) { String errMsg = "Failed to publish contrail event."; s_logger.warn(errMsg, evx); } }
private void pubishOnEventBus(String event, String status, Network vo, State oldState, State newState) { String configKey = "publish.resource.state.events"; String value = _configDao.getValue(configKey); boolean configValue = Boolean.parseBoolean(value); if(!configValue) return; try { s_eventBus = ComponentContext.getComponent(EventBus.class); } catch (NoSuchBeanDefinitionException nbe) { return; // no provider is configured to provide events bus, so just return } String resourceName = getEntityFromClassName(Network.class.getName()); org.apache.cloudstack.framework.events.Event eventMsg = new org.apache.cloudstack.framework.events.Event("management-server", EventCategory.RESOURCE_STATE_CHANGE_EVENT.getName(), event, resourceName, vo.getUuid()); Map<String, String> eventDescription = new HashMap<String, String>(); eventDescription.put("resource", resourceName); eventDescription.put("id", vo.getUuid()); eventDescription.put("old-state", oldState.name()); eventDescription.put("new-state", newState.name()); String eventDate = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss Z").format(new Date()); eventDescription.put("eventDateTime", eventDate); eventMsg.setDescription(eventDescription); try { s_eventBus.publish(eventMsg); } catch (EventBusException e) { s_logger.warn("Failed to publish state change event on the the event bus."); } }
return; try { s_eventBus = ComponentContext.getComponent(EventBus.class); } catch (NoSuchBeanDefinitionException nbe) { return; // no provider is configured to provide events bus, so just return
private void pubishOnEventBus(String event, String status, VirtualMachine vo, VirtualMachine.State oldState, VirtualMachine.State newState) { String configKey = Config.PublishResourceStateEvent.key(); String value = _configDao.getValue(configKey); boolean configValue = Boolean.parseBoolean(value); if(!configValue) return; try { s_eventBus = ComponentContext.getComponent(EventBus.class); } catch (NoSuchBeanDefinitionException nbe) { return; // no provider is configured to provide events bus, so just return } String resourceName = getEntityFromClassName(VirtualMachine.class.getName()); org.apache.cloudstack.framework.events.Event eventMsg = new org.apache.cloudstack.framework.events.Event(ManagementService.Name, EventCategory.RESOURCE_STATE_CHANGE_EVENT.getName(), event, resourceName, vo.getUuid()); Map<String, String> eventDescription = new HashMap<String, String>(); eventDescription.put("resource", resourceName); eventDescription.put("id", vo.getUuid()); eventDescription.put("old-state", oldState.name()); eventDescription.put("new-state", newState.name()); eventDescription.put("status", status); String eventDate = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss Z").format(new Date()); eventDescription.put("eventDateTime", eventDate); eventMsg.setDescription(eventDescription); try { s_eventBus.publish(eventMsg); } catch (org.apache.cloudstack.framework.events.EventBusException e) { s_logger.warn("Failed to publish state change event on the the event bus."); } }
return; try { s_eventBus = ComponentContext.getComponent(EventBus.class); } catch (NoSuchBeanDefinitionException nbe) { return; // no provider is configured to provide events bus, so just return
private void pubishOnEventBus(String event, String status, Volume vo, State oldState, State newState) { String configKey = Config.PublishResourceStateEvent.key(); String value = _configDao.getValue(configKey); boolean configValue = Boolean.parseBoolean(value); if(!configValue) return; try { s_eventBus = ComponentContext.getComponent(EventBus.class); } catch (NoSuchBeanDefinitionException nbe) { return; // no provider is configured to provide events bus, so just return } String resourceName = getEntityFromClassName(Volume.class.getName()); org.apache.cloudstack.framework.events.Event eventMsg = new org.apache.cloudstack.framework.events.Event(ManagementService.Name, EventCategory.RESOURCE_STATE_CHANGE_EVENT.getName(), event, resourceName, vo.getUuid()); Map<String, String> eventDescription = new HashMap<String, String>(); eventDescription.put("resource", resourceName); eventDescription.put("id", vo.getUuid()); eventDescription.put("old-state", oldState.name()); eventDescription.put("new-state", newState.name()); String eventDate = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss Z").format(new Date()); eventDescription.put("eventDateTime", eventDate); eventMsg.setDescription(eventDescription); try { s_eventBus.publish(eventMsg); } catch (EventBusException e) { s_logger.warn("Failed to state change event on the the event bus."); } }
private void pubishOnEventBus(String event, String status, Snapshot vo, State oldState, State newState) { String configKey = Config.PublishResourceStateEvent.key(); String value = s_configDao.getValue(configKey); boolean configValue = Boolean.parseBoolean(value); if(!configValue) { return; } try { s_eventBus = ComponentContext.getComponent(EventBus.class); } catch (NoSuchBeanDefinitionException nbe) { return; // no provider is configured to provide events bus, so just return } String resourceName = getEntityFromClassName(Snapshot.class.getName()); org.apache.cloudstack.framework.events.Event eventMsg = new org.apache.cloudstack.framework.events.Event(ManagementService.Name, EventCategory.RESOURCE_STATE_CHANGE_EVENT.getName(), event, resourceName, vo.getUuid()); Map<String, String> eventDescription = new HashMap<String, String>(); eventDescription.put("resource", resourceName); eventDescription.put("id", vo.getUuid()); eventDescription.put("old-state", oldState.name()); eventDescription.put("new-state", newState.name()); String eventDate = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss Z").format(new Date()); eventDescription.put("eventDateTime", eventDate); eventMsg.setDescription(eventDescription); try { s_eventBus.publish(eventMsg); } catch (EventBusException e) { s_logger.warn("Failed to publish state change event on the the event bus."); } }
return; try { s_eventBus = ComponentContext.getComponent(EventBus.class); } catch (NoSuchBeanDefinitionException nbe) { return; // no provider is configured to provide events bus, so just return
eventBus = ComponentContext.getComponent(EventBus.class); } catch (NoSuchBeanDefinitionException nbe) { return; // no provider is configured to provide events bus, so just return