Search in sources :

Example 41 with DriverTask

use of com.emc.storageos.storagedriver.DriverTask in project coprhd-controller by CoprHD.

the class StorageDriverSimulator method discoverStoragePorts.

@Override
public DriverTask discoverStoragePorts(StorageSystem storageSystem, List<StoragePort> storagePorts) {
    _log.info("Discovery of storage ports for storage system {} .", storageSystem.getNativeId());
    int index = 0;
    // Get "portIndexes" attribute map
    Map<String, List<String>> portIndexes = driverRegistry.getDriverAttributesForKey("simulatordriver", "portIndexes");
    if (portIndexes != null) {
        List<String> indexes = portIndexes.get(storageSystem.getNativeId());
        if (indexes != null) {
            index = Integer.parseInt(indexes.get(0));
            _log.info("Storage ports index for storage system {} is {} .", storageSystem.getNativeId(), index);
        }
    }
    if (index == 0) {
        // get the last used index and increment by 1 to generate an index
        if (portIndexes != null) {
            List<String> indexes = portIndexes.get("lastIndex");
            if (indexes != null) {
                index = Integer.parseInt(indexes.get(0)) + 1;
            } else {
                index++;
            }
        } else {
            index++;
        }
        // set this index for the system in registry
        driverRegistry.addDriverAttributeForKey("simulatordriver", "portIndexes", storageSystem.getNativeId(), Collections.singletonList(String.valueOf(index)));
        driverRegistry.addDriverAttributeForKey("simulatordriver", "portIndexes", "lastIndex", Collections.singletonList(String.valueOf(index)));
        _log.info("Storage ports index for storage system {} is {} .", storageSystem.getNativeId(), index);
    }
    // Create ports with network
    for (int i = 0; i <= 2; i++) {
        StoragePort port = new StoragePort();
        port.setNativeId("port-1234577-" + i + storageSystem.getNativeId());
        port.setStorageSystemId(storageSystem.getNativeId());
        _log.info("Discovered Port {}, storageSystem {}", port.getNativeId(), port.getStorageSystemId());
        port.setDeviceLabel("er-port-1234577" + i + storageSystem.getNativeId());
        port.setPortName(port.getDeviceLabel());
        // port.setNetworkId("er-network77"+ storageSystem.getNativeId());
        port.setNetworkId("11");
        port.setTransportType(StoragePort.TransportType.FC);
        // port.setTransportType(StoragePort.TransportType.IP);
        port.setPortNetworkId("6" + Integer.toHexString(index) + ":FE:FE:FE:FE:FE:FE:1" + i);
        port.setOperationalStatus(StoragePort.OperationalStatus.OK);
        port.setPortHAZone("zone-" + i);
        storagePorts.add(port);
    }
    // Create ports without network
    for (int i = 3; i <= 6; i++) {
        StoragePort port = new StoragePort();
        port.setNativeId("port-1234577-" + i + storageSystem.getNativeId());
        port.setStorageSystemId(storageSystem.getNativeId());
        _log.info("Discovered Port {}, storageSystem {}", port.getNativeId(), port.getStorageSystemId());
        port.setDeviceLabel("er-port-1234577" + i + storageSystem.getNativeId());
        port.setPortName(port.getDeviceLabel());
        // port.setNetworkId("er-network77"+ storageSystem.getNativeId());
        port.setTransportType(StoragePort.TransportType.FC);
        port.setPortNetworkId("6" + Integer.toHexString(index) + ":FE:FE:FE:FE:FE:FE:1" + i);
        port.setOperationalStatus(StoragePort.OperationalStatus.OK);
        port.setPortHAZone("zone-with-many-ports");
        storagePorts.add(port);
    }
    String taskType = "discover-storage-ports";
    String taskId = String.format("%s+%s+%s", DRIVER_NAME, taskType, UUID.randomUUID().toString());
    DriverTask task = new DriverSimulatorTask(taskId);
    task.setStatus(DriverTask.TaskStatus.READY);
    _log.info("StorageDriver: discoverStoragePorts information for storage system {}, nativeId {} - end", storageSystem.getIpAddress(), storageSystem.getNativeId());
    return task;
}
Also used : DriverTask(com.emc.storageos.storagedriver.DriverTask) StoragePort(com.emc.storageos.storagedriver.model.StoragePort) ArrayList(java.util.ArrayList) List(java.util.List)

Example 42 with DriverTask

use of com.emc.storageos.storagedriver.DriverTask in project coprhd-controller by CoprHD.

the class StorageDriverSimulator method deleteConsistencyGroupSnapshot.

