Search in sources :

Example 96 with StorageSystem

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

the class StorageSystemService method getStoragePort.

/**
 * Get information about the storage port with the passed id on the
 * registered storage system with the passed id.
 *
 * @param id the URN of a ViPR storage system.
 * @param portId The id of the storage port.
 *
 * @brief Show storage system storage port
 * @return A StoragePortRestRep reference specifying the data for the
 *         requested port.
 */
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}/storage-ports/{portId}")
@CheckPermission(roles = { Role.SYSTEM_ADMIN, Role.SYSTEM_MONITOR })
public StoragePortRestRep getStoragePort(@PathParam("id") URI id, @PathParam("portId") URI portId) {
    // Make sure the storage system is registered.
    ArgValidator.checkFieldUriType(id, StorageSystem.class, "id");
    StorageSystem system = queryResource(id);
    ArgValidator.checkEntity(system, id, isIdEmbeddedInURL(id));
    ArgValidator.checkFieldUriType(portId, StoragePort.class, "portId");
    StoragePort port = _dbClient.queryObject(StoragePort.class, portId);
    ArgValidator.checkEntity(port, portId, isIdEmbeddedInURL(portId));
    return MapStoragePort.getInstance(_dbClient).toStoragePortRestRep(port);
}
Also used : MapStoragePort(com.emc.storageos.api.mapper.functions.MapStoragePort) StoragePort(com.emc.storageos.db.client.model.StoragePort) StorageSystem(com.emc.storageos.db.client.model.StorageSystem) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Example 97 with StorageSystem

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

the class StorageSystemService method getStorageSystems.

/**
 * Gets the id, name, and self link for all registered storage systems.
 *
 * @brief List storage systems
 * @return A reference to a StorageSystemList.
 */
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@CheckPermission(roles = { Role.SYSTEM_ADMIN, Role.SYSTEM_MONITOR })
public StorageSystemList getStorageSystems() {
    StorageSystemList systemsList = new StorageSystemList();
    List<URI> ids = _dbClient.queryByType(StorageSystem.class, true);
    Iterator<StorageSystem> iter = _dbClient.queryIterativeObjects(StorageSystem.class, ids);
    while (iter.hasNext()) {
        systemsList.getStorageSystems().add(toNamedRelatedResource(iter.next()));
    }
    return systemsList;
}
Also used : StorageSystemList(com.emc.storageos.model.systems.StorageSystemList) URI(java.net.URI) StorageSystem(com.emc.storageos.db.client.model.StorageSystem) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Example 98 with StorageSystem

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

the class StorageSystemService method getStorageSystem.

/**
 * Get information about the registered storage system with the passed id.
 *
 * @param id the URN of a ViPR storage system.
 *
 * @brief Show storage system
 * @return A reference to a StorageSystemRestRep
 */
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}")
@CheckPermission(roles = { Role.SYSTEM_ADMIN, Role.SYSTEM_MONITOR })
public StorageSystemRestRep getStorageSystem(@PathParam("id") URI id) {
    ArgValidator.checkFieldUriType(id, StorageSystem.class, "id");
    StorageSystem system = queryResource(id);
    StorageSystemRestRep restRep = map(system);
    restRep.setNumResources(getNumResources(system, _dbClient));
    return restRep;
}
Also used : StorageSystemRestRep(com.emc.storageos.model.systems.StorageSystemRestRep) StorageSystem(com.emc.storageos.db.client.model.StorageSystem) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Example 99 with StorageSystem

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

the class InitiatorService method setInitiatorAlias.

/**
 * Sets the alias/initiator name for an initiator
 * on the Storage System
 *
 * @param id the URN of a ViPR initiator
 * @param aliasSetParam the parameter containing the storage system and alias attributes
 * @prereq none
 * @brief Set the serial number and alias on this storage system for an initiator
 * @return A reference to an InitiatorRestRep representing the Initiator Alias after Set..
 * @throws Exception When an error occurs setting the alias on a VMAX Storage System.
 */
