Search in sources :

Example 16 with ControllerException

use of com.emc.storageos.volumecontroller.ControllerException in project coprhd-controller by CoprHD.

the class NetworkDeviceController method addSanZones.

@Override
public void addSanZones(URI uri, String fabricId, String fabricWwn, List<Zone> zones, boolean activateZones, String taskId) throws ControllerException {
    NetworkSystem device = getNetworkSystemObject(uri);
    // Lock to prevent concurrent operations on the same VSAN / FABRIC.
    InterProcessLock fabricLock = NetworkFabricLocker.lockFabric(fabricId, _coordinator);
    try {
        // Get the file device reference for the type of file device managed
        // by the controller.
        NetworkSystemDevice networkDevice = getDevice(device.getSystemType());
        if (networkDevice == null) {
            throw NetworkDeviceControllerException.exceptions.addSanZonesFailedNull(device.getSystemType());
        }
        BiosCommandResult result = networkDevice.addZones(device, zones, fabricId, fabricWwn, activateZones);
        setStatus(NetworkSystem.class, device.getId(), taskId, result.isCommandSuccess(), result.getServiceCoded());
        _auditMgr.recordAuditLog(null, null, EVENT_SERVICE_TYPE, OperationTypeEnum.ADD_SAN_ZONE, System.currentTimeMillis(), AuditLogManager.AUDITLOG_SUCCESS, AuditLogManager.AUDITOP_END, device.getId().toString(), device.getLabel(), device.getPortNumber(), device.getUsername(), device.getSmisProviderIP(), device.getSmisPortNumber(), device.getSmisUserName(), device.getSmisUseSSL());
    } catch (Exception ex) {
        ServiceError serviceError = NetworkDeviceControllerException.errors.addSanZonesFailedExc(device.getSystemType(), ex);
        _dbClient.error(NetworkSystem.class, device.getId(), taskId, serviceError);
    } finally {
        NetworkFabricLocker.unlockFabric(fabricId, fabricLock);
    }
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) BiosCommandResult(com.emc.storageos.volumecontroller.impl.BiosCommandResult) NetworkSystem(com.emc.storageos.db.client.model.NetworkSystem) InterProcessLock(org.apache.curator.framework.recipes.locks.InterProcessLock) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) ControllerException(com.emc.storageos.volumecontroller.ControllerException) NetworkDeviceControllerException(com.emc.storageos.networkcontroller.exceptions.NetworkDeviceControllerException)

Example 17 with ControllerException

use of com.emc.storageos.volumecontroller.ControllerException in project coprhd-controller by CoprHD.

the class NetworkDeviceController method removeZone.

/**
 * Remove a zone.
 *
 * @param volUri URI of the Volume
 * @param fabricInfo NetworkFabricInfo generated by NetworkScheduler
 * @return BiosCommandResult
 */