@Override
public DriverTask deleteConsistencyGroupSnapshot(List<VolumeSnapshot> snapshots) {
    String taskType = "delete-volume-cg-snapshot";
    String taskId = String.format("%s+%s+%s", DRIVER_NAME, taskType, UUID.randomUUID().toString());
    DriverTask task = new DriverSimulatorTask(taskId);
    task.setStatus(DriverTask.TaskStatus.READY);
    String msg = String.format("StorageDriver: deleteConsistencyGroupSnapshot for storage system %s, " + "snapshot consistencyGroup nativeId %s, group snapshots %s - end", snapshots.get(0).getStorageSystemId(), snapshots.get(0).getConsistencyGroup(), snapshots.toString());
    _log.info(msg);
    task.setMessage(msg);
    return task;
}
Also used : DriverTask(com.emc.storageos.storagedriver.DriverTask)

Example 43 with DriverTask

use of com.emc.storageos.storagedriver.DriverTask in project coprhd-controller by CoprHD.

the class StorageDriverSimulator method deleteConsistencyGroup.

@Override
public DriverTask deleteConsistencyGroup(VolumeConsistencyGroup consistencyGroup) {
    String taskType = "delete-volume-cg";
    String taskId = String.format("%s+%s+%s", DRIVER_NAME, taskType, UUID.randomUUID().toString());
    DriverTask task = new DriverSimulatorTask(taskId);
    task.setStatus(DriverTask.TaskStatus.READY);
    String msg = String.format("StorageDriver: deleteConsistencyGroup information for storage system %s, consistencyGroup nativeId %s - end", consistencyGroup.getStorageSystemId(), consistencyGroup.getNativeId());
    _log.info(msg);
    task.setMessage(msg);
    return task;
}
Also used : DriverTask(com.emc.storageos.storagedriver.DriverTask)

Example 44 with DriverTask

use of com.emc.storageos.storagedriver.DriverTask in project coprhd-controller by CoprHD.

the class StorageDriverSimulator method restoreSnapshot.

@Override
public DriverTask restoreSnapshot(List<VolumeSnapshot> snapshots) {
    RestoreFromSnapshotSimulatorOperation restoreSnapshotSimulatorOperation = new RestoreFromSnapshotSimulatorOperation(snapshots);
    if (simulatorConfig.getSimulateAsynchronousResponses()) {
        DriverTask driverTask = restoreSnapshotSimulatorOperation.getDriverTask();
        taskOperationMap.put(driverTask.getTaskId(), restoreSnapshotSimulatorOperation);
        return driverTask;
    } else if (simulatorConfig.getSimulateFailures()) {
        String failMsg = restoreSnapshotSimulatorOperation.getFailureMessage();
        return restoreSnapshotSimulatorOperation.doFailure(failMsg);
    } else {
        String successMsg = restoreSnapshotSimulatorOperation.getSuccessMessage(snapshots);
        return restoreSnapshotSimulatorOperation.doSuccess(successMsg);
    }
}
Also used : DriverTask(com.emc.storageos.storagedriver.DriverTask) RestoreFromSnapshotSimulatorOperation(com.emc.storageos.driver.driversimulator.operations.RestoreFromSnapshotSimulatorOperation)

Example 45 with DriverTask

use of com.emc.storageos.storagedriver.DriverTask in project coprhd-controller by CoprHD.

the class ExternalDeviceCommunicationInterface method discoverStorageSystem.

