use of com.emc.storageos.model.host.IpInterfaceList in project coprhd-controller by CoprHD.
the class HostService method getIpInterfaces.
/**
* Gets the id and name for all the interfaces of a host.
*
* @param id
* the URN of a ViPR Host
* @brief List host interfaces
* @return a list of interfaces that belong to the host
* @throws DatabaseException
* when a DB error occurs
*/
@GET
@Path("/{id}/ip-interfaces")
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public IpInterfaceList getIpInterfaces(@PathParam("id") URI id) throws DatabaseException {
Host host = queryObject(Host.class, id, false);
// check the user permissions
verifyAuthorizedInTenantOrg(host.getTenant(), getUserFromContext());
// get the ip interfaces
IpInterfaceList list = new IpInterfaceList();
List<NamedElementQueryResultList.NamedElement> dataObjects = listChildren(id, IpInterface.class, "ipAddress", "host");
for (NamedElementQueryResultList.NamedElement dataObject : dataObjects) {
list.getIpInterfaces().add(toNamedRelatedResource(ResourceTypeEnum.IPINTERFACE, dataObject.getId(), dataObject.getName()));
}
return list;
}
use of com.emc.storageos.model.host.IpInterfaceList in project coprhd-controller by CoprHD.
the class NetworkService method getIpInterfaces.
/**
* This call returns a list of all IpInterfaces associated
* with the Network end points.
*
* @param id the URN of a ViPR network
* @brief List IP interfaces
* @return IpInterfaceList
*/
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@CheckPermission(roles = { Role.SYSTEM_ADMIN, Role.SYSTEM_MONITOR })
@Path("/{id}/ip-interfaces")
public IpInterfaceList getIpInterfaces(@PathParam("id") URI id) {
IpInterfaceList registeredIpInterfaces = new IpInterfaceList();
ArgValidator.checkFieldUriType(id, Network.class, "id");
Network tzone = queryResource(id);
if (StorageProtocol.Transport.IP.name().equalsIgnoreCase(tzone.getTransportType())) {
StringSet endpts = tzone.retrieveEndpoints();
Iterator<String> endptsIter = endpts.iterator();
URIQueryResultList resultsList = new URIQueryResultList();
while (endptsIter.hasNext()) {
String endpt = endptsIter.next();
_dbClient.queryByConstraint(AlternateIdConstraint.Factory.getIpInterfaceIpAddressConstraint(endpt.toUpperCase()), resultsList);
Iterator<URI> resultsIter = resultsList.iterator();
while (resultsIter.hasNext()) {
IpInterface ipInterface = _dbClient.queryObject(IpInterface.class, resultsIter.next());
if (ipInterface != null) {
registeredIpInterfaces.getIpInterfaces().add(toNamedRelatedResource(ipInterface, ipInterface.getLabel()));
}
}
}
}
return registeredIpInterfaces;
}
Aggregations