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));
}
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);
}
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()));
}
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;
}
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();
}
Aggregations