Search in sources :

Example 16 with BiosCommandResult

use of com.emc.storageos.volumecontroller.impl.BiosCommandResult in project coprhd-controller by CoprHD.

the class BrocadeNetworkSystemDevice method updateZones.

@Override
public BiosCommandResult updateZones(NetworkSystem networkSystem, List<ZoneUpdate> zoneUpdates, String fabricId, String fabricWwn, boolean activateZoneset) throws NetworkDeviceControllerException {
    BiosCommandResult cmdResults = null;
    try {
        WBEMClient client = getNetworkDeviceClient(networkSystem);
        validateFabric(networkSystem, fabricWwn, fabricId);
        Map<String, String> results = updateZonesStrategy(client, zoneUpdates, fabricId, fabricWwn, activateZoneset);
        cmdResults = getBiosCommandResult(results);
        _log.info("Update zone results {}", toMessage(results));
    } catch (NetworkDeviceControllerException ex) {
        _log.error("Cannot update zones: " + ex.getLocalizedMessage());
        throw ex;
    }
    return cmdResults;
}
Also used : NetworkDeviceControllerException(com.emc.storageos.networkcontroller.exceptions.NetworkDeviceControllerException) BiosCommandResult(com.emc.storageos.volumecontroller.impl.BiosCommandResult) WBEMClient(javax.wbem.client.WBEMClient)

Example 17 with BiosCommandResult

use of com.emc.storageos.volumecontroller.impl.BiosCommandResult in project coprhd-controller by CoprHD.

the class IsilonFileStorageDevice method doFailoverLink.

/**
 * perform failover operation
 * systemTarget - failover to target system
 * fs - target filesystem
 * completer - task completer
 *
 * return BiosCommandResult
 */
@Override
public BiosCommandResult doFailoverLink(StorageSystem systemTarget, FileShare fs, TaskCompleter completer) {
    _log.info("IsilonFileStorageDevice -  doFailoverLink started ");
    FileShare sourceFS = null;
    FileShare targetFS = null;
    StorageSystem sourceSystem = null;
    StorageSystem targetSystem = null;
    boolean failback = false;
    if (fs.getPersonality().equals(PersonalityTypes.TARGET.name())) {
        sourceFS = _dbClient.queryObject(FileShare.class, fs.getParentFileShare());
        targetFS = fs;
    } else if (fs.getPersonality().equals(PersonalityTypes.SOURCE.name())) {
        sourceFS = fs;
        List<String> targetfileUris = new ArrayList<String>();
        targetfileUris.addAll(fs.getMirrorfsTargets());
        if (!targetfileUris.isEmpty()) {
            targetFS = _dbClient.queryObject(FileShare.class, URI.create(targetfileUris.get(0)));
        } else {
            ServiceError serviceError = DeviceControllerErrors.isilon.unableToFailoverFileSystem(systemTarget.getIpAddress(), "Unable to get target filesystem for source filesystem " + fs.getName());
            return BiosCommandResult.createErrorResult(serviceError);
        }
        failback = true;
    }
    sourceSystem = _dbClient.queryObject(StorageSystem.class, sourceFS.getStorageDevice());
    targetSystem = _dbClient.queryObject(StorageSystem.class, targetFS.getStorageDevice());
    PolicyStorageResource policyStrRes = getEquivalentPolicyStorageResource(sourceFS, _dbClient);
    if (policyStrRes != null) {
        IsilonSyncPolicy syncPolicy = policyNativeIdValidation(sourceSystem, policyStrRes);
        String policyName = syncPolicy.getName();
        BiosCommandResult cmdResult = null;
        // In case of failback we do failover on the source file system, so we need to append _mirror
        if (failback) {
            String mirrorPolicyName = syncPolicy.getName();
            mirrorPolicyName = mirrorPolicyName.concat(MIRROR_POLICY);
            // prepared policy for failback
            cmdResult = prepareFailbackOp(sourceSystem, policyName);
            if (!cmdResult.isCommandSuccess()) {
                return cmdResult;
            }
            // Call Isilon Api failback job
            return doFailoverMirrorPolicy(sourceSystem, policyName, targetSystem, mirrorPolicyName, completer);
        } else {
            // prepared policy for failover
            cmdResult = prepareFailoverOp(sourceSystem, policyName);
            if (!cmdResult.isCommandSuccess()) {
                _log.info("Unable to stop replication policy on source");
                _log.info("Proceeding with failover anyway");
            }
            // Call Isilon Api failover job
            return mirrorOperations.doFailover(targetSystem, syncPolicy.getId(), completer);
        }
    }
    ServiceError serviceError = DeviceControllerErrors.isilon.unableToFailoverFileSystem(systemTarget.getIpAddress(), "Unable to get the policy details for filesystem :" + fs.getName());
    return BiosCommandResult.createErrorResult(serviceError);
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) BiosCommandResult(com.emc.storageos.volumecontroller.impl.BiosCommandResult) IsilonList(com.emc.storageos.isilon.restapi.IsilonApi.IsilonList) ArrayList(java.util.ArrayList) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) List(java.util.List) FileShare(com.emc.storageos.db.client.model.FileShare) SMBFileShare(com.emc.storageos.db.client.model.SMBFileShare) PolicyStorageResource(com.emc.storageos.db.client.model.PolicyStorageResource) IsilonSyncPolicy(com.emc.storageos.isilon.restapi.IsilonSyncPolicy) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 18 with BiosCommandResult

