Search in sources :

Example 1 with StoragePortGroupList

use of com.emc.storageos.model.portgroup.StoragePortGroupList in project coprhd-controller by CoprHD.

the class StorageSystemService method getAllStoragePortGroups.

/**
 * Get all storage port groups for the storage system with the passed id.
 *
 * @param id
 *            the URN of a ViPR storage system.
 *
 * @brief List storage system storage port groups
 * @return A reference to a StoragePortGroupList specifying the id and self link
 *         for each port group.
 */
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}/storage-port-groups")
@CheckPermission(roles = { Role.SYSTEM_ADMIN, Role.SYSTEM_MONITOR })
public StoragePortGroupList getAllStoragePortGroups(@PathParam("id") URI id) {
    ArgValidator.checkFieldUriType(id, StorageSystem.class, "id");
    StorageSystem system = queryResource(id);
    ArgValidator.checkEntity(system, id, isIdEmbeddedInURL(id));
    URIQueryResultList portGroupURIs = new URIQueryResultList();
    _dbClient.queryByConstraint(ContainmentConstraint.Factory.getStorageDevicePortGroupConstraint(id), portGroupURIs);
    StoragePortGroupList portList = new StoragePortGroupList();
    Iterator<URI> portGroupIter = portGroupURIs.iterator();
    while (portGroupIter.hasNext()) {
        URI pgURI = portGroupIter.next();
        StoragePortGroup portGroup = _dbClient.queryObject(StoragePortGroup.class, pgURI);
        if (portGroup != null && !portGroup.getInactive() && !portGroup.checkInternalFlags(Flag.INTERNAL_OBJECT)) {
            portList.getPortGroups().add(toNamedRelatedResource(portGroup, portGroup.getNativeGuid()));
        }
    }
    return portList;
}
Also used : StoragePortGroupList(com.emc.storageos.model.portgroup.StoragePortGroupList) MapStoragePortGroup(com.emc.storageos.api.mapper.functions.MapStoragePortGroup) StoragePortGroup(com.emc.storageos.db.client.model.StoragePortGroup) URI(java.net.URI) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) StorageSystem(com.emc.storageos.db.client.model.StorageSystem) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Example 2 with StoragePortGroupList

use of com.emc.storageos.model.portgroup.StoragePortGroupList in project coprhd-controller by CoprHD.

the class StorageSystems method getStoragePortGroups.

/**
 * Gets the list of storage port group from a storage system
 *
 * @param storageSystemId
 *            the ID of the storage system.
 * @param exportId
 *            the ID of the export group
 * @return the list of storage port groups.
 */
public List<NamedRelatedResourceRep> getStoragePortGroups(URI storageSystemId, URI exportId) {
    UriBuilder builder = client.uriBuilder(baseUrl + "/{id}/storage-port-groups");
    if (exportId != null && !exportId.equals("")) {
        builder = builder.queryParam("export_group", exportId);
    }
    StoragePortGroupList portGroups = client.getURI(StoragePortGroupList.class, builder.build(storageSystemId));
    return defaultList(portGroups.getPortGroups());
}
Also used : StoragePortGroupList(com.emc.storageos.model.portgroup.StoragePortGroupList) UriBuilder(javax.ws.rs.core.UriBuilder)

Aggregations

StoragePortGroupList (com.emc.storageos.model.portgroup.StoragePortGroupList)2 MapStoragePortGroup (com.emc.storageos.api.mapper.functions.MapStoragePortGroup)1 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)1 StoragePortGroup (com.emc.storageos.db.client.model.StoragePortGroup)1 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)1 CheckPermission (com.emc.storageos.security.authorization.CheckPermission)1 URI (java.net.URI)1 GET (javax.ws.rs.GET)1 Path (javax.ws.rs.Path)1 Produces (javax.ws.rs.Produces)1 UriBuilder (javax.ws.rs.core.UriBuilder)1