Search in sources :

Example 6 with ZoneMember

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

the class BrocadeNetworkSMIS method getAliasFromInstance.

/**
 * Creates an instance of {@link ZoneWwnAlias} from a {@link CIMInstance} after it retrieves
 * the alias member. Note, the alias is expected to have a single member.
 *
 * @param client and instance of WBEMClient
 * @param ins the alias WBEMClient instance
 * @param addMember if true also retrieve the alias WWN member
 * @return an instance of {@link ZoneWwnAlias}
 * @throws WBEMException
 */
private ZoneWwnAlias getAliasFromInstance(WBEMClient client, CIMInstance ins, boolean addMember) throws WBEMException {
    ZoneWwnAlias alias = new ZoneWwnAlias();
    alias.setName(cimStringProperty(ins, _CollectionAlias));
    alias.setCimObjectPath(ins.getObjectPath());
    if (addMember) {
        List<ZoneMember> members = getZoneOrAliasMembers(client, ins.getObjectPath(), true);
        for (ZoneMember member : members) {
            alias.setAddress(EndpointUtility.changeCase(member.getAddress()));
            alias.setCimMemberPath(member.getCimObjectPath());
            // there should only be 1 member
            break;
        }
    }
    return alias;
}
Also used : ZoneMember(com.emc.storageos.networkcontroller.impl.mds.ZoneMember) ZoneWwnAlias(com.emc.storageos.networkcontroller.impl.mds.ZoneWwnAlias)

Example 7 with ZoneMember

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

the class BrocadeNetworkSMIS method getZoneMembers.

/**
 * Get the zone aliases in the zone.
 *
 * @param client instance of WBEMClient
 * @param path the zone path
 * @param includeAliases if true, the aliases are retrieved and populated in the zone.
 * @return the list of aliases by name and WWN (asuming only 1 member in an alias)
 */
public List<ZoneMember> getZoneMembers(WBEMClient client, CIMObjectPath path, boolean includeAliases) throws WBEMException {
    List<ZoneMember> aliasMembers = null;
    List<ZoneMember> wwnMembers = getZoneOrAliasMembers(client, path, false);
    if (includeAliases) {
        aliasMembers = getZoneAliases(client, path);
    } else {
        _log.info("Excluding aliases while getting zone members");
        aliasMembers = wwnMembers;
        return aliasMembers;
    }
    boolean found = false;
    for (ZoneMember wwnMember : wwnMembers) {
        found = false;
        for (ZoneMember aliasMember : aliasMembers) {
            if (wwnMember.getAddress().equals(aliasMember.getAddress())) {
                found = true;
                break;
            }
        }
        if (!found) {
            aliasMembers.add(wwnMember);
        }
    }
    return aliasMembers;
}
Also used : ZoneMember(com.emc.storageos.networkcontroller.impl.mds.ZoneMember)

Example 8 with ZoneMember

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

the class BrocadeNetworkSMIS method getZoneOrAliasMembers.

/**
 * This function gets the member of a zone or an alias.
 *
 * @param client
 * @param path the path to the zone or alias
 * @param alias true if the object is of type alias
 * @return an instance of zonemember that has the WWN of the
 *         zone or alias member
 * @throws WBEMException
 */
@SuppressWarnings("unchecked")
public List<ZoneMember> getZoneOrAliasMembers(WBEMClient client, CIMObjectPath path, boolean alias) throws WBEMException {
    List<ZoneMember> members = new ArrayList<ZoneMember>();
    if (path != null) {
        CloseableIterator<CIMInstance> zoneItr = null;
        try {
            String association = alias ? _Brocade_ZoneMembershipSettingDataInZoneAlias : _Brocade_ZoneMembershipSettingDataInZone;
            zoneItr = client.associatorInstances(path, association, _Brocade_ZoneMembershipSettingData, null, null, false, null);
            while (zoneItr.hasNext()) {
                CIMInstance memberIns = zoneItr.next();
                String address = cimStringProperty(memberIns, _ConnectivityMemberID);
                ConnectivityMemberType type = ConnectivityMemberType.byValue(cimIntegerProperty(memberIns, _ConnectivityMemberType));
                if (// temporarily allow portgroup because of brocade issues
                type == ConnectivityMemberType.WWPN || type == ConnectivityMemberType.PORTGROUP) {
                    // where type is port group when wwnn=wwpn
                    address = formatWWN(address);
                }
                ZoneMember zoneMember = new ZoneMember(address, type);
                // This is the path of the association object
                zoneMember.setCimObjectPath(memberIns.getObjectPath());
                if (alias) {
                    zoneMember.setAlias(getPropertyValueFromInstanceId(path, SmisConstants.CP_NSNAME));
                    zoneMember.setAliasType(true);
                    // this is the path of the alias object
                    zoneMember.setCimAliasPath(path);
                }
                members.add(zoneMember);
            }
        } finally {
            if (zoneItr != null) {
                zoneItr.close();
            }
        }
    }
    return members;
}
Also used : ConnectivityMemberType(com.emc.storageos.networkcontroller.impl.mds.ZoneMember.ConnectivityMemberType) ArrayList(java.util.ArrayList) ZoneMember(com.emc.storageos.networkcontroller.impl.mds.ZoneMember) CIMInstance(javax.cim.CIMInstance)

