Search in sources :

Example 1 with NetworkController

use of com.emc.storageos.networkcontroller.NetworkController in project coprhd-controller by CoprHD.

the class NetworkSystemService method getFabrics.

/**
 * Returns a list of the VSAN or fabric names configured on this network system.
 * 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.
 * @prereq none
 * @brief List network system VSANs and fabrics
 * @return A list of fabric names configured on the Network System.
 * @throws InternalException
 */
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}/san-fabrics")
@CheckPermission(roles = { Role.SYSTEM_ADMIN, Role.SYSTEM_MONITOR })
public Fabrics getFabrics(@PathParam("id") URI id) throws InternalException {
    Fabrics fabrics = new Fabrics();
    ArgValidator.checkFieldUriType(id, NetworkSystem.class, "id");
    NetworkSystem device = queryResource(id);
    NetworkController controller = getNetworkController(device.getSystemType());
    List<String> fabricIds = controller.getFabricIds(device.getId());
    fabrics.setFabricIds(fabricIds);
    return fabrics;
}
Also used : NetworkSystem(com.emc.storageos.db.client.model.NetworkSystem) MapNetworkSystem(com.emc.storageos.api.mapper.functions.MapNetworkSystem) Fabrics(com.emc.storageos.model.network.Fabrics) 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 NetworkController

use of com.emc.storageos.networkcontroller.NetworkController 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 3 with NetworkController

use of com.emc.storageos.networkcontroller.NetworkController in project coprhd-controller by CoprHD.

the class NetworkSystemService method startNetworkSystem.

/**
 * Invoke connect to the NetworkSystem. This will check for basic connectivity,
 * support for the device, etc.
 *
 * @param device
 * @throws InternalException
 */
private void startNetworkSystem(NetworkSystem device) throws InternalException {
    NetworkController controller = getNetworkController(device.getSystemType());
    controller.connectNetwork(device.getId());
}
Also used : NetworkController(com.emc.storageos.networkcontroller.NetworkController)

Example 4 with NetworkController

use of com.emc.storageos.networkcontroller.NetworkController 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 5 with NetworkController

use of com.emc.storageos.networkcontroller.NetworkController 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

NetworkController (com.emc.storageos.networkcontroller.NetworkController)12 MapNetworkSystem (com.emc.storageos.api.mapper.functions.MapNetworkSystem)11 NetworkSystem (com.emc.storageos.db.client.model.NetworkSystem)11 CheckPermission (com.emc.storageos.security.authorization.CheckPermission)10 Path (javax.ws.rs.Path)10 Produces (javax.ws.rs.Produces)10 ArrayList (java.util.ArrayList)8 Operation (com.emc.storageos.db.client.model.Operation)7 Consumes (javax.ws.rs.Consumes)7 POST (javax.ws.rs.POST)5 ZoneMember (com.emc.storageos.networkcontroller.impl.mds.ZoneMember)4 SanZone (com.emc.storageos.model.network.SanZone)3 WwnAliasParam (com.emc.storageos.model.network.WwnAliasParam)3 Zone (com.emc.storageos.networkcontroller.impl.mds.Zone)3 GET (javax.ws.rs.GET)3 ZoneWwnAlias (com.emc.storageos.networkcontroller.impl.mds.ZoneWwnAlias)2 PUT (javax.ws.rs.PUT)2 DiscoveredObjectTaskScheduler (com.emc.storageos.api.service.impl.resource.utils.DiscoveredObjectTaskScheduler)1 TaskList (com.emc.storageos.model.TaskList)1 Fabrics (com.emc.storageos.model.network.Fabrics)1