Search in sources :

Example 1 with StorageCapability

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

the class SOSManager method queryStorageCapabilities.

/**
 * Makes a call to Bourne to get the details of given storage capability Ids
 *
 * @param capId
 * @return array of <code>StorageCapability</code> objects
 * @throws InvalidArgument
 * @throws InvalidSession
 * @throws StorageFault
 * @throws NotImplemented
 */
public synchronized StorageCapability[] queryStorageCapabilities(String[] capIds) throws InvalidArgument, InvalidSession, StorageFault, NotImplemented {
    final String methodName = "queryStorageCapabilities(): ";
    log.debug(methodName + "Entry");
    List<StorageCapability> returnList = null;
    List<CoS> cosList = null;
    try {
        Boolean supportsCapability = new Boolean(_config.getConfigValue("config/service/storageTopology/storageArray/support-capability-profile"));
        if (!supportsCapability) {
            log.error(methodName + " This function is not implemented");
            throw FaultUtil.NotImplemented("This function is not implemented");
        }
        if (Util.isEmpty(capIds)) {
            log.debug(methodName + "input capability Ids: " + capIds);
            cosList = _syncManager.getCosDetailList();
        } else {
            for (String inputCapId : capIds) {
                if (!Util.isEmpty(inputCapId)) {
                    if (!inputCapId.startsWith(COS_IDENTIFIER_PREFIX)) {
                        throw FaultUtil.InvalidArgument("Storage capability Id is invalid: " + inputCapId);
                    }
                } else {
                    throw FaultUtil.InvalidArgument("Storage capability Id is empty: " + inputCapId);
                }
            }
            List<String> inputCapIdList = Arrays.asList(capIds);
            log.debug(methodName + "input capability Ids: " + inputCapIdList);
            cosList = _syncManager.getCosDetailList(inputCapIdList);
        }
        returnList = new ArrayList<StorageCapability>();
        for (CoS cos : cosList) {
            StorageCapability capability = new StorageCapability();
            capability.setUniqueIdentifier(cos.getId());
            capability.setCapabilityName(cos.getLabel() + ":" + cos.getType());
            capability.setCapabilityDetail(cos.getDescription());
            if (log.isDebugEnabled()) {
                log.debug(methodName + "Capability detail: id[" + capability.getUniqueIdentifier() + "] name[" + capability.getCapabilityName() + "] detail[" + capability.getCapabilityDetail() + "]");
            }
            returnList.add(capability);
        }
    } catch (SOSFailure e) {
        log.error(methodName + "StorageOSFailure occured ", e);
        throw FaultUtil.StorageFault(e);
    } catch (InvalidArgument e) {
        log.error(methodName + "InvalidArgument occured ", e);
        throw e;
    } catch (NotImplemented e) {
        log.error(methodName + "NotImplemented occured ", e);
        throw e;
    }
    return returnList.toArray(new StorageCapability[0]);
}
Also used : StorageCapability(com.vmware.vim.vasa._1_0.data.xsd.StorageCapability) CoS(com.emc.storageos.vasa.data.internal.CoS) InvalidArgument(com.vmware.vim.vasa._1_0.InvalidArgument) SOSFailure(com.emc.storageos.vasa.fault.SOSFailure) NotImplemented(com.vmware.vim.vasa._1_0.NotImplemented)

Aggregations

CoS (com.emc.storageos.vasa.data.internal.CoS)1 SOSFailure (com.emc.storageos.vasa.fault.SOSFailure)1 InvalidArgument (com.vmware.vim.vasa._1_0.InvalidArgument)1 NotImplemented (com.vmware.vim.vasa._1_0.NotImplemented)1 StorageCapability (com.vmware.vim.vasa._1_0.data.xsd.StorageCapability)1