Search in sources :

Example 1 with InitiatorList

use of com.emc.storageos.model.host.InitiatorList in project coprhd-controller by CoprHD.

the class HostService method getInitiators.

/**
 * Gets the id and name for all the host initiators of a host.
 *
 * @param id
 *            the URN of a ViPR Host
 * @brief List host initiators
 * @return a list of initiators that belong to the host
 * @throws DatabaseException
 *             when a DB error occurs
 */
@GET
@Path("/{id}/initiators")
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public InitiatorList getInitiators(@PathParam("id") URI id) throws DatabaseException {
    Host host = queryObject(Host.class, id, false);
    // check the user permissions
    verifyAuthorizedInTenantOrg(host.getTenant(), getUserFromContext());
    // get the initiators
    InitiatorList list = new InitiatorList();
    List<NamedElementQueryResultList.NamedElement> dataObjects = listChildren(id, Initiator.class, "iniport", "host");
    for (NamedElementQueryResultList.NamedElement dataObject : dataObjects) {
        list.getInitiators().add(toNamedRelatedResource(ResourceTypeEnum.INITIATOR, dataObject.getId(), dataObject.getName()));
    }
    return list;
}
Also used : Host(com.emc.storageos.db.client.model.Host) InitiatorList(com.emc.storageos.model.host.InitiatorList) NamedElementQueryResultList(com.emc.storageos.db.client.constraint.NamedElementQueryResultList) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 2 with InitiatorList

use of com.emc.storageos.model.host.InitiatorList in project coprhd-controller by CoprHD.

the class NetworkService method getInitiators.

/**
 * This call returns a list of all Initiators associated
 * with the Network end points.
 *
 * @param id the URN of a ViPR network
 * @brief List initiators
 * @return InitiatorList
 */
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@CheckPermission(roles = { Role.SYSTEM_ADMIN, Role.SYSTEM_MONITOR })
@Path("/{id}/initiators")
public InitiatorList getInitiators(@PathParam("id") URI id) {
    InitiatorList registeredInitiators = new InitiatorList();
    ArgValidator.checkFieldUriType(id, Network.class, "id");
    Network tzone = queryResource(id);
    StringSet endpts = tzone.retrieveEndpoints();
    Iterator<String> endptsIter = endpts.iterator();
    URIQueryResultList resultsList = new URIQueryResultList();
    while (endptsIter.hasNext()) {
        String endpt = endptsIter.next();
        _dbClient.queryByConstraint(AlternateIdConstraint.Factory.getInitiatorPortInitiatorConstraint(endpt), resultsList);
        Iterator<URI> resultsIter = resultsList.iterator();
        while (resultsIter.hasNext()) {
            Initiator initiator = _dbClient.queryObject(Initiator.class, resultsIter.next());
            if (initiator != null) {
                registeredInitiators.getInitiators().add(toNamedRelatedResource(initiator, initiator.getLabel()));
            }
        }
    }
    return registeredInitiators;
}
Also used : Initiator(com.emc.storageos.db.client.model.Initiator) Network(com.emc.storageos.db.client.model.Network) MapNetwork(com.emc.storageos.api.mapper.functions.MapNetwork) StringSet(com.emc.storageos.db.client.model.StringSet) InitiatorList(com.emc.storageos.model.host.InitiatorList) 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)

Aggregations

InitiatorList (com.emc.storageos.model.host.InitiatorList)2 GET (javax.ws.rs.GET)2 Path (javax.ws.rs.Path)2 Produces (javax.ws.rs.Produces)2 MapNetwork (com.emc.storageos.api.mapper.functions.MapNetwork)1 NamedElementQueryResultList (com.emc.storageos.db.client.constraint.NamedElementQueryResultList)1 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)1 Host (com.emc.storageos.db.client.model.Host)1 Initiator (com.emc.storageos.db.client.model.Initiator)1 Network (com.emc.storageos.db.client.model.Network)1 StringSet (com.emc.storageos.db.client.model.StringSet)1 CheckPermission (com.emc.storageos.security.authorization.CheckPermission)1 URI (java.net.URI)1