Search in sources :

Example 6 with StoragePort

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

the class DellSCUtil method getStoragePortForControllerPort.

/**
 * Gets a StoragePort object for an ScControllerPort.
 *
 * @param api The API connection.
 * @param scPort The ScControllerPort.
 * @param haZone The fault domain name.
 * @return The StoragePort.
 */
public StoragePort getStoragePortForControllerPort(StorageCenterAPI api, ScControllerPort scPort, String haZone) {
    StoragePort port = new StoragePort();
    port.setNativeId(scPort.instanceId);
    port.setStorageSystemId(scPort.scSerialNumber);
    // Get the port configuration
    port.setPortHAZone(getHaZone(api, scPort, haZone));
    if (ScControllerPort.FC_TRANSPORT_TYPE.equals(scPort.transportType)) {
        setFCPortInfo(api, scPort, port);
    } else if (ScControllerPort.ISCSI_TRANSPORT_TYPE.equals(scPort.transportType)) {
        setISCSIPortInfo(api, scPort, port);
    }
    StoragePort.OperationalStatus status = StoragePort.OperationalStatus.OK;
    if (!ScControllerPort.PORT_STATUS_UP.equals(scPort.status)) {
        status = StoragePort.OperationalStatus.NOT_OK;
    }
    port.setOperationalStatus(status);
    port.setPortName(port.getDeviceLabel());
    port.setEndPointID(port.getPortNetworkId());
    port.setAccessStatus(AccessStatus.READ_WRITE);
    return port;
}
Also used : StoragePort(com.emc.storageos.storagedriver.model.StoragePort)

Example 7 with StoragePort

use of com.emc.storageos.storagedriver.model.StoragePort 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;
}
Also used : ScControllerPort(com.emc.storageos.driver.dellsc.scapi.objects.ScControllerPort) StorageCenterAPI(com.emc.storageos.driver.dellsc.scapi.StorageCenterAPI) DellSCDriverTask(com.emc.storageos.driver.dellsc.DellSCDriverTask) StoragePort(com.emc.storageos.storagedriver.model.StoragePort) ArrayList(java.util.ArrayList) List(java.util.List) DellSCDriverException(com.emc.storageos.driver.dellsc.DellSCDriverException) StorageCenterAPIException(com.emc.storageos.driver.dellsc.scapi.StorageCenterAPIException)

Example 8 with StoragePort

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

the class DellSCProvisioning method populateVolumeExportInfo.

/**
 * Fills in export information for a specific volume mapping.
 *
 * @param volumeId The volume instance ID.
 * @param map The mapping.
 * @param result The export info map.
 * @param serverCache The server cache.
 * @param serverPortCache The server HBA cache.
 * @param portCache The controller port cache.
 * @throws StorageCenterAPIException
 */
private void populateVolumeExportInfo(StorageCenterAPI api, String volumeId, ScMapping map, Map<String, HostExportInfo> result, Map<String, ScServer> serverCache, Map<String, Initiator> serverPortCache, Map<String, StoragePort> portCache) throws StorageCenterAPIException {
    ScServer server;
    Initiator initiator;
    StoragePort port;
    // Get our server info
    if (serverCache.containsKey(map.server.instanceId)) {
        server = serverCache.get(map.server.instanceId);
    } else {
        server = api.getServerDefinition(map.server.instanceId);
        serverCache.put(server.instanceId, server);
    }
    // Find the server HBA
    if (serverPortCache.containsKey(map.serverHba.instanceId)) {
        initiator = serverPortCache.get(map.serverHba.instanceId);
    } else {
        ScServerHba hba = api.getServerHba(map.serverHba.instanceId);
        initiator = getInitiatorInfo(api, server, hba);
        serverPortCache.put(hba.instanceId, initiator);
    }
    // Get the controller port info
    if (portCache.containsKey(map.controllerPort.instanceId)) {
        port = portCache.get(map.controllerPort.instanceId);
    } else {
        ScControllerPort scPort = api.getControllerPort(map.controllerPort.instanceId);
        port = util.getStoragePortForControllerPort(api, scPort);
        portCache.put(scPort.instanceId, port);
    }
    String hostName = initiator.getHostName();
    if (initiator.getInitiatorType() == Type.Cluster) {
        hostName = initiator.getClusterName();
    }
    HostExportInfo exportInfo;
    if (result.containsKey(hostName)) {
        exportInfo = result.get(hostName);
    } else {
        exportInfo = new HostExportInfo(hostName, new ArrayList<>(), new ArrayList<>(), new ArrayList<>());
    }
    // Now populate all the info
    if (!exportInfo.getStorageObjectNativeIds().contains(volumeId)) {
        exportInfo.getStorageObjectNativeIds().add(volumeId);
    }
    if (!exportInfo.getTargets().contains(port)) {
        exportInfo.getTargets().add(port);
    }
    if (!exportInfo.getInitiators().contains(initiator)) {
        exportInfo.getInitiators().add(initiator);
    }
    result.put(hostName, exportInfo);
}
Also used : ScControllerPort(com.emc.storageos.driver.dellsc.scapi.objects.ScControllerPort) ScServer(com.emc.storageos.driver.dellsc.scapi.objects.ScServer) Initiator(com.emc.storageos.storagedriver.model.Initiator) StoragePort(com.emc.storageos.storagedriver.model.StoragePort) ArrayList(java.util.ArrayList) HostExportInfo(com.emc.storageos.storagedriver.HostExportInfo) ScServerHba(com.emc.storageos.driver.dellsc.scapi.objects.ScServerHba)

