Search in sources :

Example 1 with StorageProcessor

use of com.vmware.vim.vasa._1_0.data.xsd.StorageProcessor in project coprhd-controller by CoprHD.

the class SOSManager method queryStorageProcessors.

/**
 * Makes a call to Bourne to get the details of given storage processor Ids
 *
 * @param processorId
 * @return array of <code>StorageProcessor</code> objects
 * @throws InvalidArgument
 * @throws InvalidSession
 * @throws StorageFault
 * @throws NotImplemented
 */
public synchronized StorageProcessor[] queryStorageProcessors(String[] processorId) throws InvalidArgument, InvalidSession, StorageFault, NotImplemented {
    final String methodName = "queryStorageProcessors(): ";
    log.debug(methodName + "Entry");
    List<StorageProcessor> processorList = null;
    try {
        Boolean supportsBlock = new Boolean(_config.getConfigValue("config/service/storageTopology/storageArray/support-block-profile"));
        if (!supportsBlock) {
            log.error(methodName + " This function is not implemented");
            throw FaultUtil.NotImplemented("This function is not implemented");
        }
        if (processorId != null) {
            log.debug(methodName + "input processor Ids " + Arrays.asList(processorId));
        } else {
            log.debug(methodName + "input processor Ids " + processorId);
        }
        String storageProcessorId = this.getProcessorId();
        if (!Util.isEmpty(processorId)) {
            for (String inputProcessorId : processorId) {
                if (Util.isEmpty(inputProcessorId) == true || inputProcessorId.startsWith(STORAGEPROCESSOR_IDENTIFIER_PREFIX) == false) {
                    throw FaultUtil.InvalidArgument("Given processor Id(s) are invalid");
                }
            }
        }
        processorList = new ArrayList<StorageProcessor>();
        if (Util.isEmpty(processorId)) {
            StorageProcessor processor = new StorageProcessor();
            log.debug(methodName + " adding storage processor id[" + storageProcessorId + "]");
            processor.setUniqueIdentifier(storageProcessorId);
            processor.addSpIdentifier(storageProcessorId);
            processorList.add(processor);
        } else {
            for (String inputProcessorId : processorId) {
                if (inputProcessorId != null && storageProcessorId.equals(inputProcessorId)) {
                    StorageProcessor processor = new StorageProcessor();
                    log.debug(methodName + " adding storage processor id[" + storageProcessorId + "]");
                    processor.addSpIdentifier(storageProcessorId);
                    processor.setUniqueIdentifier(storageProcessorId);
                    processorList.add(processor);
                }
            }
        }
    } catch (InvalidArgument e) {
        log.error(methodName + "InvalidArgument occured", e);
        throw (e);
    } catch (NotImplemented e) {
        log.error(methodName + "NotImplemented occured", e);
        throw FaultUtil.StorageFault(e);
    } catch (Exception e) {
        log.error(methodName + "Unexpected exception occured", e);
        throw FaultUtil.StorageFault(e);
    }
    log.debug(methodName + "Exit returning processors of size[" + processorList.size() + "]");
    return processorList.toArray(new StorageProcessor[0]);
}
Also used : InvalidArgument(com.vmware.vim.vasa._1_0.InvalidArgument) NotImplemented(com.vmware.vim.vasa._1_0.NotImplemented) StorageProcessor(com.vmware.vim.vasa._1_0.data.xsd.StorageProcessor)

Example 2 with StorageProcessor

use of com.vmware.vim.vasa._1_0.data.xsd.StorageProcessor in project coprhd-controller by CoprHD.

the class SOSManager method queryAssociatedProcessorsForArray.

/**
 * Makes a call to Bourne to get the associated processors for the given
 * storage array Ids
 *
 * @param arrayUniqueIds
 * @return array of <code>VasaAssociationObject</code> objects
 * @throws InvalidArgument
 * @throws InvalidSession
 * @throws StorageFault
 * @throws NotImplemented
 */
