Search in sources :

Example 1 with WwnAliasUpdateParam

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

the class NetworkSystemService method updateAliases.

/**
 * Changes the WWN member of one or more aliases on the specified network system. For Brocade
 * the fabric of the aliases will be removed must be specified.
 * For MDS, this input is ignored if provided.
 * <p>
 * Current address WWN is optional; however, if provided, it must match the one in system before update. If not, exception will be
 * thrown.
 * <p>
 * This is an asynchronous call.
 *
 * @param aliases A parameter structure listing the aliases to be updated
 * @param id the URN of a ViPR network system.
 * @param fabricId The name of the VSAN or fabric. This parameter is ignored
 *            if network system is an MDS
 * @prereq none
 * @brief Update aliases in network system
 * @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-aliases")
@CheckPermission(roles = { Role.SYSTEM_ADMIN, Role.RESTRICTED_SYSTEM_ADMIN })
public TaskResourceRep updateAliases(WwnAliasUpdateParams updateAliasParam, @PathParam("id") URI id) throws InternalException {
    String task = UUID.randomUUID().toString();
    ArgValidator.checkFieldUriType(id, NetworkSystem.class, "id");
    ArgValidator.checkFieldNotEmpty(updateAliasParam.getUpdateAliases(), "aliases");
    NetworkSystem device = queryResource(id);
    String fabricId = updateAliasParam.getFabricId();
    if (Type.brocade.toString().equals(device.getSystemType())) {
        ArgValidator.checkFieldNotEmpty(fabricId, "fabric-id");
    }
    String fabricWwn = null;
    if (WWNUtility.isValidWWN(fabricId)) {
        fabricWwn = fabricId;
        fabricId = fabricId.replaceAll(":", "");
    }
    Operation op = _dbClient.createTaskOpStatus(NetworkSystem.class, device.getId(), task, ResourceOperationTypeEnum.UPDATE_ALIAS);
    List<ZoneWwnAliasUpdate> zoneAliasesUpdate = new ArrayList<ZoneWwnAliasUpdate>();
    for (WwnAliasUpdateParam updateAlias : updateAliasParam.getUpdateAliases()) {
        validateAlias(updateAlias, false);
        // validate new address
        if (!StringUtils.isEmpty(updateAlias.getNewAddress())) {
            validateWWN(updateAlias.getNewAddress());
        }
        // validate new name
        if (!StringUtils.isEmpty(updateAlias.getNewName())) {
            validateWWNAlias(updateAlias.getNewName());
        }
        zoneAliasesUpdate.add(new ZoneWwnAliasUpdate(updateAlias.getName(), updateAlias.getNewName(), updateAlias.getNewAddress(), updateAlias.getAddress()));
        auditOp(OperationTypeEnum.UPDATE_ALIAS, true, AuditLogManager.AUDITOP_BEGIN, updateAlias.getName(), device.getId().toString(), device.getLabel(), device.getPortNumber(), device.getUsername(), device.getSmisProviderIP(), device.getSmisPortNumber(), device.getSmisUserName(), device.getSmisUseSSL(), device.getVersion(), device.getUptime());
    }
    NetworkController controller = getNetworkController(device.getSystemType());
    controller.updateAliases(device.getId(), fabricId, fabricWwn, zoneAliasesUpdate, 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) ZoneWwnAliasUpdate(com.emc.storageos.networkcontroller.impl.mds.ZoneWwnAliasUpdate) Operation(com.emc.storageos.db.client.model.Operation) WwnAliasUpdateParam(com.emc.storageos.model.network.WwnAliasUpdateParam) 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 WwnAliasUpdateParam (com.emc.storageos.model.network.WwnAliasUpdateParam)1 NetworkController (com.emc.storageos.networkcontroller.NetworkController)1 ZoneWwnAliasUpdate (com.emc.storageos.networkcontroller.impl.mds.ZoneWwnAliasUpdate)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