bug 9785: events around VLAN assign/release

adding usage event for new VLAN allocation for the account from the zone vlans
This commit is contained in:
Murali Reddy 2011-05-24 13:55:22 +05:30
parent 1458b3a8e2
commit 8ad3fbf9d2
2 changed files with 13 additions and 0 deletions

View File

@ -161,6 +161,8 @@ public class EventTypes {
// VLANs/IP ranges
public static final String EVENT_VLAN_IP_RANGE_CREATE = "VLAN.IP.RANGE.CREATE";
public static final String EVENT_VLAN_IP_RANGE_DELETE = "VLAN.IP.RANGE.DELETE";
public static final String EVENT_ZONE_VLAN_CREATE = "ZONE.VLAN.CREATE";
public static final String EVENT_ZONE_VLAN_DELETE = "ZONE.VLAN.DELETE";
// Configuration Table
public static final String EVENT_CONFIGURATION_VALUE_EDIT = "CONFIGURATION.VALUE.EDIT";

View File

@ -32,6 +32,9 @@ import com.cloud.dc.dao.DataCenterDao;
import com.cloud.dc.dao.VlanDao;
import com.cloud.deploy.DeployDestination;
import com.cloud.deploy.DeploymentPlan;
import com.cloud.event.EventTypes;
import com.cloud.event.UsageEventVO;
import com.cloud.event.dao.UsageEventDao;
import com.cloud.exception.InsufficientAddressCapacityException;
import com.cloud.exception.InsufficientVirtualNetworkCapcityException;
import com.cloud.exception.InvalidParameterValueException;
@ -72,6 +75,8 @@ public class GuestNetworkGuru extends AdapterBase implements NetworkGuru {
protected NicDao _nicDao;
@Inject
protected NetworkDao _networkDao;
@Inject
protected UsageEventDao _usageEventDao;
String _defaultGateway;
String _defaultCidr;
@ -154,6 +159,10 @@ public class GuestNetworkGuru extends AdapterBase implements NetworkGuru {
if (vnet == null) {
throw new InsufficientVirtualNetworkCapcityException("Unable to allocate vnet as a part of network " + network + " implement ", DataCenter.class, dcId);
}
UsageEventVO usageEvent = new UsageEventVO(EventTypes.EVENT_ZONE_VLAN_CREATE, network.getAccountId(), dcId, network.getId(), vnet);
_usageEventDao.persist(usageEvent);
implemented.setBroadcastUri(BroadcastDomainType.Vlan.toUri(vnet));
} else {
implemented.setBroadcastUri(network.getBroadcastUri());
@ -261,6 +270,8 @@ public class GuestNetworkGuru extends AdapterBase implements NetworkGuru {
s_logger.debug("Releasing vnet for the network id=" + profile.getId());
if (profile.getBroadcastUri() != null) {
_dcDao.releaseVnet(profile.getBroadcastUri().getHost(), profile.getDataCenterId(), profile.getAccountId(), profile.getReservationId());
UsageEventVO usageEvent = new UsageEventVO(EventTypes.EVENT_ZONE_VLAN_DELETE, profile.getAccountId(), profile.getDataCenterId(), profile.getId(), profile.getBroadcastUri().getHost());
_usageEventDao.persist(usageEvent);
profile.setBroadcastUri(null);
}
}