Search in sources :

Example 1 with SanZone

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

the class NetworkSystemService method removeSanZones.

/**
 * Deletes one or more zone(s) from the active zoneset of the VSAN or fabric specified in
 * the network system. This is an asynchronous call.
 *
 * @param sanZones A list of Zones and their zone members that should be deleted from
 *            the active zoneset. Note: the zone members must be included (deletion of a zone is based
 *            on matching both the name and the zone 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 none
 * @brief Delete zones from network system VSAN or fabric
 * @return A task description structure.
 * @throws InternalException
 */
@POST
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}/san-fabrics/{fabricId}/san-zones/remove")
@CheckPermission(roles = { Role.SYSTEM_ADMIN, Role.RESTRICTED_SYSTEM_ADMIN })
public TaskResourceRep removeSanZones(SanZonesDeleteParam sanZones, @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);
    Operation op = _dbClient.createTaskOpStatus(NetworkSystem.class, device.getId(), task, ResourceOperationTypeEnum.REMOVE_SAN_ZONE);
    List<Zone> zones = new ArrayList<Zone>();
    for (SanZone sz : sanZones.getZones()) {
        Zone zone = new Zone(sz.getName());
        zones.add(zone);
        for (String szm : sz.getMembers()) {
            ZoneMember member = createZoneMember(szm);
            zone.getMembers().add(member);
        }
        auditOp(OperationTypeEnum.REMOVE_SAN_ZONE, true, AuditLogManager.AUDITOP_BEGIN, zone.getName(), device.getId().toString(), device.getLabel(), device.getPortNumber(), device.getUsername(), device.getSmisProviderIP(), device.getSmisPortNumber(), device.getSmisUserName(), device.getSmisUseSSL(), device.getVersion(), device.getUptime());
    }
    ArgValidator.checkFieldNotEmpty(zones, "zones");
    NetworkController controller = getNetworkController(device.getSystemType());
    controller.removeSanZones(device.getId(), fabricId, fabricWwn, zones, false, task);
    return toTask(device, task, op);
}
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) ArrayList(java.util.ArrayList) ZoneMember(com.emc.storageos.networkcontroller.impl.mds.ZoneMember) Operation(com.emc.storageos.db.client.model.Operation) SanZone(com.emc.storageos.model.network.SanZone) NetworkController(com.emc.storageos.networkcontroller.NetworkController) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Example 2 with SanZone

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

the class NetworkSystemService method addSanZones.

/**
 * Adds one or more SAN zones to the active zoneset of the VSAN or fabric specified on a network system.
 * This is an asynchronous call.
 *
 * @param sanZones 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 none
 * @brief Add SAN zones to network system VSAN or fabric
 * @return A task description structure.
 * @throws InternalException
 */
@POST
@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 addSanZones(SanZoneCreateParam sanZones, @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<Zone> zones = new ArrayList<Zone>();
    for (SanZone sz : sanZones.getZones()) {
        Zone zone = new Zone(sz.getName());
        validateZoneName(sz.getName(), device.getSystemType());
        zones.add(zone);
        for (String szm : sz.getMembers()) {
            ZoneMember member = createZoneMember(szm);
            zone.getMembers().add(member);
        }
        ArgValidator.checkFieldNotEmpty(zone.getMembers(), "zone members");
        auditOp(OperationTypeEnum.ADD_SAN_ZONE, true, AuditLogManager.AUDITOP_BEGIN, zone.getName(), device.getId().toString(), device.getLabel(), device.getPortNumber(), device.getUsername(), device.getSmisProviderIP(), device.getSmisPortNumber(), device.getSmisUserName(), device.getSmisUseSSL(), device.getVersion(), device.getUptime());
    }
    ArgValidator.checkFieldNotEmpty(zones, "zones");
    Operation op = _dbClient.createTaskOpStatus(NetworkSystem.class, device.getId(), task, ResourceOperationTypeEnum.ADD_SAN_ZONE);
    NetworkController controller = getNetworkController(device.getSystemType());
    controller.addSanZones(device.getId(), fabricId, fabricWwn, zones, false, task);
    return toTask(device, task, op);
}
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) ArrayList(java.util.ArrayList) ZoneMember(com.emc.storageos.networkcontroller.impl.mds.ZoneMember) Operation(com.emc.storageos.db.client.model.Operation) SanZone(com.emc.storageos.model.network.SanZone) NetworkController(com.emc.storageos.networkcontroller.NetworkController) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Aggregations

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