use of com.emc.storageos.storagedriver.model.StorageVolume in project coprhd-controller by CoprHD.
the class DellSCProvisioning method createVolumes.
/**
* Create storage volumes with a given set of capabilities.
* Before completion of the request, set all required data for provisioned
* volumes in "volumes" parameter.
*
* @param volumes Input/output argument for volumes.
* @param storageCapabilities Input argument for capabilities. Defines
* storage capabilities of volumes to create.
* @return The volume creation task.
*/
public DriverTask createVolumes(List<StorageVolume> volumes, StorageCapabilities storageCapabilities) {
DriverTask task = new DellSCDriverTask("createVolume");
StringBuilder errBuffer = new StringBuilder();
int volumesCreated = 0;
for (StorageVolume volume : volumes) {
LOG.debug("Creating volume {} on system {}", volume.getDisplayName(), volume.getStorageSystemId());
String ssn = volume.getStorageSystemId();
try {
StorageCenterAPI api = connectionManager.getConnection(ssn);
ScVolume scVol = api.createVolume(ssn, volume.getDisplayName(), volume.getStoragePoolId(), SizeUtil.byteToMeg(volume.getRequestedCapacity()), volume.getConsistencyGroup());
volume.setProvisionedCapacity(SizeUtil.sizeStrToBytes(scVol.configuredSize));
// New volumes don't allocate any space
volume.setAllocatedCapacity(0L);
volume.setWwn(scVol.deviceId);
volume.setNativeId(scVol.instanceId);
volume.setDeviceLabel(scVol.name);
volume.setAccessStatus(AccessStatus.READ_WRITE);
volumesCreated++;
LOG.info("Created volume '{}'", scVol.name);
} catch (StorageCenterAPIException | DellSCDriverException dex) {
String error = String.format("Error creating volume %s: %s", volume.getDisplayName(), dex);
LOG.error(error);
errBuffer.append(String.format("%s%n", error));
}
}
task.setMessage(errBuffer.toString());
if (volumesCreated == volumes.size()) {
task.setStatus(TaskStatus.READY);
} else if (volumesCreated == 0) {
task.setStatus(TaskStatus.FAILED);
} else {
task.setStatus(TaskStatus.PARTIALLY_FAILED);
}
return task;
}
use of com.emc.storageos.storagedriver.model.StorageVolume in project coprhd-controller by CoprHD.
the class StorageDriverSimulator method getStorageObject.
@Override
public <T extends StorageObject> T getStorageObject(String storageSystemId, String objectId, Class<T> type) {
if (StorageVolume.class.getSimpleName().equals(type.getSimpleName())) {
StorageVolume obj = new StorageVolume();
obj.setAllocatedCapacity(200L);
_log.info("getStorageObject: storage volume allocated capacity: {}", obj.getAllocatedCapacity());
return (T) obj;
} else if (VolumeConsistencyGroup.class.getSimpleName().equals(type.getSimpleName())) {
VolumeConsistencyGroup cg = new VolumeConsistencyGroup();
cg.setStorageSystemId(storageSystemId);
cg.setNativeId(objectId);
cg.setDeviceLabel(objectId);
_log.info("Return volume cg {} from array {}", objectId, storageSystemId);
return (T) cg;
} else if (StoragePool.class.getSimpleName().equals(type.getSimpleName())) {
StoragePool pool = new StoragePool();
// 40 GB
pool.setFreeCapacity(40000000L);
// 10 GB
pool.setSubscribedCapacity(10000000L);
pool.setNativeId(objectId);
pool.setStorageSystemId(storageSystemId);
_log.info("getStorageObject: storage pool free capacity: {}, subscribed capacity: {}", pool.getFreeCapacity(), pool.getSubscribedCapacity());
return (T) pool;
} else {
_log.error("getStorageObject: not supported for type: {}", type.getSimpleName());
return null;
}
}
use of com.emc.storageos.storagedriver.model.StorageVolume in project coprhd-controller by CoprHD.
the class StorageDriverSimulator method getStorageVolumes.
@Override
public DriverTask getStorageVolumes(StorageSystem storageSystem, List<StorageVolume> storageVolumes, MutableInt token) {
// all volumes on the same page belong to the same consistency group
if (token.intValue() == 0) {
arrayToVolumeToVolumeExportInfoMap.clear();
}
List<StoragePort> ports = new ArrayList<>();
discoverStoragePorts(storageSystem, ports);
for (int vol = 0; vol < NUMBER_OF_VOLUMES_ON_PAGE; vol++) {
StorageVolume driverVolume = new StorageVolume();
driverVolume.setStorageSystemId(storageSystem.getNativeId());
driverVolume.setStoragePoolId("pool-1234577-" + token.intValue() + storageSystem.getNativeId());
driverVolume.setNativeId("driverSimulatorVolume-1234567-" + token.intValue() + "-" + vol);
if (VOLUMES_IN_CG) {
driverVolume.setConsistencyGroup("driverSimulatorCG-" + token.intValue());
}
driverVolume.setAccessStatus(StorageVolume.AccessStatus.READ_WRITE);
driverVolume.setThinlyProvisioned(true);
driverVolume.setThinVolumePreAllocationSize(3000L);
driverVolume.setProvisionedCapacity(3 * 1024 * 1024 * 1024L);
driverVolume.setAllocatedCapacity(50000L);
driverVolume.setDeviceLabel(driverVolume.getNativeId());
driverVolume.setWwn(String.format("%s%s", driverVolume.getStorageSystemId(), driverVolume.getNativeId()));
storageVolumes.add(driverVolume);
_log.info("Unmanaged volume info: pool {}, volume {}", driverVolume.getStoragePoolId(), driverVolume);
if (GENERATE_EXPORT_DATA) {
// get host for this page
for (String hostName : pageToHostMap.get(token.intValue())) {
_log.info("Process host {}", hostName);
generateExportDataForVolume(hostName, driverVolume.getStorageSystemId(), driverVolume.getNativeId(), vol, ports, token.intValue());
}
}
}
String taskType = "create-storage-volumes";
String taskId = String.format("%s+%s+%s", DRIVER_NAME, taskType, UUID.randomUUID().toString());
DriverTask task = new DriverSimulatorTask(taskId);
task.setStatus(DriverTask.TaskStatus.READY);
task.setMessage("Get storage volumes: page " + token);
_log.info("StorageDriver: get storage volumes information for storage system {}, token {} - end", storageSystem.getNativeId(), token);
// set next value
if (token.intValue() < NUMBER_OF_VOLUME_PAGES - 1) {
// each page has different consistency group
token.setValue(token.intValue() + 1);
// token.setValue(0); // last page
} else {
// last page
token.setValue(0);
}
return task;
}
use of com.emc.storageos.storagedriver.model.StorageVolume in project coprhd-controller by CoprHD.
the class StorageDriverSimulator method createVolumes.
@Override
public DriverTask createVolumes(List<StorageVolume> volumes, StorageCapabilities capabilities) {
// String newVolumes = "";
Set<String> newVolumes = new HashSet<>();
for (StorageVolume volume : volumes) {
volume.setNativeId("driverSimulatorVolume" + UUID.randomUUID().toString());
volume.setAccessStatus(StorageVolume.AccessStatus.READ_WRITE);
volume.setProvisionedCapacity(volume.getRequestedCapacity());
volume.setAllocatedCapacity(volume.getRequestedCapacity());
volume.setDeviceLabel(volume.getNativeId());
volume.setWwn(String.format("%s%s", volume.getStorageSystemId(), volume.getNativeId()));
// newVolumes = newVolumes + volume.getNativeId() + " ";
newVolumes.add(volume.getNativeId());
}
String taskType = "create-storage-volumes";
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: createVolumes information for storage system %s, volume nativeIds %s - end", volumes.get(0).getStorageSystemId(), newVolumes.toString());
_log.info(msg);
task.setMessage(msg);
return task;
}
use of com.emc.storageos.storagedriver.model.StorageVolume in project coprhd-controller by CoprHD.
the class ExternalDeviceExportOperations method removeInitiators.
@Override
public void removeInitiators(StorageSystem storage, URI exportMaskUri, List<URI> volumeURIList, List<com.emc.storageos.db.client.model.Initiator> initiatorList, List<URI> targetURIList, TaskCompleter taskCompleter) throws DeviceControllerException {
log.info("{} removeInitiators START...", storage.getSerialNumber());
try {
log.info("removeInitiators: Export mask id: {}", exportMaskUri);
if (volumeURIList != null) {
log.info("removeInitiators: volumes : {}", Joiner.on(',').join(volumeURIList));
}
log.info("removeInitiators: initiators : {}", Joiner.on(',').join(initiatorList));
log.info("removeInitiators: targets : {}", Joiner.on(',').join(targetURIList));
BlockStorageDriver driver = externalDevice.getDriver(storage.getSystemType());
ExportMask exportMask = (ExportMask) dbClient.queryObject(exportMaskUri);
List<URI> volumeUris = ExportMaskUtils.getVolumeURIs(exportMask);
log.info("Export mask existing volumes: {} ", volumeUris);
// Prepare volumes
List<StorageVolume> driverVolumes = new ArrayList<>();
prepareVolumes(storage, volumeUris, driverVolumes);
// Prepare initiators
List<Initiator> driverInitiators = new ArrayList<>();
// Get export group uri from task completer
URI exportGroupUri = taskCompleter.getId();
ExportGroup exportGroup = (ExportGroup) dbClient.queryObject(exportGroupUri);
prepareInitiators(initiatorList, exportGroup.forCluster(), driverInitiators);
// Ready to call driver
DriverTask task = driver.unexportVolumesFromInitiators(driverInitiators, driverVolumes);
// todo: need to implement support for async case.
if (task.getStatus() == DriverTask.TaskStatus.READY) {
String msg = String.format("Removed initiators from export mask: %s.", task.getMessage());
log.info(msg);
taskCompleter.ready(dbClient);
} else {
String errorMsg = String.format("Failed to remove initiators from export mask: %s .", task.getMessage());
log.error(errorMsg);
ServiceError serviceError = ExternalDeviceException.errors.removeInitiatorsFromExportMaskFailed("removeInitiators", errorMsg);
taskCompleter.error(dbClient, serviceError);
}
} catch (Exception ex) {
log.error("Problem in removeInitiators: ", ex);
String errorMsg = String.format("Failed to remove initiators from export mask: %s .", ex.getMessage());
log.error(errorMsg);
ServiceError serviceError = ExternalDeviceException.errors.removeInitiatorsFromExportMaskFailed("removeInitiators", errorMsg);
taskCompleter.error(dbClient, serviceError);
}
log.info("{} removeInitiators END...", storage.getSerialNumber());
}
Aggregations