Search in sources :

Example 36 with NetworkSystem

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

the class NetworkDeviceController method updateAliases.

@Override
public void updateAliases(URI uri, String fabricId, String fabricWwn, List<ZoneWwnAliasUpdate> updateAliases, 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.updateAliasesFailedNull(device.getSystemType());
        }
        BiosCommandResult result = networkDevice.updateAliases(device, updateAliases, fabricId, fabricWwn);
        setStatus(NetworkSystem.class, device.getId(), taskId, result.isCommandSuccess(), result.getServiceCoded());
        _auditMgr.recordAuditLog(null, null, EVENT_SERVICE_TYPE, OperationTypeEnum.UPDATE_ALIAS, 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.updateAliasesFailedExc(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 37 with NetworkSystem

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

the class NetworkDeviceController method addAliases.

@Override
public void addAliases(URI uri, String fabricId, String fabricWwn, List<ZoneWwnAlias> aliases, 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.addAliasesFailedNull(device.getSystemType());
        }
        BiosCommandResult result = networkDevice.addAliases(device, aliases, fabricId, fabricWwn);
        setStatus(NetworkSystem.class, device.getId(), taskId, result.isCommandSuccess(), result.getServiceCoded());
        _auditMgr.recordAuditLog(null, null, EVENT_SERVICE_TYPE, OperationTypeEnum.ADD_ALIAS, 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.addAliasesFailedExc(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 38 with NetworkSystem

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

the class NetworkDeviceController method removeAliases.

@Override
public void removeAliases(URI uri, String fabricId, String fabricWwn, List<ZoneWwnAlias> aliases, 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.removeAliasesFailedNull(device.getSystemType());
        }
        BiosCommandResult result = networkDevice.removeAliases(device, aliases, fabricId, fabricWwn);
        setStatus(NetworkSystem.class, device.getId(), taskId, result.isCommandSuccess(), result.getServiceCoded());
        _auditMgr.recordAuditLog(null, null, EVENT_SERVICE_TYPE, OperationTypeEnum.REMOVE_ALIAS, 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.removeAliasesFailedExc(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 39 with NetworkSystem

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

the class NetworkDiscoveryWorker method verifyVersion.

/**
 * Verify the firmware version for the NetworkSystem
 *
 * @param uri - Device URI
 * @throws ControllerException thrown if firmware version is not supported
 */
public void verifyVersion(URI uri) throws ControllerException {
    // Retrieve the storage device info from the database.
    NetworkSystem networkDev = getDeviceObject(uri);
    NetworkSystemDevice networkDevice = getDevice();
    if (networkDevice == null) {
        throw NetworkDeviceControllerException.exceptions.verifyVersionFailedNull(uri.toString());
    }
    String version = null;
    try {
        version = networkDevice.getVersion(networkDev);
        networkDev.setVersion(version);
        String minimumSupportedVersion = VersionChecker.getMinimumSupportedVersion(Type.valueOf(networkDev.getSystemType()));
        _log.info("Verifying version details : Minimum Supported Version {} - Discovered Firmware Version {}", minimumSupportedVersion, version);
        if (VersionChecker.verifyVersionDetails(minimumSupportedVersion, version) < 0) {
            networkDev.setCompatibilityStatus(DiscoveredDataObject.CompatibilityStatus.INCOMPATIBLE.name());
            throw NetworkDeviceControllerException.exceptions.versionNotSupported(version, minimumSupportedVersion);
        } else {
            networkDev.setCompatibilityStatus(DiscoveredDataObject.CompatibilityStatus.COMPATIBLE.name());
        }
    } catch (Exception ex) {
        Date date = new Date();
        networkDev.setLastDiscoveryStatusMessage(ex.getMessage());
        throw NetworkDeviceControllerException.exceptions.verifyVersionFailed(uri.toString(), date.toString(), ex);
    } finally {
        if (networkDev != null) {
            try {
                dbClient.updateObject(networkDev);
            } catch (DatabaseException ex) {
                _log.error("Error while persisting object to DB", ex);
            }
        }
    }
}
Also used : NetworkSystem(com.emc.storageos.db.client.model.NetworkSystem) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) 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)

Example 40 with NetworkSystem

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

the class NetworkDiscoveryWorker method updateRoutedNetworks.

/**
 * Looks in the topology view for endpoints that accessible by routing
 *
 * @param networkSystem the network system being refreshed
 * @param updatedNetworks the networks that require updating
 * @param routedEndpoints the routed endpoints map of Fabric-WWN-to-endpoints-WWN
 * @throws Exception
 */
private void updateRoutedNetworks(NetworkSystem networkSystem, List<Network> updatedNetworks, Map<String, Set<String>> routedEndpoints) throws Exception {
    if (!this.getDevice().isCapableOfRouting(networkSystem)) {
        _log.info("NetworkSystem {} does not support routing across VSANs, skipping routed networks update/discovery", networkSystem.getLabel());
        // Clear out the routedNetworks entries, if filled, for non-IVR Cisco switches. This can happen in upgrade scenarios.
        URIQueryResultList networkSystemNetworkUriList = new URIQueryResultList();
        dbClient.queryByConstraint(ContainmentConstraint.Factory.getNetworkSystemNetworkConstraint(networkSystem.getId()), networkSystemNetworkUriList);
        for (URI networkSystemNetworkUri : networkSystemNetworkUriList) {
            Network networkSystemNetwork = dbClient.queryObject(Network.class, networkSystemNetworkUri);
            boolean isNetworkConnectedToRoutableSwitch = false;
            for (String ns : networkSystemNetwork.getNetworkSystems()) {
                NetworkSystem connectedNetworkSystem = dbClient.queryObject(NetworkSystem.class, URI.create(ns));
                if (this.getDevice().isCapableOfRouting(connectedNetworkSystem)) {
                    isNetworkConnectedToRoutableSwitch = true;
                    ;
                }
            }
            // to another switch that supports routing.
            if (!isNetworkConnectedToRoutableSwitch) {
                _log.info("Updating routedNetwork to null for {}", networkSystemNetwork.getLabel());
                networkSystemNetwork.setRoutedNetworks(null);
                dbClient.updateObject(networkSystemNetwork);
            }
        }
        // Update the connected varray assignments
        _log.info("Updating connected network and varray assignments");
        for (Network network : DataObjectUtils.toMap(NetworkUtil.getDiscoveredNetworks(dbClient)).values()) {
            NetworkAssociationHelper.setNetworkConnectedVirtualArrays(network, false, dbClient);
        }
        return;
    }
    Map<URI, Network> allNetworks = DataObjectUtils.toMap(NetworkUtil.getDiscoveredNetworks(dbClient));
    // Determine routed networks. We get here only for switches that have IVR feature enabled.
    getDevice().determineRoutedNetworks(networkSystem);
    for (Network network : allNetworks.values()) {
        NetworkAssociationHelper.setNetworkConnectedVirtualArrays(network, false, dbClient);
    }
}
Also used : Network(com.emc.storageos.db.client.model.Network) NetworkSystem(com.emc.storageos.db.client.model.NetworkSystem) URI(java.net.URI) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList)

Aggregations

NetworkSystem (com.emc.storageos.db.client.model.NetworkSystem)54 MapNetworkSystem (com.emc.storageos.api.mapper.functions.MapNetworkSystem)21 CheckPermission (com.emc.storageos.security.authorization.CheckPermission)20 Produces (javax.ws.rs.Produces)20 ArrayList (java.util.ArrayList)19 Path (javax.ws.rs.Path)18 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)16 NetworkDeviceControllerException (com.emc.storageos.networkcontroller.exceptions.NetworkDeviceControllerException)16 ControllerException (com.emc.storageos.volumecontroller.ControllerException)16 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)13 URI (java.net.URI)13 NetworkController (com.emc.storageos.networkcontroller.NetworkController)11 BiosCommandResult (com.emc.storageos.volumecontroller.impl.BiosCommandResult)10 Consumes (javax.ws.rs.Consumes)10 POST (javax.ws.rs.POST)10 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)9 Operation (com.emc.storageos.db.client.model.Operation)8 ZoneMember (com.emc.storageos.networkcontroller.impl.mds.ZoneMember)8 InterProcessLock (org.apache.curator.framework.recipes.locks.InterProcessLock)8 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)7