Search in sources :

Example 86 with Network

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

the class NetworkUtil method getNetworkLiteByFabricId.

/**
 * Given the fabric name for a Network, obtain its NetworkLite structure.
 * This is done without instantiating the endpoint data in the Network
 * by calling DbClient.queryObjectFields, which retrieves only certain
 * fields from the database.
 *
 * @param fabricId
 * @param client
 * @return NetworkLite
 */
public static NetworkLite getNetworkLiteByFabricId(String fabricId, String fabricWWN, DbClient client) {
    if (fabricId != null && fabricId.length() > 0) {
        URIQueryResultList networkList = new URIQueryResultList();
        client.queryByConstraint(AlternateIdConstraint.Factory.getConstraint(Network.class, "nativeId", fabricId), networkList);
        for (URI uri : networkList) {
            // TODO -need to add check for inactive networks - Need to add code to try using WWN
            return getNetworkLite(uri, client);
        }
    }
    return null;
}
Also used : Network(com.emc.storageos.db.client.model.Network) URI(java.net.URI) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList)

Example 87 with Network

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

the class NetworkUtil method getDiscoveredNetworks.

/**
 * Get all the current networks in the database
 */
public static List<Network> getDiscoveredNetworks(DbClient dbClient) throws Exception {
    List<Network> networks = new ArrayList<Network>();
    List<URI> uriNetworksList = dbClient.queryByType(Network.class, true);
    Iterator<Network> iNetworks = dbClient.queryIterativeObjects(Network.class, uriNetworksList);
    while (iNetworks.hasNext()) {
        Network network = iNetworks.next();
        if (network != null && Transport.FC.toString().equals(network.getTransportType())) {
            networks.add(network);
        }
    }
    return networks;
}
Also used : Network(com.emc.storageos.db.client.model.Network) ArrayList(java.util.ArrayList) URI(java.net.URI)

Example 88 with Network

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

the class ControllerUtils method convertToRecordableBourneEvent.

/**
 * Create a new instance of RecordableBourneEvent with the given resource
 * and properties.
 *
 * @param resource
 *            - Type of Resource - File or Volume
 * @param type
 *            - Event Type Enum
 * @param description
 *            - Description of event if available
 * @param extensions
 *            - Extensions mapped with Event Model Extensions
 * @param eventServiceSource
 *            - URI of the Project
 * @param dbClient
 *            - DBClient reference
 * @param evtServiceType
 *            - Service Type
 * @param recordType
 *            - Type of Indication
 * @return RecordableBourneEvent
 */
