Search in sources :

Example 6 with DataDomainClient

use of com.emc.storageos.datadomain.restapi.DataDomainClient in project coprhd-controller by CoprHD.

the class DataDomainCommunicationInterface method scan.

@Override
public void scan(AccessProfile accessProfile) throws DataDomainApiException {
    DataDomainClient ddClient = getDataDomainClient(accessProfile);
    StorageProvider provider = _dbClient.queryObject(StorageProvider.class, accessProfile.getSystemId());
    DDMCInfoDetail ddmcInfo = new DDMCInfoDetail();
    try {
        ddmcInfo = ddClient.getManagementSystemInfo();
    } catch (DataDomainApiException dex) {
        provider.setConnectionStatus(ConnectionStatus.NOTCONNECTED.toString());
        String op = "DDMC info retrieval";
        String sys = provider.getLabel() + "(" + provider.getIPAddress() + ")";
        throw DataDomainApiException.exceptions.opFailedProviderUnreachable(op, sys);
    }
    if (!validDdmcVersion(accessProfile, provider, ddmcInfo)) {
        String version = null;
        String minimumSupportedVersion = null;
        Map<String, String> props = accessProfile.getProps();
        if (props != null) {
            version = props.get(CURRENT_VERSION);
            minimumSupportedVersion = props.get(MINIMUM_VERSION);
        }
        throw DataDomainApiException.exceptions.scanFailedIncompatibleDdmc(version, minimumSupportedVersion);
    }
    Map<String, StorageSystemViewObject> cache = accessProfile.getCache();
    DDSystemList systemList = ddClient.getManagedSystemList();
    for (DDSystemInfo system : systemList.getSystemInfo()) {
        DDSystem ddSystem = ddClient.getDDSystem(system.getId());
        StorageSystemViewObject view = new StorageSystemViewObject();
        view.addprovider(accessProfile.getSystemId().toString());
        view.setDeviceType(accessProfile.getSystemType());
        view.setProperty(StorageSystemViewObject.SERIAL_NUMBER, ddSystem.serialNo);
        view.setProperty(StorageSystemViewObject.MODEL, ddSystem.model);
        view.setProperty(StorageSystemViewObject.STORAGE_NAME, ddSystem.name);
        view.setProperty(StorageSystemViewObject.VERSION, ddSystem.version);
        cache.put(system.getId(), view);
    }
}
Also used : DataDomainApiException(com.emc.storageos.datadomain.restapi.errorhandling.DataDomainApiException) DDSystemInfo(com.emc.storageos.datadomain.restapi.model.DDSystemInfo) DDMCInfoDetail(com.emc.storageos.datadomain.restapi.model.DDMCInfoDetail) DDSystemList(com.emc.storageos.datadomain.restapi.model.DDSystemList) StorageSystemViewObject(com.emc.storageos.plugins.StorageSystemViewObject) DDSystem(com.emc.storageos.datadomain.restapi.model.DDSystem) StorageProvider(com.emc.storageos.db.client.model.StorageProvider) DataDomainClient(com.emc.storageos.datadomain.restapi.DataDomainClient)

Example 7 with DataDomainClient

use of com.emc.storageos.datadomain.restapi.DataDomainClient in project coprhd-controller by CoprHD.

the class DataDomainFileStorageDevice method doConnect.

@Override
public void doConnect(StorageSystem storage) {
    try {
        _log.info("doConnect {} - start", storage.getId());
        DataDomainClient ddClient = getDataDomainClient(storage);
        if (ddClient == null) {
            _log.error("doConnect failed, provider unreachable");
            String sys = storage.getLabel() + "(" + storage.getIpAddress() + ")";
            throw DataDomainApiException.exceptions.connectStorageFailed(sys);
        }
        DDMCInfoDetail ddInfo = ddClient.getManagementSystemInfo();
        String msg = String.format("doConnect %1$s - complete", ddInfo);
        _log.info(msg);
    } catch (DataDomainApiException e) {
        _log.error("doConnect failed.", e);
        throw DeviceControllerException.exceptions.connectStorageFailed(e);
    }
}
Also used : DataDomainApiException(com.emc.storageos.datadomain.restapi.errorhandling.DataDomainApiException) DDMCInfoDetail(com.emc.storageos.datadomain.restapi.model.DDMCInfoDetail) DataDomainClient(com.emc.storageos.datadomain.restapi.DataDomainClient)

