Search in sources :

Example 26 with StorageFault

use of com.vmware.vim.vasa._1_0.StorageFault in project coprhd-controller by CoprHD.

the class SOSManager method getSOSStorageArray.

private StorageArray getSOSStorageArray() throws StorageFault {
    final String methodName = "getSOSStorageArray(): ";
    StorageArray sa = new StorageArray();
    String arrayName = _config.getConfigValue("config/service/storageTopology/storageArray/name");
    Boolean supportsFile = new Boolean(_config.getConfigValue("config/service/storageTopology/storageArray/support-file-profile"));
    Boolean supportsBlock = new Boolean(_config.getConfigValue("config/service/storageTopology/storageArray/support-block-profile"));
    Boolean supportsCapabilty = new Boolean(_config.getConfigValue("config/service/storageTopology/storageArray/support-capability-profile"));
    sa.setArrayName(arrayName);
    String sosArrayId = this.getArrayId();
    sa.setUniqueIdentifier(sosArrayId);
    sa.setFirmware("1.0");
    if (supportsFile) {
        sa.addSupportedProfile(ProfileEnum.FileSystemProfile.getValue());
        sa.addSupportedFileSystem(FileSystemEnum.NFS.getValue());
    }
    if (supportsBlock) {
        sa.addSupportedProfile(ProfileEnum.BlockDeviceProfile.getValue());
        sa.addSupportedBlock(BlockEnum.FC.getValue());
        sa.addSupportedBlock(BlockEnum.ISCSI.getValue());
    }
    if (supportsCapabilty) {
        sa.addSupportedProfile(ProfileEnum.CapabilityProfile.getValue());
    }
    sa.setAlternateName(new String[] { arrayName });
    sa.setModelId(com.emc.storageos.vasa.Constants.VASA_BOURNE_PROVIDER_VENDOR_MODEL);
    sa.setVendorId(com.emc.storageos.vasa.Constants.VASA_BOURNE_PROVIDER_VENDOR_NAME);
    log.debug(methodName + "array detail: id[" + sa.getUniqueIdentifier() + "] name[" + sa.getArrayName() + "] modelId[" + sa.getModelId() + "] vendorId[" + sa.getVendorId() + "] profile(s) supported" + Arrays.asList(sa.getSupportedProfile()) + "] firmware[" + sa.getFirmware() + "]");
    log.debug(methodName + "Exting returning SOS storage array");
    return sa;
}
Also used : StorageArray(com.vmware.vim.vasa._1_0.data.xsd.StorageArray)

Example 27 with StorageFault

use of com.vmware.vim.vasa._1_0.StorageFault in project coprhd-controller by CoprHD.

the class SOSManager method queryArrays.

/**
 * Returns the storage array details for the given storage array Ids
 *
 * @param arrayId
 * @return array of <code>StorageArray</code> objects. Each having details
 *         of profiles the storage array supports
 * @throws InvalidArgument
 * @throws InvalidSession
 * @throws StorageFault
 */
public synchronized StorageArray[] queryArrays(String[] arrayId) throws InvalidArgument, InvalidSession, StorageFault {
    // Mandatory function
    final String methodName = "queryArrays(): ";
    log.debug(methodName + "Entry");
    List<StorageArray> storageArrayList = null;
    StorageArray[] arrays = null;
    if (!Util.isEmpty(arrayId)) {
        log.debug(methodName + "input array ids: " + Arrays.asList(arrayId));
    } else {
        log.debug(methodName + "input array ids: " + arrayId);
    }
    try {
        String sosArrayId = this.getArrayId();
        if (!Util.isEmpty(arrayId)) {
            storageArrayList = new ArrayList<StorageArray>();
            for (String inputArrayId : arrayId) {
                if (!inputArrayId.startsWith(STORAGEARRAY_IDENTIFIER_PREFIX)) {
                    throw FaultUtil.InvalidArgument("Given array Id is invalid:[" + arrayId + "]");
                }
                if (sosArrayId.equals(inputArrayId)) {
                    StorageArray storageArray = this.getSOSStorageArray();
                    storageArray.setUniqueIdentifier(inputArrayId);
                    storageArrayList.add(storageArray);
                }
            }
            return storageArrayList.toArray(new StorageArray[0]);
        }
        arrays = new StorageArray[1];
        StorageArray array = this.getSOSStorageArray();
        arrays[0] = array;
    } catch (StorageFault e) {
        log.error("StorageFault occured", e);
        throw e;
    } catch (InvalidArgument e) {
        log.error(methodName + "InvalidArgument occured ", e);
        throw e;
    }
    log.debug(methodName + "Exit returning arrays of size[" + arrays.length + "]");
    return arrays;
}
Also used : InvalidArgument(com.vmware.vim.vasa._1_0.InvalidArgument) StorageFault(com.vmware.vim.vasa._1_0.StorageFault) StorageArray(com.vmware.vim.vasa._1_0.data.xsd.StorageArray)

