Search in sources :

Example 21 with CheckPermission

use of com.emc.storageos.security.authorization.CheckPermission in project coprhd-controller by CoprHD.

the class StorageSystemService method getAllRAGroups.

/**
 * Get All RA Groups
 *
 * @param id
 * @brief List RDF groups names in a storage system
 * @return
 */
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}/rdf-groups")
@CheckPermission(roles = { Role.SYSTEM_ADMIN, Role.SYSTEM_MONITOR })
public RDFGroupList getAllRAGroups(@PathParam("id") URI id) {
    // Make sure storage system is registered.
    ArgValidator.checkFieldUriType(id, StorageSystem.class, "id");
    StorageSystem system = queryResource(id);
    ArgValidator.checkEntity(system, id, isIdEmbeddedInURL(id));
    RDFGroupList rdfGroupList = new RDFGroupList();
    URIQueryResultList rdfGroupURIs = new URIQueryResultList();
    _dbClient.queryByConstraint(ContainmentConstraint.Factory.getStorageDeviceRemoteGroupsConstraint(id), rdfGroupURIs);
    Iterator<URI> rdfGroupIter = rdfGroupURIs.iterator();
    while (rdfGroupIter.hasNext()) {
        URI rdfGroupURI = rdfGroupIter.next();
        RemoteDirectorGroup rdfGroup = _dbClient.queryObject(RemoteDirectorGroup.class, rdfGroupURI);
        if (rdfGroup != null && !rdfGroup.getInactive()) {
            rdfGroupList.getRdfGroups().add(toNamedRelatedResource(rdfGroup, rdfGroup.getNativeGuid()));
        }
    }
    return rdfGroupList;
}
Also used : RemoteDirectorGroup(com.emc.storageos.db.client.model.RemoteDirectorGroup) RDFGroupList(com.emc.storageos.model.rdfgroup.RDFGroupList) URI(java.net.URI) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) 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 22 with CheckPermission

use of com.emc.storageos.security.authorization.CheckPermission in project coprhd-controller by CoprHD.

the class StorageSystemService method registerStoragePool.

/**
 * Manually register the discovered storage pool with the passed id on the
 * registered storage system with the passed id.
 *
 * @param id the URN of a ViPR storage system.
 * @param poolId The id of the storage pool.
 *
 * @brief Register storage system storage pool
 * @return A reference to a StoragePoolRestRep specifying the data for the
 *         registered storage pool.
 */
@POST
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@CheckPermission(roles = { Role.SYSTEM_ADMIN, Role.RESTRICTED_SYSTEM_ADMIN })
@Path("/{id}/storage-pools/{poolId}/register")
public StoragePoolRestRep registerStoragePool(@PathParam("id") URI id, @PathParam("poolId") URI poolId) {
    // Make sure storage system is registered.
    ArgValidator.checkFieldUriType(id, StorageSystem.class, "id");
    queryRegisteredSystem(id);
    ArgValidator.checkFieldUriType(poolId, StoragePool.class, "poolId");
    StoragePool pool = _dbClient.queryObject(StoragePool.class, poolId);
    ArgValidator.checkEntity(pool, poolId, isIdEmbeddedInURL(poolId));
    if (!id.equals(pool.getStorageDevice())) {
        throw APIException.badRequests.poolNotBelongingToSystem(poolId, id);
    }
    // if not register, registered it. Otherwise, dont do anything
    if (RegistrationStatus.UNREGISTERED.toString().equalsIgnoreCase(pool.getRegistrationStatus())) {
        registerStoragePool(pool);
        StringBuffer errorMessage = new StringBuffer();
        // Pool registration also update its varray relationship, so, we should also update vpool to pool relation.
        ImplicitPoolMatcher.matchModifiedStoragePoolsWithAllVirtualPool(Arrays.asList(pool), _dbClient, _coordinator, errorMessage);
    }
    return StoragePoolService.toStoragePoolRep(pool, _dbClient, _coordinator);
}
Also used : StoragePool(com.emc.storageos.db.client.model.StoragePool) 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 23 with CheckPermission

use of com.emc.storageos.security.authorization.CheckPermission in project coprhd-controller by CoprHD.

