Search in sources :

Example 11 with GeoServiceClient

use of com.emc.storageos.security.geo.GeoServiceClient in project coprhd-controller by CoprHD.

the class ObjectVirtualPoolService method queryFilteredBulkResourceReps.

@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
protected ObjectVirtualPoolBulkRep queryFilteredBulkResourceReps(List<URI> ids) {
    if (isSystemAdmin()) {
        return queryBulkResourceReps(ids);
    }
    if (!ids.iterator().hasNext()) {
        return new ObjectVirtualPoolBulkRep();
    }
    // get vdc id from the first id; assume all id's are from the same vdc
    String shortVdcId = VdcUtil.getVdcId(VirtualArray.class, ids.iterator().next()).toString();
    Iterator<VirtualPool> dbIterator;
    if (shortVdcId.equals(VdcUtil.getLocalShortVdcId())) {
        dbIterator = _dbClient.queryIterativeObjects(getResourceClass(), ids);
    } else {
        GeoServiceClient geoClient = _geoHelper.getClient(shortVdcId);
        try {
            dbIterator = geoClient.queryObjects(getResourceClass(), ids);
        } catch (Exception ex) {
            // TODO: revisit this exception
            _log.error("error retrieving bulk virtual pools from vdc " + shortVdcId, ex);
            throw APIException.internalServerErrors.genericApisvcError("error retrieving remote virtual pool", ex);
        }
    }
    BulkList.ResourceFilter filter = new BulkList.VirtualPoolFilter(Type.object, getUserFromContext(), _permissionsHelper);
    return new ObjectVirtualPoolBulkRep(BulkList.wrapping(dbIterator, MapObjectVirtualPool.getInstance(), filter));
}
Also used : VirtualArray(com.emc.storageos.db.client.model.VirtualArray) GeoServiceClient(com.emc.storageos.security.geo.GeoServiceClient) BulkList(com.emc.storageos.api.service.impl.response.BulkList) VirtualPoolMapper.toObjectVirtualPool(com.emc.storageos.api.mapper.VirtualPoolMapper.toObjectVirtualPool) MapObjectVirtualPool(com.emc.storageos.api.mapper.functions.MapObjectVirtualPool) VirtualPool(com.emc.storageos.db.client.model.VirtualPool) ObjectVirtualPoolBulkRep(com.emc.storageos.model.vpool.ObjectVirtualPoolBulkRep) APIException(com.emc.storageos.svcs.errorhandling.resources.APIException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException)

Example 12 with GeoServiceClient

use of com.emc.storageos.security.geo.GeoServiceClient in project coprhd-controller by CoprHD.

the class VirtualArrayService method getVirtualArray.

