Search in sources :

Example 31 with Host

use of com.emc.storageos.db.client.model.Host in project coprhd-controller by CoprHD.

the class ComputeVirtualPoolService method updateHostToCVPRelation.

private void updateHostToCVPRelation(ComputeVirtualPool cvp) {
    Collection<ComputeElement> computeElements = _dbClient.queryObject(ComputeElement.class, toUriList(cvp.getMatchedComputeElements()));
    List<Host> updatedHosts = Lists.newArrayList();
    for (ComputeElement computeElement : computeElements) {
        List<Host> hosts = CustomQueryUtility.queryActiveResourcesByConstraint(_dbClient, Host.class, ContainmentConstraint.Factory.getContainedObjectsConstraint(computeElement.getId(), Host.class, "computeElement"));
        for (Host host : hosts) {
            if (NullColumnValueGetter.isNullURI(host.getComputeVirtualPoolId()) || !cvp.getId().equals(host.getComputeVirtualPoolId())) {
                host.setComputeVirtualPoolId(cvp.getId());
                updatedHosts.add(host);
            }
        }
    }
    if (CollectionUtils.isNotEmpty(updatedHosts)) {
        _dbClient.updateObject(updatedHosts);
    }
}
Also used : ComputeElement(com.emc.storageos.db.client.model.ComputeElement) Host(com.emc.storageos.db.client.model.Host)

Example 32 with Host

use of com.emc.storageos.db.client.model.Host in project coprhd-controller by CoprHD.

the class ComputeVirtualPoolService method getHostsProvisionedFromPool.

private List<Host> getHostsProvisionedFromPool(ComputeVirtualPool cvp) {
    List<Host> hostList = new ArrayList<Host>();
    URIQueryResultList hostURIs = new URIQueryResultList();
    _dbClient.queryByConstraint(ContainmentConstraint.Factory.getVirtualComputePoolHostConstraint(cvp.getId()), hostURIs);
    Iterator<URI> iter = hostURIs.iterator();
    while (iter.hasNext()) {
        URI hostURI = iter.next();
        Host host = _dbClient.queryObject(Host.class, hostURI);
        if (host != null && !host.getInactive()) {
            hostList.add(host);
        } else {
            _log.error("Can't find host {} in the database " + "or the host is marked for deletion", hostURI);
        }
    }
    return hostList;
}
Also used : ArrayList(java.util.ArrayList) Host(com.emc.storageos.db.client.model.Host) URI(java.net.URI) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList)

Example 33 with Host

use of com.emc.storageos.db.client.model.Host in project coprhd-controller by CoprHD.

the class ComputeSystemControllerImpl method addStepForUpdatingHostAndInitiatorClusterReferences.

public String addStepForUpdatingHostAndInitiatorClusterReferences(Workflow workflow, String waitFor, List<URI> hostIds, URI clusterId, URI vCenterDataCenterId, HostCompleter completer) {
    for (URI hostId : hostIds) {
        URI oldClusterId = NullColumnValueGetter.getNullURI();
        URI oldvCenterDataCenterId = NullColumnValueGetter.getNullURI();
        Host host = _dbClient.queryObject(Host.class, hostId);
        if (host != null) {
            if (!NullColumnValueGetter.isNullURI(host.getCluster())) {
                oldClusterId = host.getCluster();
            }
            if (!NullColumnValueGetter.isNullURI(host.getVcenterDataCenter())) {
                oldvCenterDataCenterId = host.getVcenterDataCenter();
            }
        }
        if (completer != null) {
            // Update the completer with the correct values to rollback
            completer.addOldHostClusterAndVcenterDataCenter(hostId, oldClusterId, oldvCenterDataCenterId);
        }
        waitFor = workflow.createStep(UPDATE_HOST_AND_INITIATOR_CLUSTER_NAMES_STEP, String.format("Updating host and initiator cluster names for host %s to %s", hostId, clusterId), waitFor, hostId, hostId.toString(), this.getClass(), updateHostAndInitiatorClusterReferencesMethod(hostId, clusterId, vCenterDataCenterId), updateHostAndInitiatorClusterReferencesMethod(hostId, oldClusterId, oldvCenterDataCenterId), null);
    }
    return waitFor;
}
Also used : Host(com.emc.storageos.db.client.model.Host) URI(java.net.URI)

