Search in sources :

Example 1 with NetworkList

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

the class NetworkService method getAllNetworks.

/**
 * This call returns a list of all the networks, regardless of whether or not
 * they are associated with a virtual array.
 * <p>
 * If network systems are discovered, fiber channel networks that are discovered are not initially associated with virtual array. The
 * discovered networks must be updated to associate then with virtual arrays.
 *
 * @brief List networks
 * @return a list of all networks
 */
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@CheckPermission(roles = { Role.SYSTEM_ADMIN, Role.SYSTEM_MONITOR })
public NetworkList getAllNetworks(@QueryParam("wwn") String wwn) {
    NetworkList tzlist = new NetworkList();
    if (wwn != null) {
        // Validate the argument for wwn structure...
        ArgValidator.checkFieldValidWwn(wwn);
        // Normalize wwn for colon-separated and all-caps
        wwn = WwnUtils.convertWWN(wwn.toUpperCase(), FORMAT.COLON);
        Network network = NetworkUtil.getEndpointNetwork(wwn, _dbClient);
        if (network != null) {
            tzlist.getNetworks().add(toNamedRelatedResource(ResourceTypeEnum.NETWORK, network.getId(), network.getLabel()));
        }
    } else {
        List<URI> networks = _dbClient.queryByType(Network.class, true);
        List<Network> transportZones = _dbClient.queryObject(Network.class, networks);
        for (Network network : transportZones) {
            if (network == null || network.getInactive() == true) {
                continue;
            }
            tzlist.getNetworks().add(toNamedRelatedResource(ResourceTypeEnum.NETWORK, network.getId(), network.getLabel()));
        }
    }
    return tzlist;
}
Also used : NetworkList(com.emc.storageos.model.varray.NetworkList) Network(com.emc.storageos.db.client.model.Network) MapNetwork(com.emc.storageos.api.mapper.functions.MapNetwork) URI(java.net.URI) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Example 2 with NetworkList

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

the class VirtualArrayService method getNetworkList.

/**
 * List transport zones in VirtualArray
 *
 * @param id the URN of a ViPR VirtualArray
 * @brief List VirtualArray Networks
 * @return List of Networks
 */
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}/networks")
@CheckPermission(roles = { Role.SYSTEM_ADMIN, Role.SYSTEM_MONITOR }, acls = { ACL.USE })
public NetworkList getNetworkList(@PathParam("id") URI id) {
    NetworkList networkList = new NetworkList();
    // Verify the passed virtual array id.
    ArgValidator.checkFieldUriType(id, VirtualArray.class, "id");
    VirtualArray varray = _dbClient.queryObject(VirtualArray.class, id);
    ArgValidator.checkEntity(varray, id, isIdEmbeddedInURL(id));
    // Get the networks assigned to the virtual array.
    List<Network> networks = CustomQueryUtility.queryActiveResourcesByRelation(_dbClient, id, Network.class, "connectedVirtualArrays");
    for (Network network : networks) {
        if (network == null || network.getInactive() == true) {
            continue;
        }
        networkList.getNetworks().add(toNamedRelatedResource(ResourceTypeEnum.NETWORK, network.getId(), network.getLabel()));
    }
    return networkList;
}
Also used : MapVirtualArray(com.emc.storageos.api.mapper.functions.MapVirtualArray) VirtualArray(com.emc.storageos.db.client.model.VirtualArray) NetworkList(com.emc.storageos.model.varray.NetworkList) Network(com.emc.storageos.db.client.model.Network) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Aggregations

Network (com.emc.storageos.db.client.model.Network)2 NetworkList (com.emc.storageos.model.varray.NetworkList)2 CheckPermission (com.emc.storageos.security.authorization.CheckPermission)2 GET (javax.ws.rs.GET)2 Produces (javax.ws.rs.Produces)2 MapNetwork (com.emc.storageos.api.mapper.functions.MapNetwork)1 MapVirtualArray (com.emc.storageos.api.mapper.functions.MapVirtualArray)1 VirtualArray (com.emc.storageos.db.client.model.VirtualArray)1 URI (java.net.URI)1 Path (javax.ws.rs.Path)1