Search in sources :

Example 86 with ExportGroup

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

the class ExportGroupService method searchForClusterExport.

/**
 * Performs the search query based on the cluster Id.
 *
 * @param clusterId search param
 * @param resRepLists result
 * @param selfOnly true or false
 */
private void searchForClusterExport(String clusterId, List<SearchResultResourceRep> resRepLists, boolean selfOnly, boolean authorized) {
    URIQueryResultList egUris = new URIQueryResultList();
    Set<URI> resultUris = new HashSet<URI>();
    List<ExportGroup> exportGroups = new ArrayList<ExportGroup>();
    if (selfOnly) {
        exportGroups = CustomQueryUtility.queryActiveResourcesByConstraint(_dbClient, ExportGroup.class, AlternateIdConstraint.Factory.getConstraint(ExportGroup.class, "clusters", clusterId));
    } else {
        List<NamedElement> hostElements = getModelClient().hosts().findIdsByCluster(URI.create(clusterId));
        List<URI> hosts = toURIs(hostElements);
        for (URI hUri : hosts) {
            List<NamedElement> initiatorElements = getModelClient().initiators().findIdsByHost(hUri);
            List<URI> initiators = toURIs(initiatorElements);
            for (URI iUri : initiators) {
                _dbClient.queryByConstraint(AlternateIdConstraint.Factory.getExportGroupInitiatorConstraint(iUri.toString()), egUris);
                for (URI eUri : egUris) {
                    resultUris.add(eUri);
                }
            }
        }
        exportGroups = _dbClient.queryObject(ExportGroup.class, resultUris, true);
    }
    buildExportGroupSearchResponse(exportGroups, resRepLists, selfOnly, ExportGroupType.Cluster.name(), authorized);
}
Also used : ExportGroup(com.emc.storageos.db.client.model.ExportGroup) ArrayList(java.util.ArrayList) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI) NamedElement(com.emc.storageos.db.client.constraint.NamedElementQueryResultList.NamedElement) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) HashSet(java.util.HashSet)

Example 87 with ExportGroup

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

the class ExportGroupService method getPortGroupsForPortGroupChange.

/**
 * Get list of eligible port groups for Change Port Group for Host operation.
 * This API returns the list of Port Groups that a user can choose from for the Change Port Group for Host operation. Currently this API
 * is available only for VMAX systems
 *
 * @param currentPortGroupURI contains CurrentPortGroup
 * @param hostOrClusterIDURI contains Host/ClusterID
 * @param varrayIDURI contains varrayID
 * @return the list of port groups that are eligible for CHnage Port Group for Host
 * @throws ControllerException
 */