Example 8 with DataDomainClient

use of com.emc.storageos.datadomain.restapi.DataDomainClient in project coprhd-controller by CoprHD.

the class DataDomainFileStorageDevice method deleteExportRules.

@Override
public BiosCommandResult deleteExportRules(StorageSystem storage, FileDeviceInputOutput args) {
    try {
        // TODO - These lines may be removed once DD snapshot APIs become available.
        if (!args.getFileOperation()) {
            // Snapshot Export operation is not supported by Data Domain.
            ServiceError serviceError = DeviceControllerErrors.datadomain.operationNotSupported();
            serviceError.setMessage("Data Domain does not support snapshot export");
            return BiosCommandResult.createErrorResult(serviceError);
        }
        _log.info("DataDomainFileStorageDevice deleteExportRules - start");
        FileShare fs = args.getFs();
        // List of existing export rules
        List<ExportRule> existingExports = args.getExistingDBExportRules();
        if ((existingExports == null) || (existingExports.isEmpty())) {
            _log.info("Export rule delete, file system {} does not have an existing export to delete", args.getFsId());
            return BiosCommandResult.createSuccessfulResult();
        }
        _log.info("Number of existng Rules found {}", existingExports.size());
        // Build export path, adding sub-directory if not null and non-empty
        String exportPath;
        String subDir = args.getSubDirectory();
        StringBuilder expPath = new StringBuilder();
        if (!args.getFileOperation()) {
            expPath.append(args.getSnapshotPath());
        } else {
            expPath.append(args.getFs().getPath());
        }
        if ((subDir != null) && (subDir.length() > 0)) {
            expPath.append("/");
            expPath.append(subDir);
        }
        exportPath = expPath.toString();
        // Data Domain attaches a prefix to every file system path
        expPath = new StringBuilder();
        if (!exportPath.startsWith(DataDomainApiConstants.FS_PATH_BASE)) {
            expPath.append(DataDomainApiConstants.FS_PATH_BASE);
        }
        expPath.append(exportPath);
        _log.info("exportPath : {}", expPath);
        args.setExportPath(expPath.toString());
        for (ExportRule expRule : existingExports) {
            if (expRule.getExportPath().equals(expPath.toString())) {
                args.setObjIdOnDevice(expRule.getDeviceExportId());
                break;
            }
        }
        // Do we need to delete all subdirectories as well?
        boolean allDirs = args.isAllDir();
        // List of IDs of exports to delete
        List<String> exportIdsToDelete = new ArrayList<>();
        exportIdsToDelete.add(args.getObjIdOnDevice());
        DataDomainClient ddClient = getDataDomainClient(storage);
        if (ddClient == null) {
            _log.error("deleteExportRules failed, provider unreachable");
            String op = "Delete export rules";
            return BiosCommandResult.createErrorResult(DeviceControllerErrors.datadomain.operationFailedProviderInaccessible(op));
        }
        URI storagePoolId = args.getFs().getPool();
        StoragePool storagePool = _dbClient.queryObject(StoragePool.class, storagePoolId);
        if (allDirs) {
            // Add to the list of IDs of exports to delete
            buildListOfIdsToDelete(ddClient, storagePool.getNativeId(), expPath.toString(), exportIdsToDelete);
        }
        doDeleteExports(ddClient, storagePool.getNativeId(), exportIdsToDelete);
        _log.info("DataDomainFileStorageDevice deleteExportRules {} - complete", args.getFsId());
        return BiosCommandResult.createSuccessfulResult();
    } catch (DataDomainApiException dde) {
        _log.error("Export update failed, device error:", dde);
        return BiosCommandResult.createErrorResult(dde);
    }
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) StoragePool(com.emc.storageos.db.client.model.StoragePool) ArrayList(java.util.ArrayList) FileShare(com.emc.storageos.db.client.model.FileShare) SMBFileShare(com.emc.storageos.db.client.model.SMBFileShare) DataDomainClient(com.emc.storageos.datadomain.restapi.DataDomainClient) URI(java.net.URI) DataDomainApiException(com.emc.storageos.datadomain.restapi.errorhandling.DataDomainApiException) ExportRule(com.emc.storageos.model.file.ExportRule)

