Skip to content

Commit ce6a53e

Browse files
karuturiKishan Kavala
authored andcommitted
Fixed CLOUDSTACK-6756: usage id is not being returned for an ip in deleted ip range
(cherry picked from commit a6ed48fc9c5f68b46f0d2e05adefc7263c4cd0d0) Conflicts: setup/db/db/schema-430to440.sql
1 parent d0f806b commit ce6a53e

7 files changed

Lines changed: 67 additions & 2 deletions

File tree

api/src/com/cloud/dc/Vlan.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
import org.apache.cloudstack.api.Identity;
2121
import org.apache.cloudstack.api.InternalIdentity;
2222

23+
import java.util.Date;
24+
2325
public interface Vlan extends InfrastructureEntity, InternalIdentity, Identity {
2426
public enum VlanType {
2527
DirectAttached, VirtualNetwork
@@ -41,6 +43,10 @@ public enum VlanType {
4143

4244
public Long getNetworkId();
4345

46+
public Date getRemoved();
47+
48+
public Date getCreated();
49+
4450
public Long getPhysicalNetworkId();
4551

4652
public String getIp6Gateway();

api/src/com/cloud/network/IpAddress.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,10 @@ enum Purpose {
8686

8787
Long getNetworkId();
8888

89-
@Override
9089
boolean isDisplay();
9190

91+
public Date getRemoved();
92+
93+
public Date getCreated();
94+
9295
}

engine/components-api/src/com/cloud/network/addr/PublicIp.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,16 @@ public boolean isDisplay() {
238238
return _addr.isDisplay();
239239
}
240240

241+
@Override
242+
public Date getRemoved() {
243+
return _addr.getRemoved();
244+
}
245+
246+
@Override
247+
public Date getCreated() {
248+
return _addr.getCreated();
249+
}
250+
241251
@Override
242252
public Class<?> getEntityType() {
243253
return IpAddress.class;

engine/schema/src/com/cloud/dc/VlanVO.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616
// under the License.
1717
package com.cloud.dc;
1818

19+
import com.cloud.utils.db.GenericDao;
20+
21+
import java.util.Date;
1922
import java.util.UUID;
2023

2124
import javax.persistence.Column;
@@ -73,6 +76,13 @@ public class VlanVO implements Vlan {
7376
@Column(name = "uuid")
7477
String uuid;
7578

79+
@Column(name= GenericDao.REMOVED_COLUMN)
80+
private Date removed;
81+
82+
@Column(name = GenericDao.CREATED_COLUMN)
83+
private Date created;
84+
85+
7686
public VlanVO(VlanType vlanType, String vlanTag, String vlanGateway, String vlanNetmask, long dataCenterId, String ipRange, Long networkId, Long physicalNetworkId,
7787
String ip6Gateway, String ip6Cidr, String ip6Range) {
7888
this.vlanType = vlanType;
@@ -150,6 +160,16 @@ public void setUuid(String uuid) {
150160
this.uuid = uuid;
151161
}
152162

163+
@Override
164+
public Date getRemoved() {
165+
return removed;
166+
}
167+
168+
@Override
169+
public Date getCreated() {
170+
return created;
171+
}
172+
153173
@Override
154174
public Long getPhysicalNetworkId() {
155175
return physicalNetworkId;

engine/schema/src/com/cloud/network/dao/IPAddressVO.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
import javax.persistence.Transient;
3333

3434
import com.cloud.network.IpAddress;
35+
import com.cloud.utils.db.GenericDao;
3536
import com.cloud.utils.net.Ip;
3637

3738
/**
@@ -117,6 +118,12 @@ public class IPAddressVO implements IpAddress {
117118
@Column(name = "display", updatable = true, nullable = false)
118119
protected boolean display = true;
119120

121+
@Column(name= GenericDao.REMOVED_COLUMN)
122+
private Date removed;
123+
124+
@Column(name = GenericDao.CREATED_COLUMN)
125+
private Date created;
126+
120127
protected IPAddressVO() {
121128
uuid = UUID.randomUUID().toString();
122129
}
@@ -351,4 +358,14 @@ public void setDisplay(boolean display) {
351358
public Class<?> getEntityType() {
352359
return IpAddress.class;
353360
}
361+
362+
@Override
363+
public Date getRemoved() {
364+
return removed;
365+
}
366+
367+
@Override
368+
public Date getCreated() {
369+
return created;
370+
}
354371
}

server/src/com/cloud/configuration/ConfigurationManagerImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3183,7 +3183,7 @@ public boolean deleteVlanAndPublicIpRange(long userId, final long vlanDbId, Acco
31833183
@Override
31843184
public void doInTransactionWithoutResult(TransactionStatus status) {
31853185
_publicIpAddressDao.deletePublicIPRange(vlanDbId);
3186-
_vlanDao.expunge(vlanDbId);
3186+
_vlanDao.remove(vlanDbId);
31873187
}
31883188
});
31893189

setup/db/db/schema-430to440.sql

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1676,3 +1676,12 @@ CREATE TABLE `cloud`.`network_acl_item_cidrs` (
16761676
ALTER TABLE `cloud`.`load_balancer_healthcheck_policies` ADD COLUMN `display` tinyint(1) NOT NULL DEFAULT '1' COMMENT 'True if the policy can be displayed to the end user';
16771677
ALTER TABLE `cloud`.`load_balancer_stickiness_policies` ADD COLUMN `display` tinyint(1) NOT NULL DEFAULT '1' COMMENT 'True if the policy can be displayed to the end user';
16781678

1679+
1680+
alter table user_ip_address add column removed datetime DEFAULT NULL COMMENT 'date removed';
1681+
alter table user_ip_address add column created datetime NULL COMMENT 'date created';
1682+
1683+
alter table vlan add column removed datetime DEFAULT NULL COMMENT 'date removed';
1684+
alter table vlan add column created datetime NULL COMMENT 'date created';
1685+
1686+
alter table user_ip_address drop key public_ip_address;
1687+
alter table user_ip_address add UNIQUE KEY public_ip_address (public_ip_address,source_network_id, removed);

0 commit comments

Comments
 (0)