use of com.emc.storageos.networkcontroller.impl.mds.Zoneset in project coprhd-controller by CoprHD.
the class NetworkDeviceController method getZonesets.
@Override
public List<Zoneset> getZonesets(URI uri, String fabricId, String fabricWwn, String zoneName, boolean excludeMembers, boolean excludeAliases) throws ControllerException {
NetworkSystem device = getNetworkSystemObject(uri);
// Get the file device reference for the type of file device managed
// by the controller.
NetworkSystemDevice networkDevice = getDevice(device.getSystemType());
if (networkDevice == null) {
throw NetworkDeviceControllerException.exceptions.getZonesetsFailedNull(device.getSystemType());
}
try {
List<Zoneset> zonesets = networkDevice.getZonesets(device, fabricId, fabricWwn, zoneName, excludeMembers, excludeAliases);
// Object pointers, so remove them here!
for (Zoneset zs : zonesets) {
zs.setCimObjectPath(null);
for (Zone zo : zs.getZones()) {
zo.setCimObjectPath(null);
for (ZoneMember zm : zo.getMembers()) {
zm.setCimObjectPath(null);
}
}
}
return zonesets;
} catch (Exception ex) {
Date date = new Date();
throw NetworkDeviceControllerException.exceptions.getZonesetsFailedExc(uri.toString(), date.toString(), ex);
}
}
use of com.emc.storageos.networkcontroller.impl.mds.Zoneset in project coprhd-controller by CoprHD.
the class BrocadeNetworkSMIS method getZoneSets.
@SuppressWarnings("unchecked")
public List<Zoneset> getZoneSets(WBEMClient client, String fabricId, String fabricWwn, String zoneName, boolean excludeMembers, boolean excludeAliases) throws WBEMException {
List<Zoneset> zonesets = new ArrayList<Zoneset>();
fabricWwn = StringUtils.isEmpty(fabricWwn) ? getFabricWwn(client, fabricId) : fabricWwn;
CIMInstance fabricIns = getFabricInstance(client, fabricId, fabricWwn);
if (fabricIns != null) {
CloseableIterator<CIMInstance> zonesetItr = null;
try {
CIMInstance activeZonesetIns = getActiveZonesetInstance(client, fabricId, fabricWwn);
if (activeZonesetIns != null) {
Zoneset activeZoneset = new Zoneset(cimStringProperty(activeZonesetIns, _element_name));
activeZoneset.setActive(cimBooleanProperty(activeZonesetIns, _active));
// if zoneName not specified, get all zones in the zoneset.
if (StringUtils.isEmpty(zoneName) || (zoneName != null && zoneName.startsWith(NetworkDeviceController.ZONESET_QUERY_FILTER))) {
activeZoneset.setZones(getZonesetZones(client, activeZonesetIns.getObjectPath(), !excludeMembers, !excludeAliases, zoneName));
} else {
// looking for a zone with given zoneName
Zone zone = getZone(client, zoneName, fabricWwn, true, !excludeMembers, !excludeAliases);
if (zone != null) {
activeZoneset.getZones().add(zone);
}
}
// get pending active zoneset and consolidate with active zoneset
zonesetItr = client.associatorInstances(fabricIns.getObjectPath(), _zoneset_fabric_path, _zoneset_name, null, null, false, null);
while (zonesetItr.hasNext()) {
CIMInstance zonesetIns = zonesetItr.next();
Zoneset zoneset = new Zoneset(cimStringProperty(zonesetIns, _element_name));
zoneset.setActive(cimBooleanProperty(zonesetIns, _active));
if (!zoneset.getActive() && StringUtils.equals(zoneset.getName(), activeZoneset.getName())) {
// found a pending active zoneset, consolidate its zones into active zoneset
if (StringUtils.isEmpty(zoneName)) {
zoneset.setZones(getZonesetZones(client, zonesetIns.getObjectPath(), !excludeMembers, !excludeAliases, null));
// consolidate active and pending zones in the zoneset
List<String> activeZoneNames = new ArrayList<String>();
for (Zone zone : activeZoneset.getZones()) {
activeZoneNames.add(zone.getName());
}
// get zones that are not yet active in zoneset, then
// append to zoneset
List<Zone> inactiveZones = new ArrayList<Zone>();
for (Zone zone : zoneset.getZones()) {
if (!activeZoneNames.contains(zone.getName())) {
inactiveZones.add(zone);
}
}
activeZoneset.getZones().addAll(inactiveZones);
} else if (activeZoneset.getZones().isEmpty()) {
// if specified zone was not found in active zone set, look into pending zoneset
Zone zone = getZone(client, zoneName, fabricWwn, true, !excludeMembers, !excludeAliases);
if (zone != null) {
zoneset.getZones().add(zone);
}
}
break;
}
}
if (activeZoneset != null) {
zonesets.add(activeZoneset);
}
}
} finally {
if (zonesetItr != null) {
zonesetItr.close();
}
}
}
return zonesets;
}
use of com.emc.storageos.networkcontroller.impl.mds.Zoneset 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;
}
Aggregations