Search in sources :

Example 1 with IpInterfaceList

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;
}
Also used : IpInterfaceList(com.emc.storageos.model.host.IpInterfaceList) Host(com.emc.storageos.db.client.model.Host) 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 IpInterfaceList

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;
}
Also used : IpInterface(com.emc.storageos.db.client.model.IpInterface) IpInterfaceList(com.emc.storageos.model.host.IpInterfaceList) Network(com.emc.storageos.db.client.model.Network) MapNetwork(com.emc.storageos.api.mapper.functions.MapNetwork) StringSet(com.emc.storageos.db.client.model.StringSet) 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

IpInterfaceList (com.emc.storageos.model.host.IpInterfaceList)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 IpInterface (com.emc.storageos.db.client.model.IpInterface)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