Search in sources :

Example 11 with ZoneMember

use of com.emc.storageos.networkcontroller.impl.mds.ZoneMember in project coprhd-controller by CoprHD.

the class NetworkSystemService method removeSanZones.

/**
 * Deletes one or more zone(s) from the active zoneset of the VSAN or fabric specified in
 * the network system. This is an asynchronous call.
 *
 * @param sanZones A list of Zones and their zone members that should be deleted from
 *            the active zoneset. Note: the zone members must be included (deletion of a zone is based
 *            on matching both the name and the zone members).
 * @param id the URN of a ViPR Network System
 * @param fabricId The name of the VSAN or fabric as returned by
 *            /vdc/network-systems/{id}/san-fabrics or the VSAN or fabric WWN
 * @prereq none
 * @brief Delete zones from network system VSAN or fabric
 * @return A task description structure.
 * @throws InternalException
 */
@POST
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}/san-fabrics/{fabricId}/san-zones/remove")
@CheckPermission(roles = { Role.SYSTEM_ADMIN, Role.RESTRICTED_SYSTEM_ADMIN })
public TaskResourceRep removeSanZones(SanZonesDeleteParam sanZones, @PathParam("id") URI id, @PathParam("fabricId") String fabricId) throws InternalException {
    String task = UUID.randomUUID().toString();
    String fabricWwn = null;
    if (WWNUtility.isValidWWN(fabricId)) {
        fabricWwn = fabricId;
        fabricId = fabricId.replaceAll(":", "");
    }
    ArgValidator.checkFieldUriType(id, NetworkSystem.class, "id");
    NetworkSystem device = queryResource(id);
    Operation op = _dbClient.createTaskOpStatus(NetworkSystem.class, device.getId(), task, ResourceOperationTypeEnum.REMOVE_SAN_ZONE);
    List<Zone> zones = new ArrayList<Zone>();
    for (SanZone sz : sanZones.getZones()) {
        Zone zone = new Zone(sz.getName());
        zones.add(zone);
        for (String szm : sz.getMembers()) {
            ZoneMember member = createZoneMember(szm);
            zone.getMembers().add(member);
        }
        auditOp(OperationTypeEnum.REMOVE_SAN_ZONE, true, AuditLogManager.AUDITOP_BEGIN, zone.getName(), device.getId().toString(), device.getLabel(), device.getPortNumber(), device.getUsername(), device.getSmisProviderIP(), device.getSmisPortNumber(), device.getSmisUserName(), device.getSmisUseSSL(), device.getVersion(), device.getUptime());
    }
    ArgValidator.checkFieldNotEmpty(zones, "zones");
    NetworkController controller = getNetworkController(device.getSystemType());
    controller.removeSanZones(device.getId(), fabricId, fabricWwn, zones, false, task);
    return toTask(device, task, op);
}
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) ArrayList(java.util.ArrayList) ZoneMember(com.emc.storageos.networkcontroller.impl.mds.ZoneMember) Operation(com.emc.storageos.db.client.model.Operation) SanZone(com.emc.storageos.model.network.SanZone) NetworkController(com.emc.storageos.networkcontroller.NetworkController) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Example 12 with ZoneMember

use of com.emc.storageos.networkcontroller.impl.mds.ZoneMember in project coprhd-controller by CoprHD.

the class NetworkSystemService method addSanZones.

/**
 * Adds one or more SAN zones to the active zoneset of the VSAN or fabric specified on a network system.
 * This is an asynchronous call.
 *
 * @param sanZones A parameter structure listing the zone(s) to be added and their members.
 * @param id the URN of a ViPR network system.
 * @param fabricId The name of the VSAN or fabric as returned by
 *            /vdc/network-systems/{id}/san-fabrics or the VSAN or fabric WWN
 * @prereq none
 * @brief Add SAN zones to network system VSAN or fabric
 * @return A task description structure.
 * @throws InternalException
 */