@PUT
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}/alias")
public InitiatorAliasRestRep setInitiatorAlias(@PathParam("id") URI id, InitiatorAliasSetParam aliasSetParam) {
    // Basic Checks
    Initiator initiator = queryResource(id);
    verifyUserPermisions(initiator);
    URI systemURI = aliasSetParam.getSystemURI();
    ArgValidator.checkFieldUriType(systemURI, StorageSystem.class, "id");
    StorageSystem system = _permissionsHelper.getObjectById(systemURI, StorageSystem.class);
    ArgValidator.checkEntity(system, systemURI, isIdEmbeddedInURL(systemURI));
    String initiatorAlias = aliasSetParam.getInitiatorAlias();
    ArgValidator.checkFieldNotNull(initiatorAlias, "alias");
    if (!initiatorAlias.contains(EMPTY_INITIATOR_ALIAS)) {
        ArgValidator.checkFieldLengthMaximum(initiatorAlias, ALIAS_MAX_LIMIT, "alias");
    } else {
        ArgValidator.checkFieldLengthMaximum(initiatorAlias.split(EMPTY_INITIATOR_ALIAS)[0], ALIAS_MAX_LIMIT, "alias node name");
        ArgValidator.checkFieldLengthMaximum(initiatorAlias.split(EMPTY_INITIATOR_ALIAS)[1], ALIAS_MAX_LIMIT, "alias port name");
    }
    if (initiatorAlias.matches(ALIAS_ILLEGAL_CHARACTERS)) {
        String errMsg = String.format("Supplied Alias: %s has invalid characters", initiatorAlias);
        _log.error(errMsg);
        throw DeviceControllerException.exceptions.couldNotPerformAliasOperation(errMsg);
    }
    _log.info("Setting alias- {} for initiator {} on system {}", initiatorAlias, id, systemURI);
    if (system != null && StorageSystem.Type.vmax.toString().equalsIgnoreCase(system.getSystemType())) {
        BlockController controller = getController(BlockController.class, system.getSystemType());
        try {
            // Actual Control
            controller.setInitiatorAlias(systemURI, id, initiatorAlias);
        } catch (Exception e) {
            _log.error("Unexpected error: Setting alias failed.", e);
            throw APIException.badRequests.unableToProcessRequest(e.getMessage());
        }
    } else {
        throw APIException.badRequests.operationNotSupportedForSystemType(ALIAS, system.getSystemType());
    }
    // Update the Initiator here..
    if (initiatorAlias.contains(EMPTY_INITIATOR_ALIAS)) {
        // If the Initiator Alias contains the "/" character, the user has supplied
        // different node and port names.
        initiator.mapInitiatorName(system.getSerialNumber(), initiatorAlias);
    } else {
        // The user has set the same node and port names.
        initiatorAlias = String.format("%s%s%s", initiatorAlias, EMPTY_INITIATOR_ALIAS, initiatorAlias);
        initiator.mapInitiatorName(system.getSerialNumber(), initiatorAlias);
    }
    _dbClient.updateObject(initiator);
    return new InitiatorAliasRestRep(system.getSerialNumber(), initiatorAlias);
}
Also used : MapInitiator(com.emc.storageos.api.mapper.functions.MapInitiator) Initiator(com.emc.storageos.db.client.model.Initiator) BlockController(com.emc.storageos.volumecontroller.BlockController) InitiatorAliasRestRep(com.emc.storageos.model.host.InitiatorAliasRestRep) URI(java.net.URI) APIException(com.emc.storageos.svcs.errorhandling.resources.APIException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) StorageSystem(com.emc.storageos.db.client.model.StorageSystem) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) Consumes(javax.ws.rs.Consumes) PUT(javax.ws.rs.PUT)

Example 100 with StorageSystem

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

the class ProtectionSystemService method getConnectivity.

/**
 * This method will assemble a connectivity table that expresses all of the storage systems
 * that are connected via this protection system. We will mark which RP site each storage
 * system is visible on.
 *
 * @param system protection system
 * @return rest response
 */
