Search in sources :

Example 61 with Cluster

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

the class VMwareHostService method validateClusterHosts.

/**
 * Validates the vCenter cluster hosts match the same hosts we have in our database for the cluster. If there is a mismatch the check
 * will fail the order.
 */
protected void validateClusterHosts() {
    if (hostCluster != null) {
        VcenterDataCenter datacenter = getModelClient().datacenters().findById(datacenterId);
        Cluster cluster = getModelClient().clusters().findById(hostCluster.getId());
        ClusterComputeResource vcenterCluster = vmware.getCluster(datacenter.getLabel(), cluster.getLabel(), checkClusterConnectivity());
        if (vcenterCluster == null) {
            ExecutionUtils.fail("failTask.vmware.cluster.notfound", args(), args(cluster.getLabel()));
        }
        Set<String> vCenterHostUuids = Sets.newHashSet();
        for (HostSystem hostSystem : vcenterCluster.getHosts()) {
            if (hostSystem.getHardware() != null && hostSystem.getHardware().systemInfo != null) {
                vCenterHostUuids.add(hostSystem.getHardware().systemInfo.uuid);
            }
        }
        List<Host> dbHosts = getModelClient().hosts().findByCluster(hostCluster.getId());
        Set<String> dbHostUuids = Sets.newHashSet();
        for (Host host : dbHosts) {
            // Validate the hosts within the cluster all have good discovery status
            if (!DiscoveredDataObject.CompatibilityStatus.COMPATIBLE.toString().equalsIgnoreCase(host.getCompatibilityStatus())) {
                ExecutionUtils.fail("failTask.vmware.cluster.hostincompatible", args(), args(cluster.getLabel(), host.getLabel()));
            } else if (DiscoveredDataObject.DataCollectionJobStatus.ERROR.toString().equalsIgnoreCase(host.getDiscoveryStatus())) {
                ExecutionUtils.fail("failTask.vmware.cluster.hostsdiscoveryfailed", args(), args(cluster.getLabel(), host.getLabel()));
            }
            dbHostUuids.add(host.getUuid());
        }
        if (!vCenterHostUuids.equals(dbHostUuids)) {
            ExecutionUtils.fail("failTask.vmware.cluster.mismatch", args(), args(cluster.getLabel()));
        } else {
            info("Hosts in cluster %s matches correctly", cluster.getLabel());
        }
    }
}
Also used : ClusterComputeResource(com.vmware.vim25.mo.ClusterComputeResource) HostSystem(com.vmware.vim25.mo.HostSystem) Cluster(com.emc.storageos.db.client.model.Cluster) VcenterDataCenter(com.emc.storageos.db.client.model.VcenterDataCenter) Host(com.emc.storageos.db.client.model.Host)

Example 62 with Cluster

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

the class BlockIngestExportOrchestrator method ingestExportMasks.

/**
 * Ingests UnManagedExportMasks associated with the current UnManagedVolume being processed.
 *
 * @param requestContext the IngestionRequestContext for this ingestion process
 * @param unManagedVolume unManagedVolume to ingest
 * @param blockObject created BlockObject
 * @param unManagedMasks list of unmanaged masks this unmanaged volume is associated with
 * @param masksIngestedCount number of export masks ingested
 */
