Search in sources :

Example 76 with StorageHADomain

use of com.emc.storageos.db.client.model.StorageHADomain in project coprhd-controller by CoprHD.

the class NetAppFileCommunicationInterface method discoverPortGroups.

private HashMap<String, List<StorageHADomain>> discoverPortGroups(StorageSystem system, List<VFilerInfo> virtualFilers) throws NetAppFileCollectionException {
    HashMap<String, List<StorageHADomain>> portGroups = new HashMap<String, List<StorageHADomain>>();
    List<StorageHADomain> newPortGroups = new ArrayList<StorageHADomain>();
    List<StorageHADomain> existingPortGroups = new ArrayList<StorageHADomain>();
    _logger.info("Start port group discovery (vfilers) for storage system {}", system.getId());
    NetAppApi netAppApi = new NetAppApi.Builder(system.getIpAddress(), system.getPortNumber(), system.getUsername(), system.getPassword()).https(true).build();
    StorageHADomain portGroup = null;
    List<VFilerInfo> vFilers = netAppApi.listVFilers(null);
    if (null == vFilers || vFilers.isEmpty()) {
        // Check if default port group was previously created.
        URIQueryResultList results = new URIQueryResultList();
        String adapterNativeGuid = NativeGUIDGenerator.generateNativeGuid(system, DEFAULT_FILER, NativeGUIDGenerator.ADAPTER);
        _dbClient.queryByConstraint(AlternateIdConstraint.Factory.getStorageHADomainByNativeGuidConstraint(adapterNativeGuid), results);
        if (results.iterator().hasNext()) {
            StorageHADomain tmpGroup = _dbClient.queryObject(StorageHADomain.class, results.iterator().next());
            if (tmpGroup.getStorageDeviceURI().equals(system.getId())) {
                portGroup = tmpGroup;
                _logger.debug("Found existing port group {} ", tmpGroup.getName());
            }
        }
        if (portGroup == null) {
            portGroup = new StorageHADomain();
            portGroup.setId(URIUtil.createId(StorageHADomain.class));
            portGroup.setName("NetApp");
            portGroup.setVirtual(false);
            portGroup.setNativeGuid(adapterNativeGuid);
            portGroup.setStorageDeviceURI(system.getId());
            StringSet protocols = new StringSet();
            protocols.add(StorageProtocol.File.NFS.name());
            protocols.add(StorageProtocol.File.CIFS.name());
            portGroup.setFileSharingProtocols(protocols);
            newPortGroups.add(portGroup);
        } else {
            existingPortGroups.add(portGroup);
        }
    } else {
        _logger.debug("Number vFilers fouund: {}", vFilers.size());
        virtualFilers.addAll(vFilers);
        StringSet protocols = new StringSet();
        protocols.add(StorageProtocol.File.NFS.name());
        protocols.add(StorageProtocol.File.CIFS.name());
        for (VFilerInfo vf : vFilers) {
            _logger.debug("vFiler name: {}", vf.getName());
            // Check if port group was previously discovered
            URIQueryResultList results = new URIQueryResultList();
            String adapterNativeGuid = NativeGUIDGenerator.generateNativeGuid(system, vf.getName(), NativeGUIDGenerator.ADAPTER);
            _dbClient.queryByConstraint(AlternateIdConstraint.Factory.getStorageHADomainByNativeGuidConstraint(adapterNativeGuid), results);
            portGroup = null;
            if (results.iterator().hasNext()) {
                StorageHADomain tmpGroup = _dbClient.queryObject(StorageHADomain.class, results.iterator().next());
                if (tmpGroup.getStorageDeviceURI().equals(system.getId())) {
                    portGroup = tmpGroup;
                    _logger.debug("Found duplicate {} ", vf.getName());
                }
            }
            if (portGroup == null) {
                portGroup = new StorageHADomain();
                portGroup.setId(URIUtil.createId(StorageHADomain.class));
                portGroup.setName(vf.getName());
                portGroup.setVirtual(true);
                portGroup.setAdapterType(StorageHADomain.HADomainType.VIRTUAL.toString());
                portGroup.setNativeGuid(adapterNativeGuid);
                portGroup.setStorageDeviceURI(system.getId());
                portGroup.setFileSharingProtocols(protocols);
                newPortGroups.add(portGroup);
            } else {
                existingPortGroups.add(portGroup);
            }
        }
    }
    portGroups.put(NEW, newPortGroups);
    portGroups.put(EXISTING, existingPortGroups);
    return portGroups;
}
Also used : ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) VFilerInfo(com.iwave.ext.netapp.VFilerInfo) StringSet(com.emc.storageos.db.client.model.StringSet) List(java.util.List) ArrayList(java.util.ArrayList) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) NetAppApi(com.emc.storageos.netapp.NetAppApi) StorageHADomain(com.emc.storageos.db.client.model.StorageHADomain)

