Search in sources :

Example 1 with WwnAliasesParam

use of com.emc.storageos.model.network.WwnAliasesParam in project coprhd-controller by CoprHD.

the class NetworkSystemService method getAliases.

/**
 * Returns a list of aliases for the specified network system. For Brocade, aliases
 * can be retrieved per fabric only and fabric-id is a required parameter. For MDS,
 * the full list of device aliases for the network system is returned and fabric-id is
 * ignored if provided.
 *
 * Note: This is a synchronous call to the device and may take a while to receive
 * a response.
 *
 * @param id the URN of a ViPR network system.
 * @param fabricId The name of the fabric as returned by
 *            /vdc/network-systems/{id}/san-fabrics or the WWN of the fabric
 * @prereq none
 * @brief List aliases in a network system or a fabric
 * @return A list of aliases.
 * @throws InternalException
 */
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}/san-aliases")
@CheckPermission(roles = { Role.SYSTEM_ADMIN })
public WwnAliasesParam getAliases(@PathParam("id") URI id, @QueryParam("fabric-id") String fabricId) throws InternalException {
    ArgValidator.checkFieldUriType(id, NetworkSystem.class, "id");
    NetworkSystem device = queryResource(id);
    if (Type.brocade.toString().equals(device.getSystemType())) {
        ArgValidator.checkFieldNotEmpty(fabricId, "fabric-id");
    }
    String fabricWwn = null;
    if (WWNUtility.isValidWWN(fabricId)) {
        fabricWwn = fabricId;
        fabricId = fabricId.replaceAll(":", "");
    }
    NetworkController controller = getNetworkController(device.getSystemType());
    List<WwnAliasParam> aliases = new ArrayList<WwnAliasParam>(controller.getAliases(device.getId(), fabricId, fabricWwn));
    return new WwnAliasesParam(aliases);
}
Also used : WwnAliasesParam(com.emc.storageos.model.network.WwnAliasesParam) WwnAliasParam(com.emc.storageos.model.network.WwnAliasParam) NetworkSystem(com.emc.storageos.db.client.model.NetworkSystem) MapNetworkSystem(com.emc.storageos.api.mapper.functions.MapNetworkSystem) ArrayList(java.util.ArrayList) NetworkController(com.emc.storageos.networkcontroller.NetworkController) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Example 2 with WwnAliasesParam

use of com.emc.storageos.model.network.WwnAliasesParam in project coprhd-controller by CoprHD.

the class NetworkSystems method getAliases.

/**
 * Gets the list of WWN Aliases in the given network system by ID and fabric name.
 * <p>
 * API Call: <tt>GET {@value PathConstants#SAN_ALIAS_URL}[?fabric-id={fabric}]</tt>
 *
 * @param id
 *            the ID of the network system.
 * @param fabric
 *            the name of the fabric, or {@code null} if there is no fabric.
 * @return the list of WWN Aliases.
 */
public List<? extends WwnAliasParam> getAliases(URI id, String fabric) {
    UriBuilder builder = client.uriBuilder(PathConstants.SAN_ALIAS_URL);
    if (fabric != null) {
        builder.queryParam("fabric-id", fabric);
    }
    WwnAliasesParam response = client.getURI(WwnAliasesParam.class, builder.build(id));
    return defaultList(response.getAliases());
}
Also used : WwnAliasesParam(com.emc.storageos.model.network.WwnAliasesParam) UriBuilder(javax.ws.rs.core.UriBuilder)

Aggregations

WwnAliasesParam (com.emc.storageos.model.network.WwnAliasesParam)2 MapNetworkSystem (com.emc.storageos.api.mapper.functions.MapNetworkSystem)1 NetworkSystem (com.emc.storageos.db.client.model.NetworkSystem)1 WwnAliasParam (com.emc.storageos.model.network.WwnAliasParam)1 NetworkController (com.emc.storageos.networkcontroller.NetworkController)1 CheckPermission (com.emc.storageos.security.authorization.CheckPermission)1 ArrayList (java.util.ArrayList)1 GET (javax.ws.rs.GET)1 Path (javax.ws.rs.Path)1 Produces (javax.ws.rs.Produces)1 UriBuilder (javax.ws.rs.core.UriBuilder)1