Search in sources :

Example 1 with WwnAliasParam

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

the class NetworkSystemService method getAliases.

/**
 * Returns a list of aliases for the specified network system. For Brocade, aliases
 * can be retrieved per fabric only and fabric-id is a required parameter. For MDS,
 * the full list of device aliases for the network system is returned and fabric-id is
 * ignored if provided.
 *
 * 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 fabric as returned by
 *            /vdc/network-systems/{id}/san-fabrics or the WWN of the fabric
 * @prereq none
 * @brief List aliases in a network system or a fabric
 * @return A list of aliases.
 * @throws InternalException
 */
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}/san-aliases")
@CheckPermission(roles = { Role.SYSTEM_ADMIN })
public WwnAliasesParam getAliases(@PathParam("id") URI id, @QueryParam("fabric-id") String fabricId) throws InternalException {
    ArgValidator.checkFieldUriType(id, NetworkSystem.class, "id");
    NetworkSystem device = queryResource(id);
    if (Type.brocade.toString().equals(device.getSystemType())) {
        ArgValidator.checkFieldNotEmpty(fabricId, "fabric-id");
    }
    String fabricWwn = null;
    if (WWNUtility.isValidWWN(fabricId)) {
        fabricWwn = fabricId;
        fabricId = fabricId.replaceAll(":", "");
    }
    NetworkController controller = getNetworkController(device.getSystemType());
    List<WwnAliasParam> aliases = new ArrayList<WwnAliasParam>(controller.getAliases(device.getId(), fabricId, fabricWwn));
    return new WwnAliasesParam(aliases);
}
Also used : WwnAliasesParam(com.emc.storageos.model.network.WwnAliasesParam) WwnAliasParam(com.emc.storageos.model.network.WwnAliasParam) NetworkSystem(com.emc.storageos.db.client.model.NetworkSystem) MapNetworkSystem(com.emc.storageos.api.mapper.functions.MapNetworkSystem) ArrayList(java.util.ArrayList) 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)

Example 2 with WwnAliasParam

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

the class NetworkSystemService method addAliases.

/**
 * Adds one or more aliases to the specified network system. For Brocade the fabric where
 * the aliases will be added must be specified. For MDS, this input is ignored if provided.
 * <p>
 * This is an asynchronous call.
 *
 * @param aliases A parameter structure listing the aliases to be added
 * @param id the URN of a ViPR network system.
 * @prereq none
 * @brief Add aliases to a network system
 * @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-aliases/")
@CheckPermission(roles = { Role.SYSTEM_ADMIN, Role.RESTRICTED_SYSTEM_ADMIN })
public TaskResourceRep addAliases(WwnAliasesCreateParam aliases, @PathParam("id") URI id) throws InternalException {
    String task = UUID.randomUUID().toString();
    ArgValidator.checkFieldUriType(id, NetworkSystem.class, "id");
    ArgValidator.checkFieldNotEmpty(aliases.getAliases(), "aliases");
    NetworkSystem device = queryResource(id);
    String fabricId = aliases.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.ADD_ALIAS);
    List<ZoneWwnAlias> zoneAliases = new ArrayList<ZoneWwnAlias>();
    for (WwnAliasParam alias : aliases.getAliases()) {
        ArgValidator.checkFieldNotEmpty(alias.getAddress(), "address");
        validateAlias(alias, true);
        zoneAliases.add(new ZoneWwnAlias(alias.getName(), alias.getAddress()));
        auditOp(OperationTypeEnum.ADD_ALIAS, true, AuditLogManager.AUDITOP_BEGIN, alias.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.addAliases(device.getId(), fabricId, fabricWwn, zoneAliases, task);
    return toTask(device, task, op);
}
Also used : WwnAliasParam(com.emc.storageos.model.network.WwnAliasParam) NetworkSystem(com.emc.storageos.db.client.model.NetworkSystem) MapNetworkSystem(com.emc.storageos.api.mapper.functions.MapNetworkSystem) ArrayList(java.util.ArrayList) Operation(com.emc.storageos.db.client.model.Operation) ZoneWwnAlias(com.emc.storageos.networkcontroller.impl.mds.ZoneWwnAlias) 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 3 with WwnAliasParam

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

the class NetworkSystemService method removeAliases.

/**
 * Removes one or more aliases from the specified network system. For Brocade the fabric from where
 * the aliases will be removed must be specified. For MDS, this input is ignored if provided.
 *
 * @param aliases A parameter structure listing the aliases to be removed. The alias member is an
 *            optional parameter and when provided, the alias membership is checked prior to removing it.
 * @param id the URN of a ViPR network system.
 * @prereq none
 * @brief Remove aliases to network system to 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-aliases/remove")
@CheckPermission(roles = { Role.SYSTEM_ADMIN, Role.RESTRICTED_SYSTEM_ADMIN })
public TaskResourceRep removeAliases(WwnAliasesDeleteParam aliases, @PathParam("id") URI id) throws InternalException {
    String task = UUID.randomUUID().toString();
    ArgValidator.checkFieldUriType(id, NetworkSystem.class, "id");
    ArgValidator.checkFieldNotEmpty(aliases.getAliases(), "aliases");
    NetworkSystem device = queryResource(id);
    String fabricId = aliases.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.REMOVE_ALIAS);
    List<ZoneWwnAlias> zoneAliases = new ArrayList<ZoneWwnAlias>();
    for (WwnAliasParam alias : aliases.getAliases()) {
        validateAlias(alias, false);
        zoneAliases.add(new ZoneWwnAlias(alias.getName(), alias.getAddress()));
        auditOp(OperationTypeEnum.REMOVE_ALIAS, true, AuditLogManager.AUDITOP_BEGIN, alias.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.removeAliases(device.getId(), fabricId, fabricWwn, zoneAliases, task);
    return toTask(device, task, op);
}
Also used : WwnAliasParam(com.emc.storageos.model.network.WwnAliasParam) NetworkSystem(com.emc.storageos.db.client.model.NetworkSystem) MapNetworkSystem(com.emc.storageos.api.mapper.functions.MapNetworkSystem) ArrayList(java.util.ArrayList) Operation(com.emc.storageos.db.client.model.Operation) ZoneWwnAlias(com.emc.storageos.networkcontroller.impl.mds.ZoneWwnAlias) 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)3 NetworkSystem (com.emc.storageos.db.client.model.NetworkSystem)3 WwnAliasParam (com.emc.storageos.model.network.WwnAliasParam)3 NetworkController (com.emc.storageos.networkcontroller.NetworkController)3 CheckPermission (com.emc.storageos.security.authorization.CheckPermission)3 ArrayList (java.util.ArrayList)3 Path (javax.ws.rs.Path)3 Produces (javax.ws.rs.Produces)3 Operation (com.emc.storageos.db.client.model.Operation)2 ZoneWwnAlias (com.emc.storageos.networkcontroller.impl.mds.ZoneWwnAlias)2 Consumes (javax.ws.rs.Consumes)2 POST (javax.ws.rs.POST)2 WwnAliasesParam (com.emc.storageos.model.network.WwnAliasesParam)1 GET (javax.ws.rs.GET)1