public BiosCommandResult removeZone(URI volUri, NetworkFCZoneInfo fabricInfo, boolean activateZones) throws ControllerException {
    ServiceError serviceError = NetworkDeviceControllerException.errors.zoningFailedArgs(volUri.toString());
    BiosCommandResult result = BiosCommandResult.createErrorResult(serviceError);
    List<Zone> zones = new ArrayList<Zone>();
    Zone zone = new Zone(fabricInfo.getZoneName());
    zones.add(zone);
    String taskId = UUID.randomUUID().toString();
    for (String address : fabricInfo.getEndPoints()) {
        ZoneMember member = new ZoneMember(address, ConnectivityMemberType.WWPN);
        zone.getMembers().add(member);
    }
    // Lock to prevent concurrent operations on the same VSAN / FABRIC.
    InterProcessLock fabricLock = NetworkFabricLocker.lockFabric(fabricInfo.getFabricId(), _coordinator);
    try {
        NetworkSystem device = getNetworkSystemObject(fabricInfo.getNetworkDeviceId());
        // Get the file device reference for the type of file device managed
        // by the controller.
        NetworkSystemDevice networkDevice = getDevice(device.getSystemType());
        if (networkDevice == null) {
            throw NetworkDeviceControllerException.exceptions.removeZoneFailedNull(device.getSystemType());
        }
        if (fabricInfo.isLastReference() == true && !fabricInfo.isExistingZone()) {
            result = networkDevice.removeZones(device, zones, fabricInfo.getFabricId(), fabricInfo.getFabricWwn(), activateZones);
        } else {
            // This is not the last reference, just mark our FCZoneReference for deletion
            result = BiosCommandResult.createSuccessfulResult();
        }
        if (result.isCommandSuccess()) {
            if (fabricInfo.getFcZoneReferenceId() != null) {
                try {
                    // Mark our FcZoneReference object for removal
                    FCZoneReference reference = _dbClient.queryObject(FCZoneReference.class, fabricInfo.getFcZoneReferenceId());
                    if (reference != null) {
                        _dbClient.markForDeletion(reference);
                        recordZoneEvent(reference, OperationTypeEnum.REMOVE_SAN_ZONE.name(), OperationTypeEnum.REMOVE_SAN_ZONE.getDescription());
                    }
                } catch (Exception ex) {
                    _log.error("Can't mark object for removal: " + fabricInfo.getFcZoneReferenceId());
                }
            }
        }
        if (!result.isCommandSuccess()) {
            ServiceError svcError = NetworkDeviceControllerException.errors.removeZoneFailed(volUri.toString(), device.getSystemType());
            setStatus(Volume.class, volUri, taskId, false, svcError);
        } else {
            setStatus(Volume.class, volUri, taskId, true, null);
        }
    } catch (ControllerException ex) {
        _log.info("waiting for 2 min before retrying removeZone with alternate device");
        try {
            Thread.sleep(1000 * 120);
        } catch (InterruptedException e) {
            _log.warn("Thread sleep interrupted.  Allowing to continue without sleep");
        }
        URI primaryUri = fabricInfo.getNetworkDeviceId();
        URI altUri = fabricInfo.getAltNetworkDeviceId();
        if (altUri != null && altUri != primaryUri) {
            NetworkFabricLocker.unlockFabric(fabricInfo.getFabricId(), fabricLock);
            fabricLock = null;
            _log.error("Remove Zone failed using device: " + primaryUri + " retrying with alternate device: " + altUri);
            fabricInfo.setNetworkDeviceId(altUri);
            return removeZone(volUri, fabricInfo, activateZones);
        } else {
            ServiceError svcError = NetworkDeviceControllerException.errors.removeZoneFailedExc(volUri.toString());
            setStatus(Volume.class, volUri, taskId, false, svcError);
            throw ex;
        }
    } finally {
        NetworkFabricLocker.unlockFabric(fabricInfo.getFabricId(), fabricLock);
    }
    return result;
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) ControllerException(com.emc.storageos.volumecontroller.ControllerException) NetworkDeviceControllerException(com.emc.storageos.networkcontroller.exceptions.NetworkDeviceControllerException) Zone(com.emc.storageos.networkcontroller.impl.mds.Zone) ArrayList(java.util.ArrayList) NetworkSystem(com.emc.storageos.db.client.model.NetworkSystem) URI(java.net.URI) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) ControllerException(com.emc.storageos.volumecontroller.ControllerException) NetworkDeviceControllerException(com.emc.storageos.networkcontroller.exceptions.NetworkDeviceControllerException) FCZoneReference(com.emc.storageos.db.client.model.FCZoneReference) Volume(com.emc.storageos.db.client.model.Volume) BiosCommandResult(com.emc.storageos.volumecontroller.impl.BiosCommandResult) ZoneMember(com.emc.storageos.networkcontroller.impl.mds.ZoneMember) InterProcessLock(org.apache.curator.framework.recipes.locks.InterProcessLock)

Example 18 with ControllerException

use of com.emc.storageos.volumecontroller.ControllerException in project coprhd-controller by CoprHD.

the class BlockDeviceController method expandVolume.

