Search in sources :

Example 46 with NetworkSystem

use of com.emc.storageos.db.client.model.NetworkSystem 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 47 with NetworkSystem

use of com.emc.storageos.db.client.model.NetworkSystem 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)

Example 48 with NetworkSystem

use of com.emc.storageos.db.client.model.NetworkSystem in project coprhd-controller by CoprHD.

the class NetworkSystemService method discoverNetworkSystem.

/**
 * Discovers (refreshes) a network system. This is an asynchronous call.
 * Currently this updates the end point (topology) information,
 * which will be reconciled with the existing networks.
 *
 * @param id the URN of a ViPR Network System.
 * @prereq none
 * @brief Discover network system
 * @return TaskResourceRep (asynchronous call)
 */
@POST
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}/discover")
@CheckPermission(roles = { Role.SYSTEM_ADMIN, Role.RESTRICTED_SYSTEM_ADMIN })
public TaskResourceRep discoverNetworkSystem(@PathParam("id") URI id) {
    ArgValidator.checkFieldUriType(id, NetworkSystem.class, "id");
    NetworkSystem device = queryObject(NetworkSystem.class, id, true);
    return doDiscoverNetworkSystem(device);
}
Also used : NetworkSystem(com.emc.storageos.db.client.model.NetworkSystem) MapNetworkSystem(com.emc.storageos.api.mapper.functions.MapNetworkSystem) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Produces(javax.ws.rs.Produces) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Example 49 with NetworkSystem

use of com.emc.storageos.db.client.model.NetworkSystem in project coprhd-controller by CoprHD.

the class NetworkSystemService method getSanZones.

/**
 * Returns a list of the active zones (and their zone members) for the specified
 * fabric or VSAN in a network system. E.g., ../san-fabrics/{fabric-id}/san-zones?zone-name="abc-zone"&exclude-members=true
 * 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 VSAN or fabric as returned by
 * @param zoneName - only returns zone with zone name matched the given name. Return all zones, if not specified.
 * @param excludeMembers - true, do not include members with zone. Include members, if not specified.
 * @param excludeAliases - true, do not include aliases with zone. Include aliases, if not specified.
 * @prereq none
 * @brief List active zones in a network system fabric or VSAN
 * @return A list of the active zones and their members. If zone name is specified, and there is a match, then only one zone is
 *         returned.
 *         If excludeMembers is true, then only zone name is present.
 * @throws InternalException
 */
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}/san-fabrics/{fabricId}/san-zones")
@CheckPermission(roles = { Role.SYSTEM_ADMIN })
public SanZonesRestRep getSanZones(@PathParam("id") URI id, @PathParam("fabricId") String fabricId, @QueryParam("zone-name") String zoneName, @QueryParam("exclude-members") boolean excludeMembers, @QueryParam("exclude-aliases") boolean excludeAliases) throws InternalException {
    SanZonesRestRep szones = new SanZonesRestRep();
    ArgValidator.checkFieldUriType(id, NetworkSystem.class, "id");
    NetworkSystem device = queryResource(id);
    String fabricWwn = null;
    if (WWNUtility.isValidWWN(fabricId)) {
        fabricWwn = fabricId;
        fabricId = fabricId.replaceAll(":", "");
    }
    NetworkController controller = getNetworkController(device.getSystemType());
    List<Zoneset> zonesets = controller.getZonesets(device.getId(), fabricId, fabricWwn, zoneName, excludeMembers, excludeAliases);
    for (Zoneset zoneset : zonesets) {
        for (Zone zone : zoneset.getZones()) {
            SanZoneRestRep sz = new SanZoneRestRep();
            sz.setName(zone.getName());
            for (ZoneMember member : zone.getMembers()) {
                // convert zone member to xml aware. Only fill in alias if member is an alias type
                sz.getMembers().add(new SanZoneMemberRestRep(member.getAddress(), member.isAliasType() ? member.getAlias() : null));
            }
            szones.getZones().add(sz);
        }
    }
    return szones;
}
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) SanZoneMemberRestRep(com.emc.storageos.model.network.SanZoneMemberRestRep) ZoneMember(com.emc.storageos.networkcontroller.impl.mds.ZoneMember) SanZonesRestRep(com.emc.storageos.model.network.SanZonesRestRep) Zoneset(com.emc.storageos.networkcontroller.impl.mds.Zoneset) SanZoneRestRep(com.emc.storageos.model.network.SanZoneRestRep) 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 50 with NetworkSystem

