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;
}
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;
}
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;
}
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);
}
}
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());
}
}
Aggregations