in cloud-vmware-server/src/main/java/jetbrains/buildServer/clouds/vmware/web/GetSnapshotsListController.java [48:90]
protected void doPost(@NotNull final HttpServletRequest request, @NotNull final HttpServletResponse response, @NotNull final Element xmlResponse) {
final BasePropertiesBean propsBean = new BasePropertiesBean(null);
PluginPropertiesUtil.bindPropertiesFromRequest(request, propsBean, true);
final Map<String, String> props = propsBean.getProperties();
@NotNull final String serverUrl = props.get(VMWareWebConstants.SERVER_URL);
@NotNull final String username = props.get(VMWareWebConstants.USERNAME);
@NotNull final String password = props.get(VMWareWebConstants.SECURE_PASSWORD);
@NotNull final String imageName = props.get("image");
if (StringUtil.isEmpty(serverUrl) ||
StringUtil.isEmpty(imageName))
return;
try {
final VMWareApiConnector myApiConnector = VmwareApiConnectorsPool.getOrCreateConnector(
new URL(serverUrl), username, password, null, null, null, myStoreProvider);
final Map<String, VirtualMachineSnapshotTree> snapshotList = IOGuard.allowNetworkCall(() -> myApiConnector.getSnapshotList(imageName));
Element snapshots = new Element("Snapshots");
snapshots.setAttribute("vmName", imageName);
final Element currentVersion = new Element("Snapshot");
currentVersion.setAttribute("name", "<Current State>");
currentVersion.setAttribute("value", VmwareConstants.CURRENT_STATE);
snapshots.addContent((Content) currentVersion);
if (snapshotList.size() > 0){
final Element latestSnapshot = new Element("Snapshot");
latestSnapshot.setAttribute("name", "<Latest snapshot>");
latestSnapshot.setAttribute("value", VmwareConstants.LATEST_SNAPSHOT);
snapshots.addContent((Content) latestSnapshot);
}
for (String snapshotName : snapshotList.keySet()) {
Element snap = new Element("Snapshot");
snap.setAttribute("name", snapshotName);
snap.setAttribute("value", snapshotName);
snapshots.addContent((Content) snap);
}
xmlResponse.addContent((Content) snapshots);
} catch (VmwareCheckedCloudException e) {
LOG.warnAndDebugDetails("Unable to get snapshot list", e);
} catch (MalformedURLException e) {
LOG.warnAndDebugDetails("Unable to get snapshot list", e);
}
}