use of com.emc.storageos.storagedriver.DriverTask in project coprhd-controller by CoprHD.
the class ExternalBlockStorageDevice method doCreateConsistencyGroup.
@Override
public void doCreateConsistencyGroup(StorageSystem storageSystem, URI consistencyGroup, String replicationGroupName, TaskCompleter taskCompleter) throws DeviceControllerException {
_log.info("Creating consistency group for volumes START.....");
BlockConsistencyGroup cg = null;
try {
VolumeConsistencyGroup driverCG = new VolumeConsistencyGroup();
cg = dbClient.queryObject(BlockConsistencyGroup.class, consistencyGroup);
driverCG.setDisplayName(cg.getLabel());
driverCG.setStorageSystemId(storageSystem.getNativeId());
// call driver
BlockStorageDriver driver = getDriver(storageSystem.getSystemType());
DriverTask task = driver.createConsistencyGroup(driverCG);
// todo: need to implement support for async case.
if (task.getStatus() == DriverTask.TaskStatus.READY) {
cg.setNativeId(driverCG.getNativeId());
cg.addSystemConsistencyGroup(storageSystem.getId().toString(), cg.getLabel());
cg.addConsistencyGroupTypes(BlockConsistencyGroup.Types.LOCAL.name());
if (NullColumnValueGetter.isNullURI(cg.getStorageController())) {
cg.setStorageController(storageSystem.getId());
}
dbClient.updateObject(cg);
String msg = String.format("doCreateConsistencyGroup -- Created consistency group: %s .", task.getMessage());
_log.info(msg);
taskCompleter.ready(dbClient);
} else {
cg.setInactive(true);
dbClient.updateObject(cg);
String errorMsg = String.format("doCreateConsistencyGroup -- Failed to create Consistency Group: %s .", task.getMessage());
_log.error(errorMsg);
ServiceError serviceError = ExternalDeviceException.errors.createConsistencyGroupFailed("doCreateConsistencyGroup", errorMsg);
taskCompleter.error(dbClient, serviceError);
}
} catch (Exception e) {
if (cg != null) {
cg.setInactive(true);
dbClient.updateObject(cg);
}
String errorMsg = String.format("doCreateConsistencyGroup -- Failed to create Consistency Group: %s .", e.getMessage());
_log.error(errorMsg, e);
ServiceError serviceError = ExternalDeviceException.errors.createConsistencyGroupFailed("doCreateConsistencyGroup", errorMsg);
taskCompleter.error(dbClient, serviceError);
} finally {
_log.info("Creating consistency group for volumes END.....");
}
}
use of com.emc.storageos.storagedriver.DriverTask in project coprhd-controller by CoprHD.
the class ExternalBlockStorageDevice method doDisconnect.
@Override
public void doDisconnect(StorageSystem storageSystem) {
try {
_log.info("doDisconnect {} - start", storageSystem.getId());
com.emc.storageos.storagedriver.model.StorageSystem driverStorageSystem = ExternalDeviceCommunicationInterface.initStorageSystem(storageSystem);
BlockStorageDriver driver = getDriver(storageSystem.getSystemType());
DriverTask task = driver.stopManagement(driverStorageSystem);
if (task.getStatus() == DriverTask.TaskStatus.READY) {
_log.info("doDisconnect -- Disconnected Storage System: {}", task.getMessage());
} else {
_log.error("doDisconnect failed. ", task.getMessage());
throw ExternalDeviceException.exceptions.doDisconnectFailed("doDisconnect", task.getMessage());
}
_log.info("doDisconnect %1$s - Complete", storageSystem.getId());
} catch (Exception e) {
_log.error("doDisconnect failed. ", e.getMessage());
throw ExternalDeviceException.exceptions.doDisconnectFailed("doDisconnect", e.getMessage());
}
}
use of com.emc.storageos.storagedriver.DriverTask in project coprhd-controller by CoprHD.
the class ExternalDeviceCommunicationInterface method discoverStoragePools.
private List<com.emc.storageos.db.client.model.StoragePool> discoverStoragePools(DiscoveryDriver driver, AccessProfile accessProfile) throws BaseCollectionException {
// Discover storage pools and associated auto tiering policies.
List<StoragePool> driverStoragePools = new ArrayList<>();
List<com.emc.storageos.db.client.model.StoragePool> allPools = new ArrayList<>();
List<com.emc.storageos.db.client.model.StoragePool> newPools = new ArrayList<>();
List<com.emc.storageos.db.client.model.StoragePool> existingPools = new ArrayList<>();
Map<String, List<com.emc.storageos.db.client.model.StoragePool>> autoTieringPolicyPoolMap = new HashMap<>();
Map<String, Map<String, List<String>>> autoTieringPolicyPropertiesMap = new HashMap<>();
com.emc.storageos.db.client.model.StorageSystem storageSystem = _dbClient.queryObject(com.emc.storageos.db.client.model.StorageSystem.class, accessProfile.getSystemId());
URI storageSystemId = storageSystem.getId();
StorageSystem driverStorageSystem = initStorageSystem(storageSystem);
try {
_log.info("discoverPools for storage system {} - start", storageSystemId);
DriverTask task = driver.discoverStoragePools(driverStorageSystem, driverStoragePools);
// todo: need to implement support for async case.
if (task.getStatus() == DriverTask.TaskStatus.READY) {
// discovery completed
for (StoragePool storagePool : driverStoragePools) {
com.emc.storageos.db.client.model.StoragePool pool;
// Check if this storage pool was already discovered
String poolNativeGuid = NativeGUIDGenerator.generateNativeGuid(storageSystem, storagePool.getNativeId(), NativeGUIDGenerator.POOL);
List<com.emc.storageos.db.client.model.StoragePool> pools = queryActiveResourcesByAltId(_dbClient, com.emc.storageos.db.client.model.StoragePool.class, "nativeGuid", poolNativeGuid);
if (pools.isEmpty()) {
_log.info("Pool {} is new, native GUID {}", storagePool.getNativeId(), poolNativeGuid);
pool = new com.emc.storageos.db.client.model.StoragePool();
pool.setId(URIUtil.createId(com.emc.storageos.db.client.model.StoragePool.class));
pool.setIsDriverManaged(true);
pool.setStorageDevice(accessProfile.getSystemId());
pool.setNativeId(storagePool.getNativeId());
pool.setNativeGuid(poolNativeGuid);
pool.setPoolName(storagePool.getPoolName());
pool.addProtocols(storagePool.getProtocols());
pool.setPoolServiceType(storagePool.getPoolServiceType());
pool.setCompatibilityStatus(storageSystem.getCompatibilityStatus());
if (storagePool.getMaximumThickVolumeSize() != null) {
pool.setMaximumThickVolumeSize(storagePool.getMaximumThickVolumeSize());
} else {
pool.setMaximumThickVolumeSize(Long.MAX_VALUE);
}
if (storagePool.getMinimumThickVolumeSize() != null) {
pool.setMinimumThickVolumeSize(storagePool.getMinimumThickVolumeSize());
} else {
pool.setMinimumThickVolumeSize(0L);
}
if (storagePool.getMaximumThinVolumeSize() != null) {
pool.setMaximumThinVolumeSize(storagePool.getMaximumThinVolumeSize());
} else {
pool.setMaximumThinVolumeSize(Long.MAX_VALUE);
}
if (storagePool.getMinimumThinVolumeSize() != null) {
pool.setMinimumThinVolumeSize(storagePool.getMinimumThinVolumeSize());
} else {
pool.setMinimumThinVolumeSize(0L);
}
pool.setSupportedResourceTypes(storagePool.getSupportedResourceType());
pool.setInactive(false);
newPools.add(pool);
} else if (pools.size() == 1) {
_log.info("Pool {} was previously discovered, native GUID {}", storagePool.getNativeId(), poolNativeGuid);
pool = pools.get(0);
existingPools.add(pool);
} else {
_log.warn(String.format("There are %d StoragePools with nativeGuid = %s", pools.size(), poolNativeGuid));
continue;
}
// applicable to new and existing storage pools
pool.setSubscribedCapacity(storagePool.getSubscribedCapacity());
pool.setFreeCapacity(storagePool.getFreeCapacity());
pool.setTotalCapacity(storagePool.getTotalCapacity());
pool.setOperationalStatus(storagePool.getOperationalStatus());
pool.addDriveTypes(storagePool.getSupportedDriveTypes());
pool.addSupportedRaidLevels(storagePool.getSupportedRaidLevels());
pool.setDiscoveryStatus(DiscoveredDataObject.DiscoveryStatus.VISIBLE.name());
// Discover the auto tiering policies supported by the storage pool.
discoverAutoTieringPoliciesForStoragePool(driverStorageSystem, storagePool, pool, autoTieringPolicyPoolMap, autoTieringPolicyPropertiesMap);
// Discover deduplication capability for storage pool.
discoverDeduplicationCapabilityForStoragePool(driverStorageSystem, storagePool, pool);
}
// Now that all storage pools have been process we can create or update
// as necessary the auto tiering policy instances in the controller.
createOrUpdateAutoTierPolicies(storageSystem, autoTieringPolicyPoolMap, autoTieringPolicyPropertiesMap);
_log.info("No of newly discovered pools {}", newPools.size());
_log.info("No of existing discovered pools {}", existingPools.size());
_dbClient.createObject(newPools);
_dbClient.updateObject(existingPools);
allPools.addAll(newPools);
allPools.addAll(existingPools);
} else {
String errorMsg = String.format("Failed to discover storage pools for system %s of type %s . \n" + " Driver task message: %s", accessProfile.getSystemId(), accessProfile.getSystemType(), task.getMessage());
storageSystem.setLastDiscoveryStatusMessage(errorMsg);
throw new ExternalDeviceCollectionException(false, ServiceCode.DISCOVERY_ERROR, null, errorMsg, null, null);
}
String message = String.format("Storage pools of storage array %s with native id %s were discovered successfully.", storageSystem.getId(), storageSystem.getNativeGuid());
_log.info(message);
return allPools;
} catch (Exception e) {
String message = String.format("Failed to discover storage pools of storage array %s with native id %s : %s .", storageSystem.getId(), storageSystem.getNativeGuid(), e.getMessage());
_log.error(message, e);
storageSystem.setLastDiscoveryStatusMessage(message);
throw e;
} finally {
_dbClient.updateObject(storageSystem);
_log.info("Discovery of storage pools of storage system {} of type {} - end", accessProfile.getSystemId(), accessProfile.getSystemType());
}
}
use of com.emc.storageos.storagedriver.DriverTask in project coprhd-controller by CoprHD.
the class ExternalDeviceCommunicationInterface method discoverStoragePorts.
private Map<String, List<com.emc.storageos.db.client.model.StoragePort>> discoverStoragePorts(DiscoveryDriver driver, Set<Network> networksToUpdate, AccessProfile accessProfile) throws BaseCollectionException {
URI storageSystemId = accessProfile.getSystemId();
com.emc.storageos.db.client.model.StorageSystem storageSystem = _dbClient.queryObject(com.emc.storageos.db.client.model.StorageSystem.class, storageSystemId);
Map<String, List<com.emc.storageos.db.client.model.StoragePort>> storagePorts = new HashMap<>();
Map<StoragePort, com.emc.storageos.db.client.model.StoragePort> driverPortsToDBPorts = new HashMap<>();
List<com.emc.storageos.db.client.model.StoragePort> newStoragePorts = new ArrayList<>();
List<com.emc.storageos.db.client.model.StoragePort> existingStoragePorts = new ArrayList<>();
List<String> endpoints = new ArrayList<>();
StorageSystem driverStorageSystem = initStorageSystem(storageSystem);
// Discover storage ports
try {
_log.info("discoverPorts for storage system {} - start", storageSystemId);
List<StoragePort> driverStoragePorts = new ArrayList<>();
// Call driver.
DriverTask task = driver.discoverStoragePorts(driverStorageSystem, driverStoragePorts);
// todo: need to implement support for async case.
if (task.getStatus() == DriverTask.TaskStatus.READY) {
for (StoragePort driverPort : driverStoragePorts) {
com.emc.storageos.db.client.model.StoragePort storagePort = null;
String portNativeGuid = NativeGUIDGenerator.generateNativeGuid(storageSystem, driverPort.getNativeId(), NativeGUIDGenerator.PORT);
// Check if storage port was already discovered
@SuppressWarnings("deprecation") List<URI> portURIs = _dbClient.queryByConstraint(AlternateIdConstraint.Factory.getStoragePortByNativeGuidConstraint(portNativeGuid));
for (URI portUri : portURIs) {
com.emc.storageos.db.client.model.StoragePort port = _dbClient.queryObject(com.emc.storageos.db.client.model.StoragePort.class, portUri);
if (port.getStorageDevice().equals(storageSystemId) && !port.getInactive()) {
storagePort = port;
break;
}
}
// Verify that discovered port has mandatory identifier "portNetworkId"
if (driverPort.getPortNetworkId() == null) {
if (storagePort == null) {
_log.error("No portNetworkId for new discovered port {}, skip discovery of this port.", portNativeGuid);
} else {
_log.error("No portNetworkId for previously discovered port {}, skip discovery of this port.", portNativeGuid);
}
continue;
}
if (storagePort == null) {
// New port processing
storagePort = new com.emc.storageos.db.client.model.StoragePort();
prepareNewPort(storagePort, driverPort);
storagePort.setNativeGuid(portNativeGuid);
storagePort.setStorageDevice(storageSystemId);
if (driverPort.getNetworkId() != null) {
// Get or create Network object for this port
Network portNetwork = getNetworkForStoragePort(driverPort);
storagePort.setNetwork(portNetwork.getId());
// Add endpoint to the network.
// Process this for all ports (existing port got a network or changed network cases)
// TODO: should we check if existing port was in other network and delete the endpoint from the old network?
portNetwork.addEndpoints(new ArrayList<>(Arrays.asList(driverPort.getPortNetworkId())), true);
networksToUpdate.add(portNetwork);
}
storagePort.setTcpPortNumber(driverPort.getTcpPortNumber());
storagePort.setRegistrationStatus(DiscoveredDataObject.RegistrationStatus.REGISTERED.toString());
_log.info("Creating new storage port using NativeGuid : {}", portNativeGuid);
newStoragePorts.add(storagePort);
} else {
existingStoragePorts.add(storagePort);
}
storagePort.setPortNetworkId(driverPort.getPortNetworkId());
if (driverPort.getTransportType() != null && driverPort.getTransportType().equalsIgnoreCase(StoragePort.TransportType.IP.toString())) {
storagePort.setIpAddress(driverPort.getIpAddress());
}
storagePort.setDiscoveryStatus(DiscoveredDataObject.DiscoveryStatus.VISIBLE.name());
storagePort.setCompatibilityStatus(DiscoveredDataObject.CompatibilityStatus.COMPATIBLE.name());
storagePort.setOperationalStatus(driverPort.getOperationalStatus());
storagePort.setAvgBandwidth(driverPort.getAvgBandwidth());
storagePort.setPortSpeed(driverPort.getPortSpeed());
// Set usage metric for the port
if (driverPort.getUtilizationMetric() != null) {
StringMap usageMetrics = storagePort.getMetrics();
MetricsKeys.putDouble(MetricsKeys.portMetric, driverPort.getUtilizationMetric(), usageMetrics);
storagePort.setMetrics(usageMetrics);
}
driverPortsToDBPorts.put(driverPort, storagePort);
}
storagePorts.put(NEW, newStoragePorts);
storagePorts.put(EXISTING, existingStoragePorts);
// Create storage ha domains for ports
processStorageHADomains(storageSystem, Collections.unmodifiableMap(driverPortsToDBPorts));
} else {
String errorMsg = String.format("Failed to discover storage ports for 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 ports of storage array %s with native id %s were discovered successfully.", storageSystem.getId(), storageSystem.getNativeGuid());
_log.info(message);
return storagePorts;
} catch (Exception e) {
String message = String.format("Failed to discover storage ports of storage array %s with native id %s : %s .", storageSystem.getId(), storageSystem.getNativeGuid(), e.getMessage());
_log.error(message, e);
storageSystem.setLastDiscoveryStatusMessage(message);
throw e;
} finally {
_dbClient.updateObject(storageSystem);
_log.info("Discovery of storage ports of storage system {} of type {} - end", accessProfile.getSystemId(), accessProfile.getSystemType());
}
}
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