use of com.intel.mtwilson.as.data.TblHosts in project OpenAttestation by OpenAttestation.
the class HostBOTest method mockGetHost.
public TblHosts mockGetHost() {
TblHosts tblHosts = new TblHosts();
tblHosts.setId(1);
tblHosts.setName(SERVER_NAME);
tblHosts.setIPAddress(SERVER_NAME);
String biosName = "DELL";
String biosVersion = "A08";
String oemName = "DELL";
TblMle biosMle = new TblMle();
biosMle.setId(1);
biosMle.setName(biosName);
biosMle.setVersion(biosVersion);
TblOem oem = new TblOem();
oem.setId(1);
oem.setName(oemName);
biosMle.setOemId(oem);
Collection<TblPcrManifest> tblPcrManifestCollection = new ArrayList<TblPcrManifest>();
TblPcrManifest tblPcrManifest = new TblPcrManifest();
tblPcrManifest.setId(1);
tblPcrManifest.setName("0");
tblPcrManifest.setValue("31B97D97B4679917EC3C1D943635693FFBAB4143");
tblPcrManifestCollection.add(tblPcrManifest);
biosMle.setTblPcrManifestCollection(tblPcrManifestCollection);
tblHosts.setBiosMleId(biosMle);
String vmmName = "XEN";
String vmmVersion = "4.3";
String osName = "Fedora";
String osVersion = "20";
TblMle vmmMle = new TblMle();
vmmMle.setId(1);
vmmMle.setName(vmmName);
vmmMle.setVersion(vmmVersion);
TblOs os = new TblOs();
os.setId(1);
os.setName(osName);
os.setVersion(osVersion);
vmmMle.setOsId(os);
Collection<TblPcrManifest> tblPcrManifestCollectionVMM = new ArrayList<TblPcrManifest>();
TblPcrManifest tblPcrManifestVMM = new TblPcrManifest();
tblPcrManifestVMM.setId(2);
tblPcrManifestVMM.setName("18");
tblPcrManifestVMM.setValue("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF");
tblPcrManifestCollection.add(tblPcrManifestVMM);
vmmMle.setTblPcrManifestCollection(tblPcrManifestCollectionVMM);
tblHosts.setVmmMleId(vmmMle);
tblHosts.setTlsPolicyName("");
tblHosts.setPort(8181);
return tblHosts;
}
use of com.intel.mtwilson.as.data.TblHosts in project OpenAttestation by OpenAttestation.
the class ReportsBOTest method mockFindByName.
public TblHosts mockFindByName() {
TblHosts tblHosts = new TblHosts();
tblHosts.setId(1);
tblHosts.setName(SERVER_NAME);
tblHosts.setIPAddress(SERVER_NAME);
String biosName = "DELL";
String biosVersion = "A08";
String oemName = "DELL";
TblMle biosMle = new TblMle();
biosMle.setId(1);
biosMle.setName(biosName);
biosMle.setVersion(biosVersion);
TblOem oem = new TblOem();
oem.setId(1);
oem.setName(oemName);
biosMle.setOemId(oem);
Collection<TblPcrManifest> tblPcrManifestCollection = new ArrayList<TblPcrManifest>();
TblPcrManifest tblPcrManifest = new TblPcrManifest();
tblPcrManifest.setId(1);
tblPcrManifest.setName("0");
tblPcrManifest.setValue("31B97D97B4679917EC3C1D943635693FFBAB4143");
tblPcrManifestCollection.add(tblPcrManifest);
biosMle.setTblPcrManifestCollection(tblPcrManifestCollection);
tblHosts.setBiosMleId(biosMle);
String vmmName = "XEN";
String vmmVersion = "4.3";
String osName = "Fedora";
String osVersion = "20";
TblMle vmmMle = new TblMle();
vmmMle.setId(1);
vmmMle.setName(vmmName);
vmmMle.setVersion(vmmVersion);
TblOs os = new TblOs();
os.setId(1);
os.setName(osName);
os.setVersion(osVersion);
vmmMle.setOsId(os);
Collection<TblPcrManifest> tblPcrManifestCollectionVMM = new ArrayList<TblPcrManifest>();
TblPcrManifest tblPcrManifestVMM = new TblPcrManifest();
tblPcrManifestVMM.setId(2);
tblPcrManifestVMM.setName("18");
tblPcrManifestVMM.setValue("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF");
tblPcrManifestCollectionVMM.add(tblPcrManifestVMM);
vmmMle.setTblPcrManifestCollection(tblPcrManifestCollectionVMM);
tblHosts.setVmmMleId(vmmMle);
return tblHosts;
}
use of com.intel.mtwilson.as.data.TblHosts in project OpenAttestation by OpenAttestation.
the class HostBO method queryForHosts.
/**
* Author: Sudhir
*
* Searches for the hosts using the criteria specified.
*
* @param searchCriteria: If in case the user has not provided any
* search criteria, then all the hosts would be returned back to the
* caller
* @param includeHardwareUuid: if this is set to true, it causes the resulting
* TxtHostRecord to include the hardware_uuid field from the tblHost
* @return
*/
public List<TxtHostRecord> queryForHosts(String searchCriteria, boolean includeHardwareUuid) {
log.debug("queryForHost " + searchCriteria + " includeHardwareUuid[" + includeHardwareUuid + "]");
try {
//TblHostsJpaController tblHostsJpaController = My.jpa().mwHosts(); //new TblHostsJpaController(getEntityManagerFactory());
TblHostsJpaController tblHostsJpaController = new TblHostsJpaController(getEntityManagerFactory());
List<TxtHostRecord> txtHostList = new ArrayList<TxtHostRecord>();
List<TblHosts> tblHostList;
if (searchCriteria != null && !searchCriteria.isEmpty()) {
tblHostList = tblHostsJpaController.findHostsByNameSearchCriteria(searchCriteria);
} else {
tblHostList = tblHostsJpaController.findTblHostsEntities();
}
if (tblHostList != null) {
log.debug(String.format("Found [%d] host results for search criteria [%s]", tblHostList.size(), searchCriteria));
for (TblHosts tblHosts : tblHostList) {
TxtHostRecord hostObj = createTxtHostFromDatabaseRecord(tblHosts, includeHardwareUuid);
txtHostList.add(hostObj);
}
} else {
log.debug(String.format("Found no hosts for search criteria [%s]", searchCriteria));
}
return txtHostList;
} catch (ASException e) {
throw e;
} catch (Exception e) {
// throw new ASException(e);
// Bug: 1038 - prevent leaks in error messages to client
log.error("Error during querying for registered hosts.", e);
throw new ASException(ErrorCode.AS_QUERY_HOST_ERROR, e.getClass().getSimpleName());
}
}
use of com.intel.mtwilson.as.data.TblHosts in project OpenAttestation by OpenAttestation.
the class HostBO method isHostRegistered.
public HostResponse isHostRegistered(String hostnameOrAddress) {
try {
TblHostsJpaController tblHostsJpaController = new TblHostsJpaController(getEntityManagerFactory());
TblHosts tblHosts = tblHostsJpaController.findByName(hostnameOrAddress);
if (tblHosts != null) {
// host name exists in database
return new HostResponse(ErrorCode.OK);
}
tblHosts = tblHostsJpaController.findByIPAddress(hostnameOrAddress);
if (tblHosts != null) {
// host IP address exists in database
return new HostResponse(ErrorCode.OK);
}
return new HostResponse(ErrorCode.AS_HOST_NOT_FOUND);
} catch (ASException e) {
throw e;
} catch (Exception e) {
throw new ASException(e);
}
}
use of com.intel.mtwilson.as.data.TblHosts in project OpenAttestation by OpenAttestation.
the class HostBO method queryForHosts.
/**
* Author: Sudhir
*
* Searches for the hosts using the criteria specified.
*
* @param searchCriteria: If in case the user has not provided any search criteria, then all the hosts
* would be returned back to the caller
* @return
*/
public List<TxtHostRecord> queryForHosts(String searchCriteria) {
try {
TblHostsJpaController tblHostsJpaController = new TblHostsJpaController(getEntityManagerFactory());
List<TxtHostRecord> txtHostList = new ArrayList<TxtHostRecord>();
List<TblHosts> tblHostList;
if (searchCriteria != null && !searchCriteria.isEmpty()) {
log.info("searchCriteria is not null -- calling tblHostsJpaController.findHostsByNameSearchCriteria(searchCriteria)");
tblHostList = tblHostsJpaController.findHostsByNameSearchCriteria(searchCriteria);
log.info(new Integer(tblHostList.size()).toString());
} else {
log.info("calling tblHostsJpaController.findTblHostsEntities()");
tblHostList = tblHostsJpaController.findTblHostsEntities();
log.info(new Integer(tblHostList.size()).toString());
}
// if (tblHostList != null) {
log.info(String.format("Found [%d] host results for search criteria [%s]", tblHostList.size(), searchCriteria));
for (TblHosts tblHosts : tblHostList) {
TxtHostRecord hostObj = createTxtHostFromDatabaseRecord(tblHosts);
txtHostList.add(hostObj);
}
return txtHostList;
} catch (ASException e) {
throw e;
} catch (CryptographyException e) {
throw new ASException(e, ErrorCode.AS_ENCRYPTION_ERROR, e.getCause() == null ? e.getMessage() : e.getCause().getMessage());
} catch (Exception e) {
throw new ASException(e);
}
}
Aggregations