Search in sources :

Example 1 with DDExportClientModify

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

the class DataDomainFileStorageDevice method ddModifyExports.

private void ddModifyExports(DataDomainClient ddClient, String storagePoolId, FSExportMap exportMap, List<FileExport> modifyFileExports) {
    for (FileExport fileExport : modifyFileExports) {
        fileExport.setNativeId(exportMap.get(fileExport.getFileExportKey()).getNativeId());
        List<DDExportClientModify> ddExportClients = ddBuildModifyExportClientList(exportMap, fileExport);
        DDExportInfoDetail ddExport = ddClient.getExport(storagePoolId, fileExport.getNativeId());
        if (ddExport.getPathStatus() != DataDomainApiConstants.PATH_EXISTS) {
            DDServiceStatus ddSvcStatus = ddClient.deleteExport(storagePoolId, ddExport.getId());
            throw DataDomainApiException.exceptions.failedExportPathDoesNotExist(ddExport.getPath());
        } else {
            DDExportInfo ddExportInfo = ddClient.modifyExport(storagePoolId, fileExport.getNativeId(), ddExportClients);
            FileExport existingExport = exportMap.get(fileExport.getFileExportKey());
            ddSetExistingExportProperties(existingExport, fileExport, ddExportInfo);
        }
    }
}
Also used : DDExportInfoDetail(com.emc.storageos.datadomain.restapi.model.DDExportInfoDetail) DDServiceStatus(com.emc.storageos.datadomain.restapi.model.DDServiceStatus) DDExportInfo(com.emc.storageos.datadomain.restapi.model.DDExportInfo) FileExport(com.emc.storageos.db.client.model.FileExport) DDExportClientModify(com.emc.storageos.datadomain.restapi.model.DDExportClientModify)

Example 2 with DDExportClientModify

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

the class DataDomainFileStorageDevice method doAddDeleteClients.

private void doAddDeleteClients(DataDomainClient ddClient, String storagePoolId, String exportId, List<ExportRule> rulesToModify, boolean delete) throws DataDomainApiException {
    if ((rulesToModify != null) && (!rulesToModify.isEmpty())) {
        // Build list of endpoints for rules being modified (added or deleted)
        List<DDExportClient> ddExportClients = new ArrayList<>();
        for (ExportRule ruleToModify : rulesToModify) {
            List<DDExportClient> ddExpClients = ddBuildExportClientList(ruleToModify);
            if (ddExpClients != null) {
                ddExportClients.addAll(ddExpClients);
            }
        }
        // Build list of clients to be modified on the array
        List<DDExportClientModify> modifyClients = new ArrayList<>();
        for (DDExportClient ddExportClient : ddExportClients) {
            DDExportClientModify modifyClient = new DDExportClientModify(ddExportClient.getName(), ddExportClient.getOptions(), delete);
            modifyClients.add(modifyClient);
        }
        // Modify clients on the array
        if (!modifyClients.isEmpty()) {
            DDExportInfo ddExportInfo = ddClient.modifyExport(storagePoolId, exportId, modifyClients);
            if (ddExportInfo.getPathStatus() != DataDomainApiConstants.PATH_EXISTS) {
                DDExportInfoDetail exportDetail = ddClient.getExport(storagePoolId, exportId);
                if (delete) {
                    throw DataDomainApiException.exceptions.failedToDeleteExportClients(exportDetail.getPath());
                } else {
                    throw DataDomainApiException.exceptions.failedToAddExportClients(exportDetail.getPath());
                }
            }
        }
    }
}
Also used : DDExportInfoDetail(com.emc.storageos.datadomain.restapi.model.DDExportInfoDetail) DDExportClient(com.emc.storageos.datadomain.restapi.model.DDExportClient) DDExportInfo(com.emc.storageos.datadomain.restapi.model.DDExportInfo) ArrayList(java.util.ArrayList) ExportRule(com.emc.storageos.model.file.ExportRule) DDExportClientModify(com.emc.storageos.datadomain.restapi.model.DDExportClientModify)

Example 3 with DDExportClientModify

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

the class DataDomainFileStorageDevice method ddBuildModifyExportClientList.

private List<DDExportClientModify> ddBuildModifyExportClientList(FSExportMap exportMap, FileExport fileExport) {
    List<DDExportClientModify> ddExportClients = new ArrayList<>();
    String options = ddSetExportOptions(fileExport);
    // Add clients from the new export
    List<String> addClients = fileExport.getClients();
    // Remove clients not in the new export
    List<String> removeClients = new ArrayList<>();
    List<String> oldClients = exportMap.get(fileExport.getFileExportKey()).getClients();
    for (String oldClient : oldClients) {
        if (!addClients.contains(oldClient)) {
            removeClients.add(oldClient);
        }
    }
    // Add new clients
    for (String client : addClients) {
        ddExportClients.add(new DDExportClientModify(client, options, false));
    }
    // Remove old clients no more in the list
    for (String client : removeClients) {
        ddExportClients.add(new DDExportClientModify(client, options, true));
    }
    return (ddExportClients);
}
Also used : ArrayList(java.util.ArrayList) DDExportClientModify(com.emc.storageos.datadomain.restapi.model.DDExportClientModify)

Aggregations

DDExportClientModify (com.emc.storageos.datadomain.restapi.model.DDExportClientModify)3 DDExportInfo (com.emc.storageos.datadomain.restapi.model.DDExportInfo)2 DDExportInfoDetail (com.emc.storageos.datadomain.restapi.model.DDExportInfoDetail)2 ArrayList (java.util.ArrayList)2 DDExportClient (com.emc.storageos.datadomain.restapi.model.DDExportClient)1 DDServiceStatus (com.emc.storageos.datadomain.restapi.model.DDServiceStatus)1 FileExport (com.emc.storageos.db.client.model.FileExport)1 ExportRule (com.emc.storageos.model.file.ExportRule)1