Search in sources :

Example 11 with InvalidArgument

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

the class SSLUtil method getCertificateThumbprint.

/**
 * getCertificateThumbprint
 *
 * @param cert
 */
public String getCertificateThumbprint(Certificate cert) throws InvalidArgument {
    // Compute the SHA-1 hash of the certificate.
    try {
        byte[] encoded;
        try {
            encoded = cert.getEncoded();
        } catch (CertificateEncodingException cee) {
            throw FaultUtil.InvalidArgument("Error reading certificate encoding: " + cee.getMessage(), cee);
        }
        MessageDigest sha1;
        try {
            sha1 = MessageDigest.getInstance("SHA-1");
        } catch (NoSuchAlgorithmException e) {
            throw FaultUtil.InvalidArgument("Could not instantiate SHA-1 hash algorithm", e);
        }
        sha1.update(encoded);
        byte[] hash = sha1.digest();
        if (hash.length != HASH_LENGTH) {
            throw FaultUtil.InvalidArgument("Computed thumbprint is " + hash.length + " bytes long, expected " + HASH_LENGTH);
        }
        StringBuilder thumbprintString = new StringBuilder(hash.length * 3);
        for (int i = 0; i < hash.length; i++) {
            if (i > 0) {
                thumbprintString.append(":");
            }
            String hexByte = Integer.toHexString(0xFF & (int) hash[i]);
            if (hexByte.length() == 1) {
                thumbprintString.append("0");
            }
            thumbprintString.append(hexByte);
        }
        return thumbprintString.toString().toUpperCase();
    } catch (InvalidArgument ia) {
        throw ia;
    } catch (Exception e) {
        throw FaultUtil.InvalidArgument("Exception: " + e);
    }
}
Also used : InvalidArgument(com.vmware.vim.vasa._1_0.InvalidArgument) CertificateEncodingException(java.security.cert.CertificateEncodingException) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) MessageDigest(java.security.MessageDigest) CertificateNotYetValidException(java.security.cert.CertificateNotYetValidException) CertificateExpiredException(java.security.cert.CertificateExpiredException) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) CertificateEncodingException(java.security.cert.CertificateEncodingException)

Example 12 with InvalidArgument

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

the class SOSManager method queryStorageFileSystems.

/**
 * Makes a call to Bourne to get the details of given file system Ids
 *
 * @param filesystemIds
 * @return array of <code>StorageFileSystem</code> objects
 * @throws InvalidArgument
 * @throws InvalidSession
 * @throws StorageFault
 * @throws NotImplemented
 * @throws NotFound
 */