@GET
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/target-storage-port-groups")
@CheckPermission(roles = { Role.TENANT_ADMIN }, acls = { ACL.OWN, ACL.ALL })
public StoragePortGroupChangeList getPortGroupsForPortGroupChange(@QueryParam("currentPortGroup") String currentPortGroupURI, @QueryParam("hostOrClusterID") String hostOrClusterIDURI, @QueryParam("varrayID") String varrayIDURI) throws ControllerException {
    ArgValidator.checkFieldNotEmpty(currentPortGroupURI, "currentPortGroup");
    ArgValidator.checkFieldNotEmpty(hostOrClusterIDURI, "hostOrClusterID");
    ArgValidator.checkFieldNotEmpty(varrayIDURI, "varrayID");
    ArgValidator.checkUri(URIUtil.uri(currentPortGroupURI));
    _log.info("verfying Port Group id: {}", currentPortGroupURI);
    ArgValidator.checkUri(URIUtil.uri(hostOrClusterIDURI));
    _log.info("verfying Host/Cluster id: {}", hostOrClusterIDURI);
    ArgValidator.checkUri(URIUtil.uri(varrayIDURI));
    _log.info("verfying Virtual Array id: {}", varrayIDURI);
    // Get the current port group
    StoragePortGroup currentPortGroup = queryObject(StoragePortGroup.class, URIUtil.uri(currentPortGroupURI), true);
    // Get the storage system of current port group
    URI currrentPortGroupStorageSystem = currentPortGroup.getStorageDevice();
    StorageSystem currentStorageSystem = queryObject(StorageSystem.class, currrentPortGroupStorageSystem, true);
    _log.info("storage system of current port group: {}", currentStorageSystem.getId());
    // Get the ports of the current port group
    StringSet currentPortGroupPorts = currentPortGroup.getStoragePorts();
    // Get the current Export Group
    URIQueryResultList exportMasksURIs = new URIQueryResultList();
    _dbClient.queryByConstraint(AlternateIdConstraint.Factory.getExportMasksByPortGroup(currentPortGroup.getId().toString()), exportMasksURIs);
    Set<URI> exportMaskURI = new HashSet<URI>();
    for (URI exportMaskURIiterator : exportMasksURIs) {
        exportMaskURI.add(exportMaskURIiterator);
    }
    ExportGroup currentExportGroup = new ExportGroup();
    URIQueryResultList exportGroupURIs = new URIQueryResultList();
    for (URI exportMaskURIiterator : exportMaskURI) {
        _dbClient.queryByConstraint(ContainmentConstraint.Factory.getExportMaskExportGroupConstraint(exportMaskURIiterator), exportGroupURIs);
        int flag = 0;
        for (URI exportGroupURIiterator : exportGroupURIs) {
            ExportGroup trialExportGroup = queryObject(ExportGroup.class, exportGroupURIiterator, true);
            Set<String> hostsInExportGroup = trialExportGroup.getHosts();
            Set<String> clustersInExportGroup = trialExportGroup.getClusters();
            if ((hostsInExportGroup != null && hostsInExportGroup.contains(URIUtil.uri(hostOrClusterIDURI).toString())) || (clustersInExportGroup != null && clustersInExportGroup.contains(URIUtil.uri(hostOrClusterIDURI).toString()))) {
                currentExportGroup = trialExportGroup;
                _log.info("the ExportGroup of current port group is: {}", currentExportGroup.getId());
                flag = 1;
                break;
            }
        }
        if (flag == 1) {
            break;
        }
    }
    // Get volumes currently in Export Group
    List<URI> volumes = new ArrayList<URI>();
    for (Map.Entry<String, String> entry : currentExportGroup.getVolumes().entrySet()) {
        URI volumeToAdd = URI.create(entry.getKey().toString());
        if (volumeToAdd != null) {
            volumes.add(volumeToAdd);
        }
    }
    // Get current ExportPathParams
    ExportPathParams pathParams = _blockStorageScheduler.calculateExportPathParamForVolumes(volumes, currentExportGroup.getNumPaths(), currentStorageSystem.getId(), currentExportGroup.getId());
    // Get initiators of Export Group
    List<Initiator> currentInitiators = getInitiators(currentExportGroup);
    StoragePortGroupChangeList invalidPortGroupList = new StoragePortGroupChangeList();
    // Get the port groups associated with the ports in the varray and the storage system
    List<StoragePortGroup> listOfPortGroups = new ArrayList<StoragePortGroup>();
    Set<URI> setOfpgURIs = new HashSet<URI>();
    Set<String> currentSystemPortsInVarray = ExportMaskUtils.getStoragePortUrisAssociatedWithVarrayAndStorageArray(currentPortGroup.getStorageDevice(), URIUtil.uri(varrayIDURI), _dbClient);
    if (null != currentSystemPortsInVarray && !currentSystemPortsInVarray.isEmpty()) {
        for (String portUriStr : currentSystemPortsInVarray) {
            URIQueryResultList pgURIs = new URIQueryResultList();
            _dbClient.queryByConstraint(ContainmentConstraint.Factory.getStoragePortPortGroupConstraint(URIUtil.uri(portUriStr)), pgURIs);
            setOfpgURIs.addAll(pgURIs);
        }
        Iterator<StoragePortGroup> _dbIterator = _dbClient.queryIterativeObjects(StoragePortGroup.class, setOfpgURIs);
        listOfPortGroups = IteratorUtils.toList(_dbIterator);
    }
    // remove port groups from the list if they do not follow conditions
    for (Iterator<StoragePortGroup> it = listOfPortGroups.iterator(); it.hasNext(); ) {
        StoragePortGroup trialPortGroup = it.next();
        StringBuffer notAllowedReasonBuff = new StringBuffer();
        // Remove trialPortGroup if it is inactive or not usable
        if (trialPortGroup == null || trialPortGroup.getInactive() || !trialPortGroup.isUsable()) {
            it.remove();
            notAllowedReasonBuff.append("Is either Inactive or not usable");
            invalidPortGroupList.getPortGroups().add(new StoragePortGroupChangeRep(trialPortGroup.getId(), trialPortGroup.getLabel(), notAllowedReasonBuff.toString(), false));
            continue;
        }
        // Remove trialPortGroup if it is the same as the currentPortGroup
        if (trialPortGroup.getId().equals(currentPortGroup.getId())) {
            _log.info("filtered out port group {} because it is the same as the current port group", trialPortGroup.getId());
            it.remove();
            notAllowedReasonBuff.append("Same as the current port group");
            invalidPortGroupList.getPortGroups().add(new StoragePortGroupChangeRep(trialPortGroup.getId(), trialPortGroup.getLabel(), notAllowedReasonBuff.toString(), false));
            continue;
        }
        // Remove trialPortGroup if it has overlapping ports with currentPortGroup
        StringSet trialPortGroupPorts = trialPortGroup.getStoragePorts();
        if (!Collections.disjoint(trialPortGroupPorts, currentPortGroupPorts)) {
            _log.info("filtered out port group {}  because it has ports overlapping the current port group", trialPortGroup.getId());
            it.remove();
            notAllowedReasonBuff.append("Ports overlapping with current port group");
            invalidPortGroupList.getPortGroups().add(new StoragePortGroupChangeRep(trialPortGroup.getId(), trialPortGroup.getLabel(), notAllowedReasonBuff.toString(), false));
            continue;
        }
        // Remove trialPortGroup if its ports do not fulfill ExportPathParams of the currentPortGroup
        pathParams.setStoragePorts(trialPortGroup.getStoragePorts());
        Map<URI, List<URI>> assignment = null;
        try {
            assignment = _blockStorageScheduler.verifyStoragePortGroups(currentStorageSystem, currentExportGroup.getVirtualArray(), currentInitiators, pathParams, new StringSetMap(), volumes);
            if (CollectionUtils.isEmpty(assignment)) {
                _log.info("filtered out port group {}  because it does not fulfil ExportPathParams of existing PortGroup", trialPortGroup.getId());
                it.remove();
                notAllowedReasonBuff.append("Does not fulfil ExportPathParams of existing PortGroup");
                invalidPortGroupList.getPortGroups().add(new StoragePortGroupChangeRep(trialPortGroup.getId(), trialPortGroup.getLabel(), notAllowedReasonBuff.toString(), false));
                continue;
            }
        } catch (Exception e) {
            _log.debug("filtered out the current port group because: {}", e.getMessage());
            if (CollectionUtils.isEmpty(assignment)) {
                it.remove();
                notAllowedReasonBuff.append(e.getMessage());
                invalidPortGroupList.getPortGroups().add(new StoragePortGroupChangeRep(trialPortGroup.getId(), trialPortGroup.getLabel(), notAllowedReasonBuff.toString(), false));
                continue;
            }
        }
    }
    StoragePortGroupChangeList changePortGroupList = new StoragePortGroupChangeList();
    // Sort the list based on its metrics
    Collections.sort(listOfPortGroups, new StoragePortGroupComparator());
    // Add the valid PGs
    for (StoragePortGroup portGroup : listOfPortGroups) {
        StoragePortGroupChangeRep changePG = new StoragePortGroupChangeRep(null, true);
        StoragePortGroupRestRep pgRep = MapStoragePortGroup.getInstance(_dbClient).toStoragePortGroupRestRep(portGroup);
        changePG.setChangePGOtherParams(pgRep);
        changePortGroupList.getPortGroups().add(changePG);
    }
    // Add invalid PGs
    for (StoragePortGroupChangeRep invalidPG : invalidPortGroupList.getPortGroups()) {
        changePortGroupList.getPortGroups().add(invalidPG);
    }
    return changePortGroupList;
}
Also used : MapStoragePortGroup(com.emc.storageos.api.mapper.functions.MapStoragePortGroup) StoragePortGroup(com.emc.storageos.db.client.model.StoragePortGroup) ArrayList(java.util.ArrayList) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) Initiator(com.emc.storageos.db.client.model.Initiator) StoragePortGroupRestRep(com.emc.storageos.model.portgroup.StoragePortGroupRestRep) StoragePortGroupComparator(com.emc.storageos.api.service.impl.resource.utils.StoragePortGroupComparator) StringSet(com.emc.storageos.db.client.model.StringSet) ITLRestRepList(com.emc.storageos.model.block.export.ITLRestRepList) StoragePortGroupChangeList(com.emc.storageos.model.portgroup.StoragePortGroupChangeList) ArrayList(java.util.ArrayList) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) List(java.util.List) BulkList(com.emc.storageos.api.service.impl.response.BulkList) SearchedResRepList(com.emc.storageos.api.service.impl.response.SearchedResRepList) StorageSystem(com.emc.storageos.db.client.model.StorageSystem) HashSet(java.util.HashSet) StoragePortGroupChangeList(com.emc.storageos.model.portgroup.StoragePortGroupChangeList) StringSetMap(com.emc.storageos.db.client.model.StringSetMap) StoragePortGroupChangeRep(com.emc.storageos.model.portgroup.StoragePortGroupChangeRep) PrefixConstraint(com.emc.storageos.db.client.constraint.PrefixConstraint) AlternateIdConstraint(com.emc.storageos.db.client.constraint.AlternateIdConstraint) ContainmentPrefixConstraint(com.emc.storageos.db.client.constraint.ContainmentPrefixConstraint) ContainmentConstraint(com.emc.storageos.db.client.constraint.ContainmentConstraint) ControllerException(com.emc.storageos.volumecontroller.ControllerException) APIException(com.emc.storageos.svcs.errorhandling.resources.APIException) BadRequestException(com.emc.storageos.svcs.errorhandling.resources.BadRequestException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) PlacementException(com.emc.storageos.volumecontroller.placement.PlacementException) ExportGroup(com.emc.storageos.db.client.model.ExportGroup) Map(java.util.Map) StringSetMap(com.emc.storageos.db.client.model.StringSetMap) OpStatusMap(com.emc.storageos.db.client.model.OpStatusMap) HashMap(java.util.HashMap) StringMap(com.emc.storageos.db.client.model.StringMap) ExportPathParams(com.emc.storageos.db.client.model.ExportPathParams) Path(javax.ws.rs.Path) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Example 88 with ExportGroup

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

