Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ public ModifyStoragePoolAnswer(ModifyStoragePoolCommand cmd, long capacityBytes,
templateInfo = tInfo;
}

public ModifyStoragePoolAnswer(final Command command, final boolean success, final String details) {
super(command, success, details);
}

public void setPoolInfo(StoragePoolInfo poolInfo) {
this.poolInfo = poolInfo;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public Answer execute(final ModifyStoragePoolCommand command, final CitrixResour
if (capacity == -1) {
final String msg = "Pool capacity is -1! pool: " + pool.getHost() + pool.getPath();
logger.warn(msg);
return new Answer(command, false, msg);
return new ModifyStoragePoolAnswer(command, false, msg);
Copy link
Contributor

@sureshanaparti sureshanaparti Feb 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@abh1sar cc @DaanHoogland we can use Answer itself here, no need for a separate constructor for ModifyStoragePoolAnswer as well. It's better to typecast Answer to ModifyStoragePoolAnswer when required, otherwise answer obj itself is enough to check for null or failure.

Also, even when ModifyStoragePoolAnswer returned here, it doesn't have datastoreClusterChildren set, so not required to call this method:

reportSucceededModifyStorePool(storagePool, (ModifyStoragePoolAnswer) answer, host, false);

Check sample impl here:

ModifyStoragePoolCommand modifyStoragePoolCommand = new ModifyStoragePoolCommand(true, pool);
final Answer answer = _agentMgr.easySend(hostId, modifyStoragePoolCommand);
if (answer == null) {
throw new CloudRuntimeException(String.format("Unable to get an answer to the modify storage pool command %s", pool));
}
if (!answer.getResult()) {
throw new CloudRuntimeException(String.format("Unable to process ModifyStoragePoolCommand for pool %s on the host %s due to %s", pool, _hostDao.findById(hostId), answer.getDetails()));
}
assert (answer instanceof ModifyStoragePoolAnswer) : "Well, now why won't you actually return the ModifyStoragePoolAnswer when it's ModifyStoragePoolCommand? Pool=" +
pool.getId() + "Host=" + hostId;
ModifyStoragePoolAnswer mspAnswer = (ModifyStoragePoolAnswer) answer;

}
final Map<String, TemplateProp> tInfo = new HashMap<String, TemplateProp>();
final ModifyStoragePoolAnswer answer = new ModifyStoragePoolAnswer(command, capacity, available, tInfo);
Expand All @@ -68,12 +68,12 @@ public Answer execute(final ModifyStoragePoolCommand command, final CitrixResour
final String msg = "ModifyStoragePoolCommand add XenAPIException:" + e.toString() + " host:" + citrixResourceBase.getHost().getUuid() + " pool: " + pool.getHost()
+ pool.getPath();
logger.warn(msg, e);
return new Answer(command, false, msg);
return new ModifyStoragePoolAnswer(command, false, msg);
} catch (final Exception e) {
final String msg = "ModifyStoragePoolCommand add XenAPIException:" + e.getMessage() + " host:" + citrixResourceBase.getHost().getUuid() + " pool: "
+ pool.getHost() + pool.getPath();
logger.warn(msg, e);
return new Answer(command, false, msg);
return new ModifyStoragePoolAnswer(command, false, msg);
}
} else {
try {
Expand All @@ -85,17 +85,17 @@ public Answer execute(final ModifyStoragePoolCommand command, final CitrixResour
if (result == null || !result.split("#")[1].equals("0")) {
throw new CloudRuntimeException("Unable to remove heartbeat file entry for SR " + srUuid + " due to " + result);
}
return new Answer(command, true, "success");
return new ModifyStoragePoolAnswer(command, true, "success");
} catch (final XenAPIException e) {
final String msg = "ModifyStoragePoolCommand remove XenAPIException:" + e.toString() + " host:" + citrixResourceBase.getHost().getUuid() + " pool: "
+ pool.getHost() + pool.getPath();
logger.warn(msg, e);
return new Answer(command, false, msg);
return new ModifyStoragePoolAnswer(command, false, msg);
} catch (final Exception e) {
final String msg = "ModifyStoragePoolCommand remove XenAPIException:" + e.getMessage() + " host:" + citrixResourceBase.getHost().getUuid() + " pool: "
+ pool.getHost() + pool.getPath();
logger.warn(msg, e);
return new Answer(command, false, msg);
return new ModifyStoragePoolAnswer(command, false, msg);
}
}
}
Expand Down
Loading