Search in sources :

Example 31 with FCZoneReference

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

the class NetworkSystemService method getReferences.

/**
 * This information is intended only for internal debugging.
 * The FCZoneReference structure represents a use of a SAN Zone by an ExportGroup/Volume
 * combination. This call allows one to check what ExportGroups/Volumes are using a given
 * SAN Zone.
 * Gets the FCZoneReference entries for a given wwnList (used to make the key).
 *
 * @param wwnList A comma separated list of wwn Zone members is used to make the search key.
 * @brief INTERNAL ONLY
 * @return FCZoneReferences a list of FCZoneReference structures
 */
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/san-references/{wwnList}")
@CheckPermission(roles = { Role.SYSTEM_ADMIN })
public FCZoneReferences getReferences(@PathParam("wwnList") String wwnList) {
    FCZoneReferences references = new FCZoneReferences();
    List<String> wwns = Arrays.asList(wwnList.split(","));
    for (int i = 0; i < wwns.size() - 1; i++) {
        for (int j = i + 1; j < wwns.size(); j++) {
            String key = FCZoneReference.makeEndpointsKey(Arrays.asList(new String[] { wwns.get(i).toUpperCase(), wwns.get(j).toUpperCase() }));
            List<URI> uris = _dbClient.queryByConstraint(AlternateIdConstraint.Factory.getFCZoneReferenceKeyConstraint(key));
            for (URI uri : uris) {
                FCZoneReference ref = _dbClient.queryObject(FCZoneReference.class, uri);
                if (ref != null) {
                    if (ref.getInactive() == false) {
                        Volume vol = _dbClient.queryObject(Volume.class, ref.getVolumeUri());
                        if (vol != null && vol.getInactive() == false) {
                            references.getReferences().add(map(ref));
                        }
                    }
                }
            }
        }
    }
    return references;
}
Also used : Volume(com.emc.storageos.db.client.model.Volume) FCZoneReferences(com.emc.storageos.model.network.FCZoneReferences) URI(java.net.URI) AlternateIdConstraint(com.emc.storageos.db.client.constraint.AlternateIdConstraint) ContainmentConstraint(com.emc.storageos.db.client.constraint.ContainmentConstraint) FCEndpoint(com.emc.storageos.db.client.model.FCEndpoint) FCZoneReference(com.emc.storageos.db.client.model.FCZoneReference) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Example 32 with FCZoneReference

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

the class NetworkSystemService method getNetworkSystemZoneRefs.

private Map<String, List<FCZoneReference>> getNetworkSystemZoneRefs(NetworkSystem system) {
    Map<String, List<FCZoneReference>> map = new HashMap<String, List<FCZoneReference>>();
    List<FCZoneReference> zoneList = CustomQueryUtility.queryActiveResourcesByConstraint(_dbClient, FCZoneReference.class, AlternateIdConstraint.Factory.getConstraint(FCZoneReference.class, "networkSystemUri", system.getId().toString()));
    List<FCZoneReference> zones = null;
    for (FCZoneReference zone : zoneList) {
        zones = map.get(zone.getFabricId());
        if (zones == null) {
            zones = new ArrayList<FCZoneReference>();
            map.put(zone.getFabricId(), zones);
        }
        zones.add(zone);
    }
    return map;
}
Also used : HashMap(java.util.HashMap) NetworkSystemList(com.emc.storageos.model.network.NetworkSystemList) List(java.util.List) ArrayList(java.util.ArrayList) TaskList(com.emc.storageos.model.TaskList) BulkList(com.emc.storageos.api.service.impl.response.BulkList) FCZoneReference(com.emc.storageos.db.client.model.FCZoneReference)

Example 33 with FCZoneReference

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

the class ExportUtils method getInitiatorsZoneReferencesForBlockObject.

/**
 * Find the san zone information for the initiator and storage ports. Returns
 * a map of zone references per port.
 *
 * @param initiator the initiator
 * @param ports the target ports
 * @param bo block object
 * @param dbClient an instance of {@link DbClient}
 * @return a map of san zones created for the initiator grouped by port for
 *         the list of target ports. Otherwise, an returns empty map.
 */
private static Map<StoragePort, List<FCZoneReference>> getInitiatorsZoneReferencesForBlockObject(Initiator initiator, List<StoragePort> ports, BlockObject bo, DbClient dbClient) {
    Map<StoragePort, List<FCZoneReference>> targetPortReferences = new HashMap<StoragePort, List<FCZoneReference>>();
    if (initiator.getProtocol().equals(Block.FC.name())) {
        List<FCZoneReference> refs = null;
        for (StoragePort port : ports) {
            String key = FCZoneReference.makeLabel(Arrays.asList(initiator.getInitiatorPort(), port.getPortNetworkId(), bo.getId().toString()));
            refs = new ArrayList<FCZoneReference>();
            targetPortReferences.put(port, refs);
            URIQueryResultList queryList = new URIQueryResultList();
            dbClient.queryByConstraint(PrefixConstraint.Factory.getLabelPrefixConstraint(FCZoneReference.class, key), queryList);
            while (queryList.iterator().hasNext()) {
                FCZoneReference ref = dbClient.queryObject(FCZoneReference.class, queryList.iterator().next());
                if (ref != null && !ref.getInactive()) {
                    refs.add(ref);
                }
            }
        }
    }
    return targetPortReferences;
}
Also used : HashMap(java.util.HashMap) StoragePort(com.emc.storageos.db.client.model.StoragePort) ITLRestRepList(com.emc.storageos.model.block.export.ITLRestRepList) List(java.util.List) ArrayList(java.util.ArrayList) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) FCZoneReference(com.emc.storageos.db.client.model.FCZoneReference)

Example 34 with FCZoneReference

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

FCZoneReference (com.emc.storageos.db.client.model.FCZoneReference)34 URI (java.net.URI)15 ArrayList (java.util.ArrayList)14 StoragePort (com.emc.storageos.db.client.model.StoragePort)10 HashMap (java.util.HashMap)8 ExportGroup (com.emc.storageos.db.client.model.ExportGroup)6 Volume (com.emc.storageos.db.client.model.Volume)6 Initiator (com.emc.storageos.db.client.model.Initiator)5 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)5 List (java.util.List)5 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)4 NetworkSystem (com.emc.storageos.db.client.model.NetworkSystem)4 NetworkFCZoneInfo (com.emc.storageos.networkcontroller.NetworkFCZoneInfo)4 Zone (com.emc.storageos.networkcontroller.impl.mds.Zone)4 ZoneMember (com.emc.storageos.networkcontroller.impl.mds.ZoneMember)4 DbClient (com.emc.storageos.db.client.DbClient)3 BlockObject (com.emc.storageos.db.client.model.BlockObject)3 BulkList (com.emc.storageos.api.service.impl.response.BulkList)2 ExportMask (com.emc.storageos.db.client.model.ExportMask)2 Network (com.emc.storageos.db.client.model.Network)2