Example 9 with DataDomainClient

use of com.emc.storageos.datadomain.restapi.DataDomainClient in project coprhd-controller by CoprHD.

the class DataDomainFileStorageDevice method doCheckFSExists.

@Override
public boolean doCheckFSExists(StorageSystem storage, FileDeviceInputOutput args) throws ControllerException {
    _log.info("checking file system existence on array: ", args.getFsName());
    boolean isMtreeExists = true;
    try {
        DataDomainClient ddClient = getDataDomainClient(storage);
        URI storagePoolId = args.getFs().getPool();
        StoragePool storagePool = _dbClient.queryObject(StoragePool.class, storagePoolId);
        DDMTreeInfoDetail mtreeInfo = ddClient.getMTree(storagePool.getNativeId(), args.getFs().getNativeId());
        if (mtreeInfo != null && (mtreeInfo.id.equals(args.getFsNativeId()))) {
            isMtreeExists = true;
        }
    } catch (DataDomainResourceNotFoundException e) {
        _log.info("Mtree not found.", e);
        isMtreeExists = false;
    }
    return isMtreeExists;
}
Also used : StoragePool(com.emc.storageos.db.client.model.StoragePool) DataDomainResourceNotFoundException(com.emc.storageos.datadomain.restapi.errorhandling.DataDomainResourceNotFoundException) DDMTreeInfoDetail(com.emc.storageos.datadomain.restapi.model.DDMTreeInfoDetail) DataDomainClient(com.emc.storageos.datadomain.restapi.DataDomainClient) URI(java.net.URI)

Example 10 with DataDomainClient

use of com.emc.storageos.datadomain.restapi.DataDomainClient in project coprhd-controller by CoprHD.

the class DataDomainFileStorageDevice method doShare.

