Search in sources :

Example 41 with StoragePortGroup

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

the class VmaxExportOperations method changePortGroupAddPaths.

@Override
public void changePortGroupAddPaths(StorageSystem storage, URI newMaskURI, URI oldMaskURI, URI portGroupURI, TaskCompleter completer) {
    try {
        ExportOperationContext context = new VmaxExportOperationContext();
        // Prime the context object
        completer.updateWorkflowStepContext(context);
        StoragePortGroup portGroup = _dbClient.queryObject(StoragePortGroup.class, portGroupURI);
        ExportMask newMask = _dbClient.queryObject(ExportMask.class, newMaskURI);
        ExportMask oldMask = _dbClient.queryObject(ExportMask.class, oldMaskURI);
        // Validate if there is no ports removed from the port group outside of ViPR
        ExportMaskValidationContext ctx = new ExportMaskValidationContext();
        ctx.setStorage(storage);
        ctx.setExportMask(oldMask);
        Collection<URI> volumes = null;
        StringMap volumeMap = oldMask.getVolumes();
        if (volumeMap == null || volumeMap.isEmpty()) {
            _log.warn("No volumes in the export mask: {}", oldMask.getId());
        } else {
            volumes = StringSetUtil.stringSetToUriList(volumeMap.keySet());
        }
        ctx.setBlockObjects(volumes, _dbClient);
        Collection<URI> inits = StringSetUtil.stringSetToUriList(oldMask.getInitiators());
        Collection<Initiator> initiators = _dbClient.queryObject(Initiator.class, inits);
        ctx.setInitiators(initiators);
        ctx.setAllowExceptions(context == null);
        Collection<StoragePort> ports = _dbClient.queryObject(StoragePort.class, StringSetUtil.stringSetToUriList(portGroup.getStoragePorts()));
        ctx.setPortGroup(portGroup);
        ctx.setStoragePorts(ports);
        validator.changePortGroupAddPaths(ctx).validate();
        String maskName = oldMask.getMaskName();
        String storageGroupName = _helper.getStorageGroupForGivenMaskingView(maskName, storage);
        CIMObjectPath storageGroupPath = _cimPath.getStorageGroupObjectPath(storageGroupName, storage);
        CIMObjectPath igPath = _helper.getInitiatorGroupForGivenMaskingView(maskName, storage);
        CIMObjectPath targetPortGroupPath = _cimPath.getMaskingGroupPath(storage, portGroup.getLabel(), SmisConstants.MASKING_GROUP_TYPE.SE_TargetMaskingGroup);
        createMaskingView(storage, newMaskURI, newMask.getMaskName(), storageGroupPath, new VolumeURIHLU[0], targetPortGroupPath, igPath, completer);
    } catch (Exception e) {
        _log.error(String.format("change port group failed %s", oldMaskURI.toString()), e);
        ServiceError serviceError = DeviceControllerException.errors.jobFailed(e);
        completer.error(_dbClient, serviceError);
    }
}
Also used : StoragePortGroup(com.emc.storageos.db.client.model.StoragePortGroup) ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) StringMap(com.emc.storageos.db.client.model.StringMap) ExportMask(com.emc.storageos.db.client.model.ExportMask) StoragePort(com.emc.storageos.db.client.model.StoragePort) CIMObjectPath(javax.cim.CIMObjectPath) URI(java.net.URI) SmisException(com.emc.storageos.volumecontroller.impl.smis.SmisException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) WBEMException(javax.wbem.WBEMException) ExportMaskValidationContext(com.emc.storageos.volumecontroller.impl.validators.contexts.ExportMaskValidationContext) Initiator(com.emc.storageos.db.client.model.Initiator) ExportOperationContext(com.emc.storageos.volumecontroller.impl.utils.ExportOperationContext)

Aggregations

StoragePortGroup (com.emc.storageos.db.client.model.StoragePortGroup)41 URI (java.net.URI)30 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)16 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)16 ArrayList (java.util.ArrayList)16 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)15 MapStoragePortGroup (com.emc.storageos.api.mapper.functions.MapStoragePortGroup)14 ExportMask (com.emc.storageos.db.client.model.ExportMask)13 StringSet (com.emc.storageos.db.client.model.StringSet)12 HashSet (java.util.HashSet)12 WBEMException (javax.wbem.WBEMException)12 Initiator (com.emc.storageos.db.client.model.Initiator)11 Produces (javax.ws.rs.Produces)10 CheckPermission (com.emc.storageos.security.authorization.CheckPermission)9 Path (javax.ws.rs.Path)9 NamedURI (com.emc.storageos.db.client.model.NamedURI)8 SmisException (com.emc.storageos.volumecontroller.impl.smis.SmisException)8 CIMObjectPath (javax.cim.CIMObjectPath)8 ExportPathParams (com.emc.storageos.db.client.model.ExportPathParams)7 CIMInstance (javax.cim.CIMInstance)7