@POST
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}/san-fabrics/{fabricId}/san-zones")
@CheckPermission(roles = { Role.SYSTEM_ADMIN, Role.RESTRICTED_SYSTEM_ADMIN })
public TaskResourceRep addSanZones(SanZoneCreateParam sanZones, @PathParam("id") URI id, @PathParam("fabricId") String fabricId) throws InternalException {
    String task = UUID.randomUUID().toString();
    String fabricWwn = null;
    if (WWNUtility.isValidWWN(fabricId)) {
        fabricWwn = fabricId;
        fabricId = fabricId.replaceAll(":", "");
    }
    ArgValidator.checkFieldUriType(id, NetworkSystem.class, "id");
    NetworkSystem device = queryResource(id);
    List<Zone> zones = new ArrayList<Zone>();
    for (SanZone sz : sanZones.getZones()) {
        Zone zone = new Zone(sz.getName());
        validateZoneName(sz.getName(), device.getSystemType());
        zones.add(zone);
        for (String szm : sz.getMembers()) {
            ZoneMember member = createZoneMember(szm);
            zone.getMembers().add(member);
        }
        ArgValidator.checkFieldNotEmpty(zone.getMembers(), "zone members");
        auditOp(OperationTypeEnum.ADD_SAN_ZONE, true, AuditLogManager.AUDITOP_BEGIN, zone.getName(), device.getId().toString(), device.getLabel(), device.getPortNumber(), device.getUsername(), device.getSmisProviderIP(), device.getSmisPortNumber(), device.getSmisUserName(), device.getSmisUseSSL(), device.getVersion(), device.getUptime());
    }
    ArgValidator.checkFieldNotEmpty(zones, "zones");
    Operation op = _dbClient.createTaskOpStatus(NetworkSystem.class, device.getId(), task, ResourceOperationTypeEnum.ADD_SAN_ZONE);
    NetworkController controller = getNetworkController(device.getSystemType());
    controller.addSanZones(device.getId(), fabricId, fabricWwn, zones, false, task);
    return toTask(device, task, op);
}
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) ArrayList(java.util.ArrayList) ZoneMember(com.emc.storageos.networkcontroller.impl.mds.ZoneMember) Operation(com.emc.storageos.db.client.model.Operation) SanZone(com.emc.storageos.model.network.SanZone) NetworkController(com.emc.storageos.networkcontroller.NetworkController) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Example 13 with ZoneMember

use of com.emc.storageos.networkcontroller.impl.mds.ZoneMember in project coprhd-controller by CoprHD.

the class NetworkDeviceController method getZoningMap.

/**
 * Finds all the zone paths that exists between a list of initiators and storage ports.
 *
 * @param initiators the list of initiators
 * @param portsMap a map of storage port keyed by the port WWN
 * @param initiatorWwnToZonesMap an OUT parameter used to store the zones retrieved mapped by initiator
 * @param networkSystemURI - an OUT parameter indicating the NetworkSystem's URI that found the zones
 *
 * @return a zoning map of zones that exists on the network systems
 */
public StringSetMap getZoningMap(NetworkLite network, List<Initiator> initiators, Map<String, StoragePort> portsMap, Map<String, List<Zone>> initiatorWwnToZonesMap, URI[] networkSystemURI) {
    StringSetMap map = new StringSetMap();
    StringSet initiatorWwns = new StringSet();
    for (Initiator initiator : initiators) {
        initiatorWwns.add(initiator.getInitiatorPort());
    }
    _log.info(String.format("Looking for zones from iniiators %s to targets %s", initiatorWwns, portsMap.keySet()));
    // find all the zones for the initiators as a map of initiator WWN to zones
    if (initiatorWwnToZonesMap == null) {
        initiatorWwnToZonesMap = new HashMap<String, List<Zone>>();
    }
    // of the zones retrieved from the network system, select the once
    NetworkSystem networkSystem = fetchInitiatorsZones(network, initiators, initiatorWwnToZonesMap);
    if (networkSystem != null && networkSystemURI != null) {
        networkSystemURI[0] = networkSystem.getId();
    }
    initiatorWwnToZonesMap = selectZonesForInitiatorsAndPorts(network, initiatorWwnToZonesMap, portsMap);
    // build the map object
    for (Initiator initiator : initiators) {
        StringSet set = new StringSet();
        List<Zone> zones = initiatorWwnToZonesMap.get(initiator.getInitiatorPort());
        if (zones != null) {
            for (Zone zone : zones) {
                _log.info(zone.getLogString());
                for (ZoneMember member : zone.getMembers()) {
                    if (portsMap.containsKey(member.getAddress())) {
                        // There can be multiple zones with the same initiator and port
                        // for this function, we're just finding all the mappings
                        set.add(portsMap.get(member.getAddress()).getId().toString());
                    }
                }
            }
        }
        if (set != null && !set.isEmpty()) {
            map.put(initiator.getId().toString(), set);
        }
    }
    _log.info("Found the following zone mappings {} for initiators {} and ports {}", new Object[] { map, initiatorWwnToZonesMap.keySet(), portsMap.keySet() });
    return map;
}
Also used : StringSetMap(com.emc.storageos.db.client.model.StringSetMap) Initiator(com.emc.storageos.db.client.model.Initiator) Zone(com.emc.storageos.networkcontroller.impl.mds.Zone) StringSet(com.emc.storageos.db.client.model.StringSet) NetworkSystem(com.emc.storageos.db.client.model.NetworkSystem) List(java.util.List) ArrayList(java.util.ArrayList) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) ZoneMember(com.emc.storageos.networkcontroller.impl.mds.ZoneMember)