public synchronized StorageFileSystem[] queryStorageFileSystems(String[] fsUniqueIds) throws InvalidArgument, StorageFault, NotImplemented, InvalidSession {
    final String methodName = "queryStorageFileSystems(): ";
    log.debug(methodName + "Entry");
    List<StorageFileSystem> list = null;
    try {
        Boolean supportsFile = new Boolean(_config.getConfigValue("config/service/storageTopology/storageArray/support-file-profile"));
        if (!supportsFile) {
            log.error(methodName + " This function is not implemented");
            throw FaultUtil.NotImplemented("This function is not implemented");
        }
        if (Util.isEmpty(fsUniqueIds)) {
            throw FaultUtil.InvalidArgument("Given file system Ids are invalid");
        }
        for (String fsId : fsUniqueIds) {
            if (!Util.isEmpty(fsId)) {
                if (!fsId.startsWith(FILESYSTEM_IDENTIFIER_PREFIX)) {
                    throw FaultUtil.InvalidArgument("Given filesytem Id is invalid: " + fsId);
                }
            } else {
                throw FaultUtil.InvalidArgument("Given filesytem Id is invalid: " + fsId);
            }
        }
        this.setFileSystemIds();
        List<String> existingFsIdList = new ArrayList<String>();
        for (String inputFSId : fsUniqueIds) {
            if (_reportedFileSystemIdList.contains(inputFSId)) {
                existingFsIdList.add(inputFSId);
            }
        }
        list = new ArrayList<StorageFileSystem>();
        List<FileShare> fsList = _syncManager.getFileSystemDetailList(existingFsIdList);
        for (FileShare fileshare : fsList) {
            StorageFileSystem fileSystem = new StorageFileSystem();
            fileSystem.setUniqueIdentifier(fileshare.getId());
            if (fileshare.getProtocols().getProtocol().contains("NFS")) {
                fileSystem.setFileSystem(FileSystemEnum.NFS.getValue());
            } else if (fileshare.getProtocols().getProtocol().contains("NFSv4")) {
                fileSystem.setFileSystem(FileSystemEnum.NFS.getValue());
            } else {
                fileSystem.setFileSystem(FileSystemEnum.Other.getValue());
            }
            fileSystem.setFileSystemVersion(FileSystemVersionEnum.NFSV3_0.getValue());
            FileSystemInfo fsDetail = new FileSystemInfo();
            String fsNetworkId = "";
            if (fileshare.getStoragePort() != null && fileshare.getStorageController() != null) {
                String storageSystemId = fileshare.getStorageController().getId();
                String storagePortId = fileshare.getStoragePort().getId();
                com.emc.storageos.vasa.data.internal.StoragePort storagePort = _syncManager.getStoragePort(storageSystemId, storagePortId);
                fsNetworkId = storagePort.getPortNetworkId();
            }
            fsDetail.setIpAddress(fsNetworkId);
            fsDetail.setFileServerName(fsNetworkId);
            fsDetail.setFileSystemPath(fileshare.getMountPath());
            fileSystem.addFileSystemInfo(fsDetail);
            fileSystem.setNativeSnapshotSupported(true);
            fileSystem.setThinProvisioningStatus(AlarmStatusEnum.Green.getValue());
            if (log.isDebugEnabled()) {
                log.debug(methodName + "filesystem: id[" + fileSystem.getUniqueIdentifier() + "] type[" + fileSystem.getFileSystem() + "] version[" + fileSystem.getFileSystemVersion() + "] thinProvisioningStatus[" + fileSystem.getThinProvisioningStatus() + "] snapShotsupported[" + fileSystem.getNativeSnapshotSupported() + "] IpAddress[" + fileSystem.getFileSystemInfo()[0].getFileServerName() + "] serverName[" + fileSystem.getFileSystemInfo()[0].getFileServerName() + "] fileSystemPath[" + fileSystem.getFileSystemInfo()[0].getFileSystemPath() + "]");
            }
            list.add(fileSystem);
        }
    } 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;
    }
    log.debug(methodName + "Exit returning list of file systems of size[" + list.size() + "]");
    return list.toArray(new StorageFileSystem[0]);
}
Also used : ArrayList(java.util.ArrayList) NotImplemented(com.vmware.vim.vasa._1_0.NotImplemented) FileShare(com.emc.storageos.vasa.data.internal.FileShare) StorageFileSystem(com.vmware.vim.vasa._1_0.data.xsd.StorageFileSystem) FileSystemInfo(com.vmware.vim.vasa._1_0.data.xsd.FileSystemInfo) InvalidArgument(com.vmware.vim.vasa._1_0.InvalidArgument) SOSFailure(com.emc.storageos.vasa.fault.SOSFailure)

Example 13 with InvalidArgument

use of com.vmware.vim.vasa._1_0.InvalidArgument 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 14 with InvalidArgument

use of com.vmware.vim.vasa._1_0.InvalidArgument 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 15 with InvalidArgument

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

the class SOSManager method queryAssociatedPortsForProcessor.

/**
 * Makes a call to Bourne to get the associated ports for the given storage
 * processor Ids
 *
 * @param spUniqueIds
 * @return array of <code>VasaAssociationObject</code> objects
 * @throws InvalidArgument
 * @throws InvalidSession
 * @throws StorageFault
 * @throws NotImplemented
 */