Example 28 with StorageFault

use of com.vmware.vim.vasa._1_0.StorageFault in project coprhd-controller by CoprHD.

the class SOSManager method isVolumeInvCenterContext.

public boolean isVolumeInvCenterContext(Volume volume) throws InvalidSession, StorageFault {
    final String methodName = "isVolumeInvCenterContext(): ";
    log.debug(methodName + "Entry with input: " + volume);
    UsageContext uc = this.getUsageContext();
    HostInitiatorInfo[] hostInitiators = uc.getHostInitiator();
    if (!Util.isEmpty(hostInitiators)) {
        for (HostInitiatorInfo initiator : hostInitiators) {
            if (Util.isEmpty(initiator.getPortWwn()) && Util.isEmpty(initiator.getIscsiIdentifier())) {
                continue;
            }
            if (!Util.isEmpty(initiator.getPortWwn()) && !initiator.getPortWwn().startsWith("0x")) {
                // convert the long into hex string value
                try {
                    long portWWN = Long.parseLong(initiator.getPortWwn());
                    initiator.setPortWwn("0x" + Long.toHexString(portWWN).toLowerCase());
                } catch (Exception e) {
                    log.warn(methodName + "Unable to parse portWWN: " + initiator.getPortWwn());
                    continue;
                }
            }
            Itls volumeExports = volume.getExports();
            List<String> volumeProtocolList = volume.getProtocols().getProtocol();
            if (volumeExports != null && volumeExports.getItls() != null) {
                for (Volume.Itls.Itl itl : volumeExports.getItls()) {
                    if (volumeProtocolList.contains("FC")) {
                        String portWWN = initiator.getPortWwn();
                        String initiatorPort = itl.getInitiator().getPort().replace(":", "");
                        if (!Util.isEmpty(portWWN)) {
                            portWWN = portWWN.substring(2);
                            log.debug(methodName + " Is portWWN[" + portWWN + "] equals initiator port[" + initiatorPort + "]");
                            if (initiatorPort.equalsIgnoreCase(portWWN)) {
                                log.debug(methodName + "Exit returning [true]");
                                return true;
                            }
                        }
                    }
                    if (volumeProtocolList.contains("iSCSI") || volumeProtocolList.contains("ISCSI")) {
                        String iscsiId = initiator.getIscsiIdentifier();
                        if (!Util.isEmpty(iscsiId)) {
                            log.debug(methodName + " Is iscsiId[" + iscsiId + "] equals initiator port[" + itl.getInitiator().getPort() + "]");
                            if (itl.getInitiator().getPort().equalsIgnoreCase(iscsiId)) {
                                log.debug(methodName + "Exit returning [true]");
                                return true;
                            }
                        }
                    }
                }
            }
        }
    }
    log.debug(methodName + "Exit returning [false]");
    return false;
}
Also used : HostInitiatorInfo(com.vmware.vim.vasa._1_0.data.xsd.HostInitiatorInfo) Itls(com.emc.storageos.vasa.data.internal.Volume.Itls) UsageContext(com.vmware.vim.vasa._1_0.data.xsd.UsageContext)

Example 29 with StorageFault

use of com.vmware.vim.vasa._1_0.StorageFault in project coprhd-controller by CoprHD.

the class ServiceImpl method handleExceptionsAsStorageFault.