Example 77 with StorageHADomain

use of com.emc.storageos.db.client.model.StorageHADomain in project coprhd-controller by CoprHD.

the class VPlexMeteringTest method testVPlexPerpetualCSVFileCollector.

@Test
public void testVPlexPerpetualCSVFileCollector() throws InstantiationException, IllegalAccessException {
    MockDbClient mockDbClient = new MockDbClient();
    mockStorageDriverManager();
    StorageSystem storageSystem = mockStorageSystem("vplex-1", "000123ABC000XYZ");
    mockDbClient.MOCK_DB.put(storageSystem.getId(), storageSystem);
    int directorIndex = 1;
    String[] directors = DIRECTORS.split(",");
    for (String directorName : directors) {
        int adapterIndex = (directorIndex % 2);
        String aOrB = directorName.substring(directorName.length() - 1);
        String adapterSerial = String.format("CF23K00000%d%d", directorIndex, adapterIndex);
        StorageHADomain director = mockVPlexAdapter(storageSystem, directorName, adapterSerial);
        mockDbClient.MOCK_DB.put(director.getId(), director);
        for (int cpuIndex = 0; cpuIndex < 2; cpuIndex++) {
            for (int portIndex = 0; portIndex < PORT_PER_DIRECTOR; portIndex++) {
                String portName = String.format("%s%d-FC%02d", aOrB, cpuIndex, portIndex);
                String wwn = String.format("5C:CC:DD:EE:FF:00:%02d:%02d", directorIndex, portIndex);
                StoragePort port = mockStoragePort(director, portName, wwn, adapterSerial);
                mockDbClient.MOCK_DB.put(port.getId(), port);
            }
        }
        directorIndex++;
    }
    AccessProfile accessProfile = new AccessProfile();
    accessProfile.setIpAddress(HOST);
    accessProfile.setUserName(USERNAME);
    accessProfile.setPassword(PASSWORD);
    accessProfile.setSystemId(storageSystem.getId());
    Map<String, Object> context = new HashMap<>();
    context.put(Constants.dbClient, mockDbClient);
    context.put(Constants._Stats, new LinkedList<Stat>());
    context.put(Constants._TimeCollected, System.currentTimeMillis());
    VPlexPerpetualCSVFileCollector collector = new VPlexPerpetualCSVFileCollector();
    PortMetricsProcessor portMetricsProcessor = mockPortMetricsProcessor(mockDbClient);
    collector.setPortMetricsProcessor(portMetricsProcessor);
    collector.collect(accessProfile, context);
}
Also used : HashMap(java.util.HashMap) StoragePort(com.emc.storageos.db.client.model.StoragePort) AccessProfile(com.emc.storageos.plugins.AccessProfile) Constraint(com.emc.storageos.db.client.constraint.Constraint) Stat(com.emc.storageos.db.client.model.Stat) PortMetricsProcessor(com.emc.storageos.volumecontroller.impl.plugins.metering.smis.processor.PortMetricsProcessor) DataObject(com.emc.storageos.db.client.model.DataObject) DiscoveredDataObject(com.emc.storageos.db.client.model.DiscoveredDataObject) StorageHADomain(com.emc.storageos.db.client.model.StorageHADomain) VPlexPerpetualCSVFileCollector(com.emc.storageos.volumecontroller.impl.plugins.metering.vplex.VPlexPerpetualCSVFileCollector) StorageSystem(com.emc.storageos.db.client.model.StorageSystem) Test(org.junit.Test)

Example 78 with StorageHADomain

use of com.emc.storageos.db.client.model.StorageHADomain in project coprhd-controller by CoprHD.

the class VNXUnityFileStorageDeviceTest method setPort.

public void setPort(List<StorageHADomain> haDomainUri) {
    VNXeApiClient apiclient = _unity.getVnxUnityClient(_device);
    StorageHADomain haDomainTemp = null;
    List<VNXeFileInterface> ports = apiclient.getFileInterfaces();
    VNXeFileInterface port = ports.get(0);
    String portNativeGuid = NativeGUIDGenerator.generateNativeGuid(_device, _device.getIpAddress(), NativeGUIDGenerator.PORT);
    _port.setId(URIUtil.createId(StoragePort.class));
    _port.setLabel(portNativeGuid);
    _port.setTransportType("IP");
    _port.setNativeGuid(portNativeGuid);
    _port.setStorageDevice(_device.getId());
    _port.setRegistrationStatus(RegistrationStatus.REGISTERED.toString());
    _port.setPortName(_device.getSystemType());
    _port.setPortNetworkId(_device.getIpAddress());
    _port.setPortGroup(port.getNasServer().getId());
    for (StorageHADomain hadomain : haDomainUri) {
        if (port.getId().equalsIgnoreCase(hadomain.getSerialNumber())) {
            haDomainTemp = hadomain;
            break;
        }
    }
    _port.setStorageHADomain(haDomainTemp.getId());
    _dbClient.updateObject(haDomainTemp);
    _dbClient.updateObject(_port);
}
Also used : VNXeFileInterface(com.emc.storageos.vnxe.models.VNXeFileInterface) VNXeApiClient(com.emc.storageos.vnxe.VNXeApiClient) StoragePort(com.emc.storageos.db.client.model.StoragePort) StorageHADomain(com.emc.storageos.db.client.model.StorageHADomain)