protected <T extends BlockObject> void ingestExportMasks(IngestionRequestContext requestContext, UnManagedVolume unManagedVolume, T blockObject, List<UnManagedExportMask> unManagedMasks, MutableInt masksIngestedCount) throws IngestionException {
    try {
        _logger.info("Ingesting unmanaged masks {} for unmanaged volume {}", Joiner.on(",").join(unManagedVolume.getUnmanagedExportMasks()), unManagedVolume.getNativeGuid());
        VolumeIngestionUtil.validateUnManagedExportMasks(unManagedVolume, unManagedMasks, _dbClient);
        List<UnManagedExportMask> uemsToPersist = new ArrayList<UnManagedExportMask>();
        Iterator<UnManagedExportMask> itr = unManagedMasks.iterator();
        List<String> errorMessages = requestContext.getErrorMessagesForVolume(unManagedVolume.getNativeGuid());
        ExportGroup exportGroup = requestContext.getExportGroup();
        StorageSystem system = requestContext.getStorageSystem();
        boolean portGroupEnabled = false;
        if (Type.vmax.name().equals(system.getSystemType())) {
            portGroupEnabled = Boolean.valueOf(_customConfigHandler.getComputedCustomConfigValue(CustomConfigConstants.VMAX_USE_PORT_GROUP_ENABLED, system.getSystemType(), null));
        }
        Host host = null;
        Cluster cluster = null;
        List<Host> hosts = new ArrayList<Host>();
        String exportGroupType = null;
        if (null != requestContext.getHost()) {
            host = _dbClient.queryObject(Host.class, requestContext.getHost());
            hosts.add(host);
            exportGroupType = ExportGroupType.Host.name();
        }
        if (null != requestContext.getCluster()) {
            cluster = _dbClient.queryObject(Cluster.class, requestContext.getCluster());
            hosts.addAll(getHostsOfCluster(requestContext.getCluster()));
            exportGroupType = ExportGroupType.Cluster.name();
        }
        // In cluster/Host , if we don't find at least 1 initiator in
        // registered state, then skip this volume from ingestion.
        StringSet computeInitiators = new StringSet();
        for (Host hostObj : hosts) {
            Set<String> initiatorSet = getInitiatorsOfHost(hostObj.getId());
            Set<URI> initiatorUris = new HashSet<URI>(Collections2.transform(initiatorSet, CommonTransformerFunctions.FCTN_STRING_TO_URI));
            List<Initiator> initiators = _dbClient.queryObject(Initiator.class, initiatorUris);
            if (!VolumeIngestionUtil.validateInitiatorPortsRegistered(initiators)) {
                // logs already inside the above method.
                _logger.warn("Host skipped {} as we can't find at least 1 initiator in registered status", hostObj.getLabel());
                return;
            }
            computeInitiators.addAll(initiatorSet);
        }
        if (null != requestContext.getDeviceInitiators() && !requestContext.getDeviceInitiators().isEmpty()) {
            if (exportGroup.checkInternalFlags(Flag.RECOVERPOINT)) {
                // RP export groups are cluster-based, although they don't contains a cluster/host ID
                exportGroupType = ExportGroupType.Cluster.name();
            } else {
                // note: ViPR-generated greenfield VPLEX export groups
                // actually have no export group type set
                exportGroupType = ExportGroupType.Host.name();
            }
            if (!VolumeIngestionUtil.validateInitiatorPortsRegistered(requestContext.getDeviceInitiators())) {
                _logger.warn("Device with initiators {} skipped as we can't " + "find at least 1 initiator in registered status", requestContext.getDeviceInitiators());
                return;
            }
            // For validation checks below, add these initiator to the compute resource list
            for (Initiator initiator : requestContext.getDeviceInitiators()) {
                computeInitiators.add(initiator.getId().toString());
            }
        }
        // update the ExportGroupType in UnManagedVolume. This will be used to place the
        // volume in the right ExportGroup based on the ExportGroupType.
        updateExportTypeInUnManagedVolume(unManagedVolume, exportGroupType);
        // then add this unmanaged volume to the mask.
        while (itr.hasNext()) {
            UnManagedExportMask unManagedExportMask = itr.next();
            if (!VolumeIngestionUtil.validateStoragePortsInVarray(_dbClient, blockObject, requestContext.getVarray(unManagedVolume).getId(), unManagedExportMask.getKnownStoragePortUris(), unManagedExportMask, errorMessages)) {
                // logs already inside the above method.
                itr.remove();
                continue;
            }
            if (!VolumeIngestionUtil.validateExportMaskMatchesComputeResourceInitiators(_dbClient, exportGroup, computeInitiators, unManagedExportMask, errorMessages)) {
                // logs already inside the above method.
                itr.remove();
                continue;
            }
            if (VolumeIngestionUtil.isVplexVolume(unManagedVolume)) {
                boolean crossConnectedDistributedVolume = VolumeIngestionUtil.isVplexDistributedVolume(unManagedVolume) && requestContext.getVpool(unManagedVolume).getAutoCrossConnectExport();
                if (!crossConnectedDistributedVolume && !VolumeIngestionUtil.isRpExportMask(unManagedExportMask, _dbClient) && !VolumeIngestionUtil.validateExportMaskMatchesVplexCluster(requestContext, unManagedVolume, unManagedExportMask)) {
                    // logs already inside the above method.
                    itr.remove();
                    continue;
                }
            }
            _logger.info("looking for an existing export mask for " + unManagedExportMask.getMaskName());
            ExportMask exportMask = getExportMaskAlreadyIngested(unManagedExportMask, _dbClient);
            if (null != exportMask) {
                // check if mask has already been loaded
                DataObject loadedExportMask = requestContext.findInUpdatedObjects(exportMask.getId());
                if (loadedExportMask != null) {
                    exportMask = (ExportMask) loadedExportMask;
                }
            } else {
                // check if mask has already been created
                exportMask = getExportMaskAlreadyCreated(unManagedExportMask, requestContext.getRootIngestionRequestContext(), _dbClient);
                if (exportMask == null) {
                    continue;
                }
            }
            _logger.info("Export Mask {} already available", exportMask.getMaskName());
            masksIngestedCount.increment();
            List<URI> iniList = new ArrayList<URI>(Collections2.transform(exportMask.getInitiators(), CommonTransformerFunctions.FCTN_STRING_TO_URI));
            List<Initiator> initiators = _dbClient.queryObject(Initiator.class, iniList);
            // of the mask, else add it to user created volumes
            if (blockObject.checkInternalFlags(Flag.PARTIALLY_INGESTED)) {
                _logger.info("Block object {} is marked internal. Adding to existing volumes of the mask {}", blockObject.getNativeGuid(), exportMask.getMaskName());
                exportMask.addToExistingVolumesIfAbsent(blockObject, ExportGroup.LUN_UNASSIGNED_STR);
            } else {
                exportMask.addToUserCreatedVolumes(blockObject);
                // remove this volume if already in existing
                exportMask.removeFromExistingVolumes(blockObject);
            }
            // Add new initiators found in ingest to list if absent.
            exportMask.addInitiators(initiators);
            // Add all unknown initiators to existing
            exportMask.addToExistingInitiatorsIfAbsent(new ArrayList(unManagedExportMask.getUnmanagedInitiatorNetworkIds()));
            // Always set this flag to true for ingested masks.
            exportMask.setCreatedBySystem(true);
            ExportMaskUtils.setExportMaskResource(_dbClient, exportGroup, exportMask);
            List<Initiator> userAddedInis = VolumeIngestionUtil.findUserAddedInisFromExistingIniListInMask(initiators, unManagedExportMask.getId(), _dbClient);
            exportMask.addToUserCreatedInitiators(userAddedInis);
            // remove from existing if present - possible in ingestion after
            // coexistence
            exportMask.removeFromExistingInitiator(userAddedInis);
            // need to sync up all remaining existing volumes
            Map<String, Integer> wwnToHluMap = VolumeIngestionUtil.extractWwnToHluMap(unManagedExportMask, _dbClient);
            exportMask.addToExistingVolumesIfAbsent(wwnToHluMap);
            // find the HLU and set it in the volumes
            Integer hlu = ExportGroup.LUN_UNASSIGNED;
            if (wwnToHluMap.containsKey(blockObject.getWWN())) {
                hlu = wwnToHluMap.get(blockObject.getWWN());
            }
            exportMask.addVolume(blockObject.getId(), hlu);
            // adding volume we need to add FCZoneReferences
            StringSetMap zoneMap = ExportMaskUtils.getZoneMapFromZoneInfoMap(unManagedExportMask.getZoningMap(), initiators);
            if (!zoneMap.isEmpty()) {
                exportMask.setZoningMap(zoneMap);
            }
            requestContext.addDataObjectToUpdate(exportMask, unManagedVolume);
            ExportMaskUtils.updateFCZoneReferences(exportGroup, exportMask, blockObject, unManagedExportMask.getZoningMap(), initiators, _dbClient);
            // remove the unmanaged mask from unmanaged volume only if the block object has not been marked as internal
            if (!blockObject.checkInternalFlags(Flag.PARTIALLY_INGESTED)) {
                _logger.info("block object {} is fully ingested, " + "breaking relationship between UnManagedExportMask {} and UnManagedVolume {}", blockObject.forDisplay(), unManagedExportMask.getMaskName(), unManagedVolume.forDisplay());
                unManagedVolume.getUnmanagedExportMasks().remove(unManagedExportMask.getId().toString());
                unManagedExportMask.getUnmanagedVolumeUris().remove(unManagedVolume.getId().toString());
                uemsToPersist.add(unManagedExportMask);
            }
            if (exportGroup.getExportMasks() == null || !exportGroup.getExportMasks().contains(exportMask.getId().toString())) {
                exportGroup.addExportMask(exportMask.getId().toString());
            }
            VolumeIngestionUtil.updateExportGroup(exportGroup, blockObject, wwnToHluMap, _dbClient, initiators, hosts, cluster);
            _logger.info("Removing unmanaged mask {} from the list of items to process, as block object is added already", unManagedExportMask.getMaskName());
            itr.remove();
            requestContext.addDataObjectToUpdate(exportMask, unManagedVolume);
        }
        _logger.info("{} unmanaged mask(s) validated as eligible for further processing: {}", unManagedMasks.size(), VolumeIngestionUtil.getMaskNames(URIUtil.toUris(unManagedMasks), _dbClient));
        URI blockId = null;
        if (!blockObject.checkInternalFlags(Flag.PARTIALLY_INGESTED)) {
            blockId = blockObject.getId();
        }
        List<ExportMask> exportMasksToCreate = new ArrayList<ExportMask>();
        List<UnManagedExportMask> eligibleMasks = null;
        if (!unManagedMasks.isEmpty()) {
            if (null != cluster) {
                _logger.info("Processing Cluster {}", cluster.forDisplay());
                // get Hosts for Cluster & get Initiators by Host Name
                // TODO handle multiple Hosts in one call
                List<URI> hostUris = ComputeSystemHelper.getChildrenUris(_dbClient, requestContext.getCluster(), Host.class, "cluster");
                _logger.info("Found Hosts {} in cluster {}", Joiner.on(",").join(hostUris), cluster.forDisplay());
                List<Set<String>> iniGroupByHost = new ArrayList<Set<String>>();
                URI varrayUri = requestContext.getVarray(unManagedVolume).getId();
                boolean isVplexDistributedVolume = VolumeIngestionUtil.isVplexDistributedVolume(unManagedVolume);
                boolean isVplexAutoCrossConnect = requestContext.getVpool(unManagedVolume).getAutoCrossConnectExport();
                for (URI hostUri : hostUris) {
                    Set<String> initsOfHost = getInitiatorsOfHost(hostUri);
                    Host host2 = _dbClient.queryObject(Host.class, hostUri);
                    _logger.info("Host {} has these initiators: " + VolumeIngestionUtil.getInitiatorNames(URIUtil.toURIList(initsOfHost), _dbClient), host2.forDisplay());
                    if (isVplexDistributedVolume && !isVplexAutoCrossConnect) {
                        _logger.info("this is a distributed vplex volume which may have split fabrics with different connectivity per host");
                        Iterator<String> initsOfHostIt = initsOfHost.iterator();
                        while (initsOfHostIt.hasNext()) {
                            String uriStr = initsOfHostIt.next();
                            Initiator init = _dbClient.queryObject(Initiator.class, URI.create(uriStr));
                            if (null != init) {
                                _logger.info("checking initiator {} for connectivity", init.getInitiatorPort());
                                Set<String> connectedVarrays = ConnectivityUtil.getInitiatorVarrays(init.getInitiatorPort(), _dbClient);
                                _logger.info("initiator's connected varrays are: {}", connectedVarrays);
                                if (!connectedVarrays.contains(varrayUri.toString())) {
                                    _logger.info("initiator {} of host {} is not connected to varray {}, removing", init.getInitiatorPort(), host2.getLabel(), VolumeIngestionUtil.getVarrayName(varrayUri, _dbClient));
                                    initsOfHostIt.remove();
                                }
                            }
                        }
                    }
                    if (!initsOfHost.isEmpty()) {
                        iniGroupByHost.add(initsOfHost);
                    }
                }
                eligibleMasks = VolumeIngestionUtil.findMatchingExportMaskForCluster(blockObject, unManagedMasks, iniGroupByHost, _dbClient, varrayUri, requestContext.getVpool(unManagedVolume).getId(), requestContext.getCluster(), errorMessages);
                // Volume cannot be exposed to both Cluster and Host
                if (eligibleMasks.size() == 1) {
                    // all initiators of all hosts in 1 MV
                    // add Volume,all Initiators and StoragePorts to
                    // ExportMask
                    _logger.info("Only 1 eligible mask found for cluster {}: ", cluster.forDisplay(), eligibleMasks.get(0).toString());
                    ExportMask exportMaskToCreate = VolumeIngestionUtil.createExportMask(eligibleMasks.get(0), unManagedVolume, exportGroup, blockObject, _dbClient, hosts, cluster, cluster.getLabel());
                    updateExportMaskWithPortGroup(system, eligibleMasks.get(0), exportMaskToCreate, exportGroup, blockId);
                    exportMasksToCreate.add(exportMaskToCreate);
                    uemsToPersist.add(eligibleMasks.get(0));
                    masksIngestedCount.increment();
                } else if (eligibleMasks.size() > 1) {
                    _logger.info("Multiple masks found for cluster {}: {}", cluster.forDisplay(), Joiner.on(";").join(eligibleMasks));
                    // 1 MV per Cluster Node
                    for (UnManagedExportMask eligibleMask : eligibleMasks) {
                        _logger.info("Setting up eligible mask " + eligibleMask.forDisplay());
                        ExportMask exportMaskToCreate = VolumeIngestionUtil.createExportMask(eligibleMask, unManagedVolume, exportGroup, blockObject, _dbClient, hosts, cluster, cluster.getLabel());
                        updateExportMaskWithPortGroup(system, eligibleMask, exportMaskToCreate, exportGroup, blockId);
                        exportMasksToCreate.add(exportMaskToCreate);
                        uemsToPersist.add(eligibleMask);
                        masksIngestedCount.increment();
                    }
                }
            } else if (null != host) {
                _logger.info("Processing Host {} ", host.forDisplay());
                Set<String> initiatorSet = getInitiatorsOfHost(requestContext.getHost());
                boolean hostPartOfCluster = (!NullColumnValueGetter.isNullURI(host.getCluster()));
                Map<String, Set<String>> iniByProtocol = VolumeIngestionUtil.groupInitiatorsByProtocol(initiatorSet, _dbClient);
                eligibleMasks = VolumeIngestionUtil.findMatchingExportMaskForHost(blockObject, unManagedMasks, initiatorSet, iniByProtocol, _dbClient, requestContext.getVarray(unManagedVolume).getId(), requestContext.getVpool(unManagedVolume).getId(), hostPartOfCluster, getInitiatorsOfCluster(host.getCluster(), hostPartOfCluster), null, errorMessages);
                if (!eligibleMasks.isEmpty()) {
                    _logger.info("Eligible masks found for Host {}: {}", host.forDisplay(), Joiner.on(",").join(eligibleMasks));
                } else {
                    _logger.info("No eligible unmanaged export masks found for Host {}", host.forDisplay());
                }
                for (UnManagedExportMask eligibleMask : eligibleMasks) {
                    _logger.info("Setting up eligible mask " + eligibleMask.forDisplay());
                    ExportMask exportMaskToCreate = VolumeIngestionUtil.createExportMask(eligibleMask, unManagedVolume, exportGroup, blockObject, _dbClient, hosts, cluster, host.getHostName());
                    updateExportMaskWithPortGroup(system, eligibleMask, exportMaskToCreate, exportGroup, blockId);
                    exportMasksToCreate.add(exportMaskToCreate);
                    uemsToPersist.add(eligibleMask);
                    masksIngestedCount.increment();
                }
            } else if (null != requestContext.getDeviceInitiators() && !requestContext.getDeviceInitiators().isEmpty()) {
                List<Initiator> deviceInitiators = requestContext.getDeviceInitiators();
                _logger.info("Processing device initiators {}", deviceInitiators);
                Set<String> initiatorSet = new HashSet<String>();
                for (Initiator init : deviceInitiators) {
                    initiatorSet.add(init.getId().toString());
                }
                boolean hostPartOfCluster = false;
                Map<String, Set<String>> iniByProtocol = VolumeIngestionUtil.groupInitiatorsByProtocol(initiatorSet, _dbClient);
                eligibleMasks = VolumeIngestionUtil.findMatchingExportMaskForHost(blockObject, unManagedMasks, initiatorSet, iniByProtocol, _dbClient, requestContext.getVarray(unManagedVolume).getId(), requestContext.getVpool(unManagedVolume).getId(), hostPartOfCluster, getInitiatorsOfCluster(null, hostPartOfCluster), null, errorMessages);
                if (!eligibleMasks.isEmpty()) {
                    _logger.info("Eligible masks found for device initiators {}: {}", deviceInitiators, Joiner.on(",").join(eligibleMasks));
                } else {
                    _logger.info("No eligible unmanaged export masks found for device initiators {}", deviceInitiators);
                }
                for (UnManagedExportMask eligibleMask : eligibleMasks) {
                    _logger.info("Setting up eligible mask " + eligibleMask.forDisplay());
                    // this getHostName will be the name of the VPLEX device
                    ExportMask exportMaskToCreate = VolumeIngestionUtil.createExportMask(eligibleMask, unManagedVolume, exportGroup, blockObject, _dbClient, hosts, cluster, deviceInitiators.get(0).getHostName());
                    updateExportMaskWithPortGroup(system, eligibleMask, exportMaskToCreate, exportGroup, blockId);
                    exportMasksToCreate.add(exportMaskToCreate);
                    uemsToPersist.add(eligibleMask);
                    masksIngestedCount.increment();
                }
            }
        }
        for (UnManagedExportMask uem : uemsToPersist) {
            requestContext.addDataObjectToUpdate(uem, unManagedVolume);
        }
        for (ExportMask exportMaskToCreate : exportMasksToCreate) {
            requestContext.addDataObjectToCreate(exportMaskToCreate, unManagedVolume);
            exportGroup.addExportMask(exportMaskToCreate.getId());
        }
    } catch (IngestionException e) {
        throw e;
    } catch (Exception e) {
        _logger.error("Export Mask Ingestion failed for UnManaged block object : {}", unManagedVolume.getNativeGuid(), e);
    }
}
Also used : HashSet(java.util.HashSet) Set(java.util.Set) StringSet(com.emc.storageos.db.client.model.StringSet) ArrayList(java.util.ArrayList) URI(java.net.URI) Initiator(com.emc.storageos.db.client.model.Initiator) StringSet(com.emc.storageos.db.client.model.StringSet) UnManagedExportMask(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedExportMask) StorageSystem(com.emc.storageos.db.client.model.StorageSystem) HashSet(java.util.HashSet) StringSetMap(com.emc.storageos.db.client.model.StringSetMap) UnManagedExportMask(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedExportMask) ExportMask(com.emc.storageos.db.client.model.ExportMask) Cluster(com.emc.storageos.db.client.model.Cluster) Host(com.emc.storageos.db.client.model.Host) ExportGroup(com.emc.storageos.db.client.model.ExportGroup) DataObject(com.emc.storageos.db.client.model.DataObject) Map(java.util.Map) StringSetMap(com.emc.storageos.db.client.model.StringSetMap) StringMap(com.emc.storageos.db.client.model.StringMap)

