Search in sources :

Example 1 with CustomServicesViPRPrimitive

use of com.emc.storageos.primitives.java.vipr.CustomServicesViPRPrimitive in project coprhd-controller by CoprHD.

the class CustomServicesViprPrimitiveDAO method bulk.

@Override
public Iterator<CustomServicesPrimitiveRestRep> bulk(final Collection<URI> ids) {
    ImmutableList.Builder<CustomServicesPrimitiveRestRep> primitives = ImmutableList.<CustomServicesPrimitiveRestRep>builder();
    for (final URI id : ids) {
        final CustomServicesViPRPrimitive primitive = PRIMITIVES_MAP.get(id);
        final ModelObject model = primitive == null ? null : primitive.asModelObject();
        ArgValidator.checkEntityNotNull(model, id, false);
        primitives.add(CustomServicesPrimitiveMapper.map(primitive));
    }
    return primitives.build().iterator();
}
Also used : ModelObject(com.emc.storageos.db.client.model.ModelObject) CustomServicesPrimitiveRestRep(com.emc.storageos.model.customservices.CustomServicesPrimitiveRestRep) ImmutableList(com.google.common.collect.ImmutableList) URI(java.net.URI) CustomServicesViPRPrimitive(com.emc.storageos.primitives.java.vipr.CustomServicesViPRPrimitive)

Example 2 with CustomServicesViPRPrimitive

use of com.emc.storageos.primitives.java.vipr.CustomServicesViPRPrimitive in project coprhd-controller by CoprHD.

the class CustomServicesService method updateViproutput.

private Map<String, List<String>> updateViproutput(final Step step, final String res) throws Exception {
    final CustomServicesViPRPrimitive primitive = customServicesViprDao.get(step.getOperation());
    if (null == primitive) {
        throw new RuntimeException("Primitive " + step.getOperation() + " not found ");
    }
    if (StringUtils.isEmpty(primitive.response())) {
        logger.debug("Vipr primitive" + primitive.name() + " has no response defined.");
        return null;
    }
    final String classname = primitive.response();
    logger.debug("Result is:{}", res);
    final ObjectMapper mapper = new ObjectMapper();
    mapper.setAnnotationIntrospector(new JaxbAnnotationIntrospector());
    final Class<?> clazz = Class.forName(classname);
    final Object responseEntity = mapper.readValue(res, clazz.newInstance().getClass());
    final Map<String, List<String>> output = parseViprOutput(responseEntity, step);
    logger.info("ViPR output for step ID: " + step.getId() + " is " + output);
    return output;
}
Also used : ArrayList(java.util.ArrayList) List(java.util.List) CustomServicesViPRPrimitive(com.emc.storageos.primitives.java.vipr.CustomServicesViPRPrimitive) ObjectMapper(org.codehaus.jackson.map.ObjectMapper) JaxbAnnotationIntrospector(org.codehaus.jackson.xc.JaxbAnnotationIntrospector)

Aggregations

CustomServicesViPRPrimitive (com.emc.storageos.primitives.java.vipr.CustomServicesViPRPrimitive)2 ModelObject (com.emc.storageos.db.client.model.ModelObject)1 CustomServicesPrimitiveRestRep (com.emc.storageos.model.customservices.CustomServicesPrimitiveRestRep)1 ImmutableList (com.google.common.collect.ImmutableList)1 URI (java.net.URI)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 ObjectMapper (org.codehaus.jackson.map.ObjectMapper)1 JaxbAnnotationIntrospector (org.codehaus.jackson.xc.JaxbAnnotationIntrospector)1