Search in sources :

Example 21 with SOSFailure

use of com.emc.storageos.vasa.fault.SOSFailure 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)

Example 22 with SOSFailure

use of com.emc.storageos.vasa.fault.SOSFailure in project coprhd-controller by CoprHD.

the class SOSManager method queryAssociatedLUNsForPort.

/**
 * Makes a call to Bourne to get the associated Luns for the given storage
 * port Ids
 *
 * @param portUniqueIds
 * @return array of <code>VasaAssociationObject</code> objects
 * @throws InvalidArgument
 * @throws InvalidSession
 * @throws StorageFault
 * @throws NotImplemented
 */
public synchronized VasaAssociationObject[] queryAssociatedLUNsForPort(String[] portUniqueIds) throws InvalidArgument, InvalidSession, StorageFault, NotImplemented {
    final String methodName = "queryAssociatedLUNsForPort(): ";
    log.debug(methodName + "Entry");
    List<VasaAssociationObject> returnList = null;
    List<String> inputPortIdList = null;
    log.info(methodName + "Input:[" + portUniqueIds + "]");
    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");
        }
        String csvSeparatedInitiatorList = this.getCSVListOfInitiatorsFromUsageContext();
        Hashtable<String, List<String>> portToVolumeTable = _syncManager.getStoragePortToVolumeTable(csvSeparatedInitiatorList);
        returnList = new ArrayList<VasaAssociationObject>();
        if (Util.isEmpty(portUniqueIds)) {
            // Return all port associated to LUNs
            for (String portId : portToVolumeTable.keySet()) {
                VasaAssociationObject associationObject = new VasaAssociationObject();
                BaseStorageEntity storagePort = new BaseStorageEntity();
                storagePort.setUniqueIdentifier(portId);
                associationObject.addEntityId(storagePort);
                for (String volumeId : portToVolumeTable.get(portId)) {
                    BaseStorageEntity associatedVolume = new BaseStorageEntity();
                    associatedVolume.setUniqueIdentifier(volumeId);
                    associationObject.addAssociatedId(associatedVolume);
                }
                returnList.add(associationObject);
            }
        } else {
            inputPortIdList = Arrays.asList(portUniqueIds);
            log.debug(methodName + "Input port ids: " + inputPortIdList);
            for (String inputPortId : inputPortIdList) {
                if (!Util.isEmpty(inputPortId)) {
                    if (!inputPortId.startsWith(STORAGEPORT_IDENTIFIER_PREFIX)) {
                        throw FaultUtil.InvalidArgument("Given port Id is invalid[" + inputPortId + "]");
                    } else {
                        List<String> volumeIdList = portToVolumeTable.get(inputPortId);
                        if (volumeIdList != null && !volumeIdList.isEmpty()) {
                            VasaAssociationObject associationObject = new VasaAssociationObject();
                            BaseStorageEntity storagePort = new BaseStorageEntity();
                            storagePort.setUniqueIdentifier(inputPortId);
                            associationObject.addEntityId(storagePort);
                            for (String volumeId : volumeIdList) {
                                BaseStorageEntity associatedVolume = new BaseStorageEntity();
                                associatedVolume.setUniqueIdentifier(volumeId);
                                associationObject.addAssociatedId(associatedVolume);
                            }
                            returnList.add(associationObject);
                        }
                    }
                }
            // }
            }
        }
        return returnList.toArray(new VasaAssociationObject[0]);
    } catch (SOSFailure e) {
        log.error("StorageOSFailure occured", e);
        throw FaultUtil.StorageFault("StorageOSFailure occured", e);
    } catch (InvalidArgument e) {
        log.error(methodName + "InvalidArgument occured ", e);
        throw e;
    } catch (NotImplemented e) {
        log.error(methodName + "NotImplemented occured ", e);
        throw e;
    }
}
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) SOSFailure(com.emc.storageos.vasa.fault.SOSFailure) NotImplemented(com.vmware.vim.vasa._1_0.NotImplemented) List(java.util.List) ArrayList(java.util.ArrayList) EventList(com.emc.storageos.vasa.data.internal.Event.EventList)

Example 23 with SOSFailure

use of com.emc.storageos.vasa.fault.SOSFailure in project coprhd-controller by CoprHD.

the class SyncManager method getStorageSystem.

/**
 * Returns Storage system with its details based on given storage system Id
 *
 * @param storageSystemId
 * @return Object of <code>StorageSystem</code>
 * @throws SOSFailure
 *             if call(s) to Bourne fails
 */
public synchronized StorageSystem getStorageSystem(String storageSystemId) throws SOSFailure {
    final String methodName = "getStorageSystem(): ";
    log.trace(methodName + "Entry with storageSystemId[" + storageSystemId + "]");
    final String STORAGE_SYSTEM_DETAIL = "/vdc/storage-systems/%s";
    StorageSystem system = null;
    try {
        system = _client.queryObject(String.format(STORAGE_SYSTEM_DETAIL, storageSystemId), StorageSystem.class);
    } catch (NoSuchAlgorithmException e) {
        log.error(methodName + "NoSuchAlgorithmException occured", e);
        throw new SOSFailure(e);
    } catch (UniformInterfaceException e) {
        log.error(methodName + "UniformInterfaceException occured", e);
        throw new SOSFailure(e);
    }
    log.trace(methodName + "Exit returning: " + system);
    return system;
}
Also used : UniformInterfaceException(com.sun.jersey.api.client.UniformInterfaceException) SOSFailure(com.emc.storageos.vasa.fault.SOSFailure) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) StorageSystem(com.emc.storageos.vasa.data.internal.StorageSystem)

