Search in sources :

Example 46 with VNXeBase

use of com.emc.storageos.vnxe.models.VNXeBase in project coprhd-controller by CoprHD.

the class VNXeApiClient method removeLunsFromLunGroup.

/**
 * Remove luns from the lun group
 *
 * @param lunGroupId
 *            lun group id
 * @param luns
 *            list of lun IDs
 * @return
 */
public VNXeCommandResult removeLunsFromLunGroup(String lunGroupId, List<String> luns) {
    LunGroupModifyParam param = new LunGroupModifyParam();
    List<LunAddParam> lunRemoves = new ArrayList<LunAddParam>();
    for (String lunId : luns) {
        VNXeBase lun = new VNXeBase(lunId);
        LunAddParam lunAdd = new LunAddParam();
        lunAdd.setLun(lun);
        lunRemoves.add(lunAdd);
    }
    param.setLunRemove(lunRemoves);
    LunGroupRequests req = new LunGroupRequests(_khClient);
    return req.modifyLunGroupSync(lunGroupId, param);
}
Also used : VNXeBase(com.emc.storageos.vnxe.models.VNXeBase) LunAddParam(com.emc.storageos.vnxe.models.LunAddParam) LunGroupRequests(com.emc.storageos.vnxe.requests.LunGroupRequests) LunGroupModifyParam(com.emc.storageos.vnxe.models.LunGroupModifyParam) ArrayList(java.util.ArrayList)

Example 47 with VNXeBase

use of com.emc.storageos.vnxe.models.VNXeBase in project coprhd-controller by CoprHD.

the class VNXeApiClient method createSnap.

/**
 * Create snapshot for VNX Unity
 *
 * @param resourceID
 *            lun or consistency group id
 * @param name
 *            snapshot name
 * @param isReadOnly
 * @return VNXeCommandJob
 */
public VNXeCommandJob createSnap(String resourceID, String name, Boolean isReadOnly) {
    _logger.info("creating snap for :" + resourceID);
    SnapCreateParam parm = new SnapCreateParam();
    parm.setStorageResource(new VNXeBase(resourceID));
    parm.setName(name);
    if (isReadOnly != null) {
        parm.setIsReadOnly(isReadOnly);
    }
    SnapRequests req = new SnapRequests(_khClient);
    return req.createSnap(parm);
}
Also used : VNXeBase(com.emc.storageos.vnxe.models.VNXeBase) SnapRequests(com.emc.storageos.vnxe.requests.SnapRequests) LunGroupSnapRequests(com.emc.storageos.vnxe.requests.LunGroupSnapRequests) FileSystemSnapRequests(com.emc.storageos.vnxe.requests.FileSystemSnapRequests) LunSnapRequests(com.emc.storageos.vnxe.requests.LunSnapRequests) SnapCreateParam(com.emc.storageos.vnxe.models.SnapCreateParam) LunSnapCreateParam(com.emc.storageos.vnxe.models.LunSnapCreateParam) FileSystemSnapCreateParam(com.emc.storageos.vnxe.models.FileSystemSnapCreateParam)

Example 48 with VNXeBase

use of com.emc.storageos.vnxe.models.VNXeBase in project coprhd-controller by CoprHD.

the class VNXeExportOperations method createExportMask.

