use of com.vmware.photon.controller.model.resources.SnapshotService.SnapshotState in project photon-model by vmware.
the class VSphereVMSnapshotEnumerationHelper method updateSnapshot.
static DeferredResult<SnapshotState> updateSnapshot(VSphereIncrementalEnumerationService service, EnumerationProgress enumerationProgress, VmOverlay vm, SnapshotState oldState, SnapshotState newState, String id) {
newState.documentSelfLink = oldState.documentSelfLink;
newState.id = id;
newState.regionId = enumerationProgress.getRegionId();
DeferredResult<SnapshotState> res = new DeferredResult<>();
VsphereEnumerationHelper.submitWorkToVSpherePool(service, () -> {
VsphereEnumerationHelper.populateTags(service, enumerationProgress, vm, newState);
newState.tenantLinks = enumerationProgress.getTenantLinks();
service.logFine(() -> String.format("Syncing snapshot %s", oldState.name));
Operation opPatchSnapshot = Operation.createPatch(UriUtils.buildUri(service.getHost(), oldState.documentSelfLink)).setBody(newState);
service.sendWithDeferredResult(opPatchSnapshot, SnapshotState.class).handle((snap, e) -> {
if (e != null) {
res.fail(e);
} else {
res.complete(snap);
}
return null;
});
});
return res;
}
use of com.vmware.photon.controller.model.resources.SnapshotService.SnapshotState in project photon-model by vmware.
the class VSphereVMSnapshotEnumerationHelper method constructSnapshot.
static SnapshotState constructSnapshot(VSphereIncrementalEnumerationService service, VirtualMachineSnapshotTree current, String parentLink, String vmSelfLink, EnumerationProgress enumerationProgress, VmOverlay vm) {
SnapshotState snapshot = new SnapshotState();
snapshot.computeLink = vmSelfLink;
snapshot.parentLink = parentLink;
snapshot.description = current.getDescription();
// TODO how to determine if the snapshot is current
// snapshot.isCurrent = current.isQuiesced()
snapshot.creationTimeMicros = current.getCreateTime().toGregorianCalendar().getTimeInMillis();
// TODO How to fetch custom properties
// snapshot.customProperties = current.get
// TODO what are snapshot grouplinks
// snapshot.groupLinks
snapshot.name = current.getName();
snapshot.regionId = enumerationProgress.getRegionId();
snapshot.id = current.getId().toString();
VsphereEnumerationHelper.populateTags(service, enumerationProgress, vm, snapshot);
snapshot.tenantLinks = enumerationProgress.getTenantLinks();
if (snapshot.endpointLinks == null) {
snapshot.endpointLinks = new HashSet<>();
}
snapshot.endpointLinks.add(enumerationProgress.getRequest().endpointLink);
CustomProperties.of(snapshot).put(CustomProperties.MOREF, VimUtils.convertMoRefToString(current.getSnapshot())).put(CustomProperties.DATACENTER_SELF_LINK, enumerationProgress.getDcLink()).put(CustomProperties.TYPE, current.getSnapshot().getType());
VsphereEnumerationHelper.populateResourceStateWithAdditionalProps(snapshot, enumerationProgress.getVcUuid());
return snapshot;
}
Aggregations