use of com.emc.storageos.db.client.model.Host in project coprhd-controller by CoprHD.
the class ComputeSystemHelper method isHostIpInterfacesInUse.
/**
* Checks if an ipInterface in use by a file export
*
* @param ipAddress the interface IP address
* @return true if the ipInterface in use by a file export
*/
public static boolean isHostIpInterfacesInUse(DbClient dbClient, List<String> endpoints, URI hostId) {
if (endpoints == null || endpoints.isEmpty()) {
return false;
}
Host host = dbClient.queryObject(Host.class, hostId);
List<FileShare> fileShares = null;
if (!NullColumnValueGetter.isNullURI(host.getProject())) {
fileShares = CustomQueryUtility.queryActiveResourcesByRelation(dbClient, host.getProject(), FileShare.class, "project");
} else if (!NullColumnValueGetter.isNullURI(host.getTenant())) {
fileShares = CustomQueryUtility.queryActiveResourcesByRelation(dbClient, host.getTenant(), FileShare.class, "tenant");
}
if (fileShares == null || fileShares.isEmpty()) {
return false;
}
for (FileShare fileShare : fileShares) {
if (fileShare != null && fileShare.getFsExports() != null) {
for (FileExport fileExport : fileShare.getFsExports().values()) {
if (fileExport != null && fileExport.getClients() != null) {
for (String endpoint : endpoints) {
if (fileExport.getClients().contains(endpoint)) {
return true;
}
}
}
}
}
}
return false;
}
use of com.emc.storageos.db.client.model.Host in project coprhd-controller by CoprHD.
the class HostToComputeElementMatcher method matchHostsToBladesAndSPs.
private static void matchHostsToBladesAndSPs() {
// lookup map (to find CEs by their UUID)
Map<String, ComputeElement> ceMap = new HashMap<>();
for (ComputeElement ce : computeElementMap.values()) {
if (isValidUuid(ce.getUuid())) {
ceMap.put(ce.getUuid(), ce);
}
}
// lookup map (to find SPs by their UUID)
Map<String, UCSServiceProfile> spMap = new HashMap<>();
for (UCSServiceProfile sp : serviceProfileMap.values()) {
if (isValidUuid(sp.getUuid())) {
spMap.put(sp.getUuid(), sp);
}
}
for (Host host : hostMap.values()) {
_log.info("matching host " + info(host));
// clear blade & SP associations for hosts that are unregistered or have bad UUIDs
if (isUnregistered(host) || !hasValidUuid(host)) {
_log.info("skipping host (unregistered or bad UUID); " + info(host));
clearHostAssociations(host);
// next host
continue;
}
// find matching blade & SP
ComputeElement ce = getMatchingComputeElement(host, ceMap);
UCSServiceProfile sp = getMatchingServiceProfile(host, spMap);
// update Host & ServiceProfile
if (sp == null) {
_log.info("no SP match for host " + info(host));
// clear associations if no SP match
clearHostAssociations(host);
} else {
_log.info("matched host to SP & CE " + info(host) + ", " + info(sp) + ", " + info(ce));
setHostAssociations(host, ce, sp);
}
}
}
use of com.emc.storageos.db.client.model.Host in project coprhd-controller by CoprHD.
the class HostToComputeElementMatcher method updateDb.
private static void updateDb() {
List<Host> hostsToUpdate = new ArrayList<>();
for (Host host : hostMap.values()) {
if (host.isChanged("computeElement") || host.isChanged("serviceProfile")) {
hostsToUpdate.add(host);
}
}
dbClient.updateObject(hostsToUpdate);
List<UCSServiceProfile> spsToUpdate = new ArrayList<>();
for (UCSServiceProfile sp : serviceProfileMap.values()) {
if (sp.isChanged("host")) {
spsToUpdate.add(sp);
}
}
dbClient.updateObject(spsToUpdate);
}
use of com.emc.storageos.db.client.model.Host in project coprhd-controller by CoprHD.
the class HostToComputeElementMatcher method setHostAssociations.
private static void setHostAssociations(Host hostIn, ComputeElement ceIn, UCSServiceProfile spIn) {
Host host = hostMap.get(hostIn.getId());
if (NullColumnValueGetter.isNullURI(host.getServiceProfile())) {
// set new SP for host
host.setServiceProfile(spIn.getId());
} else if (!host.getServiceProfile().equals(spIn.getId())) {
// Unexpected SP association changes should result in discovery failure
failureMessages.append("Host's UCS Service Profile unexpectedly tried to change from " + host.getServiceProfile() + " to " + spIn.getId() + " for host " + info(host));
clearHostAssociations(host);
return;
}
if (ceIn == null) {
// happens when blade is not associated
if (!NullColumnValueGetter.isNullURI(host.getComputeElement())) {
host.setComputeElement(NullColumnValueGetter.getNullURI());
}
} else if ((host.getComputeElement() == null) || (!host.getComputeElement().equals(ceIn.getId()))) {
// set new CE for host
host.setComputeElement(ceIn.getId());
}
if (host.isChanged("computeElement") || host.isChanged("serviceProfile")) {
hostMap.put(host.getId(), host);
}
UCSServiceProfile sp = serviceProfileMap.get(spIn.getId());
if ((sp.getHost() == null) || (!sp.getHost().equals(host.getId()))) {
// set new host in SP
sp.setHost(host.getId());
serviceProfileMap.put(sp.getId(), sp);
}
}
use of com.emc.storageos.db.client.model.Host in project coprhd-controller by CoprHD.
the class HostToComputeElementMatcher method clearHostAssociations.
private static void clearHostAssociations(Host host) {
Host h = hostMap.get(host.getId());
if (!NullColumnValueGetter.isNullURI(h.getComputeElement())) {
h.setComputeElement(NullColumnValueGetter.getNullURI());
}
if (!NullColumnValueGetter.isNullURI(h.getServiceProfile())) {
h.setServiceProfile(NullColumnValueGetter.getNullURI());
}
if (host.isChanged("computeElement") || host.isChanged("serviceProfile")) {
hostMap.put(host.getId(), host);
}
// clear reference from SPs back to this Host
for (UCSServiceProfile sp : serviceProfileMap.values()) {
if ((sp.getHost() != null) && sp.getHost().equals(host.getId())) {
sp.setHost(NullColumnValueGetter.getNullURI());
serviceProfileMap.put(sp.getId(), sp);
}
}
}
Aggregations