private void discoverStorageSystem(DiscoveryDriver driver, AccessProfile accessProfile) throws BaseCollectionException {
    StorageSystem driverStorageSystem = new StorageSystem();
    driverStorageSystem.setIpAddress(accessProfile.getIpAddress());
    driverStorageSystem.setPortNumber(accessProfile.getPortNumber());
    driverStorageSystem.setUsername(accessProfile.getUserName());
    driverStorageSystem.setPassword(accessProfile.getPassword());
    com.emc.storageos.db.client.model.StorageSystem storageSystem = _dbClient.queryObject(com.emc.storageos.db.client.model.StorageSystem.class, accessProfile.getSystemId());
    driverStorageSystem.setSystemName(storageSystem.getLabel());
    driverStorageSystem.setDisplayName(storageSystem.getLabel());
    // could be already populated by scan
    if (storageSystem.getSerialNumber() != null) {
        driverStorageSystem.setSerialNumber(storageSystem.getSerialNumber());
        _log.info("discoverStorageSystem: set serial number to {}", driverStorageSystem.getSerialNumber());
    }
    // could be already populated by scan
    if (storageSystem.getNativeId() != null) {
        driverStorageSystem.setNativeId(storageSystem.getNativeId());
        _log.info("discoverStorageSystem: set nativeId to {}", driverStorageSystem.getNativeId());
    }
    try {
        _log.info("discoverStorageSystem information for storage system {}, name {}, ip address (), port {} - start", accessProfile.getSystemId(), driverStorageSystem.getSystemName(), driverStorageSystem.getIpAddress(), driverStorageSystem.getPortNumber());
        DriverTask task = driver.discoverStorageSystem(driverStorageSystem);
        // todo: need to implement support for async case.
        if (task.getStatus() == DriverTask.TaskStatus.READY) {
            // discovery completed
            storageSystem.setIsDriverManaged(true);
            storageSystem.setSerialNumber(driverStorageSystem.getSerialNumber());
            storageSystem.setNativeId(driverStorageSystem.getNativeId());
            String nativeGuid = NativeGUIDGenerator.generateNativeGuid(accessProfile.getSystemType(), driverStorageSystem.getNativeId());
            storageSystem.setNativeGuid(nativeGuid);
            storageSystem.setFirmwareVersion(driverStorageSystem.getFirmwareVersion());
            if (driverStorageSystem.getSupportedReplications() != null) {
                _log.info("Set async actions...");
                StringSet asyncActions = new StringSet();
                Set<StorageSystem.SupportedReplication> replications = driverStorageSystem.getSupportedReplications();
                for (StorageSystem.SupportedReplication replication : replications) {
                    if (replication == StorageSystem.SupportedReplication.elementReplica) {
                        asyncActions.add(com.emc.storageos.db.client.model.StorageSystem.AsyncActions.CreateElementReplica.name());
                    } else if (replication == StorageSystem.SupportedReplication.groupReplica) {
                        asyncActions.add(com.emc.storageos.db.client.model.StorageSystem.AsyncActions.CreateGroupReplica.name());
                    }
                }
                storageSystem.setSupportedAsynchronousActions(asyncActions);
            }
            if (driverStorageSystem.isSupportedVersion()) {
                storageSystem.setCompatibilityStatus(DiscoveredDataObject.CompatibilityStatus.COMPATIBLE.name());
                storageSystem.setReachableStatus(true);
            } else {
                storageSystem.setCompatibilityStatus(DiscoveredDataObject.CompatibilityStatus.INCOMPATIBLE.name());
                storageSystem.setReachableStatus(false);
                DiscoveryUtils.setSystemResourcesIncompatible(_dbClient, _coordinator, storageSystem.getId());
                String errorMsg = String.format("Storage array %s has firmware version %s which is not supported by driver", storageSystem.getNativeGuid(), storageSystem.getFirmwareVersion());
                throw new ExternalDeviceCollectionException(false, ServiceCode.DISCOVERY_ERROR, null, errorMsg, null, null);
            }
        } else {
            storageSystem.setReachableStatus(false);
            String errorMsg = String.format("Failed to discover storage system %s of type %s. \n" + " Driver task message: %s ", accessProfile.getSystemId(), accessProfile.getSystemType(), task.getMessage());
            throw new ExternalDeviceCollectionException(false, ServiceCode.DISCOVERY_ERROR, null, errorMsg, null, null);
        }
        String message = String.format("Storage array %s with native id %s was discovered successfully.", storageSystem.getId(), storageSystem.getNativeGuid());
        _log.info(message);
        storageSystem.setLastDiscoveryStatusMessage(message);
    } catch (Exception e) {
        if (storageSystem != null) {
            String message = String.format("Failed to discover storage array %s with native id %s : %s .", storageSystem.getId(), storageSystem.getNativeGuid(), e.getMessage());
            storageSystem.setLastDiscoveryStatusMessage(message);
            _log.error(message, e);
        }
        throw e;
    } finally {
        if (storageSystem != null) {
            _dbClient.updateObject(storageSystem);
        }
        _log.info("Discovery of storage system {} of type {} - end", accessProfile.getSystemId(), accessProfile.getSystemType());
    }
}
Also used : BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException) ExternalDeviceCollectionException(com.emc.storageos.volumecontroller.impl.externaldevice.ExternalDeviceCollectionException) DriverTask(com.emc.storageos.storagedriver.DriverTask) StringSet(com.emc.storageos.db.client.model.StringSet) ExternalDeviceCollectionException(com.emc.storageos.volumecontroller.impl.externaldevice.ExternalDeviceCollectionException) StorageSystem(com.emc.storageos.storagedriver.model.StorageSystem)

Aggregations

DriverTask (com.emc.storageos.storagedriver.DriverTask)80 BlockStorageDriver (com.emc.storageos.storagedriver.BlockStorageDriver)26 StorageVolume (com.emc.storageos.storagedriver.model.StorageVolume)26 ArrayList (java.util.ArrayList)26 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)22 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)21 Volume (com.emc.storageos.db.client.model.Volume)15 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)15 IOException (java.io.IOException)15 URI (java.net.URI)15 HashMap (java.util.HashMap)13 DellSCDriverTask (com.emc.storageos.driver.dellsc.DellSCDriverTask)10 BlockConsistencyGroup (com.emc.storageos.db.client.model.BlockConsistencyGroup)9 HashSet (java.util.HashSet)9 VolumeClone (com.emc.storageos.storagedriver.model.VolumeClone)7 VolumeSnapshot (com.emc.storageos.storagedriver.model.VolumeSnapshot)7 BlockObject (com.emc.storageos.db.client.model.BlockObject)6 BlockSnapshot (com.emc.storageos.db.client.model.BlockSnapshot)6 ExportGroup (com.emc.storageos.db.client.model.ExportGroup)6 ExportMask (com.emc.storageos.db.client.model.ExportMask)6