Search in sources :

Example 1 with AttributeList

use of com.emc.storageos.model.varray.AttributeList in project coprhd-controller by CoprHD.

the class VirtualArrayService method getAvailableAttributes.

/**
 * Finds the available attributes & its values in a varray. Ex: In a
 * varray, if a system supports raid_levels such as RAID1, RAID2 then
 * this API call provides the supported information.
 *
 * @brief List available attributes for all VirtualArrays
 * @return List available attributes for all VirtualArrays
 */
@POST
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/available-attributes")
@CheckPermission(roles = { Role.SYSTEM_ADMIN, Role.SYSTEM_MONITOR })
public VArrayAttributeList getAvailableAttributes(BulkIdParam param) {
    _log.info("Finding the available attributes for all varray: {}");
    VArrayAttributeList vArrayAttributes = new VArrayAttributeList();
    ObjectLocalCache cache = new ObjectLocalCache(_dbClient);
    Map<URI, List<StoragePool>> allPools = getVirtualArrayPools(param.getIds(), cache);
    for (Map.Entry<URI, List<StoragePool>> varrEntry : allPools.entrySet()) {
        Map<String, Set<String>> availableAttrs = _matcherFramework.getAvailableAttributes(varrEntry.getKey(), varrEntry.getValue(), cache, AttributeMatcher.VPOOL_MATCHERS);
        AttributeList list = new AttributeList();
        list.setVArrayId(varrEntry.getKey());
        for (Map.Entry<String, Set<String>> entry : availableAttrs.entrySet()) {
            list.getAttributes().add(new VirtualPoolAvailableAttributesResourceRep(entry.getKey(), entry.getValue()));
        }
        if (!list.getAttributes().isEmpty()) {
            vArrayAttributes.getAttributes().add(list);
        }
    }
    cache.clearCache();
    return vArrayAttributes;
}
Also used : VArrayAttributeList(com.emc.storageos.model.varray.VArrayAttributeList) Set(java.util.Set) HashSet(java.util.HashSet) StringSet(com.emc.storageos.db.client.model.StringSet) ObjectLocalCache(com.emc.storageos.volumecontroller.impl.utils.ObjectLocalCache) VArrayAttributeList(com.emc.storageos.model.varray.VArrayAttributeList) AttributeList(com.emc.storageos.model.varray.AttributeList) URI(java.net.URI) VirtualPoolAvailableAttributesResourceRep(com.emc.storageos.model.vpool.VirtualPoolAvailableAttributesResourceRep) StoragePortGroupRestRepList(com.emc.storageos.model.portgroup.StoragePortGroupRestRepList) VArrayAttributeList(com.emc.storageos.model.varray.VArrayAttributeList) NamedElementQueryResultList(com.emc.storageos.db.client.constraint.NamedElementQueryResultList) StoragePortList(com.emc.storageos.model.ports.StoragePortList) ArrayList(java.util.ArrayList) StoragePoolList(com.emc.storageos.model.pools.StoragePoolList) VirtualArrayConnectivityList(com.emc.storageos.model.varray.VirtualArrayConnectivityList) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) VirtualArrayList(com.emc.storageos.model.varray.VirtualArrayList) AttributeList(com.emc.storageos.model.varray.AttributeList) List(java.util.List) AutoTierPolicyList(com.emc.storageos.model.block.tier.AutoTierPolicyList) BulkList(com.emc.storageos.api.service.impl.response.BulkList) VirtualPoolList(com.emc.storageos.model.vpool.VirtualPoolList) NetworkList(com.emc.storageos.model.varray.NetworkList) Map(java.util.Map) HashMap(java.util.HashMap) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Produces(javax.ws.rs.Produces) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Example 2 with AttributeList

use of com.emc.storageos.model.varray.AttributeList in project coprhd-controller by CoprHD.

the class VirtualArrayService method getAvailableAttributes.