private ProtectionSystemConnectivityRestRep getConnectivity(ProtectionSystem system) {
    ProtectionSystemConnectivityRestRep response = new ProtectionSystemConnectivityRestRep();
    // Dig through the RPSiteArray table for now and return connectivity
    Map<String, Set<URI>> siteStorageSystemMap = new HashMap<String, Set<URI>>();
    // Get the rp system's array mappings from the RP client
    URIQueryResultList sitelist = new URIQueryResultList();
    _dbClient.queryByConstraint(AlternateIdConstraint.Factory.getRPSiteArrayProtectionSystemConstraint(system.getId().toString()), sitelist);
    List<RPSiteArray> rpSiteArrays = new ArrayList<RPSiteArray>();
    Iterator<URI> it = sitelist.iterator();
    while (it.hasNext()) {
        URI rpSiteArrayId = it.next();
        RPSiteArray siteArray = _dbClient.queryObject(RPSiteArray.class, rpSiteArrayId);
        if (siteArray != null) {
            rpSiteArrays.add(siteArray);
        }
    }
    for (RPSiteArray rpSiteArray : rpSiteArrays) {
        _log.info("dicoverProtectionSystem(): analyzing rpsitearray: " + rpSiteArray.toString());
        if (siteStorageSystemMap.get(rpSiteArray.getRpSiteName()) == null) {
            siteStorageSystemMap.put(rpSiteArray.getRpSiteName(), new HashSet<URI>());
        }
        // Add this storage system associated with this RP Site
        siteStorageSystemMap.get(rpSiteArray.getRpSiteName()).add(rpSiteArray.getStorageSystem());
    }
    // Translate the primitive type into a presentable type
    for (String siteId : siteStorageSystemMap.keySet()) {
        ProtectionSystemConnectivitySiteRestRep site = new ProtectionSystemConnectivitySiteRestRep();
        site.setSiteID(siteId);
        Set<URI> addedStorageSystems = new HashSet<URI>();
        for (URI storageID : siteStorageSystemMap.get(siteId)) {
            if (!addedStorageSystems.contains(storageID)) {
                StorageSystem storageSystem = _dbClient.queryObject(StorageSystem.class, storageID);
                site.getStorageSystems().add(toRelatedResource(ResourceTypeEnum.STORAGE_SYSTEM, storageSystem.getId()));
                addedStorageSystems.add(storageID);
            }
        }
        if (response.getProtectionSites() == null) {
            response.setProtectionSites(new ArrayList<ProtectionSystemConnectivitySiteRestRep>());
        }
        response.getProtectionSites().add(site);
    }
    response.setProtectionSystem(toNamedRelatedResource(ResourceTypeEnum.PROTECTION_SYSTEM, system.getId(), system.getLabel()));
    return response;
}
Also used : RPSiteArray(com.emc.storageos.db.client.model.RPSiteArray) ProtectionSet(com.emc.storageos.db.client.model.ProtectionSet) Set(java.util.Set) HashSet(java.util.HashSet) HashMap(java.util.HashMap) ProtectionSystemConnectivitySiteRestRep(com.emc.storageos.model.protection.ProtectionSystemConnectivitySiteRestRep) ArrayList(java.util.ArrayList) URI(java.net.URI) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) ProtectionSystemConnectivityRestRep(com.emc.storageos.model.protection.ProtectionSystemConnectivityRestRep) HashSet(java.util.HashSet) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Aggregations

StorageSystem (com.emc.storageos.db.client.model.StorageSystem)1088 URI (java.net.URI)581 ArrayList (java.util.ArrayList)424 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)319 Volume (com.emc.storageos.db.client.model.Volume)299 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)272 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)258 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)246 NamedURI (com.emc.storageos.db.client.model.NamedURI)243 WorkflowException (com.emc.storageos.workflow.WorkflowException)233 ControllerException (com.emc.storageos.volumecontroller.ControllerException)231 HashMap (java.util.HashMap)172 StoragePool (com.emc.storageos.db.client.model.StoragePool)159 BaseCollectionException (com.emc.storageos.plugins.BaseCollectionException)158 StringSet (com.emc.storageos.db.client.model.StringSet)156 URISyntaxException (java.net.URISyntaxException)145 List (java.util.List)139 IOException (java.io.IOException)136 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)127 Workflow (com.emc.storageos.workflow.Workflow)126