the class ActionableEventExecutor method hostClusterChangeDetails.

/**
 * Get details for the hostClusterChange method
 * NOTE: In order to maintain backwards compatibility, do not change the signature of this method.
 *
 * @param hostId the host that is moving clusters
 * @param clusterId the cluster the host is moving to
 * @param isVcenter if true, vcenter api operations will be executed against the host to detach/unmount and attach/mount disks and
 *            datastores
 * @param vCenterDataCenterId the datacenter to assign the host to
 * @return list of event details
 */
// Invoked using reflection for the event framework
@SuppressWarnings("unused")
public List<String> hostClusterChangeDetails(URI hostId, URI clusterId, URI vCenterDataCenterId, boolean isVcenter) {
    List<String> result = Lists.newArrayList();
    Host host = _dbClient.queryObject(Host.class, hostId);
    if (host == null) {
        return Lists.newArrayList("Host has been deleted");
    }
    URI oldClusterURI = host.getCluster();
    Cluster oldCluster = null;
    if (!NullColumnValueGetter.isNullURI(oldClusterURI)) {
        oldCluster = _dbClient.queryObject(Cluster.class, oldClusterURI);
    }
    Cluster newCluster = null;
    if (!NullColumnValueGetter.isNullURI(clusterId)) {
        newCluster = _dbClient.queryObject(Cluster.class, clusterId);
    }
    if (newCluster != null && oldCluster != null) {
        result.add(ComputeSystemDialogProperties.getMessage("ComputeSystem.hostClusterChangeDetails", host.getLabel(), oldCluster.getLabel(), newCluster.getLabel()));
    } else if (newCluster == null && oldCluster != null) {
        result.add(ComputeSystemDialogProperties.getMessage("ComputeSystem.hostClusterChangeDetailsRemovedFromCluster", host.getLabel(), oldCluster.getLabel()));
    } else if (newCluster != null && oldCluster == null) {
        result.add(ComputeSystemDialogProperties.getMessage("ComputeSystem.hostClusterChangeDetailsAddedToCluster", host.getLabel(), newCluster.getLabel()));
    }
    if (!NullColumnValueGetter.isNullURI(oldClusterURI) && NullColumnValueGetter.isNullURI(clusterId) && ComputeSystemHelper.isClusterInExport(_dbClient, oldClusterURI)) {
        List<ExportGroup> exportGroups = ComputeSystemControllerImpl.getSharedExports(_dbClient, oldClusterURI);
        for (ExportGroup export : exportGroups) {
            if (export != null) {
                List<BlockObjectDetails> affectedVolumes = getBlockObjectDetails(hostId, export.getVolumes());
                result.addAll(getVolumeDetails(affectedVolumes, false));
            }
        }
    } else if (NullColumnValueGetter.isNullURI(oldClusterURI) && !NullColumnValueGetter.isNullURI(clusterId) && ComputeSystemHelper.isClusterInExport(_dbClient, clusterId)) {
        // Non-clustered host being added to a cluster
        List<ExportGroup> exportGroups = ComputeSystemControllerImpl.getSharedExports(_dbClient, clusterId);
        for (ExportGroup eg : exportGroups) {
            List<BlockObjectDetails> affectedVolumes = getBlockObjectDetails(hostId, eg.getVolumes());
            result.addAll(getVolumeDetails(affectedVolumes, true));
        }
    } else if (!NullColumnValueGetter.isNullURI(oldClusterURI) && !NullColumnValueGetter.isNullURI(clusterId) && !oldClusterURI.equals(clusterId) && (ComputeSystemHelper.isClusterInExport(_dbClient, oldClusterURI) || ComputeSystemHelper.isClusterInExport(_dbClient, clusterId))) {
        // Clustered host being moved to another cluster
        List<ExportGroup> exportGroups = ComputeSystemControllerImpl.getSharedExports(_dbClient, oldClusterURI);
        for (ExportGroup export : exportGroups) {
            if (export != null) {
                List<BlockObjectDetails> affectedVolumes = getBlockObjectDetails(hostId, export.getVolumes());
                result.addAll(getVolumeDetails(affectedVolumes, false));
            }
        }
        exportGroups = ComputeSystemControllerImpl.getSharedExports(_dbClient, clusterId);
        for (ExportGroup eg : exportGroups) {
            List<BlockObjectDetails> affectedVolumes = getBlockObjectDetails(hostId, eg.getVolumes());
            result.addAll(getVolumeDetails(affectedVolumes, true));
        }
    }
    return result;
}
Also used : ExportGroup(com.emc.storageos.db.client.model.ExportGroup) Cluster(com.emc.storageos.db.client.model.Cluster) Host(com.emc.storageos.db.client.model.Host) List(java.util.List) URI(java.net.URI)

