Search in sources :

Example 41 with Host

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;
}
Also used : FileExport(com.emc.storageos.db.client.model.FileExport) Host(com.emc.storageos.db.client.model.Host) FileShare(com.emc.storageos.db.client.model.FileShare)

Example 42 with Host

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);
        }
    }
}
Also used : UCSServiceProfile(com.emc.storageos.db.client.model.UCSServiceProfile) HashMap(java.util.HashMap) ComputeElement(com.emc.storageos.db.client.model.ComputeElement) Host(com.emc.storageos.db.client.model.Host)

Example 43 with Host

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);
}
Also used : UCSServiceProfile(com.emc.storageos.db.client.model.UCSServiceProfile) ArrayList(java.util.ArrayList) Host(com.emc.storageos.db.client.model.Host)

Example 44 with Host

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);
    }
}
Also used : UCSServiceProfile(com.emc.storageos.db.client.model.UCSServiceProfile) Host(com.emc.storageos.db.client.model.Host)

Example 45 with Host

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);
        }
    }
}
Also used : UCSServiceProfile(com.emc.storageos.db.client.model.UCSServiceProfile) Host(com.emc.storageos.db.client.model.Host)

Aggregations

Host (com.emc.storageos.db.client.model.Host)227 URI (java.net.URI)104 Initiator (com.emc.storageos.db.client.model.Initiator)52 ArrayList (java.util.ArrayList)49 HashMap (java.util.HashMap)38 Cluster (com.emc.storageos.db.client.model.Cluster)37 HashSet (java.util.HashSet)35 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)33 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)32 VcenterDataCenter (com.emc.storageos.db.client.model.VcenterDataCenter)26 ComputeElement (com.emc.storageos.db.client.model.ComputeElement)24 Volume (com.emc.storageos.db.client.model.Volume)20 Path (javax.ws.rs.Path)20 Produces (javax.ws.rs.Produces)20 Vcenter (com.emc.storageos.db.client.model.Vcenter)19 ComputeSystemControllerException (com.emc.storageos.computesystemcontroller.exceptions.ComputeSystemControllerException)18 ExportMask (com.emc.storageos.db.client.model.ExportMask)18 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)17 NamedURI (com.emc.storageos.db.client.model.NamedURI)16 StringSet (com.emc.storageos.db.client.model.StringSet)16