Example 9 with StoragePort

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

the class DellSCProvisioning method getVolumeExportInfo.

/**
 * Gets the mapping information for a volume to initiators.
 *
 * @param volumeId The volume instance ID.
 * @param systemId The storage system ID.
 * @return The mapping details. Map of HostName:HostExportInfo
 */
public Map<String, HostExportInfo> getVolumeExportInfo(String volumeId, String systemId) {
    Map<String, HostExportInfo> result = new HashMap<>();
    Map<String, ScServer> serverCache = new HashMap<>();
    Map<String, Initiator> serverPortCache = new HashMap<>();
    Map<String, StoragePort> portCache = new HashMap<>();
    try {
        StorageCenterAPI api = connectionManager.getConnection(systemId);
        ScVolume scVol = api.getVolume(volumeId);
        if (scVol == null) {
            throw new DellSCDriverException(String.format("Volume %s could not be found.", volumeId));
        }
        ScMapping[] maps = api.getVolumeMaps(scVol.instanceId);
        for (ScMapping map : maps) {
            populateVolumeExportInfo(api, volumeId, map, result, serverCache, serverPortCache, portCache);
        }
    } catch (StorageCenterAPIException | DellSCDriverException dex) {
        String message = String.format("Error getting export info for volume %s: %s", volumeId, dex);
        LOG.warn(message);
    }
    return result;
}
Also used : StorageCenterAPI(com.emc.storageos.driver.dellsc.scapi.StorageCenterAPI) ScServer(com.emc.storageos.driver.dellsc.scapi.objects.ScServer) HashMap(java.util.HashMap) StorageCenterAPIException(com.emc.storageos.driver.dellsc.scapi.StorageCenterAPIException) StoragePort(com.emc.storageos.storagedriver.model.StoragePort) HostExportInfo(com.emc.storageos.storagedriver.HostExportInfo) ScVolume(com.emc.storageos.driver.dellsc.scapi.objects.ScVolume) DellSCDriverException(com.emc.storageos.driver.dellsc.DellSCDriverException) Initiator(com.emc.storageos.storagedriver.model.Initiator) ScMapping(com.emc.storageos.driver.dellsc.scapi.objects.ScMapping)

Example 10 with StoragePort

use of com.emc.storageos.storagedriver.model.StoragePort 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;
}
Also used : DriverTask(com.emc.storageos.storagedriver.DriverTask) StorageVolume(com.emc.storageos.storagedriver.model.StorageVolume) StoragePort(com.emc.storageos.storagedriver.model.StoragePort) ArrayList(java.util.ArrayList)

Aggregations

StoragePort (com.emc.storageos.storagedriver.model.StoragePort)23 ArrayList (java.util.ArrayList)15 Initiator (com.emc.storageos.storagedriver.model.Initiator)12 HashMap (java.util.HashMap)10 URI (java.net.URI)8 List (java.util.List)8 HostExportInfo (com.emc.storageos.storagedriver.HostExportInfo)7 HashSet (java.util.HashSet)7 DriverTask (com.emc.storageos.storagedriver.DriverTask)6 StorageVolume (com.emc.storageos.storagedriver.model.StorageVolume)6 ExportGroup (com.emc.storageos.db.client.model.ExportGroup)4 ExportMask (com.emc.storageos.db.client.model.ExportMask)4 StringSet (com.emc.storageos.db.client.model.StringSet)4 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)3 ExportPathParams (com.emc.storageos.db.client.model.ExportPathParams)3 DellSCDriverException (com.emc.storageos.driver.dellsc.DellSCDriverException)3 StorageCenterAPI (com.emc.storageos.driver.dellsc.scapi.StorageCenterAPI)3 StorageCenterAPIException (com.emc.storageos.driver.dellsc.scapi.StorageCenterAPIException)3 ScControllerPort (com.emc.storageos.driver.dellsc.scapi.objects.ScControllerPort)3 ScServer (com.emc.storageos.driver.dellsc.scapi.objects.ScServer)3