Example 89 with ExportGroup

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

the class ExternalDeviceExportOperations method removeVolumes.

@Override
public void removeVolumes(StorageSystem storage, URI exportMaskUri, List<URI> volumeUris, List<com.emc.storageos.db.client.model.Initiator> initiatorList, TaskCompleter taskCompleter) throws DeviceControllerException {
    log.info("{} removeVolumes START...", storage.getSerialNumber());
    try {
        log.info("removeVolumes: Export mask id: {}", exportMaskUri);
        log.info("removeVolumes: volumes: {}", Joiner.on(',').join(volumeUris));
        if (initiatorList != null) {
            log.info("removeVolumes: impacted initiators: {}", Joiner.on(",").join(initiatorList));
        }
        BlockStorageDriver driver = externalDevice.getDriver(storage.getSystemType());
        ExportMask exportMask = (ExportMask) dbClient.queryObject(exportMaskUri);
        StringSet maskInitiators = exportMask.getInitiators();
        List<String> maskInitiatorList = new ArrayList<>();
        for (String initiatorUri : maskInitiators) {
            maskInitiatorList.add(initiatorUri);
        }
        log.info("Export mask existing initiators: {} ", Joiner.on(",").join(maskInitiatorList));
        // Prepare volumes. We send to driver only new volumes for the export mask.
        List<StorageVolume> driverVolumes = new ArrayList<>();
        prepareVolumes(storage, volumeUris, driverVolumes);
        // Prepare initiators
        Set<com.emc.storageos.db.client.model.Initiator> initiators = ExportMaskUtils.getInitiatorsForExportMask(dbClient, exportMask, null);
        List<Initiator> driverInitiators = new ArrayList<>();
        // Get export group uri from task completer
        URI exportGroupUri = taskCompleter.getId();
        ExportGroup exportGroup = (ExportGroup) dbClient.queryObject(exportGroupUri);
        prepareInitiators(initiators, exportGroup.forCluster(), driverInitiators);
        // Ready to call driver
        DriverTask task = driver.unexportVolumesFromInitiators(driverInitiators, driverVolumes);
        // todo: need to implement support for async case.
        if (task.getStatus() == DriverTask.TaskStatus.READY) {
            String msg = String.format("Removed volumes from export: %s.", task.getMessage());
            log.info(msg);
            taskCompleter.ready(dbClient);
        } else {
            String errorMsg = String.format("Failed to remove volumes from export mask: %s .", task.getMessage());
            log.error(errorMsg);
            ServiceError serviceError = ExternalDeviceException.errors.deleteVolumesFromExportMaskFailed("removeVolumes", errorMsg);
            taskCompleter.error(dbClient, serviceError);
        }
    } catch (Exception ex) {
        log.error("Problem in removeVolumes: ", ex);
        String errorMsg = String.format("Failed to remove volumes from export mask: %s .", ex.getMessage());
        log.error(errorMsg);
        ServiceError serviceError = ExternalDeviceException.errors.deleteVolumesFromExportMaskFailed("removeVolumes", errorMsg);
        taskCompleter.error(dbClient, serviceError);
    }
    log.info("{} removeVolumes END...", storage.getSerialNumber());
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) ExportMask(com.emc.storageos.db.client.model.ExportMask) ArrayList(java.util.ArrayList) URI(java.net.URI) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) DriverTask(com.emc.storageos.storagedriver.DriverTask) StorageVolume(com.emc.storageos.storagedriver.model.StorageVolume) ExportGroup(com.emc.storageos.db.client.model.ExportGroup) Initiator(com.emc.storageos.storagedriver.model.Initiator) StringSet(com.emc.storageos.db.client.model.StringSet) BlockStorageDriver(com.emc.storageos.storagedriver.BlockStorageDriver)