Example 14 with ZoneMember

use of com.emc.storageos.networkcontroller.impl.mds.ZoneMember in project coprhd-controller by CoprHD.

the class NetworkDeviceController method fetchInitiatorsInNetworkZoneInfoMap.

/**
 * For the given network and initiators, which are in the network,
 * and a given list of storage ports, find all the zones on the network
 * system for the initiators. Search the zones to find ones that have
 * one or more of the ports and create the zoning map between the
 * initiators and ports. Returns the results as {@link ZoneInfoMap} which is map
 * of initiator port WWN and storage port WWN keyed by zone-key, where zone-key
 * is the concatenation of the initiator port WWN and the storage port WWN.
 * <p>
 * Note that the map returned contains only the zones that were selected for use by ViPR. In the case of duplicate zones between an
 * initiator-port pair, ViPR applies a selection criteria to choose one. See {@link #selectZonesForInitiatorsAndPorts}
 * <p>
 * Note that a zone in the network system can have more than one initiator and one storage port. For such zone, there can be multiple
 * entries in the map, one for each initiator/port pairs.
 * <p>
 * If the initiator is not in a network or no zones could be found for the initiator, there will be no entries for this initiator in the
 * map. An empty map will be returned if no zones could be found for any initiator.
 *
 * @param network the network of the initiators
 * @param map an OUT parameter where ZoneInfoMap is stored
 * @param initiators the initiators for which the zones will be read
 * @param initiatorPortsMap the storage ports of interest in the networks.
 * @return the network system used to read the zones
 */
private NetworkSystem fetchInitiatorsInNetworkZoneInfoMap(NetworkLite network, ZoneInfoMap map, List<Initiator> initiators, Map<String, StoragePort> initiatorPortsMap) {
    Map<String, Initiator> wwnToInitiatorMap = wwnToInitiatorMap(initiators);
    // retrieve the zones
    Map<String, List<Zone>> wwnToZones = new HashMap<String, List<Zone>>();
    NetworkSystem networkSystem = fetchInitiatorsZones(network, initiators, wwnToZones);
    wwnToZones = selectZonesForInitiatorsAndPorts(network, wwnToZones, initiatorPortsMap);
    // if we successfully retrieved the zones
    if (networkSystem != null && !wwnToZones.isEmpty()) {
        ZoneInfo info = null;
        Initiator initiator = null;
        for (Map.Entry<String, List<Zone>> entry : wwnToZones.entrySet()) {
            initiator = wwnToInitiatorMap.get(entry.getKey());
            for (Zone zone : entry.getValue()) {
                // I need some logic here to make sure I select the best zone
                for (ZoneMember member : zone.getMembers()) {
                    if (initiatorPortsMap.containsKey(member.getAddress())) {
                        // double check WWN formatting
                        StoragePort port = initiatorPortsMap.get(member.getAddress());
                        info = new ZoneInfo();
                        info.setZoneName(zone.getName());
                        info.setInitiatorWwn(initiator.getInitiatorPort());
                        info.setInitiatorId(initiator.getId().toString());
                        info.setPortWwn(port.getPortNetworkId());
                        info.setPortId(port.getId().toString());
                        info.setNetworkId(network.getId().toString());
                        info.setNetworkWwn(NetworkUtil.getNetworkWwn(network));
                        info.setFabricId(network.getNativeId());
                        info.setNetworkSystemId(networkSystem.getId().toString());
                        info.setMemberCount(zone.getMembers().size());
                        map.put(info.getZoneReferenceKey(), info);
                    }
                }
            }
        }
    }
    return networkSystem;
}
Also used : HashMap(java.util.HashMap) Zone(com.emc.storageos.networkcontroller.impl.mds.Zone) NetworkSystem(com.emc.storageos.db.client.model.NetworkSystem) StoragePort(com.emc.storageos.db.client.model.StoragePort) Initiator(com.emc.storageos.db.client.model.Initiator) List(java.util.List) ArrayList(java.util.ArrayList) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) ZoneMember(com.emc.storageos.networkcontroller.impl.mds.ZoneMember) ZoneInfoMap(com.emc.storageos.db.client.model.ZoneInfoMap) Map(java.util.Map) HashMap(java.util.HashMap) StringSetMap(com.emc.storageos.db.client.model.StringSetMap) StringMap(com.emc.storageos.db.client.model.StringMap) NetworkFCZoneInfo(com.emc.storageos.networkcontroller.NetworkFCZoneInfo) ZoneInfo(com.emc.storageos.db.client.model.ZoneInfo)

