Skip to content

Commit eb93efd

Browse files
committed
Add convenient delete methods in DataObject to delete dangling data
object.
1 parent 614e08e commit eb93efd

5 files changed

Lines changed: 31 additions & 4 deletions

File tree

engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/DataObject.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ public interface DataObject {
3838
// public DiskFormat getFormat();
3939
public String getUuid();
4040

41+
boolean delete();
42+
4143
public void processEvent(ObjectInDataStoreStateMachine.Event event);
4244

4345
public void processEvent(ObjectInDataStoreStateMachine.Event event, Answer answer);

engine/storage/image/src/org/apache/cloudstack/storage/image/store/TemplateObject.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,12 +125,12 @@ public Long getSize() {
125125
}
126126

127127
/*
128-
*
128+
*
129129
* // If the template that was passed into this allocator is not
130130
* installed in the storage pool, // add 3 * (template size on secondary
131131
* storage) to the running total VMTemplateHostVO templateHostVO =
132132
* _storageMgr.findVmTemplateHost(templateForVmCreation.getId(), null);
133-
*
133+
*
134134
* if (templateHostVO == null) { VMTemplateSwiftVO templateSwiftVO =
135135
* _swiftMgr.findByTmpltId(templateForVmCreation.getId()); if
136136
* (templateSwiftVO != null) { long templateSize =
@@ -395,4 +395,13 @@ public long getDomainId() {
395395
return this.imageVO.getDomainId();
396396
}
397397

398+
@Override
399+
public boolean delete() {
400+
if (dataStore != null) {
401+
return dataStore.delete(this);
402+
}
403+
return true;
404+
}
405+
406+
398407
}

engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/SnapshotObject.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,4 +284,11 @@ public void addPayload(Object data) {
284284

285285
}
286286

287+
@Override
288+
public boolean delete() {
289+
if (store != null) {
290+
return store.delete(this);
291+
}
292+
return true;
293+
}
287294
}

engine/storage/volume/src/org/apache/cloudstack/storage/datastore/PrimaryDataStoreImpl.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -252,8 +252,9 @@ public DataObject create(DataObject obj) {
252252

253253
@Override
254254
public boolean delete(DataObject obj) {
255-
// TODO Auto-generated method stub
256-
return false;
255+
//TODO: clean up through driver
256+
objectInStoreMgr.delete(obj);
257+
return true;
257258
}
258259

259260
@Override

engine/storage/volume/src/org/apache/cloudstack/storage/volume/VolumeObject.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -505,4 +505,12 @@ public void processEventOnly(ObjectInDataStoreStateMachine.Event event, Answer a
505505
public ImageFormat getFormat() {
506506
return this.volumeVO.getFormat();
507507
}
508+
509+
@Override
510+
public boolean delete() {
511+
if (dataStore != null) {
512+
return dataStore.delete(this);
513+
}
514+
return true;
515+
}
508516
}

0 commit comments

Comments
 (0)