Example 9 with ZoneMember

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

the class BrocadeNetworkSystemDevice method getEndpointNetworks.

/**
 * This is function is used at the time an 'add zone' request is received when we need
 * to decide if the zone request requires creating an LSAN zone or a regular zone. For
 * each member find the network the member is in. Note, zones can be created for WWNs
 * that are not logged into the switch, or for aliases. In this case, we assume only
 * regular zones will be created.
 *
 * @param zone the zone to be added.
 * @return A map of zoneMember-to-network
 */
private Map<ZoneMember, NetworkLite> getEndpointNetworks(Zone zone, String fabricId, String fabricWwn) {
    NetworkLite network = NetworkUtil.getNetworkLiteByFabricId(fabricId, fabricWwn, _dbClient);
    Map<ZoneMember, NetworkLite> epNetworks = new HashMap<ZoneMember, NetworkLite>();
    NetworkLite loopNetwork = null;
    for (ZoneMember member : zone.getMembers()) {
        // For alias-type members, more investigation is needed.
        if (!StringUtils.isEmpty(member.getAddress())) {
            loopNetwork = NetworkUtil.getEndpointNetworkLite(member.getAddress(), _dbClient);
        }
        // it belongs to the request network.
        if (loopNetwork == null && network != null) {
            loopNetwork = network;
        }
        if (loopNetwork != null) {
            epNetworks.put(member, loopNetwork);
        }
    }
    return epNetworks;
}
Also used : HashMap(java.util.HashMap) NetworkLite(com.emc.storageos.util.NetworkLite) ZoneMember(com.emc.storageos.networkcontroller.impl.mds.ZoneMember)

Example 10 with ZoneMember

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

the class BrocadeNetworkSystemDevice method createZone.

/**
 * Creates the zone in the fabric's active zoneset
 *
 * @param client an instance of the SMI client
 * @param zoneServiceIns the instance of SMI zoneServices
 * @param fabricId the fabric id where the zone should created
 * @param fabricWwn the fabric WWN where the zone should created
 * @param zonesetPath the SMI path of the active zoneset for the fabric
 * @param zone the zone to be created
 * @return a boolean to indicated if a zone was created or not.
 * @throws WBEMException
 */
private boolean createZone(WBEMClient client, CIMInstance zoneServiceIns, String fabricId, String fabricWwn, CIMObjectPath zonesetPath, Zone zone) throws WBEMException {
    _log.info("Creating a new zone " + zone.getName());
    CIMObjectPath zonePath = _smisHelper.addZone(client, zoneServiceIns, zonesetPath, zone.getName(), fabricId, fabricWwn);
    if (zonePath != null) {
        boolean success = false;
        String name = null;
        for (ZoneMember member : zone.getMembers()) {
            name = member.getAlias() == null ? member.getAddress() : member.getAlias();
            _log.info("Creating zone member: " + name + " zone: " + zone.getName());
            success = _smisHelper.addZoneOrAliasMember(client, zoneServiceIns, fabricWwn, zonePath, name);
            if (!success) {
                _log.info("Failed to create memeber " + name + " for zone : " + zone.getName());
                throw NetworkDeviceControllerException.exceptions.addZonesMemberFailedPath(zone.getName(), name);
            }
        }
    } else {
        _log.info("Failed to create zone : " + zone.getName());
        throw NetworkDeviceControllerException.exceptions.addZonesStrategyFailedPath();
    }
    return true;
}
Also used : CIMObjectPath(javax.cim.CIMObjectPath) ZoneMember(com.emc.storageos.networkcontroller.impl.mds.ZoneMember)

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