Search in sources :

Example 21 with ZoneMember

use of com.emc.storageos.networkcontroller.impl.mds.ZoneMember 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

ZoneMember (com.emc.storageos.networkcontroller.impl.mds.ZoneMember)21 Zone (com.emc.storageos.networkcontroller.impl.mds.Zone)13 ArrayList (java.util.ArrayList)11 NetworkSystem (com.emc.storageos.db.client.model.NetworkSystem)8 HashMap (java.util.HashMap)5 MapNetworkSystem (com.emc.storageos.api.mapper.functions.MapNetworkSystem)4 FCZoneReference (com.emc.storageos.db.client.model.FCZoneReference)4 NetworkController (com.emc.storageos.networkcontroller.NetworkController)4 NetworkDeviceControllerException (com.emc.storageos.networkcontroller.exceptions.NetworkDeviceControllerException)4 CheckPermission (com.emc.storageos.security.authorization.CheckPermission)4 Path (javax.ws.rs.Path)4 Produces (javax.ws.rs.Produces)4 Operation (com.emc.storageos.db.client.model.Operation)3 StringMap (com.emc.storageos.db.client.model.StringMap)3 StringSetMap (com.emc.storageos.db.client.model.StringSetMap)3 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)3 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)3 SanZone (com.emc.storageos.model.network.SanZone)3 ControllerException (com.emc.storageos.volumecontroller.ControllerException)3 HashSet (java.util.HashSet)3