the class StorageSystemService method getAllStoragePorts.

/**
 * Get all storage ports for the registered storage system with the passed
 * id.
 *
 * @param id the URN of a ViPR storage system.
 *
 * @brief List storage system storage ports
 * @return A reference to a StoragePortList specifying the id and self link
 *         for each port.
 */
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}/storage-ports")
@CheckPermission(roles = { Role.SYSTEM_ADMIN, Role.SYSTEM_MONITOR })
public StoragePortList getAllStoragePorts(@PathParam("id") URI id) {
    // Make sure the storage system is registered.
    ArgValidator.checkFieldUriType(id, StorageSystem.class, "id");
    StorageSystem system = queryResource(id);
    ArgValidator.checkEntity(system, id, isIdEmbeddedInURL(id));
    {
        // Update the port metrics calculations. This makes the UI display up-to-date when ports shown.
        URIQueryResultList storagePortURIs = new URIQueryResultList();
        _dbClient.queryByConstraint(ContainmentConstraint.Factory.getStorageDeviceStoragePortConstraint(id), storagePortURIs);
        List<StoragePort> storagePorts = _dbClient.queryObject(StoragePort.class, storagePortURIs);
        portMetricsProcessor.computeStoragePortUsage(storagePorts, system, true);
    }
    StoragePortList portList = new StoragePortList();
    URIQueryResultList storagePortURIs = new URIQueryResultList();
    _dbClient.queryByConstraint(ContainmentConstraint.Factory.getStorageDeviceStoragePortConstraint(id), storagePortURIs);
    Iterator<URI> storagePortsIter = storagePortURIs.iterator();
    while (storagePortsIter.hasNext()) {
        URI storagePortURI = storagePortsIter.next();
        StoragePort storagePort = _dbClient.queryObject(StoragePort.class, storagePortURI);
        if (storagePort != null && !storagePort.getInactive()) {
            portList.getPorts().add(toNamedRelatedResource(storagePort, storagePort.getNativeGuid()));
        }
    }
    return portList;
}
Also used : MapStoragePort(com.emc.storageos.api.mapper.functions.MapStoragePort) StoragePort(com.emc.storageos.db.client.model.StoragePort) StoragePortList(com.emc.storageos.model.ports.StoragePortList) StoragePortGroupList(com.emc.storageos.model.portgroup.StoragePortGroupList) UnManagedVolumeList(com.emc.storageos.model.block.UnManagedVolumeList) StoragePortList(com.emc.storageos.model.ports.StoragePortList) ArrayList(java.util.ArrayList) StoragePoolList(com.emc.storageos.model.pools.StoragePoolList) TaskList(com.emc.storageos.model.TaskList) StorageSystemList(com.emc.storageos.model.systems.StorageSystemList) VirtualNASList(com.emc.storageos.model.vnas.VirtualNASList) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) UnManagedFileSystemList(com.emc.storageos.model.file.UnManagedFileSystemList) ObjectNamespaceList(com.emc.storageos.model.object.ObjectNamespaceList) RDFGroupList(com.emc.storageos.model.rdfgroup.RDFGroupList) StorageSystemConnectivityList(com.emc.storageos.model.systems.StorageSystemConnectivityList) List(java.util.List) AutoTierPolicyList(com.emc.storageos.model.block.tier.AutoTierPolicyList) BulkList(com.emc.storageos.api.service.impl.response.BulkList) URI(java.net.URI) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) 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 24 with CheckPermission

use of com.emc.storageos.security.authorization.CheckPermission in project coprhd-controller by CoprHD.

the class StorageSystemService method getUnManagedFileSystems.