@Override
public void createExportMask(StorageSystem storage, URI exportMask, VolumeURIHLU[] volumeURIHLUs, List<URI> targetURIList, List<Initiator> initiatorList, TaskCompleter taskCompleter) throws DeviceControllerException {
    _logger.info("{} createExportMask START...", storage.getSerialNumber());
    VNXeApiClient apiClient = getVnxeClient(storage);
    List<URI> mappedVolumes = new ArrayList<URI>();
    ExportMask mask = null;
    try {
        _logger.info("createExportMask: Export mask id: {}", exportMask);
        _logger.info("createExportMask: volume-HLU pairs: {}", Joiner.on(',').join(volumeURIHLUs));
        _logger.info("createExportMask: initiators: {}", Joiner.on(',').join(initiatorList));
        _logger.info("createExportMask: assignments: {}", Joiner.on(',').join(targetURIList));
        ExportOperationContext context = new VNXeExportOperationContext();
        taskCompleter.updateWorkflowStepContext(context);
        mask = _dbClient.queryObject(ExportMask.class, exportMask);
        if (mask == null || mask.getInactive()) {
            throw new DeviceControllerException("Invalid ExportMask URI: " + exportMask);
        }
        Set<String> processedCGs = new HashSet<String>();
        Collection<VNXeHostInitiator> initiators = prepareInitiators(initiatorList).values();
        VNXeBase host = apiClient.prepareHostsForExport(initiators);
        validateInitiators(_dbClient, initiatorList, apiClient, host.getId());
        String opId = taskCompleter.getOpId();
        for (VolumeURIHLU volURIHLU : volumeURIHLUs) {
            URI volUri = volURIHLU.getVolumeURI();
            String hlu = volURIHLU.getHLU();
            _logger.info(String.format("hlu %s", hlu));
            BlockObject blockObject = BlockObject.fetch(_dbClient, volUri);
            String nativeId = blockObject.getNativeId();
            VNXeExportResult result = null;
            Integer newhlu = -1;
            if (hlu != null && !hlu.isEmpty() && !hlu.equals(ExportGroup.LUN_UNASSIGNED_STR)) {
                newhlu = Integer.valueOf(hlu);
            }
            String cgName = VNXeUtils.getBlockObjectCGName(blockObject, _dbClient);
            if (cgName != null && !processedCGs.contains(cgName)) {
                processedCGs.add(cgName);
                VNXeUtils.getCGLock(workflowService, storage, cgName, opId);
            }
            if (URIUtil.isType(volUri, Volume.class)) {
                result = apiClient.exportLun(host, nativeId, newhlu);
                mask.addVolume(volUri, result.getHlu());
                if (result.isNewAccess()) {
                    mappedVolumes.add(volUri);
                }
            } else if (URIUtil.isType(volUri, BlockSnapshot.class)) {
                if (BlockObject.checkForRP(_dbClient, volUri)) {
                    _logger.info(String.format("BlockObject %s is a RecoverPoint bookmark.  Exporting associated lun %s instead of snap.", volUri, nativeId));
                    result = apiClient.exportLun(host, nativeId, newhlu);
                } else {
                    result = apiClient.exportSnap(host, nativeId, newhlu);
                    setSnapWWN(apiClient, blockObject, nativeId);
                }
                mask.addVolume(volUri, result.getHlu());
                if (result.isNewAccess()) {
                    mappedVolumes.add(volUri);
                }
            }
        }
        ExportOperationContext.insertContextOperation(taskCompleter, VNXeExportOperationContext.OPERATION_ADD_VOLUMES_TO_HOST_EXPORT, mappedVolumes);
        mask.setNativeId(host.getId());
        _dbClient.updateObject(mask);
        taskCompleter.ready(_dbClient);
    } catch (Exception e) {
        _logger.error("Unexpected error: createExportMask failed.", e);
        ServiceError error = DeviceControllerErrors.vnxe.jobFailed("createExportMask", e.getMessage());
        taskCompleter.error(_dbClient, error);
    }
    _logger.info("{} createExportMask END...", storage.getSerialNumber());
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) VNXeApiClient(com.emc.storageos.vnxe.VNXeApiClient) ExportMask(com.emc.storageos.db.client.model.ExportMask) ArrayList(java.util.ArrayList) BlockSnapshot(com.emc.storageos.db.client.model.BlockSnapshot) VNXeHostInitiator(com.emc.storageos.vnxe.models.VNXeHostInitiator) URI(java.net.URI) VNXeExportResult(com.emc.storageos.vnxe.models.VNXeExportResult) VNXeException(com.emc.storageos.vnxe.VNXeException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) VNXeBase(com.emc.storageos.vnxe.models.VNXeBase) ExportOperationContext(com.emc.storageos.volumecontroller.impl.utils.ExportOperationContext) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) BlockObject(com.emc.storageos.db.client.model.BlockObject) HashSet(java.util.HashSet) VolumeURIHLU(com.emc.storageos.volumecontroller.impl.VolumeURIHLU)

Example 49 with VNXeBase

use of com.emc.storageos.vnxe.models.VNXeBase in project coprhd-controller by CoprHD.

the class VNXeExportOperations method getHostIdFromInitiators.