use of com.emc.storageos.volumecontroller.impl.BiosCommandResult in project coprhd-controller by CoprHD.

the class IsilonFileStorageDevice method updateExportRules.

@Override
public BiosCommandResult updateExportRules(StorageSystem storage, FileDeviceInputOutput args) throws ControllerException {
    // Requested Export Rules
    List<ExportRule> exportAdd = args.getExportRulesToAdd();
    List<ExportRule> exportDelete = args.getExportRulesToDelete();
    List<ExportRule> exportModify = args.getExportRulesToModify();
    // To be processed export rules
    List<ExportRule> exportsToRemove = new ArrayList<>();
    List<ExportRule> exportsToModify = new ArrayList<>();
    List<ExportRule> exportsToAdd = new ArrayList<>();
    // Calculate Export Path
    String exportPath;
    String subDir = args.getSubDirectory();
    // ".snapshot"
    if (!args.getFileOperation()) {
        exportPath = args.getSnapshotPath();
        if (subDir != null && subDir.length() > 0) {
            exportPath = args.getSnapshotPath() + "/" + subDir;
        }
    } else {
        exportPath = args.getFs().getPath();
        if (subDir != null && subDir.length() > 0) {
            exportPath = args.getFs().getPath() + "/" + subDir;
        }
    }
    _log.info("exportPath : {}", exportPath);
    args.setExportPath(exportPath);
    try {
        // add the new export rule from the array into the update request.
        Map<String, ExportRule> arrayExportRuleMap = extraExportRuleFromArray(storage, args);
        if (!arrayExportRuleMap.isEmpty()) {
            if (exportModify != null) {
                // merge the end point for which sec flavor is common.
                for (ExportRule exportRule : exportModify) {
                    ExportRule arrayExportRule = arrayExportRuleMap.remove(exportRule.getSecFlavor());
                    if (arrayExportRule != null) {
                        if (exportRule.getReadOnlyHosts() != null) {
                            exportRule.getReadOnlyHosts().addAll(arrayExportRule.getReadOnlyHosts());
                        } else {
                            exportRule.setReadOnlyHosts(arrayExportRule.getReadOnlyHosts());
                        }
                        if (exportRule.getReadWriteHosts() != null) {
                            exportRule.getReadWriteHosts().addAll(arrayExportRule.getReadWriteHosts());
                        } else {
                            exportRule.setReadWriteHosts(arrayExportRule.getReadWriteHosts());
                        }
                        if (exportRule.getRootHosts() != null) {
                            exportRule.getRootHosts().addAll(arrayExportRule.getRootHosts());
                        } else {
                            exportRule.setRootHosts(arrayExportRule.getRootHosts());
                        }
                    }
                }
                // now add the remaining export rule
                exportModify.addAll(arrayExportRuleMap.values());
            } else {
                // if exportModify is null then create a new export rule and add
                exportModify = new ArrayList<ExportRule>();
                exportModify.addAll(arrayExportRuleMap.values());
            }
        }
    } catch (Exception e) {
        // TODO Auto-generated catch block
        _log.error("Not able to fetch latest Export rule from backend array.", e);
    }
    // ALL EXPORTS
    List<ExportRule> existingDBExportRule = args.getExistingDBExportRules();
    List<ExportRule> exportsToprocess = new ArrayList<>();
    for (ExportRule rule : existingDBExportRule) {
        if (rule.getExportPath().equalsIgnoreCase(exportPath)) {
            exportsToprocess.add(rule);
        }
    }
    _log.info("Number of existing Rules found {} for exportPath {}", exportsToprocess.size(), exportPath);
    // list and add to read/Write list.
    if (!exportsToprocess.isEmpty() || !exportAdd.isEmpty()) {
        if (exportModify != null && !exportModify.isEmpty()) {
            for (ExportRule existingRule : exportsToprocess) {
                for (ExportRule newExportRule : exportModify) {
                    if (newExportRule.getSecFlavor().equals(existingRule.getSecFlavor())) {
                        newExportRule.setDeviceExportId(existingRule.getDeviceExportId());
                        exportsToModify.add(newExportRule);
                    }
                }
            }
        }
        // Handle Delete export Rules
        if (exportDelete != null && !exportDelete.isEmpty()) {
            for (ExportRule existingRule : exportsToprocess) {
                for (ExportRule oldExport : exportDelete) {
                    if (oldExport.getSecFlavor().equals(existingRule.getSecFlavor())) {
                        _log.info("Deleting Export Rule {}", existingRule);
                        exportsToRemove.add(existingRule);
                    }
                }
            }
        }
        // No of exports found to remove from the list
        _log.info("No of exports found to remove from the existing exports list {}", exportsToRemove.size());
        exportsToprocess.removeAll(exportsToRemove);
        // Handle Add Export Rules
        if (exportAdd != null && !exportAdd.isEmpty()) {
            for (ExportRule newExport : exportAdd) {
                _log.info("Add Export Rule {}", newExport);
                newExport.setExportPath(exportPath);
                exportsToAdd.add(newExport);
            }
        }
        exportsToprocess.addAll(exportAdd);
    }
    // Process Mods
    IsilonApi isi = getIsilonDevice(storage);
    for (ExportRule existingRule : exportsToModify) {
        _log.info("Modify Export rule : {}", existingRule.toString());
    }
    processIsiExport(isi, args, exportsToModify);
    for (ExportRule existingRule : exportsToRemove) {
        _log.info("Remove Export rule : {}", existingRule.toString());
    }
    processRemoveIsiExport(isi, args, exportsToRemove);
    for (ExportRule existingRule : exportsToAdd) {
        _log.info("Add Export rule : {}", existingRule.toString());
    }
    processAddIsiExport(isi, args, exportsToAdd);
    BiosCommandResult result = BiosCommandResult.createSuccessfulResult();
    return result;
}
Also used : BiosCommandResult(com.emc.storageos.volumecontroller.impl.BiosCommandResult) ArrayList(java.util.ArrayList) ExportRule(com.emc.storageos.model.file.ExportRule) IsilonApi(com.emc.storageos.isilon.restapi.IsilonApi) IsilonException(com.emc.storageos.isilon.restapi.IsilonException) ControllerException(com.emc.storageos.volumecontroller.ControllerException) URISyntaxException(java.net.URISyntaxException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) IsilonCollectionException(com.emc.storageos.plugins.metering.isilon.IsilonCollectionException)