public synchronized VasaAssociationObject[] queryAssociatedPortsForProcessor(String[] spUniqueIds) throws InvalidArgument, InvalidSession, StorageFault, NotImplemented {
    final String methodName = "queryAssociatedPortsForProcessor(): ";
    log.debug(methodName + "Entry");
    List<VasaAssociationObject> returnList = 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");
        }
        String bourneProcessorId = this.getProcessorId();
        List<String> bourneStoragePortList = this.getStoragePortIds();
        returnList = new ArrayList<VasaAssociationObject>();
        if (!Util.isEmpty(spUniqueIds)) {
            List<String> inputPortIdList = Arrays.asList(spUniqueIds);
            log.debug(methodName + "input processor ids: " + inputPortIdList);
            for (String storageProcessorId : spUniqueIds) {
                if (!Util.isEmpty(storageProcessorId) && !storageProcessorId.startsWith(STORAGEPROCESSOR_IDENTIFIER_PREFIX)) {
                    throw FaultUtil.InvalidArgument("Given processor Id is invalid:[" + storageProcessorId + "]");
                }
                if (!Util.isEmpty(storageProcessorId) && bourneProcessorId.equals(storageProcessorId)) {
                    log.debug(methodName + "Input processor Id is matching with valid processor Id:[" + storageProcessorId + "]");
                    VasaAssociationObject associationObject = new VasaAssociationObject();
                    BaseStorageEntity entityObject = new BaseStorageEntity();
                    entityObject.setUniqueIdentifier(storageProcessorId);
                    associationObject.addEntityId(entityObject);
                    List<BaseStorageEntity> associatedPortList = new ArrayList<BaseStorageEntity>();
                    for (String bourneStoragePortId : bourneStoragePortList) {
                        BaseStorageEntity associatedPort = new BaseStorageEntity();
                        log.debug(methodName + "Associating storage port ID [" + bourneStoragePortId + "] to processor ID[" + storageProcessorId + "]");
                        associatedPort.setUniqueIdentifier(bourneStoragePortId);
                        associatedPortList.add(associatedPort);
                    }
                    associationObject.setAssociatedId(associatedPortList.toArray(new BaseStorageEntity[0]));
                    returnList.add(associationObject);
                }
            }
            log.debug(methodName + "Exit returning vasa association objects of size[" + returnList.size() + "]");
            return returnList.toArray(new VasaAssociationObject[0]);
        } else if (spUniqueIds != null && spUniqueIds.length == 0) {
            log.debug(methodName + "Exit returning vasa association objects of size[" + returnList.size() + "]");
            return returnList.toArray(new VasaAssociationObject[0]);
        }
        VasaAssociationObject associationObject = new VasaAssociationObject();
        BaseStorageEntity entityObject = new BaseStorageEntity();
        entityObject.setUniqueIdentifier(bourneProcessorId);
        associationObject.addEntityId(entityObject);
        List<BaseStorageEntity> associatedPortList = new ArrayList<BaseStorageEntity>();
        for (String bourneStoragePortId : bourneStoragePortList) {
            BaseStorageEntity associatedPort = new BaseStorageEntity();
            log.debug(methodName + "Associating storage port ID [" + bourneStoragePortId + "] to processor ID[" + bourneProcessorId + "]");
            associatedPort.setUniqueIdentifier(bourneStoragePortId);
            associatedPortList.add(associatedPort);
        }
        associationObject.setAssociatedId(associatedPortList.toArray(new BaseStorageEntity[0]));
        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) ArrayList(java.util.ArrayList) NotImplemented(com.vmware.vim.vasa._1_0.NotImplemented)

Aggregations

InvalidArgument (com.vmware.vim.vasa._1_0.InvalidArgument)14 NotImplemented (com.vmware.vim.vasa._1_0.NotImplemented)10 SOSFailure (com.emc.storageos.vasa.fault.SOSFailure)8 ArrayList (java.util.ArrayList)8 StorageFault (com.vmware.vim.vasa._1_0.StorageFault)5 BaseStorageEntity (com.vmware.vim.vasa._1_0.data.xsd.BaseStorageEntity)5 VasaAssociationObject (com.vmware.vim.vasa._1_0.data.xsd.VasaAssociationObject)5 FileShare (com.emc.storageos.vasa.data.internal.FileShare)3 Volume (com.emc.storageos.vasa.data.internal.Volume)3 EventList (com.emc.storageos.vasa.data.internal.Event.EventList)2 InvalidSession (com.vmware.vim.vasa._1_0.InvalidSession)2 StorageArray (com.vmware.vim.vasa._1_0.data.xsd.StorageArray)2 CertificateExpiredException (java.security.cert.CertificateExpiredException)2 CertificateNotYetValidException (java.security.cert.CertificateNotYetValidException)2 List (java.util.List)2 CoS (com.emc.storageos.vasa.data.internal.CoS)1 Event (com.emc.storageos.vasa.data.internal.Event)1 AssociatedPool (com.emc.storageos.vasa.data.internal.Volume.AssociatedPool)1 HighAvailabilityVolumes (com.emc.storageos.vasa.data.internal.Volume.HighAvailabilityVolumes)1 SessionContext (com.emc.storageos.vasa.util.SessionContext)1