Example 63 with Cluster

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

the class ClusterService method detachStorage.

/**
 * Updates export groups that are referenced by the given cluster by removing the cluster
 * reference and initiators belonging to hosts in this cluster. Volumes are left intact.
 *
 * @param id the URN of a ViPR Cluster
 * @brief Detach storage from cluster
 * @return OK if detaching completed successfully
 * @throws DatabaseException when a DB error occurs
 */
@POST
@Path("/{id}/detach-storage")
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@CheckPermission(roles = { Role.TENANT_ADMIN })
public TaskResourceRep detachStorage(@PathParam("id") URI id) throws DatabaseException {
    Cluster cluster = queryObject(Cluster.class, id, true);
    String taskId = UUID.randomUUID().toString();
    Operation op = _dbClient.createTaskOpStatus(Cluster.class, id, taskId, ResourceOperationTypeEnum.DETACH_VCENTER_DATACENTER_STORAGE);
    ComputeSystemController controller = getController(ComputeSystemController.class, null);
    controller.detachClusterStorage(cluster.getId(), false, true, taskId);
    return toTask(cluster, taskId, op);
}
Also used : ComputeSystemController(com.emc.storageos.computesystemcontroller.ComputeSystemController) MapCluster(com.emc.storageos.api.mapper.functions.MapCluster) Cluster(com.emc.storageos.db.client.model.Cluster) Operation(com.emc.storageos.db.client.model.Operation) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Produces(javax.ws.rs.Produces) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Example 64 with Cluster

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

