Search in sources :

Example 11 with ControllerException

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

the class NetworkDeviceController method zoneExportRemoveInitiators.

/**
 * This will remove zones for all the initiators in the NetworkZoningParam zoneMap.
 * Note: these arguments (except stepId) must match zoneExportRemoveInitiatorsMethod above.
 * This routine executes as a Workflow Step.
 *
 * @param zoningParams -- List of NetworkZoningParam zoning parameter blocks corresponding to ExportMasks
 * @param stepId -- step id in Workflow
 * @return
 * @throws ControllerException
 */
public boolean zoneExportRemoveInitiators(List<NetworkZoningParam> zoningParams, String stepId) throws ControllerException {
    boolean isRollback = WorkflowService.getInstance().isStepInRollbackState(stepId);
    boolean isOperationSuccessful = false;
    TaskCompleter taskCompleter = null;
    if (zoningParams.isEmpty()) {
        _log.info("zoningParams is empty, returning");
        WorkflowStepCompleter.stepSucceded(stepId);
        return true;
    }
    NetworkFCContext context = new NetworkFCContext();
    boolean status = false;
    URI exportGroupId = zoningParams.get(0).getExportGroupId();
    URI virtualArray = zoningParams.get(0).getVirtualArray();
    _log.info(String.format("Entering zoneExportRemoveInitiators for ExportGroup: %s", zoningParams.get(0).getExportGroupDisplay()));
    try {
        if (!checkZoningRequired(stepId, virtualArray)) {
            return true;
        }
        context.setAddingZones(false);
        // Get the zoning targets to be removed.
        List<NetworkFCZoneInfo> zoneInfos = _networkScheduler.getZoningRemoveTargets(zoningParams, null);
        context.getZoneInfos().addAll(zoneInfos);
        logZones(zoneInfos);
        // If there are no zones to do, we were successful.
        if (context.getZoneInfos().isEmpty()) {
            isOperationSuccessful = true;
            WorkflowStepCompleter.stepSucceded(stepId);
            return true;
        }
        // Create a local completer to handle DB cleanup in the case of failure.
        taskCompleter = new ZoneReferencesRemoveCompleter(NetworkUtil.getFCZoneReferences(context.getZoneInfos()), true, stepId);
        InvokeTestFailure.internalOnlyInvokeTestFailure(InvokeTestFailure.ARTIFICIAL_FAILURE_024);
        // Now call removeZones to remove all the required zones.
        BiosCommandResult result = addRemoveZones(exportGroupId, context.getZoneInfos(), true);
        status = result.isCommandSuccess();
        InvokeTestFailure.internalOnlyInvokeTestFailure(InvokeTestFailure.ARTIFICIAL_FAILURE_025);
        // Update the workflow state.
        completeWorkflowState(taskCompleter, stepId, "zoneExportRemoveInitiators", result, null);
        if (result.isCommandSuccess()) {
            isOperationSuccessful = true;
        }
        return status;
    } catch (Exception ex) {
        _log.error("Exception zoning remove initiators", ex);
        ServiceError svcError = NetworkDeviceControllerException.errors.zoneExportRemoveInitiatorsFailed(ex.getMessage(), ex);
        taskCompleter.error(_dbClient, svcError);
        WorkflowStepCompleter.stepFailed(stepId, svcError);
        return status;
    } finally {
        // clean up the zoning map too if the result is success or a rollback
        if (isOperationSuccessful || isRollback) {
            removeInitiatorsFromZoningMap(zoningParams);
        }
    }
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) NetworkFCZoneInfo(com.emc.storageos.networkcontroller.NetworkFCZoneInfo) BiosCommandResult(com.emc.storageos.volumecontroller.impl.BiosCommandResult) TaskCompleter(com.emc.storageos.volumecontroller.TaskCompleter) NetworkFCContext(com.emc.storageos.networkcontroller.NetworkFCContext) ZoneReferencesRemoveCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.ZoneReferencesRemoveCompleter) 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)

Example 12 with ControllerException

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

the class NetworkDeviceController method getAliases.

@Override
public List<ZoneWwnAlias> getAliases(URI uri, String fabricId, String fabricWwn) throws ControllerException {
    NetworkSystem device = getNetworkSystemObject(uri);
    // 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.getAliasesFailedNull(device.getSystemType());
    }
    try {
        List<ZoneWwnAlias> aliases = networkDevice.getAliases(device, fabricId, fabricWwn);
        return aliases;
    } catch (Exception ex) {
        Date date = new Date();
        throw NetworkDeviceControllerException.errors.getAliasesFailedExc(uri.toString(), date.toString(), ex);
    }
}
Also used : NetworkSystem(com.emc.storageos.db.client.model.NetworkSystem) ZoneWwnAlias(com.emc.storageos.networkcontroller.impl.mds.ZoneWwnAlias) 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) Date(java.util.Date)