@Override
public BiosCommandResult doShare(StorageSystem storage, FileDeviceInputOutput args, SMBFileShare smbFileShare) throws ControllerException {
    try {
        _log.info("DataDomainFileStorageDevice doShare() - start");
        DataDomainClient ddClient = getDataDomainClient(storage);
        if (ddClient == null) {
            _log.error("doShare failed, provider unreachable");
            String op = "FS share create";
            return BiosCommandResult.createErrorResult(DeviceControllerErrors.datadomain.operationFailedProviderInaccessible(op));
        }
        // Check if this is a new share or update of the existing share
        SMBShareMap smbShareMap = args.getFileObjShares();
        SMBFileShare existingShare = (smbShareMap == null) ? null : smbShareMap.get(smbFileShare.getName());
        String shareId;
        DDShareInfo ddShareInfo;
        // Cannot send empty description, send the share name in that case
        if (smbFileShare.getDescription() == null || smbFileShare.getDescription().isEmpty()) {
            _log.debug("SMB Share creation was called with empty description and setting name as desc");
            smbFileShare.setDescription(smbFileShare.getName());
        }
        if (existingShare != null) {
            shareId = existingShare.getNativeId();
            // modify share
            URI storagePoolId = args.getFs().getPool();
            StoragePool storagePool = _dbClient.queryObject(StoragePool.class, storagePoolId);
            DDShareInfoDetail ddShareInfoDetail = ddClient.getShare(storagePool.getNativeId(), shareId);
            if (ddShareInfoDetail.getPathStatus() == 0) {
                DDServiceStatus ddSvcStatus = ddClient.deleteShare(storagePool.getNativeId(), shareId);
                throw DataDomainApiException.exceptions.failedSharePathDoesNotExist(ddShareInfoDetail.getPath());
            }
            ddShareInfo = ddClient.modifyShare(storagePool.getNativeId(), shareId, smbFileShare.getDescription());
        } else {
            // new share
            URI storagePoolId = args.getFs().getPool();
            StoragePool storagePool = _dbClient.queryObject(StoragePool.class, storagePoolId);
            ddCreateShare(ddClient, storagePool.getNativeId(), smbFileShare, smbFileShare.getPath());
        }
        // init file share map
        if (args.getFileObjShares() == null) {
            args.initFileObjShares();
        }
        args.getFileObjShares().put(smbFileShare.getName(), smbFileShare);
        _log.info("DataDomainFileStorageDevice doShare() - complete");
        // Set MountPoint
        smbFileShare.setMountPoint(smbFileShare.getStoragePortNetworkId(), smbFileShare.getStoragePortName(), smbFileShare.getName());
        return BiosCommandResult.createSuccessfulResult();
    } catch (DataDomainApiException e) {
        _log.error("doShare failed, device error.", e);
        return BiosCommandResult.createErrorResult(e);
    }
}
Also used : DataDomainApiException(com.emc.storageos.datadomain.restapi.errorhandling.DataDomainApiException) SMBShareMap(com.emc.storageos.db.client.model.SMBShareMap) StoragePool(com.emc.storageos.db.client.model.StoragePool) DDShareInfoDetail(com.emc.storageos.datadomain.restapi.model.DDShareInfoDetail) DDServiceStatus(com.emc.storageos.datadomain.restapi.model.DDServiceStatus) SMBFileShare(com.emc.storageos.db.client.model.SMBFileShare) DataDomainClient(com.emc.storageos.datadomain.restapi.DataDomainClient) URI(java.net.URI) DDShareInfo(com.emc.storageos.datadomain.restapi.model.DDShareInfo)

Aggregations

DataDomainClient (com.emc.storageos.datadomain.restapi.DataDomainClient)17 DataDomainApiException (com.emc.storageos.datadomain.restapi.errorhandling.DataDomainApiException)14 URI (java.net.URI)12 StoragePool (com.emc.storageos.db.client.model.StoragePool)8 ArrayList (java.util.ArrayList)7 SMBFileShare (com.emc.storageos.db.client.model.SMBFileShare)5 StorageProvider (com.emc.storageos.db.client.model.StorageProvider)5 DataDomainResourceNotFoundException (com.emc.storageos.datadomain.restapi.errorhandling.DataDomainResourceNotFoundException)4 SMBShareMap (com.emc.storageos.db.client.model.SMBShareMap)4 FSExportMap (com.emc.storageos.db.client.model.FSExportMap)3 FileExport (com.emc.storageos.db.client.model.FileExport)3 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)3 DDMCInfoDetail (com.emc.storageos.datadomain.restapi.model.DDMCInfoDetail)2 DDMTreeInfo (com.emc.storageos.datadomain.restapi.model.DDMTreeInfo)2 DDServiceStatus (com.emc.storageos.datadomain.restapi.model.DDServiceStatus)2 FileShare (com.emc.storageos.db.client.model.FileShare)2 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)2 ExportRule (com.emc.storageos.model.file.ExportRule)2 DDMTreeInfoDetail (com.emc.storageos.datadomain.restapi.model.DDMTreeInfoDetail)1 DDMtreeCapacityInfos (com.emc.storageos.datadomain.restapi.model.DDMtreeCapacityInfos)1