@Override
public void expandVolume(URI storage, URI pool, URI volume, Long size, String opId) throws ControllerException {
    try {
        StorageSystem storageObj = _dbClient.queryObject(StorageSystem.class, storage);
        Volume volumeObj = _dbClient.queryObject(Volume.class, volume);
        _log.info(String.format("expandVolume start - Array: %s Pool:%s Volume:%s, IsMetaVolume: %s, OldSize: %s, NewSize: %s", storage.toString(), pool.toString(), volume.toString(), volumeObj.getIsComposite(), volumeObj.getCapacity(), size));
        StoragePool poolObj = _dbClient.queryObject(StoragePool.class, pool);
        VolumeExpandCompleter completer = new VolumeExpandCompleter(volume, size, opId);
        long metaMemberSize = volumeObj.getIsComposite() ? volumeObj.getMetaMemberSize() : volumeObj.getCapacity();
        long metaCapacity = volumeObj.getIsComposite() ? volumeObj.getTotalMetaMemberCapacity() : volumeObj.getCapacity();
        VirtualPool vpool = _dbClient.queryObject(VirtualPool.class, volumeObj.getVirtualPool());
        boolean isThinlyProvisioned = volumeObj.getThinlyProvisioned();
        MetaVolumeRecommendation recommendation = MetaVolumeUtils.getExpandRecommendation(storageObj, poolObj, metaCapacity, size, metaMemberSize, isThinlyProvisioned, vpool.getFastExpansion());
        if (recommendation.isCreateMetaVolumes()) {
            // Also check that this is not recovery to clean dangling meta volumes with zero-capacity expansion.
            if (recommendation.getMetaMemberCount() == 0 && (volumeObj.getMetaVolumeMembers() == null || volumeObj.getMetaVolumeMembers().isEmpty())) {
                volumeObj.setCapacity(size);
                _dbClient.updateObject(volumeObj);
                _log.info(String.format("Expanded volume within its total meta volume capacity (simple case) - Array: %s Pool:%s Volume:%s, IsMetaVolume: %s, Total meta volume capacity: %s, NewSize: %s", storage.toString(), pool.toString(), volume.toString(), volumeObj.getIsComposite(), volumeObj.getTotalMetaMemberCapacity(), volumeObj.getCapacity()));
                completer.ready(_dbClient);
            } else {
                // set meta related data in task completer
                long metaMemberCount = volumeObj.getIsComposite() ? recommendation.getMetaMemberCount() + volumeObj.getMetaMemberCount() : recommendation.getMetaMemberCount() + 1;
                completer.setMetaMemberSize(recommendation.getMetaMemberSize());
                completer.setMetaMemberCount((int) metaMemberCount);
                completer.setTotalMetaMembersSize(metaMemberCount * recommendation.getMetaMemberSize());
                completer.setComposite(true);
                completer.setMetaVolumeType(recommendation.getMetaVolumeType().toString());
                getDevice(storageObj.getSystemType()).doExpandAsMetaVolume(storageObj, poolObj, volumeObj, size, recommendation, completer);
            }
        } else {
            // expand as regular volume
            InvokeTestFailure.internalOnlyInvokeTestFailure(InvokeTestFailure.ARTIFICIAL_FAILURE_080);
            getDevice(storageObj.getSystemType()).doExpandVolume(storageObj, poolObj, volumeObj, size, completer);
        }
        _log.info(String.format("expandVolume end - Array: %s Pool:%s Volume:%s", storage.toString(), pool.toString(), volume.toString()));
    } catch (Exception e) {
        _log.error(String.format("expandVolume Failed - Array: %s Pool:%s Volume:%s", storage.toString(), pool.toString(), volume.toString()), e);
        ServiceError serviceError = DeviceControllerException.errors.jobFailed(e);
        List<URI> volumes = Arrays.asList(volume);
        doFailTask(Volume.class, volumes, opId, serviceError);
        WorkflowStepCompleter.stepFailed(opId, serviceError);
    }
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) StoragePool(com.emc.storageos.db.client.model.StoragePool) Volume(com.emc.storageos.db.client.model.Volume) VolumeExpandCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.VolumeExpandCompleter) Arrays.asList(java.util.Arrays.asList) ApplicationAddVolumeList(com.emc.storageos.volumecontroller.ApplicationAddVolumeList) ArrayList(java.util.ArrayList) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) List(java.util.List) VirtualPool(com.emc.storageos.db.client.model.VirtualPool) MetaVolumeRecommendation(com.emc.storageos.volumecontroller.impl.smis.MetaVolumeRecommendation) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException) ControllerException(com.emc.storageos.volumecontroller.ControllerException) WorkflowException(com.emc.storageos.workflow.WorkflowException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) DataBindingException(javax.xml.bind.DataBindingException) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 19 with ControllerException

use of com.emc.storageos.volumecontroller.ControllerException in project coprhd-controller by CoprHD.

the class BlockDeviceController method createMirror.

/**
 * {@inheritDoc} NOTE NOTE: The signature here MUST match the Workflow.Method createMirrorMethod just above (except
 * opId).
 */
