use of com.emc.storageos.model.block.export.InitiatorPathParam in project coprhd-controller by CoprHD.
the class ExportGroupService method validatePathAdjustment.
/**
* Validate the path adjustment request parameters
*
* @param exportGroup ExportGroup object
* @param system StorageSystem object
* @param param Export Path Adjustment Parameters
* @param varray URI of the virtual array, used to check any supplied ports are in correct varray
*/
private void validatePathAdjustment(ExportGroup exportGroup, StorageSystem system, ExportPathsAdjustmentParam param, URI varray) {
String systemType = system.getSystemType();
if (!Type.vmax.name().equalsIgnoreCase(systemType) && !Type.vplex.name().equalsIgnoreCase(systemType)) {
throw APIException.badRequests.exportPathAdjustmentSystemNotSupported(systemType);
}
List<ExportMask> exportMasks = ExportMaskUtils.getExportMasks(_dbClient, exportGroup, system.getId());
if (exportMasks.isEmpty()) {
throw APIException.badRequests.exportPathAdjustmentSystemExportGroupNotMatch(exportGroup.getLabel(), system.getNativeGuid());
}
ExportPathParameters pathParam = param.getExportPathParameters();
if (pathParam == null) {
throw APIException.badRequests.exportPathAdjustementNoPathParameters();
}
URI pgURI = pathParam.getPortGroup();
// Check if exportMask has existing volumes, if it does, make sure no remove paths.
for (ExportMask exportMask : exportMasks) {
List<InitiatorPathParam> removePaths = param.getRemovedPaths();
if (removePaths.isEmpty() || !exportMask.hasAnyExistingVolumes()) {
continue;
}
Map<URI, List<URI>> removes = new HashMap<URI, List<URI>>();
for (InitiatorPathParam initPath : removePaths) {
removes.put(initPath.getInitiator(), initPath.getStoragePorts());
}
Map<URI, List<URI>> removedPathForMask = ExportMaskUtils.getRemovePathsForExportMask(exportMask, removes);
if (removedPathForMask != null && !removedPathForMask.isEmpty() && pgURI == null) {
_log.error("It has removed path for the ExportMask with existing volumes: " + exportMask.getMaskName());
throw APIException.badRequests.externallyAddedVolumes(exportMask.getMaskName(), exportMask.getExistingVolumes().toString());
}
}
// check adjusted paths are valid. initiators are in the export group, and the targets are in the storage system, and
// in valid state.
Map<URI, List<URI>> adjustedPaths = convertInitiatorPathParamToMap(param.getAdjustedPaths());
List<URI> pathInitiatorURIs = new ArrayList<URI>(adjustedPaths.keySet());
StringSet initiatorIds = exportGroup.getInitiators();
if (!initiatorIds.containsAll(StringSetUtil.uriListToStringSet(pathInitiatorURIs))) {
// Determine all the host URIs for the egInitiators
Set<URI> egHostURIs = new HashSet<URI>();
List<Initiator> egInitiators = ExportUtils.getExportGroupInitiators(exportGroup, _dbClient);
for (Initiator egInitiator : egInitiators) {
if (!NullColumnValueGetter.isNullURI(egInitiator.getHost())) {
egHostURIs.add(egInitiator.getHost());
}
}
// Now, only throw error if there are initiators that are not of any of the egHostURIs
List<Initiator> pathInitiators = _dbClient.queryObject(Initiator.class, pathInitiatorURIs);
List<String> badInitiators = new ArrayList<String>();
for (Initiator pathInitiator : pathInitiators) {
// Bad if not in the EG initiatorIds AND not from an identifiable host or not from a host in EG
if (!initiatorIds.contains(pathInitiator.getId().toString())) {
if (pathInitiator.getHost() == null || !egHostURIs.contains(pathInitiator.getHost())) {
badInitiators.add(pathInitiator.getHostName() + "-" + pathInitiator.getInitiatorPort());
}
}
}
if (!badInitiators.isEmpty()) {
throw APIException.badRequests.exportPathAdjustmentAdjustedPathNotValid(Joiner.on(", ").join(badInitiators));
}
}
Set<URI> pathTargets = new HashSet<URI>();
for (List<URI> targets : adjustedPaths.values()) {
pathTargets.addAll(targets);
}
Set<URI> systemPorts = new HashSet<URI>();
URIQueryResultList storagePortURIs = new URIQueryResultList();
_dbClient.queryByConstraint(ContainmentConstraint.Factory.getStorageDeviceStoragePortConstraint(system.getId()), storagePortURIs);
// Validate the targets to be provisioned have a valid state (COMPATIBLE, REGISTERED, and VISIBLE) and
// that their tagged virtual array contains our varray.
List<StoragePort> storagePorts = _dbClient.queryObject(StoragePort.class, storagePortURIs);
for (StoragePort port : storagePorts) {
if (!port.getInactive() && port.getCompatibilityStatus().equals(DiscoveredDataObject.CompatibilityStatus.COMPATIBLE.name()) && port.getRegistrationStatus().equals(StoragePort.RegistrationStatus.REGISTERED.name()) && port.getDiscoveryStatus().equals(DiscoveryStatus.VISIBLE.name()) && port.getTaggedVirtualArrays() != null && port.getTaggedVirtualArrays().contains(varray.toString())) {
systemPorts.add(port.getId());
}
}
if (!systemPorts.containsAll(pathTargets)) {
// List only the invalid targets
pathTargets.removeAll(systemPorts);
throw APIException.badRequests.exportPathAdjustmentAdjustedPathNotValid(Joiner.on(",").join(pathTargets));
}
}
use of com.emc.storageos.model.block.export.InitiatorPathParam in project coprhd-controller by CoprHD.
the class ExportPathAdjustmentService method execute.
@Override
public void execute() throws Exception {
// build affect paths
List<InitiatorPathParam> toSendAffectedPaths = new ArrayList<InitiatorPathParam>();
for (Map.Entry<URI, List<URI>> entry : resultingPathsMap.entrySet()) {
InitiatorPathParam pathParam = new InitiatorPathParam();
pathParam.setInitiator(entry.getKey());
pathParam.setStoragePorts(entry.getValue());
toSendAffectedPaths.add(pathParam);
}
// build removed paths
List<InitiatorPathParam> toSendRemovedPaths = new ArrayList<InitiatorPathParam>();
for (Map.Entry<URI, List<URI>> entry : removedPathsMap.entrySet()) {
InitiatorPathParam pathParam = new InitiatorPathParam();
pathParam.setInitiator(entry.getKey());
pathParam.setStoragePorts(entry.getValue());
toSendRemovedPaths.add(pathParam);
}
BlockStorageUtils.adjustExportPaths(virtualArray, minPaths, maxPaths, pathsPerInitiator, storageSystem, exportId, toSendAffectedPaths, toSendRemovedPaths, suspendWait);
}
use of com.emc.storageos.model.block.export.InitiatorPathParam in project coprhd-controller by CoprHD.
the class AdjustExportPaths method buildPathDetails.
private String buildPathDetails(List<InitiatorPathParam> param) {
StringBuilder builder = new StringBuilder();
for (InitiatorPathParam ini : param) {
builder.append(" " + ini.getInitiator().toString() + ": [");
List<String> ports = new ArrayList<String>();
for (URI uri : ini.getStoragePorts()) {
ports.add(uri.toString());
}
builder.append(String.join(", ", ports));
builder.append("],");
}
return builder.toString();
}
Aggregations