use of com.intel.mtwilson.as.data.TblTaLog in project OpenAttestation by OpenAttestation.
the class ReportsBOTest method testGetReportManifest.
@Test
public void testGetReportManifest() {
when(tblHostsJpaController.findByName(anyString())).thenReturn(mockFindByName());
when(tblTaLogJpaController.findLastStatusTs(any(Integer.class))).thenReturn(new Date());
List<TblTaLog> taLogs = new ArrayList<TblTaLog>();
taLogs.add(new TblTaLog(Integer.valueOf(1), 1, 1, "0", "31B97D97B4679917EC3C1D943635693FFBAB4143", true, new Date()));
when(tblTaLogJpaController.findLogsByHostId(anyInt(), any(Date.class))).thenReturn(taLogs);
HostManifestReportType hostManifestReportType = reportsBO.getReportManifest(new Hostname(SERVER_NAME));
assertNotNull(hostManifestReportType);
assertNotNull(hostManifestReportType.getHost());
}
use of com.intel.mtwilson.as.data.TblTaLog in project OpenAttestation by OpenAttestation.
the class HostTrustBO method getTrustWithCache.
public HostTrust getTrustWithCache(String host, Boolean forceVerify) {
log.info("Getting trust for host: " + host + " Force verify flag: " + forceVerify);
try {
if (forceVerify != true) {
TblHosts tblHosts = getHostByName(new Hostname(host));
if (tblHosts != null) {
TblTaLog tblTaLog = new TblTaLogJpaController(getEntityManagerFactory()).getHostTALogEntryBefore(tblHosts.getId(), getCacheStaleAfter());
if (tblTaLog != null)
return getHostTrustObj(tblTaLog);
} else {
throw new ASException(ErrorCode.AS_HOST_NOT_FOUND, host);
}
}
log.info("Getting trust status from host.");
HostTrustStatus status = getTrustStatus(new Hostname(host));
HostTrust hostTrust = new HostTrust(ErrorCode.OK, "OK");
hostTrust.setBiosStatus((status.bios) ? 1 : 0);
hostTrust.setVmmStatus((status.vmm) ? 1 : 0);
hostTrust.setIpAddress(host);
return hostTrust;
} catch (ASException e) {
log.error("Error while getting trust for host " + host, e);
return new HostTrust(e.getErrorCode(), e.getErrorMessage(), host, null, null);
} catch (Exception e) {
log.error("Error while getting trust for host " + host, e);
return new HostTrust(ErrorCode.SYSTEM_ERROR, new AuthResponse(ErrorCode.SYSTEM_ERROR, e.getMessage()).getErrorMessage(), host, null, null);
}
}
use of com.intel.mtwilson.as.data.TblTaLog in project OpenAttestation by OpenAttestation.
the class HostTrustBO method logOverallTrustStatus.
private void logOverallTrustStatus(TblHosts host, String response) {
Date today = new Date(System.currentTimeMillis());
TblTaLog taLog = new TblTaLog();
taLog.setHostID(host.getId());
taLog.setMleId(0);
taLog.setTrustStatus(false);
taLog.setError(response);
taLog.setManifestName(" ");
taLog.setManifestValue(" ");
taLog.setUpdatedOn(today);
getTblTaLogJpaController().create(taLog);
}
Aggregations