use of com.emc.storageos.db.client.model.StoragePort in project coprhd-controller by CoprHD.
the class CinderStoragePortOperations method filterPortsByType.
private List<StoragePort> filterPortsByType(String transportType) {
List<StoragePort> filteredList = new ArrayList<StoragePort>();
List<StoragePort> allPorts = getStoragePortList(false);
for (StoragePort port : allPorts) {
if (transportType.equals(port.getTransportType())) {
filteredList.add(port);
}
}
return filteredList;
}
use of com.emc.storageos.db.client.model.StoragePort in project coprhd-controller by CoprHD.
the class CinderStoragePortOperations method getStoragePortList.
/**
* Gets list of active ports belonging to a storage system.
*
* @return
*/
private List<StoragePort> getStoragePortList(boolean isRefresh) {
logger.debug("Start getStoragePortList");
if (null == allStoragePortsList || isRefresh) {
allStoragePortsList = new ArrayList<StoragePort>();
URIQueryResultList storagePortURIs = new URIQueryResultList();
URI sysid = storageSystem.getId();
dbClient.queryByConstraint(ContainmentConstraint.Factory.getStorageDeviceStoragePortConstraint(sysid), storagePortURIs);
Iterator<URI> storagePortsIter = storagePortURIs.iterator();
while (storagePortsIter.hasNext()) {
URI storagePortURI = storagePortsIter.next();
StoragePort storagePort = dbClient.queryObject(StoragePort.class, storagePortURI);
if (storagePort != null && !storagePort.getInactive()) {
allStoragePortsList.add(storagePort);
}
}
}
logger.debug("End getStoragePortList");
return allStoragePortsList;
}
use of com.emc.storageos.db.client.model.StoragePort in project coprhd-controller by CoprHD.
the class ExportMaskAddInitiatorCompleter method updateDatabase.
/**
* Update the export mask and export group with the initiators are ports
*
* @param dbClient
* dbclient
* @param uris
* uris of Initiators and storage ports
*/
private void updateDatabase(DbClient dbClient, Collection<URI> uris) {
List<URI> targetURIs = _targetURIs;
List<URI> initiatorURIs = _initiatorURIs;
// initiators that appear in the context.
if (uris != null && !uris.isEmpty()) {
targetURIs = URIUtil.getURIsofType(uris, Initiator.class);
initiatorURIs = URIUtil.getURIsofType(uris, StoragePort.class);
}
ExportGroup exportGroup = dbClient.queryObject(ExportGroup.class, getId());
ExportMask exportMask = (getMask() != null) ? dbClient.queryObject(ExportMask.class, getMask()) : null;
if (exportMask != null) {
// Update the initiator tracking containers
exportMask.addToUserCreatedInitiators(dbClient.queryObject(Initiator.class, initiatorURIs));
// Save the initiators to the ExportMask
for (URI initiatorURI : initiatorURIs) {
Initiator initiator = dbClient.queryObject(Initiator.class, initiatorURI);
if (initiator != null) {
exportMask.removeFromExistingInitiators(initiator);
exportMask.addInitiator(initiator);
exportGroup.addInitiator(initiator);
} else {
_log.warn("Initiator {} does not exist.", initiatorURI);
}
}
// Save the target StoragePort URIs to the ExportMask
for (URI newTarget : targetURIs) {
exportMask.addTarget(newTarget);
}
dbClient.updateObject(exportMask);
}
ExportUtils.reconcileExportGroupsHLUs(dbClient, exportGroup);
dbClient.updateObject(exportGroup);
}
use of com.emc.storageos.db.client.model.StoragePort in project coprhd-controller by CoprHD.
the class VPlexBackEndOrchestratorUtil method allocatePorts.
public static List<StoragePort> allocatePorts(StoragePortsAllocator allocator, List<StoragePort> candidatePorts, int portsRequested, NetworkLite net, URI varrayURI, boolean simulation, BlockStorageScheduler blockScheduler, DbClient dbClient, Map<String, Integer> switchToPortNumber, PortAllocationContext context) {
Collections.shuffle(candidatePorts);
if (simulation) {
if (context == null) {
context = StoragePortsAllocator.getPortAllocationContext(net, "arrayX", allocator.getContext());
for (StoragePort port : candidatePorts) {
context.addPort(port, null, null, null, null);
}
}
List<StoragePort> portsAllocated = allocator.allocatePortsForNetwork(portsRequested, context, false, null, false, switchToPortNumber);
allocator.setContext(context);
return portsAllocated;
} else {
Map<StoragePort, Long> sportMap = blockScheduler.computeStoragePortUsage(candidatePorts);
List<StoragePort> portsAllocated = allocator.selectStoragePorts(dbClient, sportMap, net, varrayURI, portsRequested, null, false, switchToPortNumber);
return portsAllocated;
}
}
use of com.emc.storageos.db.client.model.StoragePort in project coprhd-controller by CoprHD.
the class VPlexBackEndOrchestratorUtil method validateExportMask.
/**
* Validates that an ExportMask can be used.
* There are comments for each rule that is validated below.
*
* @param varrayURI the varray URI
* @param initiatorPortMap map of Network to Vplex StoragePort list
* @param mask the ExportMask to validate
* @param invalidMasks a set of known invalidMask URIs
* @param directorToInitiatorIds a map of directors to initiator port strings
* @param idToInitiatorMap a map of initiator ports to Initiator objects
* @param dbClient a reference to the database client
* @param coordinator the system coordinator client
* @param portWwnToClusterMap a map of port wwns to VPLEX cluster
* @param errorMessages an error message builder
* @return true if the given ExportMask can be used
*/
public static boolean validateExportMask(URI varrayURI, Map<URI, List<StoragePort>> initiatorPortMap, ExportMask mask, Set<URI> invalidMasks, Map<String, Set<String>> directorToInitiatorIds, Map<String, Initiator> idToInitiatorMap, DbClient dbClient, CoordinatorClient coordinator, Map<String, String> portWwnToClusterMap, StringBuilder errorMessages) {
boolean passed = true;
Integer directorMinPortCount = Integer.valueOf(ControllerUtils.getPropertyValueFromCoordinator(coordinator, DIRECTOR_MIN_PORT_COUNT_SETTING));
// This is a warning if the ExportMask is non-ViPR.
for (String director : directorToInitiatorIds.keySet()) {
int portsInDirector = 0;
for (String initiatorId : directorToInitiatorIds.get(director)) {
Initiator initiator = idToInitiatorMap.get(initiatorId);
String initiatorPortWwn = Initiator.normalizePort(initiator.getInitiatorPort());
if (mask.hasExistingInitiator(initiatorPortWwn)) {
portsInDirector++;
} else if (mask.hasUserInitiator(initiatorPortWwn)) {
portsInDirector++;
} else if (mask.hasInitiator(initiatorId)) {
portsInDirector++;
}
}
if (portsInDirector < directorMinPortCount) {
if (mask.getCreatedBySystem()) {
// ViPR created
String msg = String.format("ExportMask %s disqualified because it only has %d back-end ports from %s (requires two). \n", mask.getMaskName(), portsInDirector, director);
_log.info(msg);
if (errorMessages != null) {
errorMessages.append(msg);
}
if (null != invalidMasks) {
invalidMasks.add(mask.getId());
}
passed = false;
} else {
// non ViPR created
String msg = String.format("ExportMask %s only has %d back-end ports from %s (should have at least two). \n", mask.getMaskName(), portsInDirector, director);
_log.info(msg);
if (errorMessages != null) {
errorMessages.append(msg);
}
}
}
}
// Rule 2. The Export Mask should have at least two ports. Four are recommended.
Set<String> usablePorts = new StringSet();
if (mask.getStoragePorts() != null) {
for (String portId : mask.getStoragePorts()) {
StoragePort port = dbClient.queryObject(StoragePort.class, URI.create(portId));
if (port == null || port.getInactive() || NullColumnValueGetter.isNullURI(port.getNetwork())) {
continue;
}
// Validate port network overlaps Initiators and port is tagged for Varray
StringSet taggedVarrays = port.getTaggedVirtualArrays();
if (ConnectivityUtil.checkNetworkConnectedToAtLeastOneNetwork(port.getNetwork(), initiatorPortMap.keySet(), dbClient) && taggedVarrays != null && taggedVarrays.contains(varrayURI.toString())) {
usablePorts.add(port.getLabel());
}
}
}
if (usablePorts.size() < 2) {
String msg = String.format("ExportMask %s disqualified because it has less than two usable target ports;" + " usable ports: %s \n", mask.getMaskName(), usablePorts.toString());
_log.warn(msg);
if (errorMessages != null) {
errorMessages.append(msg);
}
passed = false;
} else if (usablePorts.size() < 4) {
// This is a warning
String msg = String.format("Warning: ExportMask %s has only %d usable target ports (best practice is at least four);" + " usable ports: %s \n", mask.getMaskName(), usablePorts.size(), usablePorts.toString());
_log.warn(msg);
if (errorMessages != null) {
errorMessages.append(msg);
}
}
// Rule 3. No mixing of WWNs from both VPLEX clusters.
// Add the clusters for all existingInitiators to the sets computed from initiators above.
Set<String> clusters = new HashSet<String>();
for (String portWwn : portWwnToClusterMap.keySet()) {
if (mask.hasExistingInitiator(portWwn) || mask.hasUserInitiator(portWwn)) {
clusters.add(portWwnToClusterMap.get(portWwn));
}
}
if (clusters.size() > 1) {
String msg = String.format("ExportMask %s disqualified because it contains wwns from both VPLEX clusters. \n", mask.getMaskName());
_log.warn(msg);
if (errorMessages != null) {
errorMessages.append(msg);
}
passed = false;
}
// Rule 4. The ExportMask name should not have NO_VIPR in it.
if (mask.getMaskName().toUpperCase().contains(ExportUtils.NO_VIPR)) {
String msg = String.format("ExportMask %s disqualified because the name contains %s (in upper or lower case) to exclude it. \n", mask.getMaskName(), ExportUtils.NO_VIPR);
_log.warn(msg);
if (errorMessages != null) {
errorMessages.append(msg);
}
passed = false;
}
// Rule 5. Every port in the ExportMask must have the varray in its tagged varray set.
StringBuilder portsNotInVarray = new StringBuilder();
if (mask.getStoragePorts() != null) {
for (String portId : mask.getStoragePorts()) {
StoragePort port = dbClient.queryObject(StoragePort.class, URI.create(portId));
if (port == null || port.getInactive()) {
continue;
}
// Validate port is tagged for Varray
StringSet taggedVarrays = port.getTaggedVirtualArrays();
if (taggedVarrays == null || taggedVarrays.isEmpty() || !taggedVarrays.contains(varrayURI.toString())) {
portsNotInVarray.append(port.getPortName() + " ");
}
}
}
if (portsNotInVarray.length() > 0) {
String virtualArrayName = varrayURI.toString();
VirtualArray virtualArray = dbClient.queryObject(VirtualArray.class, varrayURI);
if (virtualArray != null) {
virtualArrayName = virtualArray.getLabel();
}
String msg = String.format("Validation of ExportMask %s failed; the mask has ports which are not in varray %s;\n" + " \tPorts not in varray: %s \n", mask.getMaskName(), virtualArrayName, portsNotInVarray);
_log.warn(msg);
if (errorMessages != null) {
errorMessages.append(msg);
}
passed = false;
}
int volumeCount = (mask.getVolumes() != null) ? mask.getVolumes().size() : 0;
if (mask.getExistingVolumes() != null) {
volumeCount += mask.getExistingVolumes().keySet().size();
}
if (passed) {
_log.info(String.format("Validation of ExportMask %s passed; it has %d volumes", mask.getMaskName(), volumeCount));
} else {
if (null != invalidMasks) {
invalidMasks.add(mask.getId());
}
}
return passed;
}
Aggregations