Example 79 with StorageHADomain

use of com.emc.storageos.db.client.model.StorageHADomain in project coprhd-controller by CoprHD.

the class PortAllocatorTestContext method addPort.

/**
 * Add simulated ports to a Port Allocation Context.
 *
 * @param port -- StoragePort object
 * @param switchName -- Switch name
 */
@Override
public void addPort(StoragePort port, StorageHADomain haDomain, StorageSystem.Type arrayType, String switchName, Long usage) {
    port.setRegistrationStatus(RegistrationStatus.REGISTERED.name());
    port.setNetwork(this._initiatorNetwork.getId());
    String portName = port.getPortName();
    String portGroup = port.getPortGroup();
    haDomain = new StorageHADomain();
    StorageSystem.Type type = StorageSystem.Type.vnxblock;
    if (port.getPortName().startsWith("FA-")) {
        haDomain.setNativeGuid("SYMMETRIX+" + portName);
    } else if (portGroup != null && portGroup.startsWith("director-")) {
        haDomain.setNativeGuid("VPLEX+" + port.getPortGroup());
    } else if (portGroup.startsWith("X")) {
        haDomain.setNativeGuid("XTREMIO+" + port.getPortGroup());
    } else {
        haDomain.setNativeGuid("VNX+" + portName);
    }
    if (portName.startsWith("SP_A")) {
        haDomain.setSlotNumber("1");
    } else if (portName.startsWith("SP_B")) {
        haDomain.setSlotNumber("2");
    } else if (portName.startsWith("SP_C")) {
        haDomain.setSlotNumber("3");
    } else if (portName.startsWith("SP_D")) {
        haDomain.setSlotNumber("4");
    } else if (portName.startsWith("FA-")) {
        type = StorageSystem.Type.vmax;
        int index;
        for (index = 3; index < portName.length(); index++) {
            // Stop on first non-digit after FA-
            if (Character.isDigit(portName.charAt(index)) == false) {
                break;
            }
        }
        haDomain.setSlotNumber(portName.substring(3, index));
    } else if (portName.startsWith("X")) {
        haDomain.setAdapterName(portGroup);
        type = StorageSystem.Type.xtremio;
    } else {
        haDomain.setSlotNumber("0");
    }
    if (portGroup != null) {
        if (portGroup.equals("director-1-1-A")) {
            haDomain.setSlotNumber("0");
            type = StorageSystem.Type.vplex;
        } else if (portGroup.equals("director-1-1-B")) {
            haDomain.setSlotNumber("1");
            type = StorageSystem.Type.vplex;
        } else if (portGroup.equals("director-1-2-A")) {
            haDomain.setSlotNumber("2");
            type = StorageSystem.Type.vplex;
        } else if (portGroup.equals("director-1-2-B")) {
            haDomain.setSlotNumber("3");
            type = StorageSystem.Type.vplex;
        } else if (portGroup.equals("director-2-1-A")) {
            haDomain.setSlotNumber("8");
            type = StorageSystem.Type.vplex;
        } else if (portGroup.equals("director-2-1-B")) {
            haDomain.setSlotNumber("9");
            type = StorageSystem.Type.vplex;
        } else if (portGroup.equals("director-2-2-A")) {
            haDomain.setSlotNumber("10");
            type = StorageSystem.Type.vplex;
        } else if (portGroup.equals("director-2-2-B")) {
            haDomain.setSlotNumber("11");
            type = StorageSystem.Type.vplex;
        }
        haDomain.setName(portGroup);
    }
    Random random = new Random();
    usage = (long) random.nextInt(10);
    super.addPort(port, haDomain, type, switchName, usage);
}
Also used : Random(java.util.Random) StorageHADomain(com.emc.storageos.db.client.model.StorageHADomain) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 80 with StorageHADomain

use of com.emc.storageos.db.client.model.StorageHADomain in project coprhd-controller by CoprHD.

