DeleteStoragePool command fix

1. not delete SR in xenserver side, only delete it in database.
    2. remove a storagepool,  adding it back fails
This commit is contained in:
anthony 2010-10-15 14:13:04 -07:00
parent e851353ebe
commit d41f7d78d9
3 changed files with 6 additions and 9 deletions

View File

@ -4379,15 +4379,9 @@ public abstract class CitrixResourceBase implements StoragePoolResource, ServerR
try {
Connection conn = getConnection();
SR sr = getStorageRepository(conn, poolTO);
sr.setNameLabel(conn, pool.getUuid());
sr.setNameDescription(conn, pool.getName());
removeSR(sr);
Answer answer = new Answer(cmd, true, "success");
return answer;
} catch (XenAPIException e) {
String msg = "DeleteStoragePoolCommand XenAPIException:" + e.toString() + " host:" + _host.uuid + " pool: " + pool.getName() + pool.getHostAddress() + pool.getPath();
s_logger.warn(msg, e);
return new Answer(cmd, false, msg);
} catch (Exception e) {
String msg = "DeleteStoragePoolCommand XenAPIException:" + e.getMessage() + " host:" + _host.uuid + " pool: " + pool.getName() + pool.getHostAddress() + pool.getPath();
s_logger.warn(msg, e);

View File

@ -225,7 +225,7 @@ public class StoragePoolDaoImpl extends GenericDaoBase<StoragePoolVO, Long> imp
sc.setParameters("hostAddress", host);
sc.setParameters("path", path);
return listIncludingRemovedBy(sc);
return listBy(sc);
}
public StoragePoolVO listById(Integer id)

View File

@ -1469,6 +1469,8 @@ public class StorageManagerImpl implements StorageManager {
// if not records exist, delete the given pool (base case)
if (hostPoolRecords.size() == 0) {
sPool.setUuid(null);
_storagePoolDao.update(id, sPool);
_storagePoolDao.remove(id);
return true;
} else {
@ -1514,7 +1516,8 @@ public class StorageManagerImpl implements StorageManager {
for (StoragePoolHostVO host : hostPoolRecords) {
_storagePoolHostDao.deleteStoragePoolHostDetails(host.getHostId(),host.getPoolId());
}
sPool.setUuid(null);
_storagePoolDao.update(id, sPool);
_storagePoolDao.remove(id);
return true;
}