@Override
public void createMirror(URI storage, List<URI> mirrorList, Boolean isCG, Boolean createInactive, String opId) throws ControllerException {
    TaskCompleter completer = null;
    try {
        WorkflowStepCompleter.stepExecuting(opId);
        StorageSystem storageObj = _dbClient.queryObject(StorageSystem.class, storage);
        if (!isCG && mirrorList.size() == 1) {
            completer = new BlockMirrorCreateCompleter(mirrorList.get(0), opId);
            getDevice(storageObj.getSystemType()).doCreateMirror(storageObj, mirrorList.get(0), createInactive, completer);
        } else {
            boolean isListReplicaFlow = false;
            BlockMirror mirrorObj = _dbClient.queryObject(BlockMirror.class, mirrorList.get(0));
            Volume sourceVolume = _dbClient.queryObject(Volume.class, mirrorObj.getSource().getURI());
            /**
             * VPLEX/RP CG volumes may not be having back end Array Group.
             * In this case we should create element replica using createListReplica.
             * We should not use createGroup replica as backend cg will not be available in this case.
             */
            isListReplicaFlow = isListReplicaFlow(sourceVolume);
            completer = new BlockMirrorCreateCompleter(mirrorList, opId);
            if (!isListReplicaFlow) {
                getDevice(storageObj.getSystemType()).doCreateGroupMirrors(storageObj, mirrorList, createInactive, completer);
            } else {
                // List Replica
                getDevice(storageObj.getSystemType()).doCreateListReplica(storageObj, mirrorList, createInactive, completer);
            }
        }
    } catch (Exception e) {
        ServiceError serviceError = DeviceControllerException.errors.jobFailed(e);
        if (completer != null) {
            completer.error(_dbClient, serviceError);
        }
        WorkflowStepCompleter.stepFailed(opId, serviceError);
    }
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) BlockMirror(com.emc.storageos.db.client.model.BlockMirror) Volume(com.emc.storageos.db.client.model.Volume) ScanTaskCompleter(com.emc.storageos.volumecontroller.impl.plugins.discovery.smis.ScanTaskCompleter) BlockSnapshotEstablishGroupTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.BlockSnapshotEstablishGroupTaskCompleter) BlockMirrorTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.BlockMirrorTaskCompleter) CloneTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.CloneTaskCompleter) ApplicationTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.ApplicationTaskCompleter) SimpleTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.SimpleTaskCompleter) VolumeTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.VolumeTaskCompleter) DiscoverTaskCompleter(com.emc.storageos.volumecontroller.impl.plugins.discovery.smis.DiscoverTaskCompleter) TaskCompleter(com.emc.storageos.volumecontroller.TaskCompleter) MultiVolumeTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.MultiVolumeTaskCompleter) BlockMirrorCreateCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.BlockMirrorCreateCompleter) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException) ControllerException(com.emc.storageos.volumecontroller.ControllerException) WorkflowException(com.emc.storageos.workflow.WorkflowException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) DataBindingException(javax.xml.bind.DataBindingException) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 20 with ControllerException

use of com.emc.storageos.volumecontroller.ControllerException in project coprhd-controller by CoprHD.

the class BlockDeviceController method establishVolumeSnapshotGroupRelation.

public void establishVolumeSnapshotGroupRelation(URI storage, URI sourceVolume, URI snapshot, String opId) throws ControllerException {
    try {
        WorkflowStepCompleter.stepExecuting(opId);
        StorageSystem storageObj = _dbClient.queryObject(StorageSystem.class, storage);
        TaskCompleter completer = new BlockSnapshotEstablishGroupTaskCompleter(snapshot, opId);
        getDevice(storageObj.getSystemType()).doEstablishVolumeSnapshotGroupRelation(storageObj, sourceVolume, snapshot, completer);
    } catch (Exception e) {
        ServiceError serviceError = DeviceControllerException.errors.jobFailed(e);
        WorkflowStepCompleter.stepFailed(opId, serviceError);
    }
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) BlockSnapshotEstablishGroupTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.BlockSnapshotEstablishGroupTaskCompleter) ScanTaskCompleter(com.emc.storageos.volumecontroller.impl.plugins.discovery.smis.ScanTaskCompleter) BlockSnapshotEstablishGroupTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.BlockSnapshotEstablishGroupTaskCompleter) BlockMirrorTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.BlockMirrorTaskCompleter) CloneTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.CloneTaskCompleter) ApplicationTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.ApplicationTaskCompleter) SimpleTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.SimpleTaskCompleter) VolumeTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.VolumeTaskCompleter) DiscoverTaskCompleter(com.emc.storageos.volumecontroller.impl.plugins.discovery.smis.DiscoverTaskCompleter) TaskCompleter(com.emc.storageos.volumecontroller.TaskCompleter) MultiVolumeTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.MultiVolumeTaskCompleter) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException) ControllerException(com.emc.storageos.volumecontroller.ControllerException) WorkflowException(com.emc.storageos.workflow.WorkflowException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) DataBindingException(javax.xml.bind.DataBindingException) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Aggregations

ControllerException (com.emc.storageos.volumecontroller.ControllerException)299 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)280 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)211 WorkflowException (com.emc.storageos.workflow.WorkflowException)188 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)182 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)151 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)121 ArrayList (java.util.ArrayList)93 URI (java.net.URI)87 TaskCompleter (com.emc.storageos.volumecontroller.TaskCompleter)75 Workflow (com.emc.storageos.workflow.Workflow)68 URISyntaxException (java.net.URISyntaxException)63 Volume (com.emc.storageos.db.client.model.Volume)62 BaseCollectionException (com.emc.storageos.plugins.BaseCollectionException)61 DataBindingException (javax.xml.bind.DataBindingException)61 VolumeTaskCompleter (com.emc.storageos.volumecontroller.impl.block.taskcompleter.VolumeTaskCompleter)55 CloneTaskCompleter (com.emc.storageos.volumecontroller.impl.block.taskcompleter.CloneTaskCompleter)52 SMBFileShare (com.emc.storageos.db.client.model.SMBFileShare)51 NamedURI (com.emc.storageos.db.client.model.NamedURI)50 FileShare (com.emc.storageos.db.client.model.FileShare)49