Merge branch '4.16' into main

This commit is contained in:
Suresh Kumar Anaparti 2022-01-31 00:10:03 +05:30
commit 571339f872
No known key found for this signature in database
GPG Key ID: D7CEAE3A9E71D0AA
28 changed files with 342 additions and 80 deletions

View File

@ -20,6 +20,9 @@ import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
@ -29,6 +32,12 @@ import org.apache.cloudstack.api.InternalIdentity;
@Entity
@Table(name = "usage_ip_address")
public class UsageIPAddressVO implements InternalIdentity {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id")
private Long id;
@Column(name = "account_id")
private long accountId;
@ -38,8 +47,8 @@ public class UsageIPAddressVO implements InternalIdentity {
@Column(name = "zone_id")
private long zoneId;
@Column(name = "id")
private long id;
@Column(name = "ip_id")
private long ipId;
@Column(name = "public_ip_address")
private String address = null;
@ -65,7 +74,7 @@ public class UsageIPAddressVO implements InternalIdentity {
}
public UsageIPAddressVO(long id, long accountId, long domainId, long zoneId, String address, boolean isSourceNat, boolean isSystem, Date assigned, Date released, boolean isHidden) {
this.id = id;
this.ipId = id;
this.accountId = accountId;
this.domainId = domainId;
this.zoneId = zoneId;
@ -128,4 +137,8 @@ public class UsageIPAddressVO implements InternalIdentity {
public boolean isHidden() {
return isHidden;
}
public long getIpId() {
return ipId;
}
}

View File

@ -20,6 +20,9 @@ import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
@ -30,6 +33,11 @@ import org.apache.cloudstack.api.InternalIdentity;
@Table(name = "usage_load_balancer_policy")
public class UsageLoadBalancerPolicyVO implements InternalIdentity {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id")
private Long id;
@Column(name = "zone_id")
private long zoneId;
@ -39,8 +47,8 @@ public class UsageLoadBalancerPolicyVO implements InternalIdentity {
@Column(name = "domain_id")
private long domainId;
@Column(name = "id")
private long id;
@Column(name = "lb_id")
private long lbId;
@Column(name = "created")
@Temporal(value = TemporalType.TIMESTAMP)
@ -57,7 +65,7 @@ public class UsageLoadBalancerPolicyVO implements InternalIdentity {
this.zoneId = zoneId;
this.accountId = accountId;
this.domainId = domainId;
this.id = id;
this.lbId = id;
this.created = created;
this.deleted = deleted;
}
@ -90,4 +98,8 @@ public class UsageLoadBalancerPolicyVO implements InternalIdentity {
public void setDeleted(Date deleted) {
this.deleted = deleted;
}
public long getLbId() {
return lbId;
}
}

View File

@ -16,17 +16,27 @@
// under the License.
package com.cloud.usage;
import org.apache.cloudstack.api.InternalIdentity;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
@Entity
@Table(name = "usage_network_offering")
public class UsageNetworkOfferingVO {
public class UsageNetworkOfferingVO implements InternalIdentity {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id")
private Long id;
@Column(name = "zone_id")
private long zoneId;
@ -116,4 +126,9 @@ public class UsageNetworkOfferingVO {
public void setNicId(Long nicId) {
this.nicId = nicId;
}
@Override
public long getId() {
return this.id;
}
}

View File

@ -20,6 +20,9 @@ import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
@ -30,6 +33,11 @@ import org.apache.cloudstack.api.InternalIdentity;
@Table(name = "usage_port_forwarding")
public class UsagePortForwardingRuleVO implements InternalIdentity {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id")
private Long id;
@Column(name = "zone_id")
private long zoneId;
@ -39,8 +47,8 @@ public class UsagePortForwardingRuleVO implements InternalIdentity {
@Column(name = "domain_id")
private long domainId;
@Column(name = "id")
private long id;
@Column(name = "pf_id")
private long pfId;
@Column(name = "created")
@Temporal(value = TemporalType.TIMESTAMP)
@ -57,7 +65,7 @@ public class UsagePortForwardingRuleVO implements InternalIdentity {
this.zoneId = zoneId;
this.accountId = accountId;
this.domainId = domainId;
this.id = id;
this.pfId = id;
this.created = created;
this.deleted = deleted;
}
@ -90,4 +98,8 @@ public class UsagePortForwardingRuleVO implements InternalIdentity {
public void setDeleted(Date deleted) {
this.deleted = deleted;
}
public long getPfId() {
return pfId;
}
}

View File

@ -16,17 +16,27 @@
// under the License.
package com.cloud.usage;
import org.apache.cloudstack.api.InternalIdentity;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
@Entity
@Table(name = "usage_security_group")
public class UsageSecurityGroupVO {
public class UsageSecurityGroupVO implements InternalIdentity {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id")
private Long id;
@Column(name = "zone_id")
private long zoneId;
@ -95,4 +105,9 @@ public class UsageSecurityGroupVO {
public void setDeleted(Date deleted) {
this.deleted = deleted;
}
@Override
public long getId() {
return this.id;
}
}

View File

@ -20,6 +20,9 @@ import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
@ -30,9 +33,13 @@ import org.apache.cloudstack.api.InternalIdentity;
@Table(name = "usage_snapshot_on_primary")
public class UsageSnapshotOnPrimaryVO implements InternalIdentity {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id")
// volumeId
private long id;
private Long id;
@Column(name = "volume_id")
private long volumeId;
@Column(name = "zone_id")
private long zoneId;
@ -73,7 +80,7 @@ public class UsageSnapshotOnPrimaryVO implements InternalIdentity {
}
public UsageSnapshotOnPrimaryVO(long id, long zoneId, long accountId, long domainId, long vmId, String name, int type, long virtualSize, long physicalSize, Date created, Date deleted) {
this.id = id;
this.volumeId = id;
this.zoneId = zoneId;
this.accountId = accountId;
this.domainId = domainId;
@ -153,4 +160,7 @@ public class UsageSnapshotOnPrimaryVO implements InternalIdentity {
+ ", snapshotType=" + snapshotType + ", physicalSize=" + physicalSize + ", created=" + created + ", deleted=" + deleted + ", virtualSize=" + virtualSize + ", vmSnapshotId=" + vmSnapshotId + "]";
}
public long getVolumeId() {
return volumeId;
}
}

View File

@ -20,6 +20,9 @@ import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
@ -30,6 +33,11 @@ import org.apache.cloudstack.api.InternalIdentity;
@Table(name = "usage_storage")
public class UsageStorageVO implements InternalIdentity {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id")
private Long id;
@Column(name = "zone_id")
private long zoneId;
@ -39,8 +47,8 @@ public class UsageStorageVO implements InternalIdentity {
@Column(name = "domain_id")
private long domainId;
@Column(name = "id")
private long id;
@Column(name = "entity_id")
private long entityId;
@Column(name = "storage_type")
private int storageType;
@ -69,7 +77,7 @@ public class UsageStorageVO implements InternalIdentity {
this.zoneId = zoneId;
this.accountId = accountId;
this.domainId = domainId;
this.id = id;
this.entityId = id;
this.storageType = storageType;
this.sourceId = sourceId;
this.size = size;
@ -81,7 +89,7 @@ public class UsageStorageVO implements InternalIdentity {
this.zoneId = zoneId;
this.accountId = accountId;
this.domainId = domainId;
this.id = id;
this.entityId = id;
this.storageType = storageType;
this.sourceId = sourceId;
this.size = size;
@ -134,4 +142,8 @@ public class UsageStorageVO implements InternalIdentity {
public void setDeleted(Date deleted) {
this.deleted = deleted;
}
public long getEntityId() {
return entityId;
}
}

View File

@ -16,17 +16,27 @@
// under the License.
package com.cloud.usage;
import org.apache.cloudstack.api.InternalIdentity;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
@Entity
@Table(name = "usage_vm_instance")
public class UsageVMInstanceVO {
public class UsageVMInstanceVO implements InternalIdentity {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id")
private Long id;
@Column(name = "usage_type")
private int usageType;
@ -178,4 +188,9 @@ public class UsageVMInstanceVO {
public void setCpuSpeed(Long cpuSpeed) {
this.cpuSpeed = cpuSpeed;
}
@Override
public long getId() {
return this.id;
}
}

View File

@ -20,6 +20,9 @@ import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
@ -30,9 +33,13 @@ import org.apache.cloudstack.api.InternalIdentity;
@Table(name = "usage_vmsnapshot")
public class UsageVMSnapshotVO implements InternalIdentity {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id")
// volumeId
private long id;
private Long id;
@Column(name = "volume_id")
private long volumeId;
@Column(name = "zone_id")
private long zoneId;
@ -71,7 +78,7 @@ public class UsageVMSnapshotVO implements InternalIdentity {
this.accountId = accountId;
this.domainId = domainId;
this.diskOfferingId = diskOfferingId;
this.id = id;
this.volumeId = id;
this.size = size;
this.created = created;
this.vmId = vmId;
@ -131,6 +138,10 @@ public class UsageVMSnapshotVO implements InternalIdentity {
this.vmSnapshotId = vmSnapshotId;
}
public long getVolumeId() {
return volumeId;
}
@Override
public String toString() {
return "UsageVMSnapshotVO [id=" + id + ", zoneId=" + zoneId + ", accountId=" + accountId + ", domainId=" + domainId + ", vmId=" + vmId + ", diskOfferingId="

View File

@ -16,17 +16,27 @@
// under the License.
package com.cloud.usage;
import org.apache.cloudstack.api.InternalIdentity;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
@Entity
@Table(name = "usage_vpn_user")
public class UsageVPNUserVO {
public class UsageVPNUserVO implements InternalIdentity {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id")
private Long id;
@Column(name = "zone_id")
private long zoneId;
@ -103,4 +113,9 @@ public class UsageVPNUserVO {
public void setUsername(String username) {
this.username = username;
}
@Override
public long getId() {
return this.id;
}
}

View File

@ -20,6 +20,9 @@ import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
@ -30,6 +33,11 @@ import org.apache.cloudstack.api.InternalIdentity;
@Table(name = "usage_volume")
public class UsageVolumeVO implements InternalIdentity {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id")
private Long id;
@Column(name = "zone_id")
private long zoneId;
@ -39,8 +47,8 @@ public class UsageVolumeVO implements InternalIdentity {
@Column(name = "domain_id")
private long domainId;
@Column(name = "id")
private long id;
@Column(name = "volume_id")
private long volumeId;
@Column(name = "disk_offering_id")
private Long diskOfferingId;
@ -63,7 +71,7 @@ public class UsageVolumeVO implements InternalIdentity {
}
public UsageVolumeVO(long id, long zoneId, long accountId, long domainId, Long diskOfferingId, Long templateId, long size, Date created, Date deleted) {
this.id = id;
this.volumeId = id;
this.zoneId = zoneId;
this.accountId = accountId;
this.domainId = domainId;
@ -114,4 +122,8 @@ public class UsageVolumeVO implements InternalIdentity {
public void setDeleted(Date deleted) {
this.deleted = deleted;
}
public long getVolumeId() {
return volumeId;
}
}

View File

@ -40,17 +40,17 @@ public class UsageIPAddressDaoImpl extends GenericDaoBase<UsageIPAddressVO, Long
protected static final String UPDATE_RELEASED = "UPDATE usage_ip_address SET released = ? WHERE account_id = ? AND public_ip_address = ? and released IS NULL";
protected static final String GET_USAGE_RECORDS_BY_ACCOUNT =
"SELECT id, account_id, domain_id, zone_id, public_ip_address, is_source_nat, is_system, assigned, released, is_hidden "
"SELECT ip_id, account_id, domain_id, zone_id, public_ip_address, is_source_nat, is_system, assigned, released, is_hidden "
+ "FROM usage_ip_address "
+ "WHERE account_id = ? AND ((released IS NULL AND assigned <= ?) OR (assigned BETWEEN ? AND ?) OR "
+ " (released BETWEEN ? AND ?) OR ((assigned <= ?) AND (released >= ?)))";
protected static final String GET_USAGE_RECORDS_BY_DOMAIN =
"SELECT id, account_id, domain_id, zone_id, public_ip_address, is_source_nat, is_system, assigned, released, is_hidden "
"SELECT ip_id, account_id, domain_id, zone_id, public_ip_address, is_source_nat, is_system, assigned, released, is_hidden "
+ "FROM usage_ip_address "
+ "WHERE domain_id = ? AND ((released IS NULL AND assigned <= ?) OR (assigned BETWEEN ? AND ?) OR "
+ " (released BETWEEN ? AND ?) OR ((assigned <= ?) AND (released >= ?)))";
protected static final String GET_ALL_USAGE_RECORDS =
"SELECT id, account_id, domain_id, zone_id, public_ip_address, is_source_nat, is_system, assigned, released, is_hidden "
"SELECT ip_id, account_id, domain_id, zone_id, public_ip_address, is_source_nat, is_system, assigned, released, is_hidden "
+ "FROM usage_ip_address "
+ "WHERE (released IS NULL AND assigned <= ?) OR (assigned BETWEEN ? AND ?) OR "
+ " (released BETWEEN ? AND ?) OR ((assigned <= ?) AND (released >= ?))";

View File

@ -38,13 +38,13 @@ import com.cloud.utils.db.TransactionLegacy;
public class UsageLoadBalancerPolicyDaoImpl extends GenericDaoBase<UsageLoadBalancerPolicyVO, Long> implements UsageLoadBalancerPolicyDao {
public static final Logger s_logger = Logger.getLogger(UsageLoadBalancerPolicyDaoImpl.class.getName());
protected static final String REMOVE_BY_USERID_LBID = "DELETE FROM usage_load_balancer_policy WHERE account_id = ? AND id = ?";
protected static final String UPDATE_DELETED = "UPDATE usage_load_balancer_policy SET deleted = ? WHERE account_id = ? AND id = ? and deleted IS NULL";
protected static final String GET_USAGE_RECORDS_BY_ACCOUNT = "SELECT id, zone_id, account_id, domain_id, created, deleted " + "FROM usage_load_balancer_policy "
protected static final String REMOVE_BY_USERID_LBID = "DELETE FROM usage_load_balancer_policy WHERE account_id = ? AND lb_id = ?";
protected static final String UPDATE_DELETED = "UPDATE usage_load_balancer_policy SET deleted = ? WHERE account_id = ? AND lb_id = ? and deleted IS NULL";
protected static final String GET_USAGE_RECORDS_BY_ACCOUNT = "SELECT lb_id, zone_id, account_id, domain_id, created, deleted " + "FROM usage_load_balancer_policy "
+ "WHERE account_id = ? AND ((deleted IS NULL) OR (created BETWEEN ? AND ?) OR " + " (deleted BETWEEN ? AND ?) OR ((created <= ?) AND (deleted >= ?)))";
protected static final String GET_USAGE_RECORDS_BY_DOMAIN = "SELECT id, zone_id, account_id, domain_id, created, deleted " + "FROM usage_load_balancer_policy "
protected static final String GET_USAGE_RECORDS_BY_DOMAIN = "SELECT lb_id, zone_id, account_id, domain_id, created, deleted " + "FROM usage_load_balancer_policy "
+ "WHERE domain_id = ? AND ((deleted IS NULL) OR (created BETWEEN ? AND ?) OR " + " (deleted BETWEEN ? AND ?) OR ((created <= ?) AND (deleted >= ?)))";
protected static final String GET_ALL_USAGE_RECORDS = "SELECT id, zone_id, account_id, domain_id, created, deleted " + "FROM usage_load_balancer_policy "
protected static final String GET_ALL_USAGE_RECORDS = "SELECT lb_id, zone_id, account_id, domain_id, created, deleted " + "FROM usage_load_balancer_policy "
+ "WHERE (deleted IS NULL) OR (created BETWEEN ? AND ?) OR " + " (deleted BETWEEN ? AND ?) OR ((created <= ?) AND (deleted >= ?))";
public UsageLoadBalancerPolicyDaoImpl() {
@ -80,7 +80,7 @@ public class UsageLoadBalancerPolicyDaoImpl extends GenericDaoBase<UsageLoadBala
if (pstmt != null) {
pstmt.setString(1, DateUtil.getDateDisplayString(TimeZone.getTimeZone("GMT"), usage.getDeleted()));
pstmt.setLong(2, usage.getAccountId());
pstmt.setLong(3, usage.getId());
pstmt.setLong(3, usage.getLbId());
pstmt.executeUpdate();
}
}catch (SQLException e) {

View File

@ -38,13 +38,13 @@ import com.cloud.utils.db.TransactionLegacy;
public class UsagePortForwardingRuleDaoImpl extends GenericDaoBase<UsagePortForwardingRuleVO, Long> implements UsagePortForwardingRuleDao {
public static final Logger s_logger = Logger.getLogger(UsagePortForwardingRuleDaoImpl.class.getName());
protected static final String REMOVE_BY_USERID_PFID = "DELETE FROM usage_port_forwarding WHERE account_id = ? AND id = ?";
protected static final String UPDATE_DELETED = "UPDATE usage_port_forwarding SET deleted = ? WHERE account_id = ? AND id = ? and deleted IS NULL";
protected static final String GET_USAGE_RECORDS_BY_ACCOUNT = "SELECT id, zone_id, account_id, domain_id, created, deleted " + "FROM usage_port_forwarding "
protected static final String REMOVE_BY_USERID_PFID = "DELETE FROM usage_port_forwarding WHERE account_id = ? AND pf_id = ?";
protected static final String UPDATE_DELETED = "UPDATE usage_port_forwarding SET deleted = ? WHERE account_id = ? AND pf_id = ? and deleted IS NULL";
protected static final String GET_USAGE_RECORDS_BY_ACCOUNT = "SELECT pf_id, zone_id, account_id, domain_id, created, deleted " + "FROM usage_port_forwarding "
+ "WHERE account_id = ? AND ((deleted IS NULL) OR (created BETWEEN ? AND ?) OR " + " (deleted BETWEEN ? AND ?) OR ((created <= ?) AND (deleted >= ?)))";
protected static final String GET_USAGE_RECORDS_BY_DOMAIN = "SELECT id, zone_id, account_id, domain_id, created, deleted " + "FROM usage_port_forwarding "
protected static final String GET_USAGE_RECORDS_BY_DOMAIN = "SELECT pf_id, zone_id, account_id, domain_id, created, deleted " + "FROM usage_port_forwarding "
+ "WHERE domain_id = ? AND ((deleted IS NULL) OR (created BETWEEN ? AND ?) OR " + " (deleted BETWEEN ? AND ?) OR ((created <= ?) AND (deleted >= ?)))";
protected static final String GET_ALL_USAGE_RECORDS = "SELECT id, zone_id, account_id, domain_id, created, deleted " + "FROM usage_port_forwarding "
protected static final String GET_ALL_USAGE_RECORDS = "SELECT pf_id, zone_id, account_id, domain_id, created, deleted " + "FROM usage_port_forwarding "
+ "WHERE (deleted IS NULL) OR (created BETWEEN ? AND ?) OR " + " (deleted BETWEEN ? AND ?) OR ((created <= ?) AND (deleted >= ?))";
public UsagePortForwardingRuleDaoImpl() {
@ -80,7 +80,7 @@ public class UsagePortForwardingRuleDaoImpl extends GenericDaoBase<UsagePortForw
if (pstmt != null) {
pstmt.setString(1, DateUtil.getDateDisplayString(TimeZone.getTimeZone("GMT"), usage.getDeleted()));
pstmt.setLong(2, usage.getAccountId());
pstmt.setLong(3, usage.getId());
pstmt.setLong(3, usage.getPfId());
pstmt.executeUpdate();
}
}catch (SQLException e) {

View File

@ -40,15 +40,15 @@ import com.cloud.utils.db.TransactionLegacy;
public class UsageStorageDaoImpl extends GenericDaoBase<UsageStorageVO, Long> implements UsageStorageDao {
public static final Logger s_logger = Logger.getLogger(UsageStorageDaoImpl.class.getName());
protected static final String REMOVE_BY_USERID_STORAGEID = "DELETE FROM usage_storage WHERE account_id = ? AND id = ? AND storage_type = ?";
protected static final String UPDATE_DELETED = "UPDATE usage_storage SET deleted = ? WHERE account_id = ? AND id = ? AND storage_type = ? AND zone_id = ? and deleted IS NULL";
protected static final String REMOVE_BY_USERID_STORAGEID = "DELETE FROM usage_storage WHERE account_id = ? AND entity_id = ? AND storage_type = ?";
protected static final String UPDATE_DELETED = "UPDATE usage_storage SET deleted = ? WHERE account_id = ? AND entity_id = ? AND storage_type = ? AND zone_id = ? and deleted IS NULL";
protected static final String GET_USAGE_RECORDS_BY_ACCOUNT =
"SELECT id, zone_id, account_id, domain_id, storage_type, source_id, size, created, deleted, virtual_size " + "FROM usage_storage "
"SELECT entity_id, zone_id, account_id, domain_id, storage_type, source_id, size, created, deleted, virtual_size " + "FROM usage_storage "
+ "WHERE account_id = ? AND ((deleted IS NULL) OR (created BETWEEN ? AND ?) OR " + " (deleted BETWEEN ? AND ?) OR ((created <= ?) AND (deleted >= ?)))";
protected static final String GET_USAGE_RECORDS_BY_DOMAIN =
"SELECT id, zone_id, account_id, domain_id, storage_type, source_id, size, created, deleted, virtual_size " + "FROM usage_storage "
"SELECT entity_id, zone_id, account_id, domain_id, storage_type, source_id, size, created, deleted, virtual_size " + "FROM usage_storage "
+ "WHERE domain_id = ? AND ((deleted IS NULL) OR (created BETWEEN ? AND ?) OR " + " (deleted BETWEEN ? AND ?) OR ((created <= ?) AND (deleted >= ?)))";
protected static final String GET_ALL_USAGE_RECORDS = "SELECT id, zone_id, account_id, domain_id, storage_type, source_id, size, created, deleted, virtual_size "
protected static final String GET_ALL_USAGE_RECORDS = "SELECT entity_id, zone_id, account_id, domain_id, storage_type, source_id, size, created, deleted, virtual_size "
+ "FROM usage_storage " + "WHERE (deleted IS NULL) OR (created BETWEEN ? AND ?) OR " + " (deleted BETWEEN ? AND ?) OR ((created <= ?) AND (deleted >= ?))";
private final SearchBuilder<UsageStorageVO> IdSearch;
@ -57,13 +57,13 @@ public class UsageStorageDaoImpl extends GenericDaoBase<UsageStorageVO, Long> im
public UsageStorageDaoImpl() {
IdSearch = createSearchBuilder();
IdSearch.and("accountId", IdSearch.entity().getAccountId(), SearchCriteria.Op.EQ);
IdSearch.and("id", IdSearch.entity().getId(), SearchCriteria.Op.EQ);
IdSearch.and("id", IdSearch.entity().getEntityId(), SearchCriteria.Op.EQ);
IdSearch.and("type", IdSearch.entity().getStorageType(), SearchCriteria.Op.EQ);
IdSearch.done();
IdZoneSearch = createSearchBuilder();
IdZoneSearch.and("accountId", IdZoneSearch.entity().getAccountId(), SearchCriteria.Op.EQ);
IdZoneSearch.and("id", IdZoneSearch.entity().getId(), SearchCriteria.Op.EQ);
IdZoneSearch.and("id", IdZoneSearch.entity().getEntityId(), SearchCriteria.Op.EQ);
IdZoneSearch.and("type", IdZoneSearch.entity().getStorageType(), SearchCriteria.Op.EQ);
IdZoneSearch.and("dcId", IdZoneSearch.entity().getZoneId(), SearchCriteria.Op.EQ);
IdZoneSearch.and("deleted", IdZoneSearch.entity().getDeleted(), SearchCriteria.Op.NULL);
@ -124,7 +124,7 @@ public class UsageStorageDaoImpl extends GenericDaoBase<UsageStorageVO, Long> im
if (pstmt != null) {
pstmt.setString(1, DateUtil.getDateDisplayString(TimeZone.getTimeZone("GMT"), usage.getDeleted()));
pstmt.setLong(2, usage.getAccountId());
pstmt.setLong(3, usage.getId());
pstmt.setLong(3, usage.getEntityId());
pstmt.setInt(4, usage.getStorageType());
pstmt.setLong(5, usage.getZoneId());
pstmt.executeUpdate();

View File

@ -37,13 +37,13 @@ import com.cloud.utils.db.TransactionLegacy;
@Component
public class UsageVMSnapshotDaoImpl extends GenericDaoBase<UsageVMSnapshotVO, Long> implements UsageVMSnapshotDao {
public static final Logger s_logger = Logger.getLogger(UsageVMSnapshotDaoImpl.class.getName());
protected static final String GET_USAGE_RECORDS_BY_ACCOUNT = "SELECT id, zone_id, account_id, domain_id, vm_id, disk_offering_id, size, created, processed, vm_snapshot_id "
protected static final String GET_USAGE_RECORDS_BY_ACCOUNT = "SELECT volume_id, zone_id, account_id, domain_id, vm_id, disk_offering_id, size, created, processed, vm_snapshot_id "
+ " FROM usage_vmsnapshot" + " WHERE account_id = ? " + " AND ( (created BETWEEN ? AND ?) OR "
+ " (created < ? AND processed is NULL) ) ORDER BY created asc";
protected static final String UPDATE_DELETED = "UPDATE usage_vmsnapshot SET processed = ? WHERE account_id = ? AND id = ? and vm_id = ? and created = ?";
protected static final String UPDATE_DELETED = "UPDATE usage_vmsnapshot SET processed = ? WHERE account_id = ? AND volume_id = ? and vm_id = ? and created = ?";
protected static final String PREVIOUS_QUERY = "SELECT id, zone_id, account_id, domain_id, vm_id, disk_offering_id,size, created, processed, vm_snapshot_id "
+ "FROM usage_vmsnapshot " + "WHERE account_id = ? AND id = ? AND vm_id = ? AND created < ? AND processed IS NULL " + "ORDER BY created desc limit 1";
protected static final String PREVIOUS_QUERY = "SELECT volume_id, zone_id, account_id, domain_id, vm_id, disk_offering_id,size, created, processed, vm_snapshot_id "
+ "FROM usage_vmsnapshot " + "WHERE account_id = ? AND volume_id = ? AND vm_id = ? AND created < ? AND processed IS NULL " + "ORDER BY created desc limit 1";
@Override
public void update(UsageVMSnapshotVO usage) {
@ -54,7 +54,7 @@ public class UsageVMSnapshotDaoImpl extends GenericDaoBase<UsageVMSnapshotVO, Lo
pstmt = txn.prepareAutoCloseStatement(UPDATE_DELETED);
pstmt.setString(1, DateUtil.getDateDisplayString(TimeZone.getTimeZone("GMT"), usage.getProcessed()));
pstmt.setLong(2, usage.getAccountId());
pstmt.setLong(3, usage.getId());
pstmt.setLong(3, usage.getVolumeId());
pstmt.setLong(4, usage.getVmId());
pstmt.setString(5, DateUtil.getDateDisplayString(TimeZone.getTimeZone("GMT"), usage.getCreated()));
pstmt.executeUpdate();
@ -134,7 +134,7 @@ public class UsageVMSnapshotDaoImpl extends GenericDaoBase<UsageVMSnapshotVO, Lo
int i = 1;
pstmt = txn.prepareAutoCloseStatement(sql);
pstmt.setLong(i++, rec.getAccountId());
pstmt.setLong(i++, rec.getId());
pstmt.setLong(i++, rec.getVolumeId());
pstmt.setLong(i++, rec.getVmId());
pstmt.setString(i++, DateUtil.getDateDisplayString(TimeZone.getTimeZone("GMT"), rec.getCreated()));

View File

@ -37,10 +37,10 @@ import com.cloud.utils.db.TransactionLegacy;
@Component
public class UsageVMSnapshotOnPrimaryDaoImpl extends GenericDaoBase<UsageSnapshotOnPrimaryVO, Long> implements UsageVMSnapshotOnPrimaryDao {
public static final Logger s_logger = Logger.getLogger(UsageVMSnapshotOnPrimaryDaoImpl.class.getName());
protected static final String GET_USAGE_RECORDS_BY_ACCOUNT = "SELECT id, zone_id, account_id, domain_id, vm_id, name, type, physicalsize, virtualsize, created, deleted, vm_snapshot_id "
protected static final String GET_USAGE_RECORDS_BY_ACCOUNT = "SELECT volume_id, zone_id, account_id, domain_id, vm_id, name, type, physicalsize, virtualsize, created, deleted, vm_snapshot_id "
+ " FROM usage_snapshot_on_primary" + " WHERE account_id = ? " + " AND ( (created < ? AND deleted is NULL)"
+ " OR ( deleted BETWEEN ? AND ?)) ORDER BY created asc";
protected static final String UPDATE_DELETED = "UPDATE usage_snapshot_on_primary SET deleted = ? WHERE account_id = ? AND id = ? and vm_id = ? and created = ?";
protected static final String UPDATE_DELETED = "UPDATE usage_snapshot_on_primary SET deleted = ? WHERE account_id = ? AND volume_id = ? and vm_id = ? and created = ?";
@Override
public void updateDeleted(UsageSnapshotOnPrimaryVO usage) {
@ -51,7 +51,7 @@ public class UsageVMSnapshotOnPrimaryDaoImpl extends GenericDaoBase<UsageSnapsho
pstmt = txn.prepareAutoCloseStatement(UPDATE_DELETED);
pstmt.setString(1, DateUtil.getDateDisplayString(TimeZone.getTimeZone("GMT"), usage.getDeleted()));
pstmt.setLong(2, usage.getAccountId());
pstmt.setLong(3, usage.getId());
pstmt.setLong(3, usage.getVolumeId());
pstmt.setLong(4, usage.getVmId());
pstmt.setString(5, DateUtil.getDateDisplayString(TimeZone.getTimeZone("GMT"), usage.getCreated()));
pstmt.executeUpdate();

View File

@ -38,15 +38,15 @@ import com.cloud.utils.db.TransactionLegacy;
public class UsageVolumeDaoImpl extends GenericDaoBase<UsageVolumeVO, Long> implements UsageVolumeDao {
public static final Logger s_logger = Logger.getLogger(UsageVolumeDaoImpl.class.getName());
protected static final String REMOVE_BY_USERID_VOLID = "DELETE FROM usage_volume WHERE account_id = ? AND id = ?";
protected static final String UPDATE_DELETED = "UPDATE usage_volume SET deleted = ? WHERE account_id = ? AND id = ? and deleted IS NULL";
protected static final String GET_USAGE_RECORDS_BY_ACCOUNT = "SELECT id, zone_id, account_id, domain_id, disk_offering_id, template_id, size, created, deleted "
protected static final String REMOVE_BY_USERID_VOLID = "DELETE FROM usage_volume WHERE account_id = ? AND volume_id = ?";
protected static final String UPDATE_DELETED = "UPDATE usage_volume SET deleted = ? WHERE account_id = ? AND volume_id = ? and deleted IS NULL";
protected static final String GET_USAGE_RECORDS_BY_ACCOUNT = "SELECT volume_id, zone_id, account_id, domain_id, disk_offering_id, template_id, size, created, deleted "
+ "FROM usage_volume " + "WHERE account_id = ? AND ((deleted IS NULL) OR (created BETWEEN ? AND ?) OR "
+ " (deleted BETWEEN ? AND ?) OR ((created <= ?) AND (deleted >= ?)))";
protected static final String GET_USAGE_RECORDS_BY_DOMAIN = "SELECT id, zone_id, account_id, domain_id, disk_offering_id, template_id, size, created, deleted "
protected static final String GET_USAGE_RECORDS_BY_DOMAIN = "SELECT volume_id, zone_id, account_id, domain_id, disk_offering_id, template_id, size, created, deleted "
+ "FROM usage_volume " + "WHERE domain_id = ? AND ((deleted IS NULL) OR (created BETWEEN ? AND ?) OR "
+ " (deleted BETWEEN ? AND ?) OR ((created <= ?) AND (deleted >= ?)))";
protected static final String GET_ALL_USAGE_RECORDS = "SELECT id, zone_id, account_id, domain_id, disk_offering_id, template_id, size, created, deleted "
protected static final String GET_ALL_USAGE_RECORDS = "SELECT volume_id, zone_id, account_id, domain_id, disk_offering_id, template_id, size, created, deleted "
+ "FROM usage_volume " + "WHERE (deleted IS NULL) OR (created BETWEEN ? AND ?) OR " + " (deleted BETWEEN ? AND ?) OR ((created <= ?) AND (deleted >= ?))";
public UsageVolumeDaoImpl() {
@ -85,7 +85,7 @@ public class UsageVolumeDaoImpl extends GenericDaoBase<UsageVolumeVO, Long> impl
pstmt = txn.prepareAutoCloseStatement(UPDATE_DELETED);
pstmt.setString(1, DateUtil.getDateDisplayString(TimeZone.getTimeZone("GMT"), usage.getDeleted()));
pstmt.setLong(2, usage.getAccountId());
pstmt.setLong(3, usage.getId());
pstmt.setLong(3, usage.getVolumeId());
pstmt.executeUpdate();
}
txn.commit();

View File

@ -16,10 +16,14 @@
// under the License.
package com.cloud.user;
import org.apache.cloudstack.api.InternalIdentity;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Temporal;
@ -27,8 +31,13 @@ import javax.persistence.TemporalType;
@Entity
@Table(name = "op_user_stats_log")
public class UserStatsLogVO {
public class UserStatsLogVO implements InternalIdentity {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id")
private Long id;
@Column(name = "user_stats_id")
private long userStatsId;
@ -129,4 +138,8 @@ public class UserStatsLogVO {
this.updatedTime = updatedTime;
}
@Override
public long getId() {
return this.id;
}
}

View File

@ -20,3 +20,110 @@
--;
ALTER TABLE `cloud`.`vm_work_job` ADD COLUMN `secondary_object` char(100) COMMENT 'any additional item that must be checked during queueing' AFTER `vm_instance_id`;
-- Stored procedures to handle cloud and cloud_schema changes
-- Idempotent ADD COLUMN
DROP PROCEDURE IF EXISTS `cloud`.`IDEMPOTENT_ADD_COLUMN`;
CREATE PROCEDURE `cloud`.`IDEMPOTENT_ADD_COLUMN` (
IN in_table_name VARCHAR(200)
, IN in_column_name VARCHAR(200)
, IN in_column_definition VARCHAR(1000)
)
BEGIN
DECLARE CONTINUE HANDLER FOR 1060 BEGIN END; SET @ddl = CONCAT('ALTER TABLE ', in_table_name); SET @ddl = CONCAT(@ddl, ' ', 'ADD COLUMN') ; SET @ddl = CONCAT(@ddl, ' ', in_column_name); SET @ddl = CONCAT(@ddl, ' ', in_column_definition); PREPARE stmt FROM @ddl; EXECUTE stmt; DEALLOCATE PREPARE stmt; END;
-- Idempotent ADD COLUMN
DROP PROCEDURE IF EXISTS `cloud_usage`.`IDEMPOTENT_ADD_COLUMN`;
CREATE PROCEDURE `cloud_usage`.`IDEMPOTENT_ADD_COLUMN` (
IN in_table_name VARCHAR(200)
, IN in_column_name VARCHAR(200)
, IN in_column_definition VARCHAR(1000)
)
BEGIN
DECLARE CONTINUE HANDLER FOR 1060 BEGIN END; SET @ddl = CONCAT('ALTER TABLE ', in_table_name); SET @ddl = CONCAT(@ddl, ' ', 'ADD COLUMN') ; SET @ddl = CONCAT(@ddl, ' ', in_column_name); SET @ddl = CONCAT(@ddl, ' ', in_column_definition); PREPARE stmt FROM @ddl; EXECUTE stmt; DEALLOCATE PREPARE stmt; END;
-- Idempotent DROP INDEX
DROP PROCEDURE IF EXISTS `cloud_usage`.`IDEMPOTENT_DROP_INDEX`;
CREATE PROCEDURE `cloud_usage`.`IDEMPOTENT_DROP_INDEX` (
IN in_index_name VARCHAR(200)
, IN in_table_name VARCHAR(200)
)
BEGIN
DECLARE CONTINUE HANDLER FOR 1091 BEGIN END; SET @ddl = CONCAT('DROP INDEX ', in_index_name); SET @ddl = CONCAT(@ddl, ' ', ' ON ') ; SET @ddl = CONCAT(@ddl, ' ', in_table_name); PREPARE stmt FROM @ddl; EXECUTE stmt; DEALLOCATE PREPARE stmt; END;
-- Idempotent ADD UNIQUE INDEX
DROP PROCEDURE IF EXISTS `cloud_usage`.`IDEMPOTENT_ADD_UNIQUE_INDEX`;
CREATE PROCEDURE `cloud_usage`.`IDEMPOTENT_ADD_UNIQUE_INDEX` (
IN in_table_name VARCHAR(200)
, IN in_index_name VARCHAR(200)
, IN in_index_definition VARCHAR(1000)
)
BEGIN
DECLARE CONTINUE HANDLER FOR 1061 BEGIN END; SET @ddl = CONCAT('ALTER TABLE ', in_table_name); SET @ddl = CONCAT(@ddl, ' ', 'ADD UNIQUE INDEX ', in_index_name); SET @ddl = CONCAT(@ddl, ' ', in_index_definition); PREPARE stmt FROM @ddl; EXECUTE stmt; DEALLOCATE PREPARE stmt; END;
-- Idempotent CHANGE COLUMN
DROP PROCEDURE IF EXISTS `cloud_usage`.`IDEMPOTENT_CHANGE_COLUMN`;
CREATE PROCEDURE `cloud_usage`.`IDEMPOTENT_CHANGE_COLUMN` (
IN in_table_name VARCHAR(200)
, IN in_old_column_name VARCHAR(200)
, IN in_new_column_name VARCHAR(200)
, IN in_column_definition VARCHAR(1000)
)
BEGIN
DECLARE CONTINUE HANDLER FOR 1060 BEGIN END; SET @ddl = CONCAT('ALTER TABLE ', in_table_name); SET @ddl = CONCAT(@ddl, ' ', ' CHANGE COLUMN') ; SET @ddl = CONCAT(@ddl, ' ', in_old_column_name); SET @ddl = CONCAT(@ddl, ' ', in_new_column_name); SET @ddl = CONCAT(@ddl, ' ', in_column_definition); PREPARE stmt FROM @ddl; EXECUTE stmt; DEALLOCATE PREPARE stmt; END;
-- Invoke stored procedures to add primary keys on missing tables
-- Add PK to cloud.op_user_stats_log
CALL `cloud`.`IDEMPOTENT_ADD_COLUMN`('cloud.op_user_stats_log', 'id', 'BIGINT(20) NOT NULL AUTO_INCREMENT FIRST, ADD PRIMARY KEY (`id`)');
-- Add PK to cloud_usage.usage_ip_address
CALL `cloud_usage`.`IDEMPOTENT_DROP_INDEX`('id','cloud_usage.usage_ip_address');
CALL `cloud_usage`.`IDEMPOTENT_CHANGE_COLUMN`('cloud_usage.usage_ip_address', 'id', 'ip_id', 'BIGINT(20) UNSIGNED NOT NULL');
CALL `cloud_usage`.`IDEMPOTENT_ADD_COLUMN`('cloud_usage.usage_ip_address', 'id', 'BIGINT(20) NOT NULL AUTO_INCREMENT FIRST, ADD PRIMARY KEY (`id`)');
CALL `cloud_usage`.`IDEMPOTENT_ADD_UNIQUE_INDEX`('cloud_usage.usage_ip_address', 'id', '(ip_id ASC, assigned ASC)');
-- Add PK to usage_load_balancer_policy
CALL `cloud_usage`.`IDEMPOTENT_CHANGE_COLUMN`('cloud_usage.usage_load_balancer_policy', 'id', 'lb_id', 'BIGINT(20) UNSIGNED NOT NULL');
CALL `cloud_usage`.`IDEMPOTENT_ADD_COLUMN`('cloud_usage.usage_load_balancer_policy', 'id', 'BIGINT(20) NOT NULL AUTO_INCREMENT FIRST, ADD PRIMARY KEY (`id`)');
-- Add PK to cloud_usage.usage_network_offering
CALL `cloud_usage`.`IDEMPOTENT_ADD_COLUMN`('cloud_usage.usage_network_offering', 'id', 'BIGINT(20) NOT NULL AUTO_INCREMENT FIRST, ADD PRIMARY KEY (`id`)');
-- Add PK to cloud_usage.usage_port_forwarding
CALL `cloud_usage`.`IDEMPOTENT_CHANGE_COLUMN`('cloud_usage.usage_port_forwarding', 'id', 'pf_id', 'BIGINT(20) UNSIGNED NOT NULL');
CALL `cloud_usage`.`IDEMPOTENT_ADD_COLUMN`('cloud_usage.usage_port_forwarding', 'id', 'BIGINT(20) NOT NULL AUTO_INCREMENT FIRST, ADD PRIMARY KEY (`id`)');
-- Add PK to cloud_usage.usage_security_group
CALL `cloud_usage`.`IDEMPOTENT_ADD_COLUMN`('cloud_usage.usage_security_group', 'id', 'BIGINT(20) NOT NULL AUTO_INCREMENT FIRST, ADD PRIMARY KEY (`id`)');
-- cloud_usage.usage_snapshot_on_primary
CALL `cloud_usage`.`IDEMPOTENT_DROP_INDEX`('i_usage_snapshot_on_primary','cloud_usage.usage_snapshot_on_primary');
CALL `cloud_usage`.`IDEMPOTENT_CHANGE_COLUMN`('cloud_usage.usage_snapshot_on_primary', 'id', 'volume_id', 'BIGINT(20) UNSIGNED NOT NULL');
CALL `cloud_usage`.`IDEMPOTENT_ADD_COLUMN`('cloud_usage.usage_snapshot_on_primary', 'id', 'BIGINT(20) NOT NULL AUTO_INCREMENT FIRST, ADD PRIMARY KEY (`id`)');
CALL `cloud_usage`.`IDEMPOTENT_ADD_UNIQUE_INDEX`('cloud_usage.usage_snapshot_on_primary', 'i_usage_snapshot_on_primary', '(account_id ASC, volume_id ASC, vm_id ASC, created ASC)');
-- Add PK to cloud_usage.usage_storage
CALL `cloud_usage`.`IDEMPOTENT_DROP_INDEX`('id','cloud_usage.usage_storage');
CALL `cloud_usage`.`IDEMPOTENT_CHANGE_COLUMN`('cloud_usage.usage_storage', 'id', 'entity_id', 'BIGINT(20) UNSIGNED NOT NULL');
CALL `cloud_usage`.`IDEMPOTENT_ADD_COLUMN`('cloud_usage.usage_storage', 'id', 'BIGINT(20) NOT NULL AUTO_INCREMENT FIRST, ADD PRIMARY KEY (`id`)');
CALL `cloud_usage`.`IDEMPOTENT_ADD_UNIQUE_INDEX`('cloud_usage.usage_storage', 'id', '(entity_id ASC, storage_type ASC, zone_id ASC, created ASC)');
-- Add PK to cloud_usage.usage_vm_instance
CALL `cloud_usage`.`IDEMPOTENT_ADD_COLUMN`('cloud_usage.usage_vm_instance', 'id', 'BIGINT(20) NOT NULL AUTO_INCREMENT FIRST, ADD PRIMARY KEY (`id`)');
-- Add PK to cloud_usage.usage_vmsnapshot
CALL `cloud_usage`.`IDEMPOTENT_DROP_INDEX`('i_usage_vmsnapshot','cloud_usage.usage_vmsnapshot');
CALL `cloud_usage`.`IDEMPOTENT_CHANGE_COLUMN`('cloud_usage.usage_vmsnapshot', 'id', 'volume_id', 'BIGINT(20) UNSIGNED NOT NULL');
CALL `cloud_usage`.`IDEMPOTENT_ADD_COLUMN`('cloud_usage.usage_vmsnapshot', 'id', 'BIGINT(20) NOT NULL AUTO_INCREMENT FIRST, ADD PRIMARY KEY (`id`)');
CALL `cloud_usage`.`IDEMPOTENT_ADD_UNIQUE_INDEX`('cloud_usage.usage_vmsnapshot', 'i_usage_vmsnapshot', '(account_id ASC, volume_id ASC, vm_id ASC, created ASC)');
-- Add PK to cloud_usage.usage_volume
CALL `cloud_usage`.`IDEMPOTENT_DROP_INDEX`('id','cloud_usage.usage_volume');
CALL `cloud_usage`.`IDEMPOTENT_CHANGE_COLUMN`('cloud_usage.usage_volume', 'id', 'volume_id', 'BIGINT(20) UNSIGNED NOT NULL');
CALL `cloud_usage`.`IDEMPOTENT_ADD_COLUMN`('cloud_usage.usage_volume', 'id', 'BIGINT(20) NOT NULL AUTO_INCREMENT FIRST, ADD PRIMARY KEY (`id`)');
CALL `cloud_usage`.`IDEMPOTENT_ADD_UNIQUE_INDEX`('cloud_usage.usage_volume', 'id', '(volume_id ASC, created ASC)');
-- Add PK to cloud_usage.usage_vpn_user
CALL `cloud_usage`.`IDEMPOTENT_ADD_COLUMN`('cloud_usage.usage_vpn_user', 'id', 'BIGINT(20) NOT NULL AUTO_INCREMENT FIRST, ADD PRIMARY KEY (`id`)');

View File

@ -60,7 +60,7 @@ public class UsageStorageDaoImplTest {
long id = 21, zoneId = 31, accountId = 41;
int storageType = 1;
String UPDATE_DELETED = "UPDATE usage_storage SET deleted = ? WHERE account_id = ? AND id = ? AND storage_type = ? AND zone_id = ? and deleted IS NULL";
String UPDATE_DELETED = "UPDATE usage_storage SET deleted = ? WHERE account_id = ? AND entity_id = ? AND storage_type = ? AND zone_id = ? and deleted IS NULL";
Date deleted = new Date();
PowerMockito.mockStatic(TransactionLegacy.class);
@ -68,7 +68,7 @@ public class UsageStorageDaoImplTest {
when(transactionMock.prepareStatement(contains(UPDATE_DELETED))).thenReturn(preparedStatementMock);
when(userStorageVOMock.getAccountId()).thenReturn(accountId);
when(userStorageVOMock.getId()).thenReturn(id);
when(userStorageVOMock.getEntityId()).thenReturn(id);
when(userStorageVOMock.getStorageType()).thenReturn(storageType);
when(userStorageVOMock.getZoneId()).thenReturn(zoneId);
when(userStorageVOMock.getDeleted()).thenReturn(deleted);

View File

@ -82,7 +82,7 @@ public class IPAddressUsageParser {
// loop through all the usage IPs, create a usage record for each
for (UsageIPAddressVO usageIp : usageIPAddress) {
long IpId = usageIp.getId();
long IpId = usageIp.getIpId();
String key = "" + IpId;
@ -108,7 +108,7 @@ public class IPAddressUsageParser {
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.getIpId(), currentDuration);
}
for (String ipIdKey : usageMap.keySet()) {

View File

@ -81,7 +81,7 @@ public class LoadBalancerUsageParser {
// loop through all the load balancer policies, create a usage record for each
for (UsageLoadBalancerPolicyVO usageLB : usageLBs) {
long lbId = usageLB.getId();
long lbId = usageLB.getLbId();
String key = "" + lbId;
lbMap.put(key, new LBInfo(lbId, usageLB.getZoneId()));
@ -105,7 +105,7 @@ public class LoadBalancerUsageParser {
long currentDuration = (lbDeleteDate.getTime() - lbCreateDate.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)
updateLBUsageData(usageMap, key, usageLB.getId(), currentDuration);
updateLBUsageData(usageMap, key, usageLB.getLbId(), currentDuration);
}
for (String lbIdKey : usageMap.keySet()) {

View File

@ -81,7 +81,7 @@ public class PortForwardingUsageParser {
// loop through all the port forwarding rule, create a usage record for each
for (UsagePortForwardingRuleVO usagePF : usagePFs) {
long pfId = usagePF.getId();
long pfId = usagePF.getPfId();
String key = "" + pfId;
pfMap.put(key, new PFInfo(pfId, usagePF.getZoneId()));
@ -105,7 +105,7 @@ public class PortForwardingUsageParser {
long currentDuration = (pfDeleteDate.getTime() - pfCreateDate.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)
updatePFUsageData(usageMap, key, usagePF.getId(), currentDuration);
updatePFUsageData(usageMap, key, usagePF.getPfId(), currentDuration);
}
for (String pfIdKey : usageMap.keySet()) {

View File

@ -85,7 +85,7 @@ public class StorageUsageParser {
// loop through all the usage volumes, create a usage record for each
for (UsageStorageVO usageStorage : usageUsageStorages) {
long storageId = usageStorage.getId();
long storageId = usageStorage.getEntityId();
int storage_type = usageStorage.getStorageType();
long size = usageStorage.getSize();
Long virtualSize = usageStorage.getVirtualSize();
@ -116,7 +116,7 @@ public class StorageUsageParser {
long currentDuration = (storageDeleteDate.getTime() - storageCreateDate.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)
updateStorageUsageData(usageMap, key, usageStorage.getId(), currentDuration);
updateStorageUsageData(usageMap, key, usageStorage.getEntityId(), currentDuration);
}
for (String storageIdKey : usageMap.keySet()) {

View File

@ -95,7 +95,7 @@ public class VMSnapshotOnPrimaryParser {
s_logger.debug("Remoevd vm snapshot found endDateEffective " + endDateEffective + " period end data " + endDate);
}
long duration = (endDateEffective.getTime() - created.getTime()) + 1;
createUsageRecord(UsageTypes.VM_SNAPSHOT_ON_PRIMARY, duration, created, endDateEffective, account, usageRec.getId(), usageRec.getName(), usageRec.getZoneId(),
createUsageRecord(UsageTypes.VM_SNAPSHOT_ON_PRIMARY, duration, created, endDateEffective, account, usageRec.getVolumeId(), usageRec.getName(), usageRec.getZoneId(),
usageRec.getVirtualSize(), usageRec.getPhysicalSize(), usageRec.getVmSnapshotId());
}

View File

@ -74,7 +74,7 @@ public class VMSnapshotUsageParser {
Map<String, UsageVMSnapshotVO> unprocessedUsage = new HashMap<String, UsageVMSnapshotVO>();
for (UsageVMSnapshotVO usageRec : usageUsageVMSnapshots) {
long zoneId = usageRec.getZoneId();
Long volId = usageRec.getId();
Long volId = usageRec.getVolumeId();
long vmId = usageRec.getVmId();
String key = vmId + ":" + volId;
if (usageRec.getCreated().before(startDate)) {
@ -114,7 +114,7 @@ public class VMSnapshotUsageParser {
created = startDate;
}
long duration = (endDate.getTime() - created.getTime()) + 1;
createUsageRecord(UsageTypes.VM_SNAPSHOT, duration, created, endDate, account, usageRec.getId(), usageRec.getZoneId(), usageRec.getDiskOfferingId(),
createUsageRecord(UsageTypes.VM_SNAPSHOT, duration, created, endDate, account, usageRec.getVolumeId(), usageRec.getZoneId(), usageRec.getDiskOfferingId(),
usageRec.getVmId(), usageRec.getSize(), usageRec.getVmSnapshotId());
}

View File

@ -82,7 +82,7 @@ public class VolumeUsageParser {
// loop through all the usage volumes, create a usage record for each
for (UsageVolumeVO usageVol : usageUsageVols) {
long volId = usageVol.getId();
long volId = usageVol.getVolumeId();
Long doId = usageVol.getDiskOfferingId();
long zoneId = usageVol.getZoneId();
Long templateId = usageVol.getTemplateId();
@ -110,7 +110,7 @@ public class VolumeUsageParser {
long currentDuration = (volDeleteDate.getTime() - volCreateDate.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)
updateVolUsageData(usageMap, key, usageVol.getId(), currentDuration);
updateVolUsageData(usageMap, key, usageVol.getVolumeId(), currentDuration);
}
for (String volIdKey : usageMap.keySet()) {