Example 13 with ControllerException

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

the class NetworkDeviceController method testCommunication.

@Override
public void testCommunication(URI network, String task) throws ControllerException {
    try {
        BiosCommandResult result = doConnect(network);
        if (result.isCommandSuccess()) {
            Operation op = new Operation();
            op.setMessage(result.getMessage());
            _dbClient.ready(NetworkSystem.class, network, task);
        } else {
            String opName = ResourceOperationTypeEnum.UPDATE_NETWORK.getName();
            ServiceError serviceError = NetworkDeviceControllerException.errors.testCommunicationFailed(opName, network.toString());
            _dbClient.error(NetworkSystem.class, network, task, serviceError);
        }
    } catch (Exception e) {
        _log.error("Exception while trying update task status");
        try {
            String opName = ResourceOperationTypeEnum.UPDATE_NETWORK.getName();
            ServiceError serviceError = NetworkDeviceControllerException.errors.testCommunicationFailedExc(opName, network.toString(), e);
            _dbClient.error(NetworkSystem.class, network, task, serviceError);
        } catch (DatabaseException ioe) {
            _log.error(ioe.getMessage());
        }
    }
}
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) Operation(com.emc.storageos.db.client.model.Operation) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) 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 14 with ControllerException

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

the class NetworkDiscoveryWorker method updatePhysicalInventory.

/**
 * Update the network system physical inventory and creates/updates the discovered FC transport
 * zones as needed. The physical inventory is primarily the FCEndpoints (FCPortConnections),
 * which contains a record for each endpoint logged into the Fiber Channel Nameserver database.
 * The endpoints per fabric (vsan) constitute an FC transport zone which get created/updated
 * based on the FCEndpoints discovered.
 *
 * @param uri - Device URI
 */
public void updatePhysicalInventory(URI uri) throws ControllerException {
    // Retrieve the storage device info from the database.
    long start = System.currentTimeMillis();
    NetworkSystem networkDev = getDeviceObject(uri);
    String msg = "unknown status";
    NetworkSystemDevice networkDevice = getDevice();
    if (networkDevice == null) {
        throw NetworkDeviceControllerException.exceptions.updatePhysicalInventoryFailedNull(uri.toString(), networkDev.getSystemType());
    }
    try {
        // === Reconcile the FCEndpoints of this device ===
        List<FCEndpoint> currentConnections = new ArrayList<FCEndpoint>();
        // IN/OUT parameter to get the routed endpoints map - Fabric-WWN-to-endpoints-WWN
        Map<String, Set<String>> routedEndpoints = new HashMap<String, Set<String>>();
        try {
            currentConnections = networkDevice.getPortConnections(networkDev, routedEndpoints);
            msg = MessageFormat.format("Retrieved {0} connections from device {1} at {2}", new Integer(currentConnections.size()), uri, new Date());
            _log.info(msg);
        } catch (Exception e) {
            msg = MessageFormat.format("Discovery failed getting port connections for Network System : {0}", uri.toString());
            throw (e);
        }
        try {
            reconcileFCEndpoints(networkDev, currentConnections);
        } catch (Exception e) {
            msg = MessageFormat.format("Discovery failed reconciling FC endpoints for Network System : {0}", uri.toString());
            throw (e);
        }
        // ==== Reconcile the discovered transport zones ======
        try {
            reconcileTransportZones(networkDev, routedEndpoints);
        } catch (Exception e) {
            msg = MessageFormat.format("Discovery failed reconciling networks for Network System : {0}", uri.toString());
            throw (e);
        }
        try {
            networkDev.setUptime(networkDevice.getUptime(networkDev));
        } catch (Exception e) {
            msg = MessageFormat.format("Discovery failed setting version/uptime for Network System : {0}", uri.toString());
            throw (e);
        }
        // discovery succeeds
        msg = MessageFormat.format("Discovery completed successfully for Network System : {0}", uri.toString());
    } catch (Exception ex) {
        Date date = new Date();
        throw NetworkDeviceControllerException.exceptions.updatePhysicalInventoryFailedExc(uri.toString(), date.toString(), ex);
    } finally {
        if (networkDev != null) {
            try {
                // set detailed message
                networkDev.setLastDiscoveryStatusMessage(msg);
                dbClient.updateObject(networkDev);
                _log.info("Discovery took {}", (System.currentTimeMillis() - start));
            } catch (DatabaseException ex) {
                _log.error("Error while persisting object to DB", ex);
            }
        }
    }
}
Also used : HashSet(java.util.HashSet) Set(java.util.Set) StringSet(com.emc.storageos.db.client.model.StringSet) HashMap(java.util.HashMap) NetworkSystem(com.emc.storageos.db.client.model.NetworkSystem) ArrayList(java.util.ArrayList) FCEndpoint(com.emc.storageos.db.client.model.FCEndpoint) Date(java.util.Date) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) ControllerException(com.emc.storageos.volumecontroller.ControllerException) IOException(java.io.IOException) NetworkDeviceControllerException(com.emc.storageos.networkcontroller.exceptions.NetworkDeviceControllerException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException)