the class StoragePortsAllocatorTest method addPort.

/**
 * Add ports to a Port Allocation Context.
 *
 * @param context -- PortAllocationContext used by StoragePortsAllocator
 * @param port -- StoragePort object
 * @param switchName -- Switch name
 */
public static void addPort(PortAllocationContext context, StoragePort port, String switchName) {
    port.setRegistrationStatus(RegistrationStatus.REGISTERED.name());
    port.setNetwork(context._initiatorNetwork.getId());
    String portName = port.getPortName();
    String portGroup = port.getPortGroup();
    StorageHADomain haDomain = new StorageHADomain();
    StorageSystem.Type type = StorageSystem.Type.vnxblock;
    if (port.getPortName().startsWith("FA-")) {
        haDomain.setNativeGuid("SYMMETRIX+" + portName);
    } else if (portGroup != null && portGroup.startsWith("director-")) {
        haDomain.setNativeGuid("VPLEX+" + port.getPortGroup());
    } else if (portGroup.startsWith("X")) {
        haDomain.setNativeGuid("XTREMIO+" + port.getPortGroup());
    } else {
        haDomain.setNativeGuid("VNX+" + portName);
    }
    if (portName.startsWith("SP_A")) {
        haDomain.setSlotNumber("1");
    } else if (portName.startsWith("SP_B")) {
        haDomain.setSlotNumber("2");
    } else if (portName.startsWith("SP_C")) {
        haDomain.setSlotNumber("3");
    } else if (portName.startsWith("SP_D")) {
        haDomain.setSlotNumber("4");
    } else if (portName.startsWith("FA-")) {
        type = StorageSystem.Type.vmax;
        int index;
        for (index = 3; index < portName.length(); index++) {
            // Stop on first non-digit after FA-
            if (Character.isDigit(portName.charAt(index)) == false) {
                break;
            }
        }
        haDomain.setSlotNumber(portName.substring(3, index));
    } else if (portName.startsWith("X")) {
        haDomain.setAdapterName(portGroup);
        type = StorageSystem.Type.xtremio;
    } else {
        haDomain.setSlotNumber("0");
    }
    if (portGroup != null) {
        if (portGroup.equals("director-1-1-A")) {
            haDomain.setSlotNumber("0");
            type = StorageSystem.Type.vplex;
        } else if (portGroup.equals("director-1-1-B")) {
            haDomain.setSlotNumber("1");
            type = StorageSystem.Type.vplex;
        } else if (portGroup.equals("director-1-2-A")) {
            haDomain.setSlotNumber("2");
            type = StorageSystem.Type.vplex;
        } else if (portGroup.equals("director-1-2-B")) {
            haDomain.setSlotNumber("3");
            type = StorageSystem.Type.vplex;
        } else if (portGroup.equals("director-2-1-A")) {
            haDomain.setSlotNumber("8");
            type = StorageSystem.Type.vplex;
        } else if (portGroup.equals("director-2-1-B")) {
            haDomain.setSlotNumber("9");
            type = StorageSystem.Type.vplex;
        } else if (portGroup.equals("director-2-2-A")) {
            haDomain.setSlotNumber("10");
            type = StorageSystem.Type.vplex;
        } else if (portGroup.equals("director-2-2-B")) {
            haDomain.setSlotNumber("11");
            type = StorageSystem.Type.vplex;
        }
        haDomain.setName(portGroup);
    }
    String digits = port.getPortName().replaceAll("[^0-9]", "");
    Long usage = new Long(digits);
    context.addPort(port, haDomain, type, switchName, usage);
}
Also used : StorageHADomain(com.emc.storageos.db.client.model.StorageHADomain) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Aggregations

StorageHADomain (com.emc.storageos.db.client.model.StorageHADomain)80 URI (java.net.URI)41 StoragePort (com.emc.storageos.db.client.model.StoragePort)35 ArrayList (java.util.ArrayList)33 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)26 HashMap (java.util.HashMap)22 List (java.util.List)20 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)19 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)18 StringSet (com.emc.storageos.db.client.model.StringSet)17 VNXException (com.emc.storageos.vnx.xmlapi.VNXException)12 BaseCollectionException (com.emc.storageos.plugins.BaseCollectionException)11 NamespaceList (com.emc.storageos.plugins.common.domainmodel.NamespaceList)11 URISyntaxException (java.net.URISyntaxException)11 LinkedList (java.util.LinkedList)10 IOException (java.io.IOException)9 AlternateIdConstraint (com.emc.storageos.db.client.constraint.AlternateIdConstraint)8 XMLApiResult (com.emc.storageos.vnx.xmlapi.XMLApiResult)8 HashSet (java.util.HashSet)8 Map (java.util.Map)7