Search in sources :

Example 56 with StorageHADomain

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

the class StorageAdapterProcessor method checkStorageAdapterExistsInDB.

/**
 * Check if Adapter exists in DB.
 *
 * @param adapterInstance
 * @return
 * @throws IOException
 */
private StorageHADomain checkStorageAdapterExistsInDB(CIMInstance adapterInstance, StorageSystem device) throws IOException {
    StorageHADomain adapter = null;
    String adapterNativeGuid = NativeGUIDGenerator.generateNativeGuid(device, adapterInstance.getPropertyValue(EMCADAPTERNAME).toString(), NativeGUIDGenerator.ADAPTER);
    @SuppressWarnings("deprecation") List<URI> adapterURIs = _dbClient.queryByConstraint(AlternateIdConstraint.Factory.getStorageHADomainByNativeGuidConstraint(adapterNativeGuid));
    if (!adapterURIs.isEmpty()) {
        adapter = _dbClient.queryObject(StorageHADomain.class, adapterURIs.get(0));
    }
    return adapter;
}
Also used : StorageHADomain(com.emc.storageos.db.client.model.StorageHADomain) URI(java.net.URI)

Example 57 with StorageHADomain

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

the class StorageAdapterProcessor method createStorageAdapter.

/**
 * create StorageAdapter Record, if not present already, else update only the properties.
 *
 * @param adapter
 * @param adapterInstance
 * @throws URISyntaxException
 * @throws IOException
 */
private void createStorageAdapter(StorageHADomain adapter, CIMInstance adapterInstance, AccessProfile profile) throws URISyntaxException, IOException {
    if (null == adapter) {
        adapter = new StorageHADomain();
        adapter.setId(URIUtil.createId(StorageHADomain.class));
        adapter.setStorageDeviceURI(profile.getSystemId());
        adapter.setName(getCIMPropertyValue(adapterInstance, NAME));
        adapter.setAdapterName(getCIMPropertyValue(adapterInstance, EMCADAPTERNAME));
        // Don't change the order of setting this nativeGuid as nativeGuid depends on adapter name.
        adapter.setNativeGuid(NativeGUIDGenerator.generateNativeGuid(_dbClient, adapter));
    }
    adapter.setNumberofPorts(getCIMPropertyValue(adapterInstance, EMCNUMPORTS));
    adapter.setProtocol(getCIMPropertyValue(adapterInstance, EMCPROTOCOL));
    adapter.setSlotNumber(getCIMPropertyValue(adapterInstance, EMCSLOTNUMBER));
    String[] roles = (String[]) adapterInstance.getPropertyValue(ROLES);
    adapter.setAdapterType(HADomainType.getHADomainTypeName(roles[0]));
    _storageAdapterList.add(adapter);
}
Also used : StorageHADomain(com.emc.storageos.db.client.model.StorageHADomain)

Example 58 with StorageHADomain

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

the class StoragePortProcessor method setStorageAdapterReference.

private void setStorageAdapterReference(StoragePort port, CIMInstance portInstance, StorageSystem device) {
    String adapterName = null;
    try {
        adapterName = portInstance.getObjectPath().getKey(SYSTEMNAME).getValue().toString();
        Iterable<String> adapterItr = Splitter.on(Constants.PATH_DELIMITER_PATTERN).limit(3).split(adapterName);
        URIQueryResultList result = new URIQueryResultList();
        _dbClient.queryByConstraint(AlternateIdConstraint.Factory.getStorageHADomainByNativeGuidConstraint(NativeGUIDGenerator.generateNativeGuid(device, Iterables.getLast(adapterItr), NativeGUIDGenerator.ADAPTER)), result);
        if (result.iterator().hasNext()) {
            URI portGroup = result.iterator().next();
            port.setStorageHADomain(portGroup);
            StorageHADomain haDomain = _dbClient.queryObject(StorageHADomain.class, portGroup);
            port.setPortGroup(haDomain.getAdapterName());
        }
    } catch (Exception e) {
        _logger.warn("Storage Port not found : {}", adapterName);
    }
}
Also used : StorageHADomain(com.emc.storageos.db.client.model.StorageHADomain) URI(java.net.URI) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) URISyntaxException(java.net.URISyntaxException) IOException(java.io.IOException) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException)

Example 59 with StorageHADomain

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

the class StoragePortProcessor method processResult.

/**
 * {@inheritDoc}
 */
