mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
updating copyright licenses, including build-usage.xml
This commit is contained in:
parent
7621dea575
commit
81c376dd5b
@ -25,4 +25,5 @@
|
|||||||
<import file="${base.dir}/build/build-tests.xml" optional="true"/>
|
<import file="${base.dir}/build/build-tests.xml" optional="true"/>
|
||||||
<import file="${base.dir}/build/package.xml" optional="true"/>
|
<import file="${base.dir}/build/package.xml" optional="true"/>
|
||||||
<import file="${base.dir}/build/developer.xml" optional="true"/>
|
<import file="${base.dir}/build/developer.xml" optional="true"/>
|
||||||
|
<import file="${base.dir}/build/build-usage.xml" optional="false"/>
|
||||||
</project>
|
</project>
|
||||||
|
|||||||
49
build/build-usage.xml
Normal file
49
build/build-usage.xml
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!-- Copyright 2008 Cloud, Inc. All Rights Reserved -->
|
||||||
|
<project name="Cloud Stack Usage Server" default="help" basedir=".">
|
||||||
|
<description>
|
||||||
|
Cloud Stack Usage server build
|
||||||
|
</description>
|
||||||
|
<property name="base.dir" location="${ant.file.Cloud Stack Usage Server}/../../.."/>
|
||||||
|
<property name="oss.build.dir" location="${base.dir}/build"/>
|
||||||
|
<property name="usage.jar" value="cloud-usage.jar" />
|
||||||
|
<dirname property="proprietary.dir" file="${ant.file.Cloud Stack Usage Server}/../"/>
|
||||||
|
<property name="usage.build.dir" location="${proprietary.dir}/build"/>
|
||||||
|
|
||||||
|
<import file="${oss.build.dir}/build-cloud.xml" optional="false"/>
|
||||||
|
<property name="usage.dir" location="${base.dir}/usage" />
|
||||||
|
<property name="usage.dist.dir" location="${dist.dir}/usage" />
|
||||||
|
|
||||||
|
<!-- ===================== Usage.Jar ===================== -->
|
||||||
|
<path id="usage.classpath">
|
||||||
|
<path refid="thirdparty.classpath" />
|
||||||
|
<path refid="dist.classpath" />
|
||||||
|
</path>
|
||||||
|
<target name="compile-usage" depends="-init, compile-utils, compile-core, compile-server" description="Compile the usage server">
|
||||||
|
<compile-java jar.name="${usage.jar}" top.dir="${usage.dir}" classpath="usage.classpath" />
|
||||||
|
</target>
|
||||||
|
|
||||||
|
<target name="build-usage" depends="build-all, compile-usage">
|
||||||
|
<mkdir dir="${usage.dist.dir}/bin" />
|
||||||
|
<mkdir dir="${usage.dist.dir}/conf" />
|
||||||
|
|
||||||
|
<copy todir="${usage.dist.dir}/bin">
|
||||||
|
<fileset dir="${usage.dir}/scripts">
|
||||||
|
<include name="usageserver.sh" />
|
||||||
|
</fileset>
|
||||||
|
</copy>
|
||||||
|
<copy overwrite="true" todir="${usage.dist.dir}/lib">
|
||||||
|
<fileset dir="${jar.dir}">
|
||||||
|
<include name="${usage.jar}" />
|
||||||
|
</fileset>
|
||||||
|
</copy>
|
||||||
|
</target>
|
||||||
|
|
||||||
|
<target name="run-usage">
|
||||||
|
<echo message="Run usage server ${usage.build.dir}/usage-runner" />
|
||||||
|
<exec dir="${usage.build.dir}" executable="bash">
|
||||||
|
<arg value="usage-runner" />
|
||||||
|
</exec>
|
||||||
|
</target>
|
||||||
|
|
||||||
|
</project>
|
||||||
@ -1,5 +1,21 @@
|
|||||||
/**
|
/**
|
||||||
* * Copyright (C) 2011 Citrix Systems, Inc. All rights reserved
|
* * Copyright (C) 2011 Citrix Systems, Inc. All rights reserved
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* This software is licensed under the GNU General Public License v3 or later.
|
||||||
|
*
|
||||||
|
* It is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or any later version.
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -1,5 +1,20 @@
|
|||||||
/**
|
/**
|
||||||
* * Copyright (C) 2011 Citrix Systems, Inc. All rights reserved
|
* Copyright (C) 2011 Citrix Systems, Inc. All rights reserved
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* This software is licensed under the GNU General Public License v3 or later.
|
||||||
|
*
|
||||||
|
* It is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or any later version.
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -1,5 +1,21 @@
|
|||||||
/**
|
/**
|
||||||
* * Copyright (C) 2011 Citrix Systems, Inc. All rights reserved
|
* Copyright (C) 2011 Citrix Systems, Inc. All rights reserved
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* This software is licensed under the GNU General Public License v3 or later.
|
||||||
|
*
|
||||||
|
* It is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or any later version.
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -1,5 +1,20 @@
|
|||||||
/**
|
/**
|
||||||
* * Copyright (C) 2011 Citrix Systems, Inc. All rights reserved
|
* Copyright (C) 2011 Citrix Systems, Inc. All rights reserved
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* This software is licensed under the GNU General Public License v3 or later.
|
||||||
|
*
|
||||||
|
* It is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or any later version.
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -1,6 +1,19 @@
|
|||||||
/**
|
/**
|
||||||
* * Copyright (C) 2011 Citrix Systems, Inc. All rights reserved
|
* Copyright (C) 2011 Citrix Systems, Inc. All rights reserved
|
||||||
*
|
*
|
||||||
|
*
|
||||||
|
* This software is licensed under the GNU General Public License v3 or later.
|
||||||
|
*
|
||||||
|
* It is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or any later version.
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.*
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|||||||
@ -1,16 +1,29 @@
|
|||||||
/**
|
/**
|
||||||
* * Copyright (C) 2011 Citrix Systems, Inc. All rights reserved
|
* Copyright (C) 2011 Citrix Systems, Inc. All rights reserved
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
*/
|
* This software is licensed under the GNU General Public License v3 or later.
|
||||||
|
*
|
||||||
|
* It is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or any later version.
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
package com.cloud.usage.parser;
|
package com.cloud.usage.parser;
|
||||||
|
|
||||||
import java.text.DecimalFormat;
|
import java.text.DecimalFormat;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
@ -21,7 +34,7 @@ import com.cloud.usage.UsageVO;
|
|||||||
import com.cloud.usage.dao.UsageDao;
|
import com.cloud.usage.dao.UsageDao;
|
||||||
import com.cloud.usage.dao.UsageIPAddressDao;
|
import com.cloud.usage.dao.UsageIPAddressDao;
|
||||||
import com.cloud.user.AccountVO;
|
import com.cloud.user.AccountVO;
|
||||||
import com.cloud.utils.Pair;
|
import com.cloud.utils.Pair;
|
||||||
import com.cloud.utils.component.ComponentLocator;
|
import com.cloud.utils.component.ComponentLocator;
|
||||||
|
|
||||||
public class IPAddressUsageParser {
|
public class IPAddressUsageParser {
|
||||||
@ -30,136 +43,136 @@ public class IPAddressUsageParser {
|
|||||||
private static ComponentLocator _locator = ComponentLocator.getLocator(UsageServer.Name, "usage-components.xml", "log4j-cloud_usage");
|
private static ComponentLocator _locator = ComponentLocator.getLocator(UsageServer.Name, "usage-components.xml", "log4j-cloud_usage");
|
||||||
private static UsageDao m_usageDao = _locator.getDao(UsageDao.class);
|
private static UsageDao m_usageDao = _locator.getDao(UsageDao.class);
|
||||||
private static UsageIPAddressDao m_usageIPAddressDao = _locator.getDao(UsageIPAddressDao.class);
|
private static UsageIPAddressDao m_usageIPAddressDao = _locator.getDao(UsageIPAddressDao.class);
|
||||||
|
|
||||||
|
|
||||||
public static boolean parse(AccountVO account, Date startDate, Date endDate) {
|
public static boolean parse(AccountVO account, Date startDate, Date endDate) {
|
||||||
if (s_logger.isDebugEnabled()) {
|
if (s_logger.isDebugEnabled()) {
|
||||||
s_logger.debug("Parsing IP Address usage for account: " + account.getId());
|
s_logger.debug("Parsing IP Address usage for account: " + account.getId());
|
||||||
}
|
}
|
||||||
if ((endDate == null) || endDate.after(new Date())) {
|
if ((endDate == null) || endDate.after(new Date())) {
|
||||||
endDate = new Date();
|
endDate = new Date();
|
||||||
}
|
}
|
||||||
|
|
||||||
// - query usage_ip_address table with the following criteria:
|
// - query usage_ip_address table with the following criteria:
|
||||||
// - look for an entry for accountId with start date in the given range
|
// - look for an entry for accountId with start date in the given range
|
||||||
// - look for an entry for accountId with end date in the given range
|
// - look for an entry for accountId with end date in the given range
|
||||||
// - look for an entry for accountId with end date null (currently running vm or owned IP)
|
// - look for an entry for accountId with end date null (currently running vm or owned IP)
|
||||||
// - look for an entry for accountId with start date before given range *and* end date after given range
|
// - look for an entry for accountId with start date before given range *and* end date after given range
|
||||||
List<UsageIPAddressVO> usageIPAddress = m_usageIPAddressDao.getUsageRecords(account.getId(), account.getDomainId(), startDate, endDate);
|
List<UsageIPAddressVO> usageIPAddress = m_usageIPAddressDao.getUsageRecords(account.getId(), account.getDomainId(), startDate, endDate);
|
||||||
|
|
||||||
if(usageIPAddress.isEmpty()){
|
if(usageIPAddress.isEmpty()){
|
||||||
s_logger.debug("No IP Address usage for this period");
|
s_logger.debug("No IP Address usage for this period");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// This map has both the running time *and* the usage amount.
|
// This map has both the running time *and* the usage amount.
|
||||||
Map<String, Pair<Long, Long>> usageMap = new HashMap<String, Pair<Long, Long>>();
|
Map<String, Pair<Long, Long>> usageMap = new HashMap<String, Pair<Long, Long>>();
|
||||||
|
|
||||||
Map<String, IpInfo> IPMap = new HashMap<String, IpInfo>();
|
Map<String, IpInfo> IPMap = new HashMap<String, IpInfo>();
|
||||||
|
|
||||||
// loop through all the usage IPs, create a usage record for each
|
// loop through all the usage IPs, create a usage record for each
|
||||||
for (UsageIPAddressVO usageIp : usageIPAddress) {
|
for (UsageIPAddressVO usageIp : usageIPAddress) {
|
||||||
long IpId = usageIp.getId();
|
long IpId = usageIp.getId();
|
||||||
|
|
||||||
String key = ""+IpId;
|
String key = ""+IpId;
|
||||||
|
|
||||||
// store the info in the IP map
|
// store the info in the IP map
|
||||||
IPMap.put(key, new IpInfo(usageIp.getZoneId(), IpId, usageIp.getAddress(), usageIp.isSourceNat()));
|
IPMap.put(key, new IpInfo(usageIp.getZoneId(), IpId, usageIp.getAddress(), usageIp.isSourceNat()));
|
||||||
|
|
||||||
Date IpAssignDate = usageIp.getAssigned();
|
Date IpAssignDate = usageIp.getAssigned();
|
||||||
Date IpReleaseDeleteDate = usageIp.getReleased();
|
Date IpReleaseDeleteDate = usageIp.getReleased();
|
||||||
|
|
||||||
if ((IpReleaseDeleteDate == null) || IpReleaseDeleteDate.after(endDate)) {
|
if ((IpReleaseDeleteDate == null) || IpReleaseDeleteDate.after(endDate)) {
|
||||||
IpReleaseDeleteDate = endDate;
|
IpReleaseDeleteDate = endDate;
|
||||||
}
|
}
|
||||||
|
|
||||||
// clip the start date to the beginning of our aggregation range if the vm has been running for a while
|
// clip the start date to the beginning of our aggregation range if the vm has been running for a while
|
||||||
if (IpAssignDate.before(startDate)) {
|
if (IpAssignDate.before(startDate)) {
|
||||||
IpAssignDate = startDate;
|
IpAssignDate = startDate;
|
||||||
}
|
}
|
||||||
|
|
||||||
long currentDuration = (IpReleaseDeleteDate.getTime() - IpAssignDate.getTime()) + 1; // make sure this is an inclusive check for milliseconds (i.e. use n - m + 1 to find total number of millis to charge)
|
long currentDuration = (IpReleaseDeleteDate.getTime() - IpAssignDate.getTime()) + 1; // make sure this is an inclusive check for milliseconds (i.e. use n - m + 1 to find total number of millis to charge)
|
||||||
|
|
||||||
updateIpUsageData(usageMap, key, usageIp.getId(), currentDuration);
|
updateIpUsageData(usageMap, key, usageIp.getId(), currentDuration);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (String ipIdKey : usageMap.keySet()) {
|
for (String ipIdKey : usageMap.keySet()) {
|
||||||
Pair<Long, Long> ipTimeInfo = usageMap.get(ipIdKey);
|
Pair<Long, Long> ipTimeInfo = usageMap.get(ipIdKey);
|
||||||
long useTime = ipTimeInfo.second().longValue();
|
long useTime = ipTimeInfo.second().longValue();
|
||||||
|
|
||||||
// Only create a usage record if we have a runningTime of bigger than zero.
|
// Only create a usage record if we have a runningTime of bigger than zero.
|
||||||
if (useTime > 0L) {
|
if (useTime > 0L) {
|
||||||
IpInfo info = IPMap.get(ipIdKey);
|
IpInfo info = IPMap.get(ipIdKey);
|
||||||
createUsageRecord(info.getZoneId(), useTime, startDate, endDate, account, info.getIpId(), info.getIPAddress(), info.isSourceNat());
|
createUsageRecord(info.getZoneId(), useTime, startDate, endDate, account, info.getIpId(), info.getIPAddress(), info.isSourceNat());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void updateIpUsageData(Map<String, Pair<Long, Long>> usageDataMap, String key, long ipId, long duration) {
|
private static void updateIpUsageData(Map<String, Pair<Long, Long>> usageDataMap, String key, long ipId, long duration) {
|
||||||
Pair<Long, Long> ipUsageInfo = usageDataMap.get(key);
|
Pair<Long, Long> ipUsageInfo = usageDataMap.get(key);
|
||||||
if (ipUsageInfo == null) {
|
if (ipUsageInfo == null) {
|
||||||
ipUsageInfo = new Pair<Long, Long>(new Long(ipId), new Long(duration));
|
ipUsageInfo = new Pair<Long, Long>(new Long(ipId), new Long(duration));
|
||||||
} else {
|
} else {
|
||||||
Long runningTime = ipUsageInfo.second();
|
Long runningTime = ipUsageInfo.second();
|
||||||
runningTime = new Long(runningTime.longValue() + duration);
|
runningTime = new Long(runningTime.longValue() + duration);
|
||||||
ipUsageInfo = new Pair<Long, Long>(ipUsageInfo.first(), runningTime);
|
ipUsageInfo = new Pair<Long, Long>(ipUsageInfo.first(), runningTime);
|
||||||
}
|
}
|
||||||
usageDataMap.put(key, ipUsageInfo);
|
usageDataMap.put(key, ipUsageInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void createUsageRecord(long zoneId, long runningTime, Date startDate, Date endDate, AccountVO account, long IpId, String IPAddress, boolean isSourceNat) {
|
private static void createUsageRecord(long zoneId, long runningTime, Date startDate, Date endDate, AccountVO account, long IpId, String IPAddress, boolean isSourceNat) {
|
||||||
if (s_logger.isDebugEnabled()) {
|
if (s_logger.isDebugEnabled()) {
|
||||||
s_logger.debug("Total usage time " + runningTime + "ms");
|
s_logger.debug("Total usage time " + runningTime + "ms");
|
||||||
}
|
}
|
||||||
|
|
||||||
float usage = runningTime / 1000f / 60f / 60f;
|
float usage = runningTime / 1000f / 60f / 60f;
|
||||||
|
|
||||||
DecimalFormat dFormat = new DecimalFormat("#.######");
|
DecimalFormat dFormat = new DecimalFormat("#.######");
|
||||||
String usageDisplay = dFormat.format(usage);
|
String usageDisplay = dFormat.format(usage);
|
||||||
|
|
||||||
if (s_logger.isDebugEnabled()) {
|
if (s_logger.isDebugEnabled()) {
|
||||||
s_logger.debug("Creating IP usage record with id: " + IpId + ", usage: " + usageDisplay + ", startDate: " + startDate + ", endDate: " + endDate + ", for account: " + account.getId());
|
s_logger.debug("Creating IP usage record with id: " + IpId + ", usage: " + usageDisplay + ", startDate: " + startDate + ", endDate: " + endDate + ", for account: " + account.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
String usageDesc = "IPAddress: "+IPAddress;
|
String usageDesc = "IPAddress: "+IPAddress;
|
||||||
|
|
||||||
// Create the usage record
|
// Create the usage record
|
||||||
|
|
||||||
UsageVO usageRecord = new UsageVO(zoneId, account.getAccountId(), account.getDomainId(), usageDesc, usageDisplay + " Hrs",
|
UsageVO usageRecord = new UsageVO(zoneId, account.getAccountId(), account.getDomainId(), usageDesc, usageDisplay + " Hrs",
|
||||||
UsageTypes.IP_ADDRESS, new Double(usage), null, null, null, null, IpId, startDate, endDate, (isSourceNat?"SourceNat":""));
|
UsageTypes.IP_ADDRESS, new Double(usage), null, null, null, null, IpId, startDate, endDate, (isSourceNat?"SourceNat":""));
|
||||||
m_usageDao.persist(usageRecord);
|
m_usageDao.persist(usageRecord);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class IpInfo {
|
private static class IpInfo {
|
||||||
private long zoneId;
|
private long zoneId;
|
||||||
private long IpId;
|
private long IpId;
|
||||||
private String IPAddress;
|
private String IPAddress;
|
||||||
private boolean isSourceNat;
|
private boolean isSourceNat;
|
||||||
|
|
||||||
public IpInfo(long zoneId,long IpId, String IPAddress, boolean isSourceNat) {
|
public IpInfo(long zoneId,long IpId, String IPAddress, boolean isSourceNat) {
|
||||||
this.zoneId = zoneId;
|
this.zoneId = zoneId;
|
||||||
this.IpId = IpId;
|
this.IpId = IpId;
|
||||||
this.IPAddress = IPAddress;
|
this.IPAddress = IPAddress;
|
||||||
this.isSourceNat = isSourceNat;
|
this.isSourceNat = isSourceNat;
|
||||||
}
|
}
|
||||||
|
|
||||||
public long getZoneId() {
|
public long getZoneId() {
|
||||||
return zoneId;
|
return zoneId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public long getIpId() {
|
public long getIpId() {
|
||||||
return IpId;
|
return IpId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getIPAddress() {
|
public String getIPAddress() {
|
||||||
return IPAddress;
|
return IPAddress;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isSourceNat() {
|
public boolean isSourceNat() {
|
||||||
return isSourceNat;
|
return isSourceNat;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,8 +1,21 @@
|
|||||||
/**
|
/**
|
||||||
* * Copyright (C) 2011 Citrix Systems, Inc. All rights reserved
|
* Copyright (C) 2011 Citrix Systems, Inc. All rights reserved
|
||||||
*
|
*
|
||||||
*/
|
*
|
||||||
|
* This software is licensed under the GNU General Public License v3 or later.
|
||||||
|
*
|
||||||
|
* It is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or any later version.
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
package com.cloud.usage.parser;
|
package com.cloud.usage.parser;
|
||||||
|
|
||||||
import java.text.DecimalFormat;
|
import java.text.DecimalFormat;
|
||||||
|
|||||||
@ -1,8 +1,21 @@
|
|||||||
/**
|
/**
|
||||||
* * Copyright (C) 2011 Citrix Systems, Inc. All rights reserved
|
* Copyright (C) 2011 Citrix Systems, Inc. All rights reserved
|
||||||
*
|
*
|
||||||
*/
|
*
|
||||||
|
* This software is licensed under the GNU General Public License v3 or later.
|
||||||
|
*
|
||||||
|
* It is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or any later version.
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
package com.cloud.usage.parser;
|
package com.cloud.usage.parser;
|
||||||
|
|
||||||
import java.text.DecimalFormat;
|
import java.text.DecimalFormat;
|
||||||
|
|||||||
@ -1,8 +1,21 @@
|
|||||||
/**
|
/**
|
||||||
* * Copyright (C) 2011 Citrix Systems, Inc. All rights reserved
|
* Copyright (C) 2011 Citrix Systems, Inc. All rights reserved
|
||||||
*
|
*
|
||||||
*/
|
*
|
||||||
|
* This software is licensed under the GNU General Public License v3 or later.
|
||||||
|
*
|
||||||
|
* It is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or any later version.
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
package com.cloud.usage.parser;
|
package com.cloud.usage.parser;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|||||||
@ -1,8 +1,21 @@
|
|||||||
/**
|
/**
|
||||||
* * Copyright (C) 2011 Citrix Systems, Inc. All rights reserved
|
* Copyright (C) 2011 Citrix Systems, Inc. All rights reserved
|
||||||
*
|
*
|
||||||
*/
|
*
|
||||||
|
* This software is licensed under the GNU General Public License v3 or later.
|
||||||
|
*
|
||||||
|
* It is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or any later version.
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
package com.cloud.usage.parser;
|
package com.cloud.usage.parser;
|
||||||
|
|
||||||
import java.text.DecimalFormat;
|
import java.text.DecimalFormat;
|
||||||
|
|||||||
@ -1,8 +1,21 @@
|
|||||||
/**
|
/**
|
||||||
* * Copyright (C) 2011 Citrix Systems, Inc. All rights reserved
|
* Copyright (C) 2011 Citrix Systems, Inc. All rights reserved
|
||||||
*
|
*
|
||||||
*/
|
*
|
||||||
|
* This software is licensed under the GNU General Public License v3 or later.
|
||||||
|
*
|
||||||
|
* It is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or any later version.
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
package com.cloud.usage.parser;
|
package com.cloud.usage.parser;
|
||||||
|
|
||||||
import java.text.DecimalFormat;
|
import java.text.DecimalFormat;
|
||||||
@ -61,7 +74,7 @@ public class StorageUsageParser {
|
|||||||
long storageId = usageStorage.getId();
|
long storageId = usageStorage.getId();
|
||||||
int storage_type = usageStorage.getStorageType();
|
int storage_type = usageStorage.getStorageType();
|
||||||
long size = usageStorage.getSize();
|
long size = usageStorage.getSize();
|
||||||
long zoneId = usageStorage.getZoneId();
|
long zoneId = usageStorage.getZoneId();
|
||||||
Long sourceId = usageStorage.getSourceId();
|
Long sourceId = usageStorage.getSourceId();
|
||||||
|
|
||||||
String key = ""+storageId+"Z"+zoneId+"T"+storage_type;
|
String key = ""+storageId+"Z"+zoneId+"T"+storage_type;
|
||||||
@ -127,14 +140,14 @@ public class StorageUsageParser {
|
|||||||
s_logger.debug("Creating Storage usage record for type: "+ type + " with id: " + storageId + ", usage: " + usageDisplay + ", startDate: " + startDate + ", endDate: " + endDate + ", for account: " + account.getId());
|
s_logger.debug("Creating Storage usage record for type: "+ type + " with id: " + storageId + ", usage: " + usageDisplay + ", startDate: " + startDate + ", endDate: " + endDate + ", for account: " + account.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
String usageDesc = "";
|
String usageDesc = "";
|
||||||
Long tmplSourceId = null;
|
Long tmplSourceId = null;
|
||||||
|
|
||||||
int usage_type = 0;
|
int usage_type = 0;
|
||||||
switch(type){
|
switch(type){
|
||||||
case StorageTypes.TEMPLATE:
|
case StorageTypes.TEMPLATE:
|
||||||
usage_type = UsageTypes.TEMPLATE;
|
usage_type = UsageTypes.TEMPLATE;
|
||||||
usageDesc += "Template ";
|
usageDesc += "Template ";
|
||||||
tmplSourceId = sourceId;
|
tmplSourceId = sourceId;
|
||||||
break;
|
break;
|
||||||
case StorageTypes.ISO:
|
case StorageTypes.ISO:
|
||||||
@ -158,14 +171,14 @@ public class StorageUsageParser {
|
|||||||
private static class StorageInfo {
|
private static class StorageInfo {
|
||||||
private long zoneId;
|
private long zoneId;
|
||||||
private long storageId;
|
private long storageId;
|
||||||
private int storageType;
|
private int storageType;
|
||||||
private Long sourceId;
|
private Long sourceId;
|
||||||
private long size;
|
private long size;
|
||||||
|
|
||||||
public StorageInfo(long zoneId, long storageId, int storageType, Long sourceId, long size) {
|
public StorageInfo(long zoneId, long storageId, int storageType, Long sourceId, long size) {
|
||||||
this.zoneId = zoneId;
|
this.zoneId = zoneId;
|
||||||
this.storageId = storageId;
|
this.storageId = storageId;
|
||||||
this.storageType = storageType;
|
this.storageType = storageType;
|
||||||
this.sourceId = sourceId;
|
this.sourceId = sourceId;
|
||||||
this.size = size;
|
this.size = size;
|
||||||
}
|
}
|
||||||
@ -181,11 +194,11 @@ public class StorageUsageParser {
|
|||||||
public int getStorageType() {
|
public int getStorageType() {
|
||||||
return storageType;
|
return storageType;
|
||||||
}
|
}
|
||||||
|
|
||||||
public long getSourceId() {
|
public long getSourceId() {
|
||||||
return sourceId;
|
return sourceId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public long getSize() {
|
public long getSize() {
|
||||||
return size;
|
return size;
|
||||||
|
|||||||
@ -1,8 +1,21 @@
|
|||||||
/**
|
/**
|
||||||
* * Copyright (C) 2011 Citrix Systems, Inc. All rights reserved
|
* Copyright (C) 2011 Citrix Systems, Inc. All rights reserved
|
||||||
*
|
*
|
||||||
*/
|
*
|
||||||
|
* This software is licensed under the GNU General Public License v3 or later.
|
||||||
|
*
|
||||||
|
* It is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or any later version.
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
package com.cloud.usage.parser;
|
package com.cloud.usage.parser;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|||||||
@ -1,8 +1,21 @@
|
|||||||
/**
|
/**
|
||||||
* * Copyright (C) 2011 Citrix Systems, Inc. All rights reserved
|
* Copyright (C) 2011 Citrix Systems, Inc. All rights reserved
|
||||||
*
|
*
|
||||||
*/
|
*
|
||||||
|
* This software is licensed under the GNU General Public License v3 or later.
|
||||||
|
*
|
||||||
|
* It is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or any later version.
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
package com.cloud.usage.parser;
|
package com.cloud.usage.parser;
|
||||||
|
|
||||||
import java.text.DecimalFormat;
|
import java.text.DecimalFormat;
|
||||||
|
|||||||
@ -1,8 +1,21 @@
|
|||||||
/**
|
/**
|
||||||
* * Copyright (C) 2011 Citrix Systems, Inc. All rights reserved
|
* Copyright (C) 2011 Citrix Systems, Inc. All rights reserved
|
||||||
*
|
*
|
||||||
*/
|
*
|
||||||
|
* This software is licensed under the GNU General Public License v3 or later.
|
||||||
|
*
|
||||||
|
* It is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or any later version.
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
package com.cloud.usage.parser;
|
package com.cloud.usage.parser;
|
||||||
|
|
||||||
import java.text.DecimalFormat;
|
import java.text.DecimalFormat;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user