Example 19 with BiosCommandResult

use of com.emc.storageos.volumecontroller.impl.BiosCommandResult in project coprhd-controller by CoprHD.

the class IsilonFileStorageDevice method prepareFailbackOp.

/**
 * prepare policy to failback.
 *
 * @param systemTarget - target storagesystem
 * @param policyName -failback mirror policy
 * @return
 */
private BiosCommandResult prepareFailbackOp(final StorageSystem targetSystem, String policyName) {
    BiosCommandResult cmdResult = null;
    // check for target device up and then disable the policy
    cmdResult = mirrorOperations.doTestReplicationPolicy(targetSystem, policyName);
    if (cmdResult.isCommandSuccess()) {
        // if policy enables on target storage then We should disable it before failback job
        cmdResult = mirrorOperations.doStopReplicationPolicy(targetSystem, policyName);
    } else {
        ServiceError serviceError = DeviceControllerErrors.isilon.unableToFailbackReplicationPolicy(targetSystem.getIpAddress(), policyName, cmdResult.getMessage());
        return BiosCommandResult.createErrorResult(serviceError);
    }
    return cmdResult;
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) BiosCommandResult(com.emc.storageos.volumecontroller.impl.BiosCommandResult)

Example 20 with BiosCommandResult

use of com.emc.storageos.volumecontroller.impl.BiosCommandResult in project coprhd-controller by CoprHD.

the class IsilonFileStorageDevice method doRestoreFS.

@Override
public BiosCommandResult doRestoreFS(StorageSystem storage, FileDeviceInputOutput args) throws ControllerException {
    BiosCommandResult result = new BiosCommandResult();
    String opName = ResourceOperationTypeEnum.RESTORE_FILE_SNAPSHOT.getName();
    ServiceError serviceError = IsilonException.errors.jobFailed(opName);
    result.error(serviceError);
    return result;
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) BiosCommandResult(com.emc.storageos.volumecontroller.impl.BiosCommandResult)

Aggregations

BiosCommandResult (com.emc.storageos.volumecontroller.impl.BiosCommandResult)135 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)76 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)69 ControllerException (com.emc.storageos.volumecontroller.ControllerException)64 NetAppException (com.emc.storageos.netapp.NetAppException)34 ArrayList (java.util.ArrayList)34 NetworkDeviceControllerException (com.emc.storageos.networkcontroller.exceptions.NetworkDeviceControllerException)28 NetAppCException (com.emc.storageos.netappc.NetAppCException)19 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)18 NetAppApi (com.emc.storageos.netapp.NetAppApi)18 NetAppClusterApi (com.emc.storageos.netappc.NetAppClusterApi)18 URI (java.net.URI)16 VNXException (com.emc.storageos.vnx.xmlapi.VNXException)15 XMLApiResult (com.emc.storageos.vnx.xmlapi.XMLApiResult)15 VNXFileCommApi (com.emc.storageos.volumecontroller.impl.plugins.provisioning.VNXFileCommApi)15 ApplicationContext (org.springframework.context.ApplicationContext)15 ClassPathXmlApplicationContext (org.springframework.context.support.ClassPathXmlApplicationContext)15 FileShare (com.emc.storageos.db.client.model.FileShare)14 SMBFileShare (com.emc.storageos.db.client.model.SMBFileShare)14 NetworkSystem (com.emc.storageos.db.client.model.NetworkSystem)11