the class ClusterService method createNewCluster.

/**
 * Creates an instance of host cluster for the provided parameter
 *
 * @param tenant the tenant organization to which the cluster belongs
 * @param param the parameter that contains the cluster properties and attributes.
 * @return an instance of {@link Host}
 */
protected Cluster createNewCluster(TenantOrg tenant, ClusterParam param) {
    Cluster cluster = new Cluster();
    cluster.setId(URIUtil.createId(Cluster.class));
    cluster.setTenant(tenant.getId());
    populateCluster(param, cluster);
    return cluster;
}
Also used : MapCluster(com.emc.storageos.api.mapper.functions.MapCluster) Cluster(com.emc.storageos.db.client.model.Cluster)

Example 65 with Cluster

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

the class ComputeElementService method getComputeElement.

/**
 * Gets the data for a compute element.
 *
 * @param id the URN of a ViPR compute element.
 *
 * @brief Show compute element
 * @return A ComputeElementRestRep reference specifying the data for the
 *         compute element with the passed id.
 */
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}")
@CheckPermission(roles = { Role.SYSTEM_ADMIN, Role.SYSTEM_MONITOR })
public ComputeElementRestRep getComputeElement(@PathParam("id") URI id) {
    ArgValidator.checkFieldUriType(id, ComputeElement.class, "id");
    ComputeElement ce = queryResource(id);
    ArgValidator.checkEntity(ce, id, isIdEmbeddedInURL(id));
    Host associatedHost = getAssociatedHost(ce, _dbClient);
    Cluster cluster = null;
    if (associatedHost != null && !NullColumnValueGetter.isNullURI(associatedHost.getCluster())) {
        cluster = _dbClient.queryObject(Cluster.class, associatedHost.getCluster());
    }
    return ComputeMapper.map(ce, associatedHost, cluster);
}
Also used : ComputeElement(com.emc.storageos.db.client.model.ComputeElement) Cluster(com.emc.storageos.db.client.model.Cluster) Host(com.emc.storageos.db.client.model.Host) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Aggregations

