Search in sources :

Example 66 with Network

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

the class NetworkDeviceController method deleteNetworkSystem.

@Override
public void deleteNetworkSystem(URI network, String taskId) throws ControllerException {
    try {
        NetworkSystem networkDevice = getNetworkSystemObject(network);
        URIQueryResultList epUriList = new URIQueryResultList();
        _dbClient.queryByConstraint(ContainmentConstraint.Factory.getNetworkSystemFCPortConnectionConstraint(network), epUriList);
        while (epUriList.iterator().hasNext()) {
            FCEndpoint connection = _dbClient.queryObject(FCEndpoint.class, epUriList.iterator().next());
            if (connection != null) {
                _dbClient.removeObject(connection);
            }
        }
        List<URI> tzUriList = _dbClient.queryByType(Network.class, true);
        NetworkDiscoveryWorker worker = new NetworkDiscoveryWorker(getDevice(networkDevice.getSystemType()), _dbClient);
        worker.setCoordinator(_coordinator);
        for (URI tzUri : tzUriList) {
            Network tz = _dbClient.queryObject(Network.class, tzUri);
            if (tz != null && (tz.getNetworkSystems() != null && tz.getNetworkSystems().contains(network.toString()))) {
                worker.removeNetworkSystemTransportZone(tz, network.toString());
            }
        }
        if (taskId != null) {
            _dbClient.ready(NetworkSystem.class, network, taskId);
            _auditMgr.recordAuditLog(null, null, EVENT_SERVICE_TYPE, OperationTypeEnum.DELETE_NETWORK_SYSTEM, System.currentTimeMillis(), AuditLogManager.AUDITLOG_SUCCESS, AuditLogManager.AUDITOP_END, networkDevice.getId().toString(), networkDevice.getLabel(), networkDevice.getPortNumber(), networkDevice.getUsername(), networkDevice.getSmisProviderIP(), networkDevice.getSmisPortNumber(), networkDevice.getSmisUserName(), networkDevice.getSmisUseSSL());
        }
    } catch (Exception ex) {
        String msg = MessageFormat.format("Exception encountered while removing FC Port Connection for {0} because: {1}", network, ex.getLocalizedMessage());
        _log.error(msg);
        if (taskId != null) {
            try {
                ServiceError serviceError = NetworkDeviceControllerException.errors.deleteNetworkSystemFailed(network.toString(), ex);
                _dbClient.error(NetworkSystem.class, network, taskId, serviceError);
            } catch (DatabaseException e) {
                _log.error(e.getMessage());
            }
        }
    }
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) Network(com.emc.storageos.db.client.model.Network) NetworkSystem(com.emc.storageos.db.client.model.NetworkSystem) FCEndpoint(com.emc.storageos.db.client.model.FCEndpoint) URI(java.net.URI) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) 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 67 with Network

use of com.emc.storageos.db.client.model.Network 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)

Example 68 with Network

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

the class TransportZoneReconciler method createTransportZone.

private Network createTransportZone(NetworkSystem network, String fabricWwn, String fabricId) {
    Network newTZ = new Network();
    String nativeGuid = NativeGUIDGenerator.generateTransportZoneNativeGuid(Transport.FC.toString(), network.getSystemType(), fabricWwn);
    String prefix = network.getSystemType().equals(NetworkSystem.Type.mds.toString()) ? PREFIX_VSAN : PREFIX_FABRIC;
    newTZ.setId(URIUtil.createId(Network.class));
    newTZ.setLabel(prefix + fabricId);
    newTZ.setNativeId(fabricId);
    newTZ.setTransportType(Transport.FC.toString());
    newTZ.setDiscovered(true);
    newTZ.setNativeGuid(nativeGuid);
    newTZ.setNetworkSystems(new StringSet());
    newTZ.getNetworkSystems().add(network.getId().toString());
    newTZ.setRegistrationStatus(network.getRegistrationStatus());
    return newTZ;
}
Also used : Network(com.emc.storageos.db.client.model.Network) StringSet(com.emc.storageos.db.client.model.StringSet)

Example 69 with Network

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

the class NetworkService method getStoragePorts.