Example 15 with ControllerException

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

the class NetworkDiscoveryWorker method reconcileTransportZones.

/**
 * Given the updated list of end points for one network system, this function will update
 * the transport zones.
 * Require lock when reconciles vsan in fabrics that are linked through ISL. Without locking, multiple VSANs
 * could have same native gui id within the same fabric.
 *
 * @param networkSystem the network system
 * @param routedEndpoints IN/OUT parameter to get the routed endpoints map of Fabric-WWN-to-endpoints-WWN
 * @throws ControllerException
 */
private void reconcileTransportZones(NetworkSystem networkSystem, Map<String, Set<String>> routedEndpoints) throws ControllerException {
    _log.info("reconcileTransportZones for networkSystem {}", networkSystem.getId());
    ControllerServiceImpl.Lock lock = ControllerServiceImpl.Lock.getLock(ControllerServiceImpl.DISCOVERY_RECONCILE_TZ);
    try {
        _log.debug("Acquiring lock to reconcile transport zone for networkSystem {}", networkSystem.getId());
        lock.acquire();
        _log.info("Acquired lock to reconcile transport zone for networkSystem {}", networkSystem.getId());
        // get the network system's connections from the database
        Iterator<FCEndpoint> iNewEndPoints = getNetworkSystemEndPoints(networkSystem);
        // get all the transport zones we have in the DB
        List<Network> oldTransportZones = NetworkUtil.getDiscoveredNetworks(dbClient);
        _log.info("Found {} existing transport zones", oldTransportZones.size());
        // get the fabrics that exist on the network system
        Map<String, String> fabricIdsMap = getDevice().getFabricIdsMap(networkSystem);
        // get the list of fabrics added, removed, changed
        TransportZoneReconciler reconciler = new TransportZoneReconciler();
        TransportZoneReconciler.Results results = reconciler.reconcile(networkSystem, iNewEndPoints, fabricIdsMap, oldTransportZones);
        String networkSystemUri = networkSystem.getId().toString();
        for (Network tzone : results.getRemoved()) {
            List<String> removedEps = removeNetworkSystemTransportZone(tzone, networkSystemUri);
            _log.info("Removed network {} which removed discovered endpoints {}", tzone.getNativeGuid(), removedEps);
        }
        for (Network tzone : results.getAdded()) {
            handleEndpointsAdded(tzone, tzone.retrieveEndpoints());
            saveTransportZone(tzone, true);
        }
        for (Network tzone : results.getModified()) {
            if (results.getRemovedEndPoints().get(tzone) != null) {
                NetworkAssociationHelper.handleEndpointsRemoved(tzone, results.getRemovedEndPoints().get(tzone), dbClient, _coordinator);
            }
            if (results.getAddedEndPoints().get(tzone) != null) {
                handleEndpointsAdded(tzone, results.getAddedEndPoints().get(tzone));
            }
            saveTransportZone(tzone, false);
        }
        // update routed networks for routed and modified networks
        updateRoutedNetworks(networkSystem, results.getAddedAndModified(), routedEndpoints);
    } catch (Exception ex) {
        throw NetworkDeviceControllerException.exceptions.reconcileTransportZonesFailedExc(new Date().toString(), ex);
    } finally {
        try {
            _log.debug("Releasing reconcile transport zone lock for networkSystem {}", networkSystem.getId());
            lock.release();
            _log.info("Released reconcile transport zone lock for networkSystem {}", networkSystem.getId());
        } catch (Exception e) {
            _log.error("Failed to release  Lock while reconcile transport zone for network {} -->{}", networkSystem.getId(), e.getMessage());
        }
    }
}
Also used : FCEndpoint(com.emc.storageos.db.client.model.FCEndpoint) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) ControllerException(com.emc.storageos.volumecontroller.ControllerException) IOException(java.io.IOException) NetworkDeviceControllerException(com.emc.storageos.networkcontroller.exceptions.NetworkDeviceControllerException) Date(java.util.Date) ControllerServiceImpl(com.emc.storageos.volumecontroller.impl.ControllerServiceImpl) Network(com.emc.storageos.db.client.model.Network)

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