public synchronized VasaAssociationObject[] queryAssociatedProcessorsForArray(String[] arrayUniqueIds) throws InvalidArgument, StorageFault, NotImplemented, InvalidSession {
    final String methodName = "queryAssociatedProcessorsForArray(): ";
    List<VasaAssociationObject> returnList = null;
    String bourneArrayId = this.getArrayId();
    log.debug(methodName + "Entry");
    Boolean supportsBlock = new Boolean(_config.getConfigValue("config/service/storageTopology/storageArray/support-block-profile"));
    try {
        if (!supportsBlock) {
            log.error(methodName + " This function is not implemented");
            throw FaultUtil.NotImplemented("This function is not implemented");
        }
        if (!Util.isEmpty(arrayUniqueIds)) {
            List<String> inputArrayIdList = Arrays.asList(arrayUniqueIds);
            log.debug(methodName + "input array ids: " + inputArrayIdList);
            for (String inputArrayId : inputArrayIdList) {
                if (!Util.isEmpty(inputArrayId) && !inputArrayId.startsWith(STORAGEARRAY_IDENTIFIER_PREFIX)) {
                    throw FaultUtil.InvalidArgument("Given array Id is invalid:[" + inputArrayId + "]");
                }
            }
        }
        returnList = new ArrayList<VasaAssociationObject>();
        VasaAssociationObject associationObject = new VasaAssociationObject();
        BaseStorageEntity entity = new BaseStorageEntity();
        entity.setUniqueIdentifier(bourneArrayId);
        BaseStorageEntity associatedEntity = new BaseStorageEntity();
        associatedEntity.setUniqueIdentifier(this.getProcessorId());
        associationObject.addEntityId(entity);
        associationObject.addAssociatedId(associatedEntity);
        if (Util.isEmpty(arrayUniqueIds)) {
            log.debug(methodName + "Exit returning vasa association objects of size[" + returnList.size() + "]");
            returnList.add(associationObject);
        // return returnList.toArray(new VasaAssociationObject[0]);
        } else {
            /*
                 * StorageProcessor[] processorList = this
                 * .queryStorageProcessors(null);
                 */
            for (String arrayID : arrayUniqueIds) {
                if (bourneArrayId.equals(arrayID)) {
                    /*
                         * VasaAssociationObject associationObject = new
                         * VasaAssociationObject(); BaseStorageEntity entityObj
                         * = new BaseStorageEntity();
                         * entityObj.setUniqueIdentifier(arrayID);
                         * associationObject.addEntityId(entityObj);
                         */
                    // for (StorageProcessor proc : processorList) {
                    log.debug(methodName + "array[" + entity.getUniqueIdentifier() + "] is associated to processor[" + associatedEntity.getUniqueIdentifier() + "]");
                    returnList.add(associationObject);
                }
            // returnList.add(associationObject);
            // }
            }
        }
    } catch (InvalidArgument e) {
        log.error(methodName + "InvalidArgument occured ", e);
        throw e;
    } catch (NotImplemented e) {
        log.error(methodName + "NotImplemented occured ", e);
        throw e;
    } catch (StorageFault e) {
        log.error(methodName + "StorageFault occured ", e);
        throw e;
    }
    log.debug(methodName + "Exit returning vasa association objects of size[" + returnList.size() + "]");
    return returnList.toArray(new VasaAssociationObject[0]);
}
Also used : VasaAssociationObject(com.vmware.vim.vasa._1_0.data.xsd.VasaAssociationObject) BaseStorageEntity(com.vmware.vim.vasa._1_0.data.xsd.BaseStorageEntity) InvalidArgument(com.vmware.vim.vasa._1_0.InvalidArgument) StorageFault(com.vmware.vim.vasa._1_0.StorageFault) NotImplemented(com.vmware.vim.vasa._1_0.NotImplemented)

Aggregations

InvalidArgument (com.vmware.vim.vasa._1_0.InvalidArgument)2 NotImplemented (com.vmware.vim.vasa._1_0.NotImplemented)2 StorageFault (com.vmware.vim.vasa._1_0.StorageFault)1 BaseStorageEntity (com.vmware.vim.vasa._1_0.data.xsd.BaseStorageEntity)1 StorageProcessor (com.vmware.vim.vasa._1_0.data.xsd.StorageProcessor)1 VasaAssociationObject (com.vmware.vim.vasa._1_0.data.xsd.VasaAssociationObject)1