Example 34 with Host

use of com.emc.storageos.db.client.model.Host in project coprhd-controller by CoprHD.

the class ComputeSystemControllerImpl method rollbackHostBootVolumeId.

public void rollbackHostBootVolumeId(URI hostId, URI volumeId, String stepId) throws ControllerException {
    _log.info("rollbackHostBootVolumeId:" + hostId.toString());
    Host host = null;
    try {
        WorkflowStepCompleter.stepExecuting(stepId);
        host = _dbClient.queryObject(Host.class, hostId);
        if (host == null) {
            throw ComputeSystemControllerException.exceptions.hostNotFound(hostId.toString());
        }
        _log.info("Rolling back boot volume association for host");
        host.setBootVolumeId(NullColumnValueGetter.getNullURI());
        _dbClient.persistObject(host);
        WorkflowStepCompleter.stepSucceded(stepId);
    } catch (Exception e) {
        _log.error("unexpected exception: " + e.getMessage(), e);
        String hostString = hostId.toString();
        if (host != null) {
            hostString = host.getHostName();
        }
        ServiceCoded serviceCoded = ComputeSystemControllerException.exceptions.unableToRollbackBootVolume(hostString, e);
        WorkflowStepCompleter.stepFailed(stepId, serviceCoded);
    }
}
Also used : ServiceCoded(com.emc.storageos.svcs.errorhandling.model.ServiceCoded) Host(com.emc.storageos.db.client.model.Host) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) ControllerException(com.emc.storageos.volumecontroller.ControllerException) ComputeSystemControllerException(com.emc.storageos.computesystemcontroller.exceptions.ComputeSystemControllerException) APIException(com.emc.storageos.svcs.errorhandling.resources.APIException) WorkflowException(com.emc.storageos.workflow.WorkflowException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) RemoteException(java.rmi.RemoteException) CoordinatorException(com.emc.storageos.coordinator.exceptions.CoordinatorException) ClientControllerException(com.emc.storageos.exceptions.ClientControllerException)

Example 35 with Host

use of com.emc.storageos.db.client.model.Host in project coprhd-controller by CoprHD.

the class ComputeSystemControllerImpl method attachAndMountVolumes.

/**
 * Creates workflow steps for attaching disks and mounting datastores
 *
 * @param vCenterHostExportMap
 *            the map of hosts and export groups to operate on
 * @param waitFor
 *            the step to wait on for this workflow step
 * @param workflow
 *            the workflow to create the step
 * @return the step id
 */
private String attachAndMountVolumes(Map<URI, Collection<URI>> vCenterHostExportMap, String waitFor, Workflow workflow) {
    if (vCenterHostExportMap == null) {
        return waitFor;
    }
    for (URI hostId : vCenterHostExportMap.keySet()) {
        Host esxHost = _dbClient.queryObject(Host.class, hostId);
        if (esxHost != null) {
            URI virtualDataCenter = esxHost.getVcenterDataCenter();
            VcenterDataCenter vcenterDataCenter = _dbClient.queryObject(VcenterDataCenter.class, virtualDataCenter);
            URI vCenterId = vcenterDataCenter.getVcenter();
            for (URI export : vCenterHostExportMap.get(hostId)) {
                waitFor = workflow.createStep(MOUNT_AND_ATTACH_STEP, String.format("Mounting and attaching volumes from export group %s", export), waitFor, export, export.toString(), this.getClass(), attachAndMountMethod(export, esxHost.getId(), vCenterId, vcenterDataCenter.getId()), rollbackMethodNullMethod(), null);
            }
        }
    }
    return waitFor;
}
Also used : Host(com.emc.storageos.db.client.model.Host) VcenterDataCenter(com.emc.storageos.db.client.model.VcenterDataCenter) URI(java.net.URI)

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