/**
 * Get info for VirtualArray
 *
 * @param id the URN of a ViPR VirtualArray
 * @brief Show VirtualArray
 * @return VirtualArray details
 */
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}")
@CheckPermission(roles = { Role.SYSTEM_ADMIN, Role.SYSTEM_MONITOR }, acls = { ACL.USE })
public VirtualArrayRestRep getVirtualArray(@PathParam("id") URI id) {
    ArgValidator.checkFieldUriType(id, VirtualArray.class, "id");
    VirtualArray varray = null;
    if (_geoHelper.isLocalURI(id)) {
        _log.debug("retrieving varray via dbclient");
        varray = getVirtualArrayById(id, false);
    } else {
        _log.debug("retrieving varray via geoclient");
        String shortVdcId = VdcUtil.getVdcId(VirtualArray.class, id).toString();
        // TODO: do we want to leverage caching like the native lookup
        GeoServiceClient geoClient = _geoHelper.getClient(shortVdcId);
        try {
            varray = geoClient.queryObject(VirtualArray.class, id);
        } catch (Exception ex) {
            // TODO: revisit this exception
            _log.error("error retrieving virtual array from vdc " + shortVdcId, ex);
            throw APIException.internalServerErrors.genericApisvcError("error retrieving remote array", ex);
        }
    }
    return map(varray);
}
Also used : MapVirtualArray(com.emc.storageos.api.mapper.functions.MapVirtualArray) VirtualArray(com.emc.storageos.db.client.model.VirtualArray) GeoServiceClient(com.emc.storageos.security.geo.GeoServiceClient) APIException(com.emc.storageos.svcs.errorhandling.resources.APIException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Example 13 with GeoServiceClient

use of com.emc.storageos.security.geo.GeoServiceClient in project coprhd-controller by CoprHD.

the class VirtualArrayService method queryBulkResourceReps.

@Override
public VirtualArrayBulkRep queryBulkResourceReps(List<URI> ids) {
    if (!ids.iterator().hasNext()) {
        return new VirtualArrayBulkRep();
    }
    // get vdc id from the first id; assume all id's are from the same vdc
    String shortVdcId = VdcUtil.getVdcId(getResourceClass(), ids.iterator().next()).toString();
    Iterator<VirtualArray> dbIterator;
    if (shortVdcId.equals(VdcUtil.getLocalShortVdcId())) {
        dbIterator = _dbClient.queryIterativeObjects(getResourceClass(), ids);
    } else {
        GeoServiceClient geoClient = _geoHelper.getClient(shortVdcId);
        try {
            dbIterator = geoClient.queryObjects(getResourceClass(), ids);
        } catch (Exception ex) {
            // TODO: revisit this exception
            _log.error("error retrieving bulk virtual arrays from vdc " + shortVdcId, ex);
            throw APIException.internalServerErrors.genericApisvcError("error retrieving remote array", ex);
        }
    }
    return new VirtualArrayBulkRep(BulkList.wrapping(dbIterator, MapVirtualArray.getInstance()));
}
Also used : MapVirtualArray(com.emc.storageos.api.mapper.functions.MapVirtualArray) VirtualArray(com.emc.storageos.db.client.model.VirtualArray) GeoServiceClient(com.emc.storageos.security.geo.GeoServiceClient) VirtualArrayBulkRep(com.emc.storageos.model.varray.VirtualArrayBulkRep) APIException(com.emc.storageos.svcs.errorhandling.resources.APIException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException)

Example 14 with GeoServiceClient

use of com.emc.storageos.security.geo.GeoServiceClient in project coprhd-controller by CoprHD.

the class VirtualPoolService method getVirtualPool.

protected VirtualPool getVirtualPool(VirtualPool.Type type, URI id) {
    ArgValidator.checkUri(id);
    VirtualPool vpool = null;
    if (_geoHelper.isLocalURI(id)) {
        _log.debug("retrieving vpool via dbclient");
        vpool = _permissionsHelper.getObjectById(id, VirtualPool.class);
    } else {
        _log.debug("retrieving vpool via geoclient");
        String shortVdcId = VdcUtil.getVdcId(VirtualPool.class, id).toString();
        // TODO: do we want to leverage caching like the native lookup
        GeoServiceClient geoClient = _geoHelper.getClient(shortVdcId);
        try {
            vpool = geoClient.queryObject(VirtualPool.class, id);
        } catch (Exception ex) {
            // TODO: revisit this exception
            _log.error("error retrieving virtual pools from vdc " + shortVdcId, ex);
            throw APIException.internalServerErrors.genericApisvcError("error retrieving remote pool", ex);
        }
    }
    ArgValidator.checkEntityNotNull(vpool, id, isIdEmbeddedInURL(id));
    if (!vpool.getType().equals(type.name())) {
        throw APIException.badRequests.invalidParameterNoSuchVirtualPoolOfType(id, type.toString());
    }
    return vpool;
}
Also used : GeoServiceClient(com.emc.storageos.security.geo.GeoServiceClient) VirtualPool(com.emc.storageos.db.client.model.VirtualPool) APIException(com.emc.storageos.svcs.errorhandling.resources.APIException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException)

Example 15 with GeoServiceClient

use of com.emc.storageos.security.geo.GeoServiceClient in project coprhd-controller by CoprHD.

the class GeoTest method setup.

@Before
public void setup() throws Exception {
    setupHttpsResources();
    geoClient = new GeoServiceClient();
    geoClient.setServer(server);
    geoClient.setCoordinatorClient(coordinatorClient);
    geoClient.addFilter(new ServiceClientRetryFilter(geoClient.getClientMaxRetries(), geoClient.getClientRetryInterval()));
    geoClient.addFilter(new GeoServiceExceptionFilter());
    // prepare test data
    createVirtualArrays();
    createVirtualPools();
}
Also used : ServiceClientRetryFilter(com.emc.storageos.security.helpers.ServiceClientRetryFilter) GeoServiceExceptionFilter(com.emc.storageos.security.geo.GeoServiceExceptionFilter) GeoServiceClient(com.emc.storageos.security.geo.GeoServiceClient) Before(org.junit.Before)

Aggregations

GeoServiceClient (com.emc.storageos.security.geo.GeoServiceClient)17 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)12 APIException (com.emc.storageos.svcs.errorhandling.resources.APIException)12 VirtualArray (com.emc.storageos.db.client.model.VirtualArray)8 VirtualPool (com.emc.storageos.db.client.model.VirtualPool)8 MapVirtualArray (com.emc.storageos.api.mapper.functions.MapVirtualArray)4 BulkList (com.emc.storageos.api.service.impl.response.BulkList)4 VirtualPoolMapper.toBlockVirtualPool (com.emc.storageos.api.mapper.VirtualPoolMapper.toBlockVirtualPool)2 VirtualPoolMapper.toFileVirtualPool (com.emc.storageos.api.mapper.VirtualPoolMapper.toFileVirtualPool)2 VirtualPoolMapper.toObjectVirtualPool (com.emc.storageos.api.mapper.VirtualPoolMapper.toObjectVirtualPool)2 MapFileVirtualPool (com.emc.storageos.api.mapper.functions.MapFileVirtualPool)2 MapObjectVirtualPool (com.emc.storageos.api.mapper.functions.MapObjectVirtualPool)2 TenantOrg (com.emc.storageos.db.client.model.TenantOrg)2 VdcNodeCheckParam (com.emc.storageos.geomodel.VdcNodeCheckParam)2 VirtualArrayBulkRep (com.emc.storageos.model.varray.VirtualArrayBulkRep)2 BlockVirtualPoolBulkRep (com.emc.storageos.model.vpool.BlockVirtualPoolBulkRep)2 FileVirtualPoolBulkRep (com.emc.storageos.model.vpool.FileVirtualPoolBulkRep)2 ObjectVirtualPoolBulkRep (com.emc.storageos.model.vpool.ObjectVirtualPoolBulkRep)2 StorageOSUser (com.emc.storageos.security.authentication.StorageOSUser)2 URI (java.net.URI)2