Search in sources :

Example 1 with SanZoneMemberRestRep

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

the class NetworkSystemService method getSanZones.

/**
 * Returns a list of the active zones (and their zone members) for the specified
 * fabric or VSAN in a network system. E.g., ../san-fabrics/{fabric-id}/san-zones?zone-name="abc-zone"&exclude-members=true
 * 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 VSAN or fabric as returned by
 * @param zoneName - only returns zone with zone name matched the given name. Return all zones, if not specified.
 * @param excludeMembers - true, do not include members with zone. Include members, if not specified.
 * @param excludeAliases - true, do not include aliases with zone. Include aliases, if not specified.
 * @prereq none
 * @brief List active zones in a network system fabric or VSAN
 * @return A list of the active zones and their members. If zone name is specified, and there is a match, then only one zone is
 *         returned.
 *         If excludeMembers is true, then only zone name is present.
 * @throws InternalException
 */
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}/san-fabrics/{fabricId}/san-zones")
@CheckPermission(roles = { Role.SYSTEM_ADMIN })
public SanZonesRestRep getSanZones(@PathParam("id") URI id, @PathParam("fabricId") String fabricId, @QueryParam("zone-name") String zoneName, @QueryParam("exclude-members") boolean excludeMembers, @QueryParam("exclude-aliases") boolean excludeAliases) throws InternalException {
    SanZonesRestRep szones = new SanZonesRestRep();
    ArgValidator.checkFieldUriType(id, NetworkSystem.class, "id");
    NetworkSystem device = queryResource(id);
    String fabricWwn = null;
    if (WWNUtility.isValidWWN(fabricId)) {
        fabricWwn = fabricId;
        fabricId = fabricId.replaceAll(":", "");
    }
    NetworkController controller = getNetworkController(device.getSystemType());
    List<Zoneset> zonesets = controller.getZonesets(device.getId(), fabricId, fabricWwn, zoneName, excludeMembers, excludeAliases);
    for (Zoneset zoneset : zonesets) {
        for (Zone zone : zoneset.getZones()) {
            SanZoneRestRep sz = new SanZoneRestRep();
            sz.setName(zone.getName());
            for (ZoneMember member : zone.getMembers()) {
                // convert zone member to xml aware. Only fill in alias if member is an alias type
                sz.getMembers().add(new SanZoneMemberRestRep(member.getAddress(), member.isAliasType() ? member.getAlias() : null));
            }
            szones.getZones().add(sz);
        }
    }
    return szones;
}
Also used : Zone(com.emc.storageos.networkcontroller.impl.mds.Zone) SanZone(com.emc.storageos.model.network.SanZone) NetworkSystem(com.emc.storageos.db.client.model.NetworkSystem) MapNetworkSystem(com.emc.storageos.api.mapper.functions.MapNetworkSystem) SanZoneMemberRestRep(com.emc.storageos.model.network.SanZoneMemberRestRep) ZoneMember(com.emc.storageos.networkcontroller.impl.mds.ZoneMember) SanZonesRestRep(com.emc.storageos.model.network.SanZonesRestRep) Zoneset(com.emc.storageos.networkcontroller.impl.mds.Zoneset) SanZoneRestRep(com.emc.storageos.model.network.SanZoneRestRep) 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)

Aggregations

MapNetworkSystem (com.emc.storageos.api.mapper.functions.MapNetworkSystem)1 NetworkSystem (com.emc.storageos.db.client.model.NetworkSystem)1 SanZone (com.emc.storageos.model.network.SanZone)1 SanZoneMemberRestRep (com.emc.storageos.model.network.SanZoneMemberRestRep)1 SanZoneRestRep (com.emc.storageos.model.network.SanZoneRestRep)1 SanZonesRestRep (com.emc.storageos.model.network.SanZonesRestRep)1 NetworkController (com.emc.storageos.networkcontroller.NetworkController)1 Zone (com.emc.storageos.networkcontroller.impl.mds.Zone)1 ZoneMember (com.emc.storageos.networkcontroller.impl.mds.ZoneMember)1 Zoneset (com.emc.storageos.networkcontroller.impl.mds.Zoneset)1 CheckPermission (com.emc.storageos.security.authorization.CheckPermission)1 GET (javax.ws.rs.GET)1 Path (javax.ws.rs.Path)1 Produces (javax.ws.rs.Produces)1