Example 24 with SOSFailure

use of com.emc.storageos.vasa.fault.SOSFailure in project coprhd-controller by CoprHD.

the class SyncManager method verifyLogin.

/**
 * Makes call to Bourne to verify login attempt
 *
 * @param username
 * @param password
 * @throws SOSAuthenticationFailure
 *             on invalid login attempt
 * @throws SOSFailure
 */
public synchronized void verifyLogin(String username, String password) throws SOSAuthenticationFailure, SOSFailure {
    final String methodName = "verifyLogin(): ";
    final String FILE_COS_LIST_URI = "/file/vpools";
    try {
        _client.setLoginCredentials(username, password);
        _client.queryObject(FILE_COS_LIST_URI, String.class);
    } catch (NoSuchAlgorithmException e) {
        log.error(methodName + "NoSuchAlgorithmException occured", e);
        throw new SOSFailure(e);
    } catch (UniformInterfaceException e) {
        if (e.toString().contains("403 Forbidden")) {
            throw new SOSAuthenticationFailure("Incorrect login credentials");
        }
        if (e.toString().contains("401 Unauthorized")) {
            throw new SOSAuthenticationFailure("Incorrect login credentials");
        }
    }
}
Also used : UniformInterfaceException(com.sun.jersey.api.client.UniformInterfaceException) SOSFailure(com.emc.storageos.vasa.fault.SOSFailure) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) SOSAuthenticationFailure(com.emc.storageos.vasa.fault.SOSAuthenticationFailure)

Example 25 with SOSFailure

use of com.emc.storageos.vasa.fault.SOSFailure in project coprhd-controller by CoprHD.

the class SyncManager method getStatistics.

/**
 * Returns Bourne stats list based on given timestamp
 *
 * @param timestamp
 *            of the format <code>YYYY-MM-DDTHH:mm</code>
 * @return Object of <code>EventList</code>
 * @throws SOSFailure
 *             if call(s) to Bourne fails
 */
public synchronized StatList getStatistics(String timestamp) throws SOSFailure {
    final String methodName = "getStatistics(): ";
    final String METER_URI = "/metering/stats.xml/?time_bucket=%s";
    log.trace(methodName + "Entry with timestamp[" + timestamp + "]");
    StatList statListObj = null;
    try {
        statListObj = _client.queryObject(String.format(METER_URI, timestamp), StatList.class);
    } catch (NoSuchAlgorithmException e) {
        log.error(methodName + "NoSuchAlgorithmException occured", e);
        throw new SOSFailure(e);
    } catch (UniformInterfaceException e) {
        log.error(methodName + "UniformInterfaceException occured", e);
        throw new SOSFailure(e);
    }
    log.trace(methodName + "Exit returing eventListObj[" + statListObj + "]");
    return statListObj;
}
Also used : StatList(com.emc.storageos.vasa.data.internal.StatList) UniformInterfaceException(com.sun.jersey.api.client.UniformInterfaceException) SOSFailure(com.emc.storageos.vasa.fault.SOSFailure) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException)

Aggregations

SOSFailure (com.emc.storageos.vasa.fault.SOSFailure)29 UniformInterfaceException (com.sun.jersey.api.client.UniformInterfaceException)18 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)18 ArrayList (java.util.ArrayList)15 InvalidArgument (com.vmware.vim.vasa._1_0.InvalidArgument)7 NotImplemented (com.vmware.vim.vasa._1_0.NotImplemented)6 FileShare (com.emc.storageos.vasa.data.internal.FileShare)5 CoS (com.emc.storageos.vasa.data.internal.CoS)4 StoragePool (com.emc.storageos.vasa.data.internal.StoragePool)4 Volume (com.emc.storageos.vasa.data.internal.Volume)4 AssociatedPool (com.emc.storageos.vasa.data.internal.Volume.AssociatedPool)4 EventList (com.emc.storageos.vasa.data.internal.Event.EventList)3 BaseStorageEntity (com.vmware.vim.vasa._1_0.data.xsd.BaseStorageEntity)3 VasaAssociationObject (com.vmware.vim.vasa._1_0.data.xsd.VasaAssociationObject)3 CoSElement (com.emc.storageos.vasa.data.internal.CoS.CoSElement)2 CoSList (com.emc.storageos.vasa.data.internal.CoS.CoSList)2 FileSystemExports (com.emc.storageos.vasa.data.internal.FileShare.FileSystemExports)2 List (java.util.List)2 Event (com.emc.storageos.vasa.data.internal.Event)1 AssociatedResource (com.emc.storageos.vasa.data.internal.FileShare.AssociatedResource)1