@SuppressWarnings("unchecked")
@Override
public void processResult(Operation operation, Object resultObj, Map<String, Object> keyMap) throws BaseCollectionException {
    try {
        final Iterator<CIMInstance> it = (Iterator<CIMInstance>) resultObj;
        profile = (AccessProfile) keyMap.get(Constants.ACCESSPROFILE);
        Set<String> protocols = (Set<String>) keyMap.get(Constants.PROTOCOLS);
        _newPortList = new ArrayList<StoragePort>();
        _updatePortList = new ArrayList<StoragePort>();
        _dbClient = (DbClient) keyMap.get(Constants.dbClient);
        CoordinatorClient coordinator = (CoordinatorClient) keyMap.get(Constants.COORDINATOR_CLIENT);
        Map<URI, StoragePool> poolsToMatchWithVpool = (Map<URI, StoragePool>) keyMap.get(Constants.MODIFIED_STORAGEPOOLS);
        Set<URI> systemsToRunRPConnectivity = (HashSet<URI>) keyMap.get(Constants.SYSTEMS_RUN_RP_CONNECTIVITY);
        StorageSystem device = _dbClient.queryObject(StorageSystem.class, profile.getSystemId());
        CIMObjectPath storageAdapterPath = getObjectPathfromCIMArgument(args);
        Iterable<String> adapterItr = Splitter.on(Constants.PATH_DELIMITER_PATTERN).limit(3).split(storageAdapterPath.getKey(Constants.NAME).getValue().toString());
        String adapterNativeGuid = NativeGUIDGenerator.generateNativeGuid(device, Iterables.getLast(adapterItr), NativeGUIDGenerator.ADAPTER);
        StorageHADomain haDomain = getStorageAdapter(_dbClient, adapterNativeGuid);
        if (null == haDomain) {
            _logger.info("Adapter Not found");
            return;
        }
        while (it.hasNext()) {
            CIMInstance portInstance = null;
            StoragePort port = null;
            try {
                portInstance = it.next();
                // skip back end ports other than RDF Ports
                if (!HADomainType.REMOTE.name().equalsIgnoreCase(haDomain.getAdapterType()) && BACKEND_PORT.equalsIgnoreCase(getCIMPropertyValue(portInstance, USAGERESTRICTION))) {
                    continue;
                }
                // 2 - Ethernet Port 4 - FC Port
                if (LINKTECHNOLOGY_ETHERNET.equalsIgnoreCase(getCIMPropertyValue(portInstance, LINKTECHNOLOGY))) {
                    port = createStoragePort(null, portInstance, profile, haDomain, false, IP, device);
                    checkProtocolAlreadyExists(protocols, ISCSI);
                    String deviceId = getCIMPropertyValue(portInstance, DEVICEID);
                    /*
                         * For SMI-S 8.x, While getting the iSCSI Port details, we use SystemName property
                         * (Ex. SYMMETRIX-+-<<SERIAL>>-+-SE-1G-+-0)
                         * Where this call just add the deviceId to the KeyMap (i.e SE-1G-+-0).
                         * Hence manually constructing the key.
                         */
                    if (device.getUsingSmis80()) {
                        String systemName = getCIMPropertyValue(portInstance, SYSTEM_NAME);
                        StringBuffer deviceIdStrBuf = new StringBuffer(systemName);
                        deviceIdStrBuf.append(Constants.SMIS80_DELIMITER).append(deviceId);
                        deviceId = deviceIdStrBuf.toString();
                    }
                    _logger.debug("Adding iSCSI Port instance {} to keyMap", deviceId);
                    keyMap.put(deviceId, port);
                    addPath(keyMap, operation.getResult(), portInstance.getObjectPath());
                } else if (LINKTECHNOLOGY_FC.equalsIgnoreCase(getCIMPropertyValue(portInstance, LINKTECHNOLOGY))) {
                    port = checkStoragePortExistsInDB(portInstance, device, _dbClient);
                    checkProtocolAlreadyExists(protocols, FC);
                    createStoragePort(port, portInstance, profile, haDomain, true, FC, device);
                } else {
                    _logger.debug("Unsupported Port : {}", getCIMPropertyValue(portInstance, DEVICEID));
                }
            } catch (Exception e) {
                _logger.warn("Port Discovery failed for {}", getCIMPropertyValue(portInstance, DEVICEID), e);
            }
        }
        _dbClient.createObject(_newPortList);
        _dbClient.persistObject(_updatePortList);
        // ports used later to run Transport Zone connectivity
        List<List<StoragePort>> portsUsedToRunTZoneConnectivity = (List<List<StoragePort>>) keyMap.get(Constants.STORAGE_PORTS);
        portsUsedToRunTZoneConnectivity.add(_newPortList);
        portsUsedToRunTZoneConnectivity.add(_updatePortList);
        List<StoragePool> modifiedPools = StoragePoolAssociationHelper.getStoragePoolsFromPorts(_dbClient, _newPortList, _updatePortList);
        for (StoragePool pool : modifiedPools) {
            // pool matcher will be invoked on this pool
            if (!poolsToMatchWithVpool.containsKey(pool.getId())) {
                poolsToMatchWithVpool.put(pool.getId(), pool);
            }
        }
        // Systems used to run RP connectivity later after runing pool matcher
        systemsToRunRPConnectivity.addAll(StoragePoolAssociationHelper.getStorageSytemsFromPorts(_newPortList, null));
        systemsToRunRPConnectivity.addAll(StoragePoolAssociationHelper.getStorageSytemsFromPorts(_updatePortList, null));
        // discovered ports used later to check for not visible ports
        List<StoragePort> discoveredPorts = (List<StoragePort>) keyMap.get(Constants.DISCOVERED_PORTS);
        discoveredPorts.addAll(_newPortList);
        discoveredPorts.addAll(_updatePortList);
        _logger.debug("# Pools used in invoking PoolMatcher during StoragePortProcessor {}", Joiner.on("\t").join(poolsToMatchWithVpool.keySet()));
    } catch (Exception e) {
        _logger.error("Port Discovery failed -->{}", getMessage(e));
    } finally {
        _newPortList = null;
        _updatePortList = null;
    }
}
Also used : HashSet(java.util.HashSet) Set(java.util.Set) StoragePool(com.emc.storageos.db.client.model.StoragePool) URI(java.net.URI) CIMInstance(javax.cim.CIMInstance) Iterator(java.util.Iterator) CoordinatorClient(com.emc.storageos.coordinator.client.service.CoordinatorClient) ArrayList(java.util.ArrayList) List(java.util.List) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) StorageHADomain(com.emc.storageos.db.client.model.StorageHADomain) HashSet(java.util.HashSet) StorageSystem(com.emc.storageos.db.client.model.StorageSystem) StoragePort(com.emc.storageos.db.client.model.StoragePort) CIMObjectPath(javax.cim.CIMObjectPath) URISyntaxException(java.net.URISyntaxException) IOException(java.io.IOException) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException) Map(java.util.Map)