/**
 * List all unmanaged file systems which are available for a storage system.Unmanaged file systems refers to file systems which are
 * available within underlying storage systems , but
 * still not managed in ViPR.
 * As these file systems are not managed in ViPR, there will not be any ViPR specific
 * details associated such as, virtual array, virtual pool, or project.
 *
 * @param id the URN of a ViPR storage system
 *
 * @prereq none
 * @brief List of all unmanaged file systems available for a storage system
 * @return UnManagedFileSystemList
 */
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@CheckPermission(roles = { Role.SYSTEM_ADMIN, Role.SYSTEM_MONITOR })
@Path("/{id}/unmanaged/filesystems")
public UnManagedFileSystemList getUnManagedFileSystems(@PathParam("id") URI id) {
    ArgValidator.checkFieldUriType(id, StorageSystem.class, "id");
    UnManagedFileSystemList unManagedFileSystemList = new UnManagedFileSystemList();
    URIQueryResultList result = new URIQueryResultList();
    _dbClient.queryByConstraint(ContainmentConstraint.Factory.getStorageDeviceUnManagedFileSystemConstraint(id), result);
    Iterator<UnManagedFileSystem> unmanagedFileSystemItr = _dbClient.queryIterativeObjects(UnManagedFileSystem.class, result, true);
    while (unmanagedFileSystemItr.hasNext()) {
        UnManagedFileSystem umfs = unmanagedFileSystemItr.next();
        unManagedFileSystemList.getUnManagedFileSystem().add(toRelatedResource(ResourceTypeEnum.UNMANAGED_FILESYSTEMS, umfs.getId()));
    }
    return unManagedFileSystemList;
}
Also used : UnManagedFileSystemList(com.emc.storageos.model.file.UnManagedFileSystemList) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) UnManagedFileSystem(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedFileSystem) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Example 25 with CheckPermission

use of com.emc.storageos.security.authorization.CheckPermission in project coprhd-controller by CoprHD.

the class StorageSystemService method getStoragePortGroup.

/**
 * Get information about the storage port group with the passed id on the
 * storage system.
 *
 * @param id
 *            the URN of a ViPR storage system.
 * @param portGroupId
 *            The id of the storage portgroup.
 *
 * @brief Show storage system storage port group
 * @return A StoragePortGroupRestRep reference specifying the data for the
 *         requested port group.
 */
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}/storage-port-groups/{portGroupId}")
@CheckPermission(roles = { Role.SYSTEM_ADMIN, Role.SYSTEM_MONITOR })
public StoragePortGroupRestRep getStoragePortGroup(@PathParam("id") URI id, @PathParam("portGroupId") URI portGroupId) {
    ArgValidator.checkFieldUriType(id, StorageSystem.class, "id");
    ArgValidator.checkFieldUriType(portGroupId, StoragePortGroup.class, "portGroupId");
    StoragePortGroup portGroup = _dbClient.queryObject(StoragePortGroup.class, portGroupId);
    ArgValidator.checkEntity(portGroup, portGroupId, isIdEmbeddedInURL(portGroupId));
    if (!portGroup.getStorageDevice().equals(id)) {
        throw APIException.badRequests.portGroupInvalid(portGroup.getNativeGuid());
    }
    return MapStoragePortGroup.getInstance(_dbClient).toStoragePortGroupRestRep(portGroup);
}
Also used : MapStoragePortGroup(com.emc.storageos.api.mapper.functions.MapStoragePortGroup) StoragePortGroup(com.emc.storageos.db.client.model.StoragePortGroup) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Aggregations

CheckPermission (com.emc.storageos.security.authorization.CheckPermission)566 Produces (javax.ws.rs.Produces)512 Path (javax.ws.rs.Path)487 POST (javax.ws.rs.POST)240 Consumes (javax.ws.rs.Consumes)215 GET (javax.ws.rs.GET)194 URI (java.net.URI)185 Operation (com.emc.storageos.db.client.model.Operation)105 ArrayList (java.util.ArrayList)97 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)93 PUT (javax.ws.rs.PUT)85 APIException (com.emc.storageos.svcs.errorhandling.resources.APIException)69 Volume (com.emc.storageos.db.client.model.Volume)68 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)65 TaskList (com.emc.storageos.model.TaskList)61 FileShare (com.emc.storageos.db.client.model.FileShare)56 SMBFileShare (com.emc.storageos.db.client.model.SMBFileShare)54 TaskResourceRep (com.emc.storageos.model.TaskResourceRep)53 NamedURI (com.emc.storageos.db.client.model.NamedURI)47 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)46