public static RecordableBourneEvent convertToRecordableBourneEvent(DataObject resource, String type, String description, String extensions, DbClient dbClient, String evtServiceType, String recordType, String eventServiceSource) {
    URI cos = null;
    URI id = null;
    String nativeGuid = null;
    URI projectURI = null;
    URI tenantURI = null;
    RecordableBourneEvent event = null;
    if (resource != null) {
        if (resource instanceof Volume) {
            Volume volume = (Volume) resource;
            cos = volume.getVirtualPool();
            id = volume.getId();
            nativeGuid = volume.getNativeGuid();
            projectURI = volume.getProject().getURI();
            tenantURI = volume.getTenant().getURI();
        } else if (resource instanceof FileShare) {
            FileShare fs = (FileShare) resource;
            cos = fs.getVirtualPool();
            id = fs.getId();
            nativeGuid = fs.getNativeGuid();
            projectURI = (fs.getProject() != null) ? fs.getProject().getURI() : null;
            tenantURI = (fs.getTenant() != null) ? fs.getTenant().getURI() : null;
        } else if (resource instanceof VplexMirror) {
            VplexMirror vplexMirror = (VplexMirror) resource;
            cos = vplexMirror.getVirtualPool();
            id = vplexMirror.getId();
            projectURI = vplexMirror.getProject().getURI();
            tenantURI = vplexMirror.getTenant().getURI();
        } else if (resource instanceof BlockSnapshot) {
            BlockSnapshot snapshot = (BlockSnapshot) resource;
            try {
                if (!NullColumnValueGetter.isNullNamedURI(snapshot.getParent())) {
                    Volume volume = dbClient.queryObject(Volume.class, snapshot.getParent());
                    cos = volume.getVirtualPool();
                    tenantURI = (volume.getTenant() != null) ? volume.getTenant().getURI() : null;
                }
                id = snapshot.getId();
                nativeGuid = snapshot.getNativeGuid();
                projectURI = snapshot.getProject().getURI();
            } catch (DatabaseException e) {
                s_logger.error("Exception caught", e);
            }
        } else if (resource instanceof BlockSnapshotSession) {
            BlockSnapshotSession session = (BlockSnapshotSession) resource;
            try {
                id = session.getId();
                projectURI = session.getProject().getURI();
            } catch (DatabaseException e) {
                s_logger.error("Exception caught", e);
            }
        } else if (resource instanceof ExportGroup) {
            ExportGroup exportGroup = (ExportGroup) resource;
            try {
                id = exportGroup.getId();
                projectURI = exportGroup.getProject().getURI();
                tenantURI = (exportGroup.getTenant() != null) ? exportGroup.getTenant().getURI() : null;
            } catch (Exception e) {
                s_logger.error("Exception caught", e);
            }
        } else if (resource instanceof FCZoneReference) {
            FCZoneReference zone = (FCZoneReference) resource;
            try {
                id = zone.getId();
            } catch (Exception e) {
                s_logger.error("Exception caught", e);
            }
        } else if (resource instanceof Network) {
            Network tz = (Network) resource;
            id = tz.getId();
            nativeGuid = tz.getNativeGuid();
        } else if (resource instanceof BlockConsistencyGroup) {
            BlockConsistencyGroup consistencyGroup = (BlockConsistencyGroup) resource;
            try {
                id = consistencyGroup.getId();
                projectURI = consistencyGroup.getProject().getURI();
                tenantURI = (consistencyGroup.getTenant() != null) ? consistencyGroup.getTenant().getURI() : null;
            } catch (Exception e) {
                s_logger.error("Exception caught", e);
            }
        } else if (resource instanceof StoragePool) {
            StoragePool sp = (StoragePool) resource;
            id = sp.getId();
            nativeGuid = sp.getNativeGuid();
        } else {
            s_logger.info("Error getting vpool,id,NativeGuid for event. Unexpected resource type {}.", resource.getClass().getName());
        }
        // TODO fix the bogus tenant, user ID once we have AuthZ working
        if (tenantURI == null && projectURI != null) {
            tenantURI = ControllerUtils.getProjectTenantOrgURI(dbClient, projectURI);
        }
        event = new RecordableBourneEvent(type, tenantURI, // user ID TODO when AAA
        URI.create("ViPR-User"), // fixed
        projectURI, cos, evtServiceType, id, description, System.currentTimeMillis(), extensions, nativeGuid, recordType, eventServiceSource, "", "");
    }
    return event;
}
Also used : StoragePool(com.emc.storageos.db.client.model.StoragePool) BlockSnapshotSession(com.emc.storageos.db.client.model.BlockSnapshotSession) RecordableBourneEvent(com.emc.storageos.volumecontroller.impl.monitoring.RecordableBourneEvent) BlockSnapshot(com.emc.storageos.db.client.model.BlockSnapshot) URI(java.net.URI) FileShare(com.emc.storageos.db.client.model.FileShare) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) FCZoneReference(com.emc.storageos.db.client.model.FCZoneReference) BlockConsistencyGroup(com.emc.storageos.db.client.model.BlockConsistencyGroup) ExportGroup(com.emc.storageos.db.client.model.ExportGroup) Volume(com.emc.storageos.db.client.model.Volume) Network(com.emc.storageos.db.client.model.Network) VplexMirror(com.emc.storageos.db.client.model.VplexMirror) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException)

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