Example 15 with ZoneMember

use of com.emc.storageos.networkcontroller.impl.mds.ZoneMember in project coprhd-controller by CoprHD.

the class NetworkDeviceController method createZoneReferences.

/**
 * Create zone references when we discover zones off the switch.
 * Normally this routine will not do anything, because the ExportMask is freshly created, and
 * will therefore have no volumes in it.
 * @param network -- Network Lite
 * @param networkSystem -- URI of network system
 * @param exportGroup -- ExportGroup
 * @param exportMask -- ExportMask
 * @param initiatorWwntoZonesMap -- Map of initiator WWN string to a list of corresponding Zones
 */
void createZoneReferences(NetworkLite network, URI networkSystem, ExportGroup exportGroup, ExportMask exportMask, Map<String, List<Zone>> initiatorWwntoZonesMap) {
    StringMap maskVolumes = exportMask.getVolumes();
    if (maskVolumes == null || maskVolumes.isEmpty()) {
        _log.info(String.format("No volumes in ExportMask %s %s so no zone references created", exportMask.getMaskName(), exportMask.getId()));
        return;
    }
    // create a separate zone reference for each initiator - target pair.
    for (String maskVolume : maskVolumes.keySet()) {
        for (List<Zone> zones : initiatorWwntoZonesMap.values()) {
            for (Zone zone : zones) {
                // Find the initiatorWwn
                String initiatorWwn = null;
                for (ZoneMember member : zone.getMembers()) {
                    if (initiatorWwntoZonesMap.containsKey(member.getAddress())) {
                        initiatorWwn = member.getAddress();
                        break;
                    }
                }
                if (initiatorWwn == null) {
                    // Could not locate the initiator
                    _log.info("Could not locat the initiator: " + zone.getName());
                    continue;
                }
                for (ZoneMember member : zone.getMembers()) {
                    if (initiatorWwn.equals(member.getAddress())) {
                        continue;
                    }
                    String key = FCZoneReference.makeEndpointsKey(initiatorWwn, member.getAddress());
                    String[] newOrExisting = new String[1];
                    FCZoneReference ref = addZoneReference(exportGroup.getId(), URI.create(maskVolume), key, network.getNativeId(), networkSystem, zone.getName(), true, newOrExisting);
                    _log.info(String.format("Created FCZoneReference for existing zone %s %s %s %s", ref.getZoneName(), ref.getPwwnKey(), ref.getVolumeUri(), ref.getGroupUri()));
                }
            }
        }
    }
}
Also used : StringMap(com.emc.storageos.db.client.model.StringMap) Zone(com.emc.storageos.networkcontroller.impl.mds.Zone) ZoneMember(com.emc.storageos.networkcontroller.impl.mds.ZoneMember) FCZoneReference(com.emc.storageos.db.client.model.FCZoneReference)

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