@@ -0,0 +1,3087 @@
+package com.cloud.event;%0A%0Aimport com.cloud.event.dao.EventDao;%0Aimport com.cloud.server.ManagementServer;%0Aimport com.cloud.utils.component.ComponentLocator;%0A%0Apublic class EventUtils %7B%0A%09private static EventDao _eventDao = ComponentLocator.getLocator(ManagementServer.Name).getDao(EventDao.class);%0A%0A    public static Long saveEvent(Long userId, Long accountId, String type, String description) %7B%0A        EventVO event = new EventVO();%0A        event.setUserId(userId);%0A        event.setAccountId(accountId);%0A        event.setType(type);%0A        event.setDescription(description);%0A        event = _eventDao.persist(event);%0A        return event.getId();%0A    %7D%0A    %0A    /*%0A     * Save event after scheduling an async job%0A     */%0A    public static Long saveScheduledEvent(Long userId, Long accountId, String type, String description) %7B%0A        EventVO event = new EventVO();%0A        event.setUserId(userId);%0A        event.setAccountId(accountId);%0A        event.setType(type);%0A        event.setState(EventState.Scheduled);%0A        event.setDescription(%22Scheduled async job for %22+description);%0A        event = _eventDao.persist(event);%0A        return event.getId();%0A    %7D%0A    %0A    /*%0A     * Save event after starting execution of an async job%0A     */%0A    public static Long saveStartedEvent(Long userId, Long accountId, String type, String description, long startEventId) %7B%0A        EventVO event = new EventVO();%0A        event.setUserId(userId);%0A        event.setAccountId(accountId);%0A        event.setType(type);%0A        event.setState(EventState.Started);%0A        event.setDescription(description);%0A        event.setStartId(startEventId);%0A        event = _eventDao.persist(event);%0A    %09return event.getId();%0A    %7D%0A%0A    public static Long saveEvent(Long userId, Long accountId, String level, String type, String description) %7B%0A        EventVO event = new EventVO();%0A        event.setUserId(userId);%0A        event.setAccountId(accountId);%0A        event.setType(type);%0A        event.setDescription(description);%0A        event.setLevel(level);%0A        event = _eventDao.persist(event);%0A        return event.getId();%0A    %7D%0A    %0A    public static Long saveEvent(Long userId, Long accountId, String level, String type, String description, String params) %7B%0A        EventVO event = new EventVO();%0A        event.setUserId(userId);%0A        event.setAccountId(accountId);%0A        event.setType(type);%0A        event.setDescription(description);%0A        event.setLevel(level);%0A        event.setParameters(params);%0A        event = _eventDao.persist(event);%0A        return event.getId();%0A    %7D%0A%0A    public static Long saveEvent(Long userId, Long accountId, String level, String type, String description, String params, long startEventId) %7B%0A        EventVO event = new EventVO();%0A        event.setUserId(userId);%0A        event.setAccountId(accountId);%0A        event.setType(type);%0A        event.setDescription(description);%0A        event.setLevel(level);%0A        event.setParameters(params);%0A        event.setStartId(startEventId);%0A        event = _eventDao.persist(event);%0A        return event.getId();%0A    %7D%0A%7D%0A

Add EventUtils to consolidate the creation of events and make it usable from all managers (there were some private methods in ManagementServerImpl). Add some validation logic to AssignToLoadBalancer implementation in NetworkManagerImpl.