private String getHostIdFromInitiators(Collection<Initiator> initiators, VNXeApiClient apiClient) throws Exception {
    // all initiator on ViPR host should be on single host
    String vnxeHostId = null;
    for (Initiator initiator : initiators) {
        _logger.info("Processing initiator {}", initiator.getLabel());
        String initiatorId = initiator.getInitiatorPort();
        if (Protocol.FC.name().equals(initiator.getProtocol())) {
            initiatorId = initiator.getInitiatorNode() + ":" + initiatorId;
        }
        // query initiator on array
        VNXeHostInitiator vnxeInitiator = apiClient.getInitiatorByWWN(initiatorId);
        if (vnxeInitiator != null) {
            VNXeBase parentHost = vnxeInitiator.getParentHost();
            if (parentHost != null) {
                if (vnxeHostId == null) {
                    vnxeHostId = parentHost.getId();
                } else if (!vnxeHostId.equals(parentHost.getId())) {
                    String msg = String.format("Initiator %s belongs to %s, but other initiator belongs to %s. Please move initiator to the correct host", initiator.getInitiatorPort(), parentHost.getId(), vnxeHostId);
                    _logger.error(msg);
                    throw new DeviceControllerException(msg);
                }
            }
        }
    }
    if (vnxeHostId == null) {
        _logger.warn("No host found");
    }
    return vnxeHostId;
}
Also used : VNXeBase(com.emc.storageos.vnxe.models.VNXeBase) Initiator(com.emc.storageos.db.client.model.Initiator) VNXeHostInitiator(com.emc.storageos.vnxe.models.VNXeHostInitiator) VNXeHostInitiator(com.emc.storageos.vnxe.models.VNXeHostInitiator) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException)

Example 50 with VNXeBase

use of com.emc.storageos.vnxe.models.VNXeBase in project coprhd-controller by CoprHD.

the class VNXUnityArrayAffinityDiscoverer method getHostURIs.

/**
 * Find host URIs that a LUN is exported to
 *
 * @param lun
 * @param apiClient
 * @param dbClient
 * @param hostIdToHostURIMap
 * @return set of host URIs
 */
private Set<URI> getHostURIs(VNXeLun lun, VNXeApiClient apiClient, DbClient dbClient, Map<String, URI> hostIdToHostURIMap) {
    Set<URI> hostURIs = new HashSet<URI>();
    List<BlockHostAccess> accesses = lun.getHostAccess();
    if (accesses != null && !accesses.isEmpty()) {
        for (BlockHostAccess access : accesses) {
            if (access != null) {
                VNXeBase hostId = access.getHost();
                if (hostId != null) {
                    hostURIs.add(getHostURI(apiClient, hostId.getId(), dbClient, hostIdToHostURIMap));
                }
            }
        }
    }
    return hostURIs;
}
Also used : VNXeBase(com.emc.storageos.vnxe.models.VNXeBase) URI(java.net.URI) HashSet(java.util.HashSet) BlockHostAccess(com.emc.storageos.vnxe.models.BlockHostAccess)

Aggregations

VNXeBase (com.emc.storageos.vnxe.models.VNXeBase)71 ArrayList (java.util.ArrayList)39 URI (java.net.URI)17 HashMap (java.util.HashMap)14 LunGroupModifyParam (com.emc.storageos.vnxe.models.LunGroupModifyParam)13 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)12 VNXeHostInitiator (com.emc.storageos.vnxe.models.VNXeHostInitiator)11 HashSet (java.util.HashSet)11 List (java.util.List)11 StoragePort (com.emc.storageos.db.client.model.StoragePort)9 VNXeException (com.emc.storageos.vnxe.VNXeException)9 VNXeCommandJob (com.emc.storageos.vnxe.models.VNXeCommandJob)9 ConsistencyGroupRequests (com.emc.storageos.vnxe.requests.ConsistencyGroupRequests)9 LunGroupRequests (com.emc.storageos.vnxe.requests.LunGroupRequests)9 VNXeApiClient (com.emc.storageos.vnxe.VNXeApiClient)8 BlockHostAccess (com.emc.storageos.vnxe.models.BlockHostAccess)8 LunParam (com.emc.storageos.vnxe.models.LunParam)8 ModifyFileSystemParam (com.emc.storageos.vnxe.models.ModifyFileSystemParam)8 Initiator (com.emc.storageos.db.client.model.Initiator)7 VNXeHost (com.emc.storageos.vnxe.models.VNXeHost)7