/**
 * Finds the available attributes & its values in a varray. Ex: In a
 * varray, if a system supports raid_levels such as RAID1, RAID2 then
 * this API call provides the supported information.
 *
 * @param id the URN of a ViPR VirtualArray.
 * @brief List available attributes for VirtualArray
 * @return List available attributes for VirtualArray
 */
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}/available-attributes")
@CheckPermission(roles = { Role.SYSTEM_ADMIN, Role.SYSTEM_MONITOR })
public AttributeList getAvailableAttributes(@PathParam("id") URI id) {
    // Get and validate the varray with the passed id.
    ArgValidator.checkFieldUriType(id, VirtualArray.class, "id");
    VirtualArray varray = _dbClient.queryObject(VirtualArray.class, id);
    ArgValidator.checkEntityNotNull(varray, id, isIdEmbeddedInURL(id));
    _log.info("Finding the available attributes for varray: {}", id);
    AttributeList list = new AttributeList();
    list.setVArrayId(id);
    ObjectLocalCache cache = new ObjectLocalCache(_dbClient);
    List<StoragePool> pools = getVirtualArrayPools(Arrays.asList(id), cache).get(id);
    Map<String, Set<String>> availableAttrs = _matcherFramework.getAvailableAttributes(id, pools, cache, AttributeMatcher.VPOOL_MATCHERS);
    cache.clearCache();
    for (Map.Entry<String, Set<String>> entry : availableAttrs.entrySet()) {
        list.getAttributes().add(new VirtualPoolAvailableAttributesResourceRep(entry.getKey(), entry.getValue()));
    }
    return list;
}
Also used : MapVirtualArray(com.emc.storageos.api.mapper.functions.MapVirtualArray) VirtualArray(com.emc.storageos.db.client.model.VirtualArray) StoragePool(com.emc.storageos.db.client.model.StoragePool) Set(java.util.Set) HashSet(java.util.HashSet) StringSet(com.emc.storageos.db.client.model.StringSet) VirtualPoolAvailableAttributesResourceRep(com.emc.storageos.model.vpool.VirtualPoolAvailableAttributesResourceRep) VArrayAttributeList(com.emc.storageos.model.varray.VArrayAttributeList) AttributeList(com.emc.storageos.model.varray.AttributeList) ObjectLocalCache(com.emc.storageos.volumecontroller.impl.utils.ObjectLocalCache) Map(java.util.Map) HashMap(java.util.HashMap) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Example 3 with AttributeList

use of com.emc.storageos.model.varray.AttributeList in project coprhd-controller by CoprHD.

the class VirtualArrays method getAvailableAttributes.

/**
 * Gets the available attributes for the given virtual arrays.
 * <p>
 * API Call: <tt>GET /vdc/varrays/available-attributes</tt>
 *
 * @param virtualArrayIds
 *            the IDs of the virtual arrays.
 * @return the list of available attributes.
 */
public Map<URI, List<VirtualPoolAvailableAttributesResourceRep>> getAvailableAttributes(Collection<URI> virtualArrayIds) {
    BulkIdParam input = new BulkIdParam((List<URI>) virtualArrayIds);
    VArrayAttributeList response = client.post(VArrayAttributeList.class, input, PathConstants.AVAILABLE_ATTRIBUTES_FOR_ALL_VARRAY);
    Map<URI, List<VirtualPoolAvailableAttributesResourceRep>> availableAttributes = new HashMap<URI, List<VirtualPoolAvailableAttributesResourceRep>>();
    for (AttributeList attributes : response.getAttributes()) {
        availableAttributes.put(attributes.getVArrayId(), attributes.getAttributes());
    }
    return availableAttributes;
}
Also used : VArrayAttributeList(com.emc.storageos.model.varray.VArrayAttributeList) VirtualPoolAvailableAttributesResourceRep(com.emc.storageos.model.vpool.VirtualPoolAvailableAttributesResourceRep) BulkIdParam(com.emc.storageos.model.BulkIdParam) HashMap(java.util.HashMap) AttributeList(com.emc.storageos.model.varray.AttributeList) VArrayAttributeList(com.emc.storageos.model.varray.VArrayAttributeList) ResourceUtils.defaultList(com.emc.vipr.client.core.util.ResourceUtils.defaultList) StoragePortGroupRestRepList(com.emc.storageos.model.portgroup.StoragePortGroupRestRepList) VirtualArrayList(com.emc.storageos.model.varray.VirtualArrayList) AttributeList(com.emc.storageos.model.varray.AttributeList) StoragePortGroupList(com.emc.storageos.model.portgroup.StoragePortGroupList) VirtualArrayConnectivityList(com.emc.storageos.model.varray.VirtualArrayConnectivityList) List(java.util.List) VArrayAttributeList(com.emc.storageos.model.varray.VArrayAttributeList) URI(java.net.URI)

Aggregations

AttributeList (com.emc.storageos.model.varray.AttributeList)3 VArrayAttributeList (com.emc.storageos.model.varray.VArrayAttributeList)3 VirtualPoolAvailableAttributesResourceRep (com.emc.storageos.model.vpool.VirtualPoolAvailableAttributesResourceRep)3 HashMap (java.util.HashMap)3 StringSet (com.emc.storageos.db.client.model.StringSet)2 StoragePortGroupRestRepList (com.emc.storageos.model.portgroup.StoragePortGroupRestRepList)2 VirtualArrayConnectivityList (com.emc.storageos.model.varray.VirtualArrayConnectivityList)2 VirtualArrayList (com.emc.storageos.model.varray.VirtualArrayList)2 CheckPermission (com.emc.storageos.security.authorization.CheckPermission)2 ObjectLocalCache (com.emc.storageos.volumecontroller.impl.utils.ObjectLocalCache)2 URI (java.net.URI)2 HashSet (java.util.HashSet)2 List (java.util.List)2 Map (java.util.Map)2 Set (java.util.Set)2 Path (javax.ws.rs.Path)2 Produces (javax.ws.rs.Produces)2 MapVirtualArray (com.emc.storageos.api.mapper.functions.MapVirtualArray)1 BulkList (com.emc.storageos.api.service.impl.response.BulkList)1 NamedElementQueryResultList (com.emc.storageos.db.client.constraint.NamedElementQueryResultList)1