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;
}
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;
}
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;
}
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;
}
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;
}
Aggregations