Search in sources :

Example 1 with Zoneset

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);
    }
}
Also used : Zone(com.emc.storageos.networkcontroller.impl.mds.Zone) NetworkSystem(com.emc.storageos.db.client.model.NetworkSystem) ZoneMember(com.emc.storageos.networkcontroller.impl.mds.ZoneMember) Zoneset(com.emc.storageos.networkcontroller.impl.mds.Zoneset) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) ControllerException(com.emc.storageos.volumecontroller.ControllerException) NetworkDeviceControllerException(com.emc.storageos.networkcontroller.exceptions.NetworkDeviceControllerException) Date(java.util.Date)

Example 2 with Zoneset

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;
}
Also used : DateTimeZone(org.joda.time.DateTimeZone) Zone(com.emc.storageos.networkcontroller.impl.mds.Zone) TimeZone(java.util.TimeZone) ArrayList(java.util.ArrayList) Zoneset(com.emc.storageos.networkcontroller.impl.mds.Zoneset) CIMInstance(javax.cim.CIMInstance)

Example 3 with Zoneset

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

Zone (com.emc.storageos.networkcontroller.impl.mds.Zone)3 Zoneset (com.emc.storageos.networkcontroller.impl.mds.Zoneset)3 NetworkSystem (com.emc.storageos.db.client.model.NetworkSystem)2 ZoneMember (com.emc.storageos.networkcontroller.impl.mds.ZoneMember)2 MapNetworkSystem (com.emc.storageos.api.mapper.functions.MapNetworkSystem)1 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)1 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)1 SanZone (com.emc.storageos.model.network.SanZone)1 SanZoneMemberRestRep (com.emc.storageos.model.network.SanZoneMemberRestRep)1 SanZoneRestRep (com.emc.storageos.model.network.SanZoneRestRep)1 SanZonesRestRep (com.emc.storageos.model.network.SanZonesRestRep)1 NetworkController (com.emc.storageos.networkcontroller.NetworkController)1 NetworkDeviceControllerException (com.emc.storageos.networkcontroller.exceptions.NetworkDeviceControllerException)1 CheckPermission (com.emc.storageos.security.authorization.CheckPermission)1 ControllerException (com.emc.storageos.volumecontroller.ControllerException)1 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 TimeZone (java.util.TimeZone)1 CIMInstance (javax.cim.CIMInstance)1 GET (javax.ws.rs.GET)1