From 8ad3fbf9d2e73d6f19cb19afa344a877ae623657 Mon Sep 17 00:00:00 2001 From: Murali Reddy Date: Tue, 24 May 2011 13:55:22 +0530 Subject: [PATCH] bug 9785: events around VLAN assign/release adding usage event for new VLAN allocation for the account from the zone vlans --- api/src/com/cloud/event/EventTypes.java | 2 ++ .../src/com/cloud/network/guru/GuestNetworkGuru.java | 11 +++++++++++ 2 files changed, 13 insertions(+) diff --git a/api/src/com/cloud/event/EventTypes.java b/api/src/com/cloud/event/EventTypes.java index 4c1d5c76622..f1ad1f52680 100755 --- a/api/src/com/cloud/event/EventTypes.java +++ b/api/src/com/cloud/event/EventTypes.java @@ -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"; diff --git a/server/src/com/cloud/network/guru/GuestNetworkGuru.java b/server/src/com/cloud/network/guru/GuestNetworkGuru.java index de9dd38cebd..7a6bd8af4cf 100644 --- a/server/src/com/cloud/network/guru/GuestNetworkGuru.java +++ b/server/src/com/cloud/network/guru/GuestNetworkGuru.java @@ -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); } }