use of com.emc.storageos.db.client.model.ComputeElementHBA in project coprhd-controller by CoprHD.
the class ComputeSystemService method isSPTBootDefinitionValid.
private boolean isSPTBootDefinitionValid(UCSServiceProfileTemplate serviceProfileTemplate, ComputeBootDef bootDef) {
boolean valid = true;
_log.debug("validating SPT Boot Def " + bootDef.getId().toString());
if (bootDef.getEnforceVnicVhbaNames() == true) {
_log.debug("enforce vhba vnic names -- true");
URIQueryResultList uriVhbas = new URIQueryResultList();
_dbClient.queryByConstraint(ContainmentConstraint.Factory.getServiceProfileTemplateComputeElemetHBAsConstraint(serviceProfileTemplate.getId()), uriVhbas);
List<ComputeElementHBA> vhbas = _dbClient.queryObject(ComputeElementHBA.class, uriVhbas, true);
URIQueryResultList uriSanBoot = new URIQueryResultList();
_dbClient.queryByConstraint(ContainmentConstraint.Factory.getComputeBootDefComputeSanBootConstraint(bootDef.getId()), uriSanBoot);
List<ComputeSanBoot> computeSanBoots = _dbClient.queryObject(ComputeSanBoot.class, uriSanBoot, true);
if (computeSanBoots == null || computeSanBoots.isEmpty()) {
_log.error("SPT: " + serviceProfileTemplate.getLabel() + " no san boot policy specified");
valid = false;
}
for (ComputeSanBoot computeSanBoot : computeSanBoots) {
if (!computeSanBoot.getIsFirstBootDevice()) {
_log.error("SPT: " + serviceProfileTemplate.getLabel() + " san is not the first boot device");
valid = false;
}
URIQueryResultList sanImageUris = new URIQueryResultList();
_dbClient.queryByConstraint(ContainmentConstraint.Factory.getComputeSanBootImageConstraint(computeSanBoot.getId()), sanImageUris);
List<ComputeSanBootImage> sanBootImageList = _dbClient.queryObject(ComputeSanBootImage.class, sanImageUris, true);
for (ComputeSanBootImage image : sanBootImageList) {
boolean matched = false;
for (ComputeElementHBA hba : vhbas) {
if (hba.getLabel().equals(image.getVnicName())) {
matched = true;
}
}
if (!matched) {
_log.error("SPT: " + serviceProfileTemplate.getLabel() + " enforces vnic and vhba names,but hba names in san boot policy do not match the names of the hbas on the template");
valid = false;
}
}
}
URIQueryResultList uriVnics = new URIQueryResultList();
_dbClient.queryByConstraint(ContainmentConstraint.Factory.getServiceProfileTemplateComputeVnicsConstraint(serviceProfileTemplate.getId()), uriVnics);
List<ComputeVnic> vnics = _dbClient.queryObject(ComputeVnic.class, uriVnics, true);
URIQueryResultList uriLanBoot = new URIQueryResultList();
_dbClient.queryByConstraint(ContainmentConstraint.Factory.getComputeBootDefComputeLanBootConstraint(bootDef.getId()), uriLanBoot);
List<ComputeLanBoot> computeLanBoots = _dbClient.queryObject(ComputeLanBoot.class, uriLanBoot, true);
for (ComputeLanBoot computeLanBoot : computeLanBoots) {
URIQueryResultList lanImageUris = new URIQueryResultList();
_dbClient.queryByConstraint(ContainmentConstraint.Factory.getComputeLanBootImagePathsConstraint(computeLanBoot.getId()), lanImageUris);
List<ComputeLanBootImagePath> lanBootImageList = _dbClient.queryObject(ComputeLanBootImagePath.class, lanImageUris, true);
for (ComputeLanBootImagePath image : lanBootImageList) {
boolean matched = false;
for (ComputeVnic nic : vnics) {
if (nic.getName().equals(image.getVnicName())) {
matched = true;
}
}
if (!matched) {
_log.error("SPT: " + serviceProfileTemplate.getLabel() + " enforces vnic and vhba names,but vnic names in lan boot policy do not match the names of the hbas on the template");
valid = false;
}
}
}
}
return valid;
}
use of com.emc.storageos.db.client.model.ComputeElementHBA in project coprhd-controller by CoprHD.
the class ComputeSystemService method isSPTBootPolicyValid.
private boolean isSPTBootPolicyValid(UCSServiceProfileTemplate serviceProfileTemplate, ComputeBootPolicy bootPolicy) {
boolean valid = true;
_log.debug("validating SPT Boot Policy" + bootPolicy.getId().toString());
if (bootPolicy.getEnforceVnicVhbaNames() == true) {
_log.debug("enforce vhba vnic names -- true");
URIQueryResultList uriVhbas = new URIQueryResultList();
_dbClient.queryByConstraint(ContainmentConstraint.Factory.getServiceProfileTemplateComputeElemetHBAsConstraint(serviceProfileTemplate.getId()), uriVhbas);
List<ComputeElementHBA> vhbas = _dbClient.queryObject(ComputeElementHBA.class, uriVhbas, true);
URIQueryResultList uriSanBoot = new URIQueryResultList();
_dbClient.queryByConstraint(ContainmentConstraint.Factory.getComputeBootPolicyComputeSanBootConstraint(bootPolicy.getId()), uriSanBoot);
List<ComputeSanBoot> computeSanBoots = _dbClient.queryObject(ComputeSanBoot.class, uriSanBoot, true);
if (computeSanBoots == null || computeSanBoots.isEmpty()) {
_log.error("SPT: " + serviceProfileTemplate.getLabel() + " no san boot policy specified");
valid = false;
}
for (ComputeSanBoot computeSanBoot : computeSanBoots) {
if (!computeSanBoot.getIsFirstBootDevice()) {
_log.error("SPT: " + serviceProfileTemplate.getLabel() + " san is not the first boot device");
valid = false;
}
URIQueryResultList sanImageUris = new URIQueryResultList();
_dbClient.queryByConstraint(ContainmentConstraint.Factory.getComputeSanBootImageConstraint(computeSanBoot.getId()), sanImageUris);
List<ComputeSanBootImage> sanBootImageList = _dbClient.queryObject(ComputeSanBootImage.class, sanImageUris, true);
for (ComputeSanBootImage image : sanBootImageList) {
boolean matched = false;
for (ComputeElementHBA hba : vhbas) {
if (hba.getLabel().equals(image.getVnicName())) {
matched = true;
}
}
if (!matched) {
_log.error("SPT: " + serviceProfileTemplate.getLabel() + " enforces vnic and vhba names,but hba names in san boot policy do not match the names of the hbas on the template");
valid = false;
}
}
}
URIQueryResultList uriVnics = new URIQueryResultList();
_dbClient.queryByConstraint(ContainmentConstraint.Factory.getServiceProfileTemplateComputeVnicsConstraint(serviceProfileTemplate.getId()), uriVnics);
List<ComputeVnic> vnics = _dbClient.queryObject(ComputeVnic.class, uriVnics, true);
URIQueryResultList uriLanBoot = new URIQueryResultList();
_dbClient.queryByConstraint(ContainmentConstraint.Factory.getComputeBootPolicyComputeLanBootConstraint(bootPolicy.getId()), uriLanBoot);
List<ComputeLanBoot> computeLanBoots = _dbClient.queryObject(ComputeLanBoot.class, uriLanBoot, true);
for (ComputeLanBoot computeLanBoot : computeLanBoots) {
URIQueryResultList lanImageUris = new URIQueryResultList();
_dbClient.queryByConstraint(ContainmentConstraint.Factory.getComputeLanBootImagePathsConstraint(computeLanBoot.getId()), lanImageUris);
List<ComputeLanBootImagePath> lanBootImageList = _dbClient.queryObject(ComputeLanBootImagePath.class, lanImageUris, true);
for (ComputeLanBootImagePath image : lanBootImageList) {
boolean matched = false;
for (ComputeVnic nic : vnics) {
if (nic.getName().equals(image.getVnicName())) {
matched = true;
}
}
if (!matched) {
_log.error("SPT: " + serviceProfileTemplate.getLabel() + " enforces vnic and vhba names,but vnic names in lan boot policy do not match the names of the hbas on the template");
valid = false;
}
}
}
}
return valid;
}
use of com.emc.storageos.db.client.model.ComputeElementHBA in project coprhd-controller by CoprHD.
the class UcsComputeDevice method getInitiatorToHBAMapping.
private Map<String, String> getInitiatorToHBAMapping(URI computeElement) {
Map<String, String> hostInitiatorToHBAMapping = new HashMap<String, String>();
List<ComputeElementHBA> hbas = CustomQueryUtility.queryActiveResourcesByRelation(_dbClient, computeElement, ComputeElementHBA.class, "computeElement");
for (ComputeElementHBA hba : hbas) {
hostInitiatorToHBAMapping.put(hba.getPort(), hba.getLabel());
}
return hostInitiatorToHBAMapping;
}
use of com.emc.storageos.db.client.model.ComputeElementHBA in project coprhd-controller by CoprHD.
the class UcsComputeDevice method removeHostInitiatorsFromNetworks.
/**
* Gets rid of the Initiators that were added to network. Also gets rid of
* the ComputeElementHBAs that were created when the service profile was
* bound to the host
*
* @param host
*/
private void removeHostInitiatorsFromNetworks(Host host) {
URIQueryResultList ceHBAUriList = new URIQueryResultList();
_dbClient.queryByConstraint(ContainmentConstraint.Factory.getHostComputeElemetHBAsConstraint(host.getId()), ceHBAUriList);
Set<Network> networks = new HashSet<Network>();
List<String> endpoints = new ArrayList<String>();
List<ComputeElementHBA> computeElementHBAs = _dbClient.queryObject(ComputeElementHBA.class, ceHBAUriList, true);
for (ComputeElementHBA computeElementHBA : computeElementHBAs) {
endpoints.add(computeElementHBA.getPort());
networks.addAll(CustomQueryUtility.queryActiveResourcesByAltId(_dbClient, Network.class, "nativeId", computeElementHBA.getVsanId()));
_dbClient.markForDeletion(computeElementHBA);
}
for (Network network : networks) {
Collection<String> removedEndpoints = network.removeEndpoints(endpoints);
NetworkAssociationHelper.handleEndpointsRemoved(network, removedEndpoints, _dbClient, _coordinator);
}
_dbClient.persistObject(networks);
}
use of com.emc.storageos.db.client.model.ComputeElementHBA in project coprhd-controller by CoprHD.
the class UcsDiscoveryWorker method reconcileVhbas.
private void reconcileVhbas(ComputeSystem cs, Map<String, LsServer> associatedLsServers, VhbaHelper lookUpVsan) {
_log.info("Reconciling Vhbas");
URIQueryResultList uris = new URIQueryResultList();
_dbClient.queryByConstraint(ContainmentConstraint.Factory.getComputeSystemComputeElemetsConstraint(cs.getId()), uris);
List<ComputeElement> elements = _dbClient.queryObject(ComputeElement.class, uris, true);
for (ComputeElement computeElement : elements) {
Map<String, ComputeElementHBA> removeVhbas = new HashMap<>();
Map<String, ComputeElementHBA> addVhbas = new HashMap<>();
Map<String, ComputeElementHBA> updateVhbas = new HashMap<>();
URIQueryResultList uriVhbas = new URIQueryResultList();
_dbClient.queryByConstraint(ContainmentConstraint.Factory.getComputeElementComputeElemetHBAsConstraint(computeElement.getId()), uriVhbas);
List<ComputeElementHBA> vbhas = _dbClient.queryObject(ComputeElementHBA.class, uriVhbas, true);
for (ComputeElementHBA hba : vbhas) {
removeVhbas.put(hba.getLabel(), hba);
}
LsServer lsServer = associatedLsServers.get(computeElement.getLabel());
if (lsServer != null && lsServer.getContent() != null && !lsServer.getContent().isEmpty()) {
for (Serializable contentElement : lsServer.getContent()) {
if (contentElement instanceof JAXBElement<?> && ((JAXBElement) contentElement).getValue() instanceof VnicFc) {
VnicFc vnicFc = (VnicFc) ((JAXBElement) contentElement).getValue();
ComputeElementHBA hba = removeVhbas.get(vnicFc.getName());
if (hba != null) {
updateVhbas.put(vnicFc.getName(), hba);
removeVhbas.remove(hba.getLabel());
updateComputeElementHBA(hba, vnicFc);
} else {
hba = new ComputeElementHBA();
addVhbas.put(vnicFc.getName(), hba);
createComputeElementHBA(cs, computeElement, hba, vnicFc);
}
}
}
}
createDataObjects(new ArrayList<DataObject>(addVhbas.values()));
persistDataObjects(new ArrayList<DataObject>(updateVhbas.values()));
// Do not delete vHBAs that are still linked to the ViPR host
Iterator<Map.Entry<String, ComputeElementHBA>> vhbaIterator = removeVhbas.entrySet().iterator();
while (vhbaIterator.hasNext()) {
Map.Entry<String, ComputeElementHBA> entry = vhbaIterator.next();
if (entry.getValue().getHost() != null) {
vhbaIterator.remove();
} else {
_log.info("vHBA is marked for deletion {}", entry.getKey());
}
}
deleteDataObjects(new ArrayList<DataObject>(removeVhbas.values()));
}
}
Aggregations