use of com.cloud.event.UsageEventVO in project cloudstack by apache.
the class Upgrade218to22 method convertTemplateEvent.
private UsageEventVO convertTemplateEvent(EventVO event) throws IOException {
Properties templateEventParams = new Properties();
long templateId = -1L;
long zoneId = -1L;
long templateSize = -1L;
UsageEventVO usageEvent = null;
templateEventParams.load(new StringReader(event.getParameters()));
templateId = Long.parseLong(templateEventParams.getProperty("id"));
if (templateEventParams.getProperty("dcId") != null) {
zoneId = Long.parseLong(templateEventParams.getProperty("dcId"));
}
if (EventTypes.EVENT_TEMPLATE_CREATE.equals(event.getType()) || EventTypes.EVENT_TEMPLATE_COPY.equals(event.getType())) {
templateSize = Long.parseLong(templateEventParams.getProperty("size"));
if (templateSize < 1) {
return null;
}
if (zoneId == -1L) {
return null;
}
usageEvent = new UsageEventVO(event.getType(), event.getAccountId(), zoneId, templateId, "", null, null, templateSize);
} else if (EventTypes.EVENT_TEMPLATE_DELETE.equals(event.getType())) {
usageEvent = new UsageEventVO(event.getType(), event.getAccountId(), zoneId, templateId, null);
}
return usageEvent;
}
use of com.cloud.event.UsageEventVO in project cloudstack by apache.
the class Upgrade218to22 method convertIPEvent.
private UsageEventVO convertIPEvent(EventVO event, Connection conn) throws IOException, SQLException {
Properties ipEventParams = new Properties();
UsageEventVO usageEvent = null;
ipEventParams.load(new StringReader(event.getParameters()));
String ipAddress = ipEventParams.getProperty("address");
if (ipAddress == null) {
ipAddress = ipEventParams.getProperty("guestIPaddress");
if (ipAddress == null) {
// can not find IP address, bail for this event
return null;
}
}
// Get ip address information
Long ipId = 0L;
Long zoneId = 0L;
try (PreparedStatement pstmt = conn.prepareStatement("SELECT id, data_center_id from user_ip_address where public_ip_address=?")) {
pstmt.setString(1, ipAddress);
try (ResultSet rs = pstmt.executeQuery()) {
if (rs.next()) {
ipId = rs.getLong(1);
zoneId = rs.getLong(2);
}
boolean isSourceNat = Boolean.parseBoolean(ipEventParams.getProperty("sourceNat"));
if (EventTypes.EVENT_NET_IP_ASSIGN.equals(event.getType())) {
zoneId = Long.parseLong(ipEventParams.getProperty("dcId"));
usageEvent = new UsageEventVO(EventTypes.EVENT_NET_IP_ASSIGN, event.getAccountId(), zoneId, ipId, ipAddress, isSourceNat, "", false);
} else if (EventTypes.EVENT_NET_IP_RELEASE.equals(event.getType())) {
usageEvent = new UsageEventVO(EventTypes.EVENT_NET_IP_RELEASE, event.getAccountId(), zoneId, ipId, ipAddress, isSourceNat, "", false);
}
}
}
return usageEvent;
}
Aggregations