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;
}
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);
}
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);
}
}
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;
}
}
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;
}
Aggregations