Example 60 with StorageHADomain

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

the class XIVStoragePortProcessor method getStorageAdapter.

/**
 * Returns StorageAdapter instance. Create one, if not present already
 *
 * @param name adapter (module) name
 * @param device StorageSystem
 * @return instance of StorageHADomain
 * @throws URISyntaxException
 * @throws IOException
 */
private StorageHADomain getStorageAdapter(String name, StorageSystem device) throws URISyntaxException, IOException {
    StorageHADomain adapter = null;
    String nativeGuid = NativeGUIDGenerator.generateNativeGuid(device, name, NativeGUIDGenerator.ADAPTER);
    @SuppressWarnings("deprecation") List<URI> adapterURIs = _dbClient.queryByConstraint(AlternateIdConstraint.Factory.getStorageHADomainByNativeGuidConstraint(nativeGuid));
    if (!adapterURIs.isEmpty()) {
        adapter = _dbClient.queryObject(StorageHADomain.class, adapterURIs.get(0));
    }
    if (adapter == null) {
        adapter = new StorageHADomain();
        adapter.setId(URIUtil.createId(StorageHADomain.class));
        adapter.setStorageDeviceURI(device.getId());
        adapter.setName(name);
        adapter.setAdapterName(name);
        adapter.setNativeGuid(nativeGuid);
        adapter.setAdapterType(HADomainType.FRONTEND.name());
        adapter.setVirtual(true);
        // note serial number and number of ports is not set
        // 3 is "mixed", to be consistent with EMC provider
        adapter.setProtocol("3");
        // slot number is used in port selection
        // e.g., name="1:Module:6", 6 is the module
        adapter.setSlotNumber(name.split(Pattern.quote(Constants.COLON))[2]);
        _dbClient.createObject(adapter);
    }
    return adapter;
}
Also used : StorageHADomain(com.emc.storageos.db.client.model.StorageHADomain) URI(java.net.URI)

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