/**
 * This call returns a list of all Storage Ports associated
 * with the Network end points.
 * <p>
 *
 * @param id the URN of a ViPR network
 * @brief List storage ports
 * @return StoragePortList
 */
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@CheckPermission(roles = { Role.SYSTEM_ADMIN, Role.SYSTEM_MONITOR })
@Path("/{id}/storage-ports")
public StoragePortList getStoragePorts(@PathParam("id") URI id) {
    ArgValidator.checkUri(id);
    Network tzone = _dbClient.queryObject(Network.class, id);
    ArgValidator.checkEntityNotNull(tzone, id, isIdEmbeddedInURL(id));
    StoragePortList registeredStoragePorts = new StoragePortList();
    URIQueryResultList storagePortURIs = new URIQueryResultList();
    _dbClient.queryByConstraint(AlternateIdConstraint.Factory.getNetworkStoragePortConstraint(id.toString()), storagePortURIs);
    Iterator<URI> storagePortURIsIter = storagePortURIs.iterator();
    while (storagePortURIsIter.hasNext()) {
        URI storagePortURI = storagePortURIsIter.next();
        StoragePort storagePort = _dbClient.queryObject(StoragePort.class, storagePortURI);
        if (storagePort != null && !storagePort.getInactive()) {
            registeredStoragePorts.getPorts().add(toNamedRelatedResource(storagePort, storagePort.getNativeGuid()));
        }
    }
    return registeredStoragePorts;
}
Also used : Network(com.emc.storageos.db.client.model.Network) MapNetwork(com.emc.storageos.api.mapper.functions.MapNetwork) StoragePort(com.emc.storageos.db.client.model.StoragePort) StoragePortList(com.emc.storageos.model.ports.StoragePortList) URI(java.net.URI) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Example 70 with Network

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

the class NetworkService method deleteNetwork.

/**
 * Deactivate network, this will delete a manually created network. The
 * network must be deregistered and has no endpoints. When force is set to true
 * the network can be deleted even if it has endpoints.
 *
 * @param id the URN of a ViPR Network
 * @param force if set to true will delete a network even if it has endpoints
 * @brief Delete network
 * @return No data returned in response body
 */
@POST
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}/deactivate")
@CheckPermission(roles = { Role.SYSTEM_ADMIN, Role.RESTRICTED_SYSTEM_ADMIN })
public Response deleteNetwork(@PathParam("id") URI id, @QueryParam("force") boolean force) {
    ArgValidator.checkFieldUriType(id, Network.class, "id");
    Network network = _dbClient.queryObject(Network.class, id);
    ArgValidator.checkEntityNotNull(network, id, isIdEmbeddedInURL(id));
    if (!RegistrationStatus.UNREGISTERED.toString().equals(network.getRegistrationStatus())) {
        throw APIException.badRequests.invalidParameterCannotDeactivateRegisteredNetwork(network.getId());
    }
    if (network.getDiscovered()) {
        throw APIException.badRequests.invalidParameterCannotDeleteDiscoveredNetwork(network.getId());
    }
    if (network.getDiscovered() != true && force) {
        // dis-associated the storage port from the network before marking it for deletion
        NetworkAssociationHelper.handleEndpointsRemoved(network, network.retrieveEndpoints(), _dbClient, _coordinator);
        _dbClient.markForDeletion(network);
    } else if (network.getDiscovered() != true && network.retrieveEndpoints() != null && !network.retrieveEndpoints().isEmpty()) {
        throw APIException.badRequests.unableToDeleteNetworkContainsEndpoints();
    } else {
        NetworkAssociationHelper.handleEndpointsRemoved(network, network.retrieveEndpoints(), _dbClient, _coordinator);
        _dbClient.markForDeletion(network);
    }
    recordAndAudit(network, OperationTypeEnum.DELETE_NETWORK);
    return Response.ok().build();
}
Also used : Network(com.emc.storageos.db.client.model.Network) MapNetwork(com.emc.storageos.api.mapper.functions.MapNetwork) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Produces(javax.ws.rs.Produces) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Aggregations

Network (com.emc.storageos.db.client.model.Network)88 URI (java.net.URI)42 ArrayList (java.util.ArrayList)38 StringSet (com.emc.storageos.db.client.model.StringSet)31 VirtualArray (com.emc.storageos.db.client.model.VirtualArray)28 StoragePort (com.emc.storageos.db.client.model.StoragePort)25 StringMap (com.emc.storageos.db.client.model.StringMap)23 List (java.util.List)23 StoragePool (com.emc.storageos.db.client.model.StoragePool)22 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)22 Test (org.junit.Test)20 NamedURI (com.emc.storageos.db.client.model.NamedURI)19 Project (com.emc.storageos.db.client.model.Project)19 VirtualPool (com.emc.storageos.db.client.model.VirtualPool)19 VirtualPoolCapabilityValuesWrapper (com.emc.storageos.volumecontroller.impl.utils.VirtualPoolCapabilityValuesWrapper)19 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)17 TenantOrg (com.emc.storageos.db.client.model.TenantOrg)17 CheckPermission (com.emc.storageos.security.authorization.CheckPermission)16 Produces (javax.ws.rs.Produces)16 RPProtectionRecommendation (com.emc.storageos.volumecontroller.RPProtectionRecommendation)15