use of com.emc.storageos.driver.dellsc.DellSCDriverTask in project coprhd-controller by CoprHD.
the class DellSCDiscovery method discoverStorageSystem.
/**
* Discover storage systems and their capabilities.
*
* @param storageSystem Storage system to discover.
* @return The discovery task.
*/
public DriverTask discoverStorageSystem(StorageSystem storageSystem) {
DriverTask task = new DellSCDriverTask("discover");
try {
LOG.info("Getting information for storage system [{}] - {}", storageSystem.getIpAddress(), storageSystem.getSystemName());
String sn = storageSystem.getSerialNumber();
if (sn == null || sn.length() == 0) {
// Directly added system, no SSN yet so we use the name field
sn = storageSystem.getSystemName();
// name with provider_name+serial_number
if (sn.contains("+")) {
String[] parts = sn.split("\\+");
sn = parts[1];
}
}
int port = storageSystem.getPortNumber();
if (port == 0) {
port = 3033;
}
StorageCenterAPI api = connectionManager.getConnection(storageSystem.getIpAddress(), port, storageSystem.getUsername(), storageSystem.getPassword(), false);
// Populate the SC information
StorageCenter sc = api.findStorageCenter(sn);
util.getStorageSystemFromStorageCenter(api, sc, storageSystem);
storageSystem.setSystemType(driverName);
task.setStatus(DriverTask.TaskStatus.READY);
} catch (Exception e) {
String msg = String.format("Exception encountered getting storage system information: %s", e);
LOG.error(msg);
task.setMessage(msg);
task.setStatus(DriverTask.TaskStatus.FAILED);
}
return task;
}
use of com.emc.storageos.driver.dellsc.DellSCDriverTask in project coprhd-controller by CoprHD.
the class DellSCDiscovery method discoverStorageProvider.
/**
* Perform discovery for a storage provider.
*
* @param storageProvider The provider.
* @param storageSystems The storage systems collection to populate.
* @return The driver task.
*/
public DriverTask discoverStorageProvider(StorageProvider storageProvider, List<StorageSystem> storageSystems) {
DellSCDriverTask task = new DellSCDriverTask("discover");
try {
LOG.info("Getting information for storage provider [{}:{}] as user {}", storageProvider.getProviderHost(), storageProvider.getPortNumber(), storageProvider.getUsername());
StorageCenterAPI api = connectionManager.getConnection(storageProvider.getProviderHost(), storageProvider.getPortNumber(), storageProvider.getUsername(), storageProvider.getPassword(), true);
LOG.info("Connected to DSM {} as user {}", storageProvider.getProviderHost(), storageProvider.getUsername());
// Populate the provider information
storageProvider.setAccessStatus(AccessStatus.READ_WRITE);
storageProvider.setManufacturer("Dell");
storageProvider.setProviderVersion(driverVersion);
storageProvider.setIsSupportedVersion(true);
// Get some info about the DSM for debugging purposes
EmDataCollector em = api.getDSMInfo();
if (em != null) {
LOG.info("Connected to {} DSM version {}, Java version {}", em.type, em.version, em.javaVersion);
storageProvider.setProviderVersion(em.version);
}
// Populate the basic SC information
StorageCenter[] scs = api.getStorageCenterInfo();
for (StorageCenter sc : scs) {
StorageSystem storageSystem = util.getStorageSystemFromStorageCenter(api, sc, null);
storageSystem.setSystemType(driverName);
storageSystems.add(storageSystem);
}
task.setStatus(DriverTask.TaskStatus.READY);
} catch (Exception e) {
String msg = String.format("Exception encountered getting storage provider information: %s", e);
LOG.error(msg);
task.setFailed(msg);
}
return task;
}
use of com.emc.storageos.driver.dellsc.DellSCDriverTask in project coprhd-controller by CoprHD.
the class DellSCDiscovery method discoverStoragePorts.
/**
* Discover storage ports and their capabilities.
*
* @param storageSystem The storage system on which to discover.
* @param storagePorts The storage ports.
* @return The discovery task.
*/
public DriverTask discoverStoragePorts(StorageSystem storageSystem, List<StoragePort> storagePorts) {
LOG.info("Discovering storage ports for [{}] {} {}", storageSystem.getSystemName(), storageSystem.getIpAddress(), storageSystem.getNativeId());
DellSCDriverTask task = new DellSCDriverTask("discoverStoragePorts");
try {
String ssn = storageSystem.getNativeId();
StorageCenterAPI api = connectionManager.getConnection(ssn);
Map<String, List<ScControllerPort>> ports = getPortList(api, ssn);
for (Entry<String, List<ScControllerPort>> entry : ports.entrySet()) {
for (ScControllerPort scPort : entry.getValue()) {
StoragePort port = util.getStoragePortForControllerPort(api, scPort, entry.getKey());
LOG.info("Discovered Port {}, storageSystem {}", scPort.instanceId, scPort.scSerialNumber);
storagePorts.add(port);
}
}
task.setStatus(DriverTask.TaskStatus.READY);
} catch (Exception e) {
String failureMessage = String.format("Error getting port information: %s", e);
task.setFailed(failureMessage);
LOG.warn(failureMessage);
}
return task;
}
use of com.emc.storageos.driver.dellsc.DellSCDriverTask 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.driver.dellsc.DellSCDriverTask in project coprhd-controller by CoprHD.
the class DellSCProvisioning method unexportVolumesFromInitiators.
/**
* Remove volume exports to initiators.
*
* @param initiators The initiators to remove from.
* @param volumes The volumes to remove.
* @return The unexport task.
*/
public DriverTask unexportVolumesFromInitiators(List<Initiator> initiators, List<StorageVolume> volumes) {
LOG.info("Unexporting volumes from initiators");
DriverTask task = new DellSCDriverTask("unexportVolumes");
ScServer server = null;
StringBuilder errBuffer = new StringBuilder();
int volumesUnmapped = 0;
for (StorageVolume volume : volumes) {
String ssn = volume.getStorageSystemId();
boolean isSnapshot = StringUtils.countMatches(volume.getNativeId(), ".") == 2;
try {
StorageCenterAPI api = connectionManager.getConnection(ssn);
// Find our actual volume
ScVolume scVol = null;
if (isSnapshot) {
scVol = api.findReplayView(volume.getNativeId());
// For snapshot views we can just delete the view
if (scVol != null) {
api.deleteVolume(scVol.instanceId);
volumesUnmapped++;
continue;
}
} else {
scVol = api.getVolume(volume.getNativeId());
}
if (scVol == null) {
throw new DellSCDriverException(String.format("Unable to find volume %s", volume.getNativeId()));
}
// Look up the server if needed
if (server == null) {
server = findScServer(api, ssn, initiators);
}
if (server == null) {
// Unable to find the server, can't continue
throw new DellSCDriverException(SERVER_CREATE_FAIL_MSG);
}
ScMappingProfile[] mappingProfiles = api.findMappingProfiles(server.instanceId, scVol.instanceId);
for (ScMappingProfile mappingProfile : mappingProfiles) {
api.deleteMappingProfile(mappingProfile.instanceId);
}
volumesUnmapped++;
LOG.info("Volume '{}' unexported from server '{}'", scVol.name, server.name);
} catch (StorageCenterAPIException | DellSCDriverException dex) {
String error = String.format("Error unmapping volume %s: %s", volume.getDisplayName(), dex);
LOG.error(error);
errBuffer.append(String.format("%s%n", error));
if (SERVER_CREATE_FAIL_MSG.equals(dex.getMessage())) {
// Game over
break;
}
}
}
task.setMessage(errBuffer.toString());
if (volumesUnmapped == volumes.size()) {
task.setStatus(TaskStatus.READY);
} else if (volumesUnmapped == 0) {
task.setStatus(TaskStatus.FAILED);
} else {
task.setStatus(TaskStatus.PARTIALLY_FAILED);
}
return task;
}
Aggregations