Example 90 with ExportGroup

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

the class ExportAddInitiatorCompleter method complete.

@Override
protected void complete(DbClient dbClient, Operation.Status status, ServiceCoded coded) throws DeviceControllerException {
    try {
        ExportGroup exportGroup = dbClient.queryObject(ExportGroup.class, getId());
        Operation operation = new Operation();
        switch(status) {
            case error:
                operation.error(coded);
                break;
            case ready:
                operation.ready();
                break;
            case suspended_no_error:
                operation.suspendedNoError();
                break;
            case suspended_error:
                operation.suspendedError(coded);
                break;
            default:
                break;
        }
        exportGroup.getOpStatus().updateTaskStatus(getOpId(), operation);
        _log.info("export_initiator_add: completed");
        _log.info(String.format("Done ExportMaskAddInitiator - Id: %s, OpId: %s, status: %s", getId().toString(), getOpId(), status.name()));
        for (URI initiatorURI : _initiatorURIs) {
            Initiator initiator = dbClient.queryObject(Initiator.class, initiatorURI);
            recordBlockExportOperation(dbClient, OperationTypeEnum.ADD_EXPORT_INITIATOR, status, eventMessage(status, initiator, exportGroup), exportGroup, initiator);
            if (status.name().equals(Operation.Status.error.name())) {
                exportGroup.removeInitiator(initiator);
            }
        }
        dbClient.updateObject(exportGroup);
    } catch (Exception e) {
        _log.error(String.format("Failed updating status for ExportMaskAddInitiator - Id: %s, OpId: %s", getId().toString(), getOpId()), e);
    } finally {
        super.complete(dbClient, status, coded);
    }
}
Also used : ExportGroup(com.emc.storageos.db.client.model.ExportGroup) Initiator(com.emc.storageos.db.client.model.Initiator) Operation(com.emc.storageos.db.client.model.Operation) URI(java.net.URI) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException)

Aggregations

ExportGroup (com.emc.storageos.db.client.model.ExportGroup)278 URI (java.net.URI)206 ArrayList (java.util.ArrayList)139 ExportMask (com.emc.storageos.db.client.model.ExportMask)138 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)111 HashMap (java.util.HashMap)94 Initiator (com.emc.storageos.db.client.model.Initiator)86 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)84 NamedURI (com.emc.storageos.db.client.model.NamedURI)80 HashSet (java.util.HashSet)70 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)63 Workflow (com.emc.storageos.workflow.Workflow)61 List (java.util.List)59 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)55 BlockObject (com.emc.storageos.db.client.model.BlockObject)49 Map (java.util.Map)47 ExportOrchestrationTask (com.emc.storageos.volumecontroller.impl.block.taskcompleter.ExportOrchestrationTask)44 ControllerException (com.emc.storageos.volumecontroller.ControllerException)41 StringSet (com.emc.storageos.db.client.model.StringSet)38 StringMap (com.emc.storageos.db.client.model.StringMap)33