Search in sources :

Example 6 with StorageSystem

use of com.emc.storageos.storagedriver.model.StorageSystem 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)

Example 7 with StorageSystem

use of com.emc.storageos.storagedriver.model.StorageSystem 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());
    }
}
Also used : StringMap(com.emc.storageos.db.client.model.StringMap) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) URI(java.net.URI) DriverTask(com.emc.storageos.storagedriver.DriverTask) Network(com.emc.storageos.db.client.model.Network) ExternalDeviceCollectionException(com.emc.storageos.volumecontroller.impl.externaldevice.ExternalDeviceCollectionException) List(java.util.List) ArrayList(java.util.ArrayList) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) StorageSystem(com.emc.storageos.storagedriver.model.StorageSystem) StoragePort(com.emc.storageos.storagedriver.model.StoragePort) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException) ExternalDeviceCollectionException(com.emc.storageos.volumecontroller.impl.externaldevice.ExternalDeviceCollectionException)

Example 8 with StorageSystem

use of com.emc.storageos.storagedriver.model.StorageSystem 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());
    }
}
Also used : StoragePool(com.emc.storageos.storagedriver.model.StoragePool) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) URI(java.net.URI) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException) ExternalDeviceCollectionException(com.emc.storageos.volumecontroller.impl.externaldevice.ExternalDeviceCollectionException) DriverTask(com.emc.storageos.storagedriver.DriverTask) ExternalDeviceCollectionException(com.emc.storageos.volumecontroller.impl.externaldevice.ExternalDeviceCollectionException) List(java.util.List) ArrayList(java.util.ArrayList) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) Map(java.util.Map) HashMap(java.util.HashMap) StringMap(com.emc.storageos.db.client.model.StringMap) StorageSystem(com.emc.storageos.storagedriver.model.StorageSystem)

Example 9 with StorageSystem

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

the class StorageDriverSimulator method discoverStorageProvider.

@Override
public DriverTask discoverStorageProvider(StorageProvider storageProvider, List<StorageSystem> storageSystems) {
    storageProvider.setIsSupportedVersion(true);
    StorageSystem providerSystem = new StorageSystem();
    providerSystem.setSystemType("providersystem");
    providerSystem.setNativeId("providerSystem-1");
    providerSystem.setSerialNumber("1234567-1");
    providerSystem.setFirmwareVersion("1.2.3");
    storageSystems.add(providerSystem);
    providerSystem = new StorageSystem();
    providerSystem.setSystemType("providersystem");
    providerSystem.setNativeId("providerSystem-2");
    providerSystem.setSerialNumber("1234567-2");
    providerSystem.setFirmwareVersion("1.2.3");
    storageSystems.add(providerSystem);
    providerSystem = new StorageSystem();
    providerSystem.setSystemType("providersystem");
    providerSystem.setNativeId("providerSystem-3");
    providerSystem.setSerialNumber("1234567-3");
    providerSystem.setFirmwareVersion("1.2.3");
    storageSystems.add(providerSystem);
    String taskType = "discover-storage-provider";
    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("Discovered provider: %s, discovered %s storage systems.", storageProvider.getProviderName(), storageSystems.size());
    task.setMessage(msg);
    _log.info(msg);
    return task;
}
Also used : DriverTask(com.emc.storageos.storagedriver.DriverTask) StorageSystem(com.emc.storageos.storagedriver.model.StorageSystem)

Aggregations

StorageSystem (com.emc.storageos.storagedriver.model.StorageSystem)9 DriverTask (com.emc.storageos.storagedriver.DriverTask)5 BaseCollectionException (com.emc.storageos.plugins.BaseCollectionException)4 ExternalDeviceCollectionException (com.emc.storageos.volumecontroller.impl.externaldevice.ExternalDeviceCollectionException)4 ArrayList (java.util.ArrayList)4 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)3 URI (java.net.URI)3 HashMap (java.util.HashMap)3 List (java.util.List)3 StringMap (com.emc.storageos.db.client.model.StringMap)2 HashSet (java.util.HashSet)2 Network (com.emc.storageos.db.client.model.Network)1 StringSet (com.emc.storageos.db.client.model.StringSet)1 UnManagedConsistencyGroup (com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedConsistencyGroup)1 UnManagedVolume (com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume)1 Volume (com.emc.storageos.db.client.model.Volume)1 DellSCDriverException (com.emc.storageos.driver.dellsc.DellSCDriverException)1 DellSCDriverTask (com.emc.storageos.driver.dellsc.DellSCDriverTask)1 StorageCenterAPI (com.emc.storageos.driver.dellsc.scapi.StorageCenterAPI)1 StorageCenterAPIException (com.emc.storageos.driver.dellsc.scapi.StorageCenterAPIException)1