protected void handleExceptionsAsStorageFault(Exception e) throws InvalidArgument, InvalidSession, StorageFault {
    if (e instanceof InvalidArgument) {
        throw (InvalidArgument) e;
    } else if (e instanceof InvalidSession) {
        throw (InvalidSession) e;
    } else if (e instanceof StorageFault) {
        throw (StorageFault) e;
    } else {
        StorageFault sfe = FaultUtil.StorageFault(e);
        sfe.setStackTrace(e.getStackTrace());
        throw sfe;
    }
}
Also used : InvalidArgument(com.vmware.vim.vasa._1_0.InvalidArgument) StorageFault(com.vmware.vim.vasa._1_0.StorageFault) InvalidSession(com.vmware.vim.vasa._1_0.InvalidSession)

Example 30 with StorageFault

use of com.vmware.vim.vasa._1_0.StorageFault in project coprhd-controller by CoprHD.

the class ServiceImpl method queryArrays.

/**
 * Returns array details of the requested arrayIds
 *
 * @param arrayId
 *            array of arrayIds
 * @return array of StorageArray objects having storage array details
 *         respectively
 * @throws InvalidArgument
 *             if usage context is incorrect
 * @throws InvalidSession
 *             if session Id is invalid
 * @throws StorageFault
 *             if there is a failure in the underlying storage
 */
public StorageArray[] queryArrays(String[] arrayId) throws InvalidArgument, InvalidSession, StorageFault {
    // Mandatory function
    final String methodName = "queryArrays(): ";
    log.info(methodName + "Entry");
    if (arrayId != null) {
        log.info(methodName + "input array Ids: " + Arrays.asList(arrayId));
    }
    // verify valid SSL and VASA Sessions.
    sslUtil.checkHttpRequest(true, true);
    UsageContext uc = contextManager.getUsageContext();
    if (Util.isEmpty(uc.getHostInitiator())) {
        StorageArray[] arrays = new StorageArray[0];
        log.info(methodName + "Exit returning storage arrays of size[" + (arrays != null ? arrays.length : 0) + "]");
        return arrays;
    }
    SOSManager sosManager = contextManager.getSOSManager();
    StorageArray[] arrays = sosManager.queryArrays(arrayId);
    log.info(methodName + "Exit returning storage arrays of size[" + (arrays != null ? arrays.length : 0) + "]");
    return arrays;
}
Also used : UsageContext(com.vmware.vim.vasa._1_0.data.xsd.UsageContext) StorageArray(com.vmware.vim.vasa._1_0.data.xsd.StorageArray)

Aggregations

InvalidArgument (com.vmware.vim.vasa._1_0.InvalidArgument)13 ArrayList (java.util.ArrayList)11 NotImplemented (com.vmware.vim.vasa._1_0.NotImplemented)10 SOSFailure (com.emc.storageos.vasa.fault.SOSFailure)8 StorageFault (com.vmware.vim.vasa._1_0.StorageFault)8 CertificateExpiredException (java.security.cert.CertificateExpiredException)7 CertificateNotYetValidException (java.security.cert.CertificateNotYetValidException)7 InvalidSession (com.vmware.vim.vasa._1_0.InvalidSession)6 UsageContext (com.vmware.vim.vasa._1_0.data.xsd.UsageContext)6 BaseStorageEntity (com.vmware.vim.vasa._1_0.data.xsd.BaseStorageEntity)5 VasaAssociationObject (com.vmware.vim.vasa._1_0.data.xsd.VasaAssociationObject)5 Volume (com.emc.storageos.vasa.data.internal.Volume)4 FileShare (com.emc.storageos.vasa.data.internal.FileShare)3 SessionContext (com.emc.storageos.vasa.util.SessionContext)3 HostInitiatorInfo (com.vmware.vim.vasa._1_0.data.xsd.HostInitiatorInfo)3 StorageArray (com.vmware.vim.vasa._1_0.data.xsd.StorageArray)3 EventList (com.emc.storageos.vasa.data.internal.Event.EventList)2 InvalidCertificate (com.vmware.vim.vasa._1_0.InvalidCertificate)2 MessageCatalog (com.vmware.vim.vasa._1_0.data.xsd.MessageCatalog)2 MountInfo (com.vmware.vim.vasa._1_0.data.xsd.MountInfo)2