Cluster (com.emc.storageos.db.client.model.Cluster)67 Host (com.emc.storageos.db.client.model.Host)38 URI (java.net.URI)26 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)20 VcenterDataCenter (com.emc.storageos.db.client.model.VcenterDataCenter)19 Initiator (com.emc.storageos.db.client.model.Initiator)15 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)15 Path (javax.ws.rs.Path)14 Produces (javax.ws.rs.Produces)14 VcenterControllerException (com.emc.storageos.vcentercontroller.exceptions.VcenterControllerException)13 VcenterObjectConnectionException (com.emc.storageos.vcentercontroller.exceptions.VcenterObjectConnectionException)13 VcenterObjectNotFoundException (com.emc.storageos.vcentercontroller.exceptions.VcenterObjectNotFoundException)13 ArrayList (java.util.ArrayList)13 Vcenter (com.emc.storageos.db.client.model.Vcenter)12 VcenterServerConnectionException (com.emc.storageos.vcentercontroller.exceptions.VcenterServerConnectionException)11 HashSet (java.util.HashSet)9 MapCluster (com.emc.storageos.api.mapper.functions.MapCluster)8 VcenterApiClient (com.emc.storageos.vcentercontroller.VcenterApiClient)8 GET (javax.ws.rs.GET)8 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)6