Search in sources :

Example 1 with SanZoneUpdateParam

use of com.emc.storageos.model.network.SanZoneUpdateParam in project coprhd-controller by CoprHD.

the class NetworkSystemService method updateSanZones.

/**
 * For given network system's fabric, update zones via add and/or remove their pwwns or aliases.
 * This is an asynchronous call.
 *
 * @param updateSanZones 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 Updating zones must be exist in network system with given <code>id</code>
 * @brief Update SAN zones details for network system VSAN or fabric
 * @return A task description structure.
 * @throws InternalException
 */
@PUT
@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 updateSanZones(SanZoneUpdateParams updateSanZones, @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<ZoneUpdate> updateZones = new ArrayList<ZoneUpdate>();
    for (SanZoneUpdateParam sz : updateSanZones.getUpdateZones()) {
        ZoneUpdate updateZone = new ZoneUpdate(sz.getName());
        validateZoneName(sz.getName(), device.getSystemType());
        for (String szm : sz.getAddMembers()) {
            if (StringUtils.isEmpty(szm)) {
                continue;
            }
            ZoneMember member = createZoneMember(szm);
            updateZone.getAddZones().add(member);
        }
        for (String szm : sz.getRemoveMembers()) {
            if (StringUtils.isEmpty(szm)) {
                continue;
            }
            ZoneMember member = createZoneMember(szm);
            updateZone.getRemoveZones().add(member);
        }
        updateZones.add(updateZone);
        auditOp(OperationTypeEnum.UPDATE_SAN_ZONE, true, AuditLogManager.AUDITOP_BEGIN, updateZone.getName(), device.getId().toString(), device.getLabel(), device.getPortNumber(), device.getUsername(), device.getSmisProviderIP(), device.getSmisPortNumber(), device.getSmisUserName(), device.getSmisUseSSL(), device.getVersion(), device.getUptime());
    }
    ArgValidator.checkFieldNotEmpty(updateZones, "zones");
    Operation op = _dbClient.createTaskOpStatus(NetworkSystem.class, device.getId(), task, ResourceOperationTypeEnum.UPDATE_SAN_ZONE);
    NetworkController controller = getNetworkController(device.getSystemType());
    controller.updateSanZones(device.getId(), fabricId, fabricWwn, updateZones, false, task);
    return toTask(device, task, op);
}
Also used : 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) ZoneUpdate(com.emc.storageos.networkcontroller.impl.mds.ZoneUpdate) SanZoneUpdateParam(com.emc.storageos.model.network.SanZoneUpdateParam) NetworkController(com.emc.storageos.networkcontroller.NetworkController) Path(javax.ws.rs.Path) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces) PUT(javax.ws.rs.PUT) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Aggregations

MapNetworkSystem (com.emc.storageos.api.mapper.functions.MapNetworkSystem)1 NetworkSystem (com.emc.storageos.db.client.model.NetworkSystem)1 Operation (com.emc.storageos.db.client.model.Operation)1 SanZoneUpdateParam (com.emc.storageos.model.network.SanZoneUpdateParam)1 NetworkController (com.emc.storageos.networkcontroller.NetworkController)1 ZoneMember (com.emc.storageos.networkcontroller.impl.mds.ZoneMember)1 ZoneUpdate (com.emc.storageos.networkcontroller.impl.mds.ZoneUpdate)1 CheckPermission (com.emc.storageos.security.authorization.CheckPermission)1 ArrayList (java.util.ArrayList)1 Consumes (javax.ws.rs.Consumes)1 PUT (javax.ws.rs.PUT)1 Path (javax.ws.rs.Path)1 Produces (javax.ws.rs.Produces)1