use of com.emc.storageos.db.client.model.NetworkSystem in project coprhd-controller by CoprHD.

the class NetworkSystemService method deregisterNetworkSystem.

/**
 * Deregister a network system.
 *
 * @param id the URN of a ViPR network system.
 *
 * @prereq none
 * @brief Deregister network system
 * @return A NetworkSystemRestRep reference specifying the data for the
 *         updated network system.
 * @throws ControllerException
 *
 * @throws IllegalArgumentException When the network system is already
 *             registered.
 */
@POST
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}/deregister")
@CheckPermission(roles = { Role.SYSTEM_ADMIN, Role.RESTRICTED_SYSTEM_ADMIN })
public NetworkSystemRestRep deregisterNetworkSystem(@PathParam("id") URI id) throws ControllerException {
    // Validate the storage system.
    ArgValidator.checkUri(id);
    NetworkSystem networkSystem = _dbClient.queryObject(NetworkSystem.class, id);
    ArgValidator.checkEntity(networkSystem, id, isIdEmbeddedInURL(id));
    if (!RegistrationStatus.UNREGISTERED.toString().equalsIgnoreCase(networkSystem.getRegistrationStatus())) {
        // Deregister all Networks for this system.
        List<Network> networkList = CustomQueryUtility.queryActiveResourcesByConstraint(_dbClient, Network.class, AlternateIdConstraint.Factory.getConstraint(Network.class, "networkSystems", networkSystem.getId().toString()));
        for (Network network : networkList) {
            if (network.getInactive() || DiscoveredDataObject.RegistrationStatus.UNREGISTERED.toString().equals(network.getRegistrationStatus())) {
                continue;
            }
            List<URI> registeredNetworkSystems = NetworkService.getRegisteredNetworkSystems(network, _dbClient);
            registeredNetworkSystems.remove(networkSystem.getId());
            // Only unregister Network if it is not managed by other registered NetworkSystems
            if (registeredNetworkSystems.isEmpty()) {
                network.setRegistrationStatus(RegistrationStatus.UNREGISTERED.toString());
                _dbClient.updateObject(network);
                auditOp(OperationTypeEnum.DEREGISTER_NETWORK, true, null, id.toString());
            }
        }
        networkSystem.setRegistrationStatus(RegistrationStatus.UNREGISTERED.toString());
        _dbClient.updateObject(networkSystem);
        auditOp(OperationTypeEnum.DEREGISTER_NETWORK_SYSTEM, true, null, networkSystem.getId().toString(), networkSystem.getLabel(), networkSystem.getPortNumber(), networkSystem.getUsername(), networkSystem.getSmisProviderIP(), networkSystem.getSmisPortNumber(), networkSystem.getSmisUserName(), networkSystem.getSmisUseSSL());
    }
    return map(networkSystem);
}
Also used : Network(com.emc.storageos.db.client.model.Network) NetworkSystem(com.emc.storageos.db.client.model.NetworkSystem) MapNetworkSystem(com.emc.storageos.api.mapper.functions.MapNetworkSystem) URI(java.net.URI) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Produces(javax.ws.rs.Produces) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Aggregations

NetworkSystem (com.emc.storageos.db.client.model.NetworkSystem)54 MapNetworkSystem (com.emc.storageos.api.mapper.functions.MapNetworkSystem)21 CheckPermission (com.emc.storageos.security.authorization.CheckPermission)20 Produces (javax.ws.rs.Produces)20 ArrayList (java.util.ArrayList)19 Path (javax.ws.rs.Path)18 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)16 NetworkDeviceControllerException (com.emc.storageos.networkcontroller.exceptions.NetworkDeviceControllerException)16 ControllerException (com.emc.storageos.volumecontroller.ControllerException)16 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)13 URI (java.net.URI)13 NetworkController (com.emc.storageos.networkcontroller.NetworkController)11 BiosCommandResult (com.emc.storageos.volumecontroller.impl.BiosCommandResult)10 Consumes (javax.ws.rs.Consumes)10 POST (javax.ws.rs.POST)10 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)9 Operation (com.emc.storageos.db.client.model.Operation)8 ZoneMember (com.emc.storageos.networkcontroller.impl.mds.ZoneMember)8 InterProcessLock (org.apache.curator.framework.recipes.locks.InterProcessLock)8 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)7