Skip to content

Commit 85677b7

Browse files
author
Alena Prokharchyk
committed
Resource tags: CS-15473 - fixed delete/list by resourceId when UUID is specified as a value
Conflicts: server/src/com/cloud/network/dao/FirewallRulesDaoImpl.java server/src/com/cloud/network/vpc/Dao/StaticRouteDaoImpl.java server/src/com/cloud/network/vpc/Dao/VpcDaoImpl.java server/src/com/cloud/projects/dao/ProjectDaoImpl.java
1 parent 710fa36 commit 85677b7

16 files changed

Lines changed: 67 additions & 23 deletions

‎api/src/com/cloud/server/ResourceTag.java‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,4 +64,9 @@ public enum TaggedResourceType {
6464
*/
6565
String getCustomer();
6666

67+
/**
68+
* @return
69+
*/
70+
String getResourceUuid();
71+
6772
}

‎server/src/com/cloud/network/dao/FirewallRulesDaoImpl.java‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -280,11 +280,11 @@ public boolean remove(Long id) {
280280
FirewallRuleVO entry = findById(id);
281281
if (entry != null) {
282282
if (entry.getPurpose() == Purpose.LoadBalancing) {
283-
_tagsDao.removeBy(id, TaggedResourceType.LoadBalancer);
283+
_tagsDao.removeByIdAndType(id, TaggedResourceType.LoadBalancer);
284284
} else if (entry.getPurpose() == Purpose.PortForwarding) {
285-
_tagsDao.removeBy(id, TaggedResourceType.PortForwardingRule);
285+
_tagsDao.removeByIdAndType(id, TaggedResourceType.PortForwardingRule);
286286
} else if (entry.getPurpose() == Purpose.Firewall) {
287-
_tagsDao.removeBy(id, TaggedResourceType.FirewallRule);
287+
_tagsDao.removeByIdAndType(id, TaggedResourceType.FirewallRule);
288288
}
289289
}
290290
boolean result = super.remove(id);

‎server/src/com/cloud/network/dao/IPAddressDaoImpl.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ public boolean remove(Long id) {
323323
txn.start();
324324
IPAddressVO entry = findById(id);
325325
if (entry != null) {
326-
_tagsDao.removeBy(id, TaggedResourceType.SecurityGroup);
326+
_tagsDao.removeByIdAndType(id, TaggedResourceType.SecurityGroup);
327327
}
328328
boolean result = super.remove(id);
329329
txn.commit();

‎server/src/com/cloud/network/dao/NetworkDaoImpl.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,7 @@ public boolean remove(Long id) {
495495
txn.start();
496496
NetworkVO entry = findById(id);
497497
if (entry != null) {
498-
_tagsDao.removeBy(id, TaggedResourceType.Network);
498+
_tagsDao.removeByIdAndType(id, TaggedResourceType.Network);
499499
}
500500
boolean result = super.remove(id);
501501
txn.commit();

‎server/src/com/cloud/network/security/dao/SecurityGroupDaoImpl.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ public boolean remove(Long id) {
108108
txn.start();
109109
SecurityGroupVO entry = findById(id);
110110
if (entry != null) {
111-
_tagsDao.removeBy(id, TaggedResourceType.SecurityGroup);
111+
_tagsDao.removeByIdAndType(id, TaggedResourceType.SecurityGroup);
112112
}
113113
boolean result = super.remove(id);
114114
txn.commit();

‎server/src/com/cloud/projects/dao/ProjectDaoImpl.java‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,6 @@ public boolean remove(Long projectId) {
7373
if (!update(projectId, projectToRemove)) {
7474
s_logger.warn("Failed to reset name for the project id=" + projectId + " as a part of project remove");
7575
return false;
76-
} else {
77-
7876
}
7977
result = super.remove(projectId);
8078
txn.commit();

‎server/src/com/cloud/storage/dao/SnapshotDaoImpl.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ public boolean remove(Long id) {
301301
txn.start();
302302
SnapshotVO entry = findById(id);
303303
if (entry != null) {
304-
_tagsDao.removeBy(id, TaggedResourceType.Snapshot);
304+
_tagsDao.removeByIdAndType(id, TaggedResourceType.Snapshot);
305305
}
306306
boolean result = super.remove(id);
307307
txn.commit();

‎server/src/com/cloud/storage/dao/VMTemplateDaoImpl.java‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -805,9 +805,9 @@ public boolean remove(Long id) {
805805
template.setRemoved(new Date());
806806
if (template != null) {
807807
if (template.getFormat() == ImageFormat.ISO) {
808-
_tagsDao.removeBy(id, TaggedResourceType.ISO);
808+
_tagsDao.removeByIdAndType(id, TaggedResourceType.ISO);
809809
} else {
810-
_tagsDao.removeBy(id, TaggedResourceType.Template);
810+
_tagsDao.removeByIdAndType(id, TaggedResourceType.Template);
811811
}
812812
}
813813

‎server/src/com/cloud/storage/dao/VolumeDaoImpl.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,7 @@ public boolean remove(Long id) {
407407
txn.start();
408408
VolumeVO entry = findById(id);
409409
if (entry != null) {
410-
_tagsDao.removeBy(id, TaggedResourceType.Volume);
410+
_tagsDao.removeByIdAndType(id, TaggedResourceType.Volume);
411411
}
412412
boolean result = super.remove(id);
413413
txn.commit();

‎server/src/com/cloud/tags/ResourceTagVO.java‎

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,9 @@ public class ResourceTagVO implements Identity, ResourceTag{
6161
@Column(name="resource_id")
6262
long resourceId;
6363

64+
@Column(name="resource_uuid")
65+
private String resourceUuid;
66+
6467
@Column(name="resource_type")
6568
@Enumerated(value=EnumType.STRING)
6669
private TaggedResourceType resourceType;
@@ -81,9 +84,10 @@ protected ResourceTagVO(){
8184
* @param resourceId
8285
* @param resourceType
8386
* @param customer TODO
87+
* @param resourceUuid TODO
8488
*/
8589
public ResourceTagVO(String key, String value, long accountId, long domainId, long resourceId,
86-
TaggedResourceType resourceType, String customer) {
90+
TaggedResourceType resourceType, String customer, String resourceUuid) {
8791
super();
8892
this.key = key;
8993
this.value = value;
@@ -93,6 +97,7 @@ public ResourceTagVO(String key, String value, long accountId, long domainId, lo
9397
this.resourceType = resourceType;
9498
this.uuid = UUID.randomUUID().toString();
9599
this.customer = customer;
100+
this.resourceUuid = resourceUuid;
96101
}
97102

98103

@@ -149,4 +154,9 @@ public String getUuid() {
149154
public String getCustomer() {
150155
return customer;
151156
}
157+
158+
@Override
159+
public String getResourceUuid() {
160+
return resourceUuid;
161+
}
152162
}

0 commit comments

Comments
 (0)