private Snapshot populateSnapshotConfiguration (Snapshot model) { QueryReturnValue queryReturnValue = runQuery(QueryType.GetSnapshotBySnapshotId, new IdQueryParameters(Guid.createGuidFromString(model.getId()))); if (queryReturnValue.getSucceeded() && queryReturnValue.getReturnValue() != null) { org.ovirt.engine.core.common.businessentities.Snapshot snapshot = queryReturnValue.getReturnValue(); if (snapshot.getVmConfiguration() != null) { return SnapshotMapper.map(snapshot.getVmConfiguration(), ConfigurationType.OVF, model); } } return model; } }
/** * Asserts the result of {@link SnapshotDao#getAll(Guid)} contains the correct snapshots. * * @param snapshots * The result to check */ private static void assertFullGetAllByVmResult(List<Snapshot> snapshots) { assertEquals(1, snapshots.size(), "VM should have a snapshot"); for (Snapshot snapshot : snapshots) { assertFalse(snapshot.isVmConfigurationAvailable(), "Snapshot shouldn't have configuration available"); assertTrue(StringUtils.isEmpty(snapshot.getVmConfiguration()), "Snapshot should have no configuration"); } }
@Test public void getAllByVmWithConfiguration() { List<Snapshot> snapshots = dao.getAllWithConfiguration(FixturesTool.VM_RHEL5_POOL_50); assertEquals(1, snapshots.size(), "VM should have a snapshot"); for (Snapshot snapshot : snapshots) { assertEquals("test!", snapshot.getVmConfiguration(), "Snapshot should have configuration"); assertTrue(snapshot.isVmConfigurationAvailable(), "Snapshot should have configuration available"); } }
if (snapshot.getVmConfiguration() != null) { _writer.writeElement("VmConfiguration", Base64.encodeBase64String(snapshot.getVmConfiguration().getBytes()));
@Override protected MapSqlParameterSource createFullParametersMapper(Snapshot entity) { return createIdParameterMapper(entity.getId()) .addValue("vm_id", entity.getVmId()) .addValue("snapshot_type", EnumUtils.nameOrNull(entity.getType())) .addValue("status", EnumUtils.nameOrNull(entity.getStatus())) .addValue("description", entity.getDescription()) .addValue("creation_date", entity.getCreationDate()) .addValue("app_list", entity.getAppList()) .addValue("vm_configuration", entity.getVmConfiguration()) .addValue("memory_dump_disk_id", entity.getMemoryDiskId()) .addValue("memory_metadata_disk_id", entity.getMetadataDiskId()) .addValue("vm_configuration_broken", entity.isVmConfigurationBroken()); }