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;
}
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;
}
Aggregations