use of com.emc.storageos.db.client.model.ExportMask in project coprhd-controller by CoprHD.
the class AbstractDefaultMaskingOrchestrator method generateZoningAddVolumesWorkflow.
protected String generateZoningAddVolumesWorkflow(Workflow workflow, String previousStep, ExportGroup exportGroup, List<ExportMask> exportMasks, List<URI> volumeURIs) throws WorkflowException {
URI exportGroupURI = exportGroup.getId();
List<URI> exportMaskURIs = new ArrayList<URI>();
for (ExportMask mask : exportMasks) {
exportMaskURIs.add(mask.getId());
}
String zoningStep = workflow.createStepId();
Workflow.Method zoningExecuteMethod = _networkDeviceController.zoneExportAddVolumesMethod(exportGroupURI, exportMaskURIs, volumeURIs);
Workflow.Method rollbackMethod = _networkDeviceController.zoneRollbackMethod(exportGroupURI, zoningStep);
zoningStep = workflow.createStep((previousStep == null ? EXPORT_GROUP_ZONING_TASK : null), "Zoning subtask for export-group: " + exportGroupURI, previousStep, NullColumnValueGetter.getNullURI(), "network-system", _networkDeviceController.getClass(), zoningExecuteMethod, rollbackMethod, zoningStep);
return zoningStep;
}
use of com.emc.storageos.db.client.model.ExportMask in project coprhd-controller by CoprHD.
the class AbstractDefaultMaskingOrchestrator method logExportGroup.
/**
* Method to display the ExportGroup collections and its related ExportMasks per StorageSystem
*
* @param exportGroup
* [in] - ExportGroup to display
* @param storage
* [in] - Used to filter the associated ExportMasks to display
*/
protected void logExportGroup(ExportGroup exportGroup, URI storage) {
if (exportGroup != null) {
StackTraceElement[] elements = new Throwable().getStackTrace();
String caller = String.format("%s#%s", elements[1].getClassName(), elements[1].getMethodName());
StringBuilder message = new StringBuilder();
message.append(String.format("ExportGroup before %s %n %s", caller, exportGroup.toString()));
message.append(String.format("ExportMasks associated with ExportGroup and StorageSystem %s:", storage));
for (ExportMask exportMask : ExportMaskUtils.getExportMasks(_dbClient, exportGroup, storage)) {
message.append('\n').append(exportMask.toString());
}
_log.info(message.toString());
}
}
use of com.emc.storageos.db.client.model.ExportMask in project coprhd-controller by CoprHD.
the class AbstractDefaultMaskingOrchestrator method generateZoningDeleteWorkflow.
protected String generateZoningDeleteWorkflow(Workflow workflow, String previousStep, ExportGroup exportGroup, List<ExportMask> exportMasks) throws WorkflowException {
URI exportGroupURI = exportGroup.getId();
List<URI> exportMaskURIs = new ArrayList<URI>();
Set<URI> volumeURIs = new HashSet<>();
for (ExportMask mask : exportMasks) {
exportMaskURIs.add(mask.getId());
volumeURIs.addAll(ExportMaskUtils.getVolumeURIs(mask));
}
List<NetworkZoningParam> zoningParams = NetworkZoningParam.convertExportMasksToNetworkZoningParam(exportGroupURI, exportMaskURIs, _dbClient);
String zoningStep = workflow.createStepId();
Workflow.Method zoningExecuteMethod = _networkDeviceController.zoneExportMasksDeleteMethod(zoningParams, volumeURIs);
zoningStep = workflow.createStep((previousStep == null ? EXPORT_GROUP_ZONING_TASK : null), "Zoning subtask for export-group: " + exportGroupURI, previousStep, NullColumnValueGetter.getNullURI(), "network-system", _networkDeviceController.getClass(), zoningExecuteMethod, null, zoningStep);
return zoningStep;
}
use of com.emc.storageos.db.client.model.ExportMask in project coprhd-controller by CoprHD.
the class NetworkZoningParam method convertExportMaskInitiatorMapsToNetworkZoningParam.
/**
* Generates a list of NetworkZoningParam objects from a map of export mask URI to a list of initiator URIs.
* Only the initiators in the exportMaskToInitiators map are retained from the ExportMask initiators.
* @param exportGroupURI
* @param exportMaskToInitiators
* @param dbClient
* @return
*/
public static List<NetworkZoningParam> convertExportMaskInitiatorMapsToNetworkZoningParam(URI exportGroupURI, Map<URI, List<URI>> exportMaskToInitiators, DbClient dbClient) {
ExportGroup exportGroup = dbClient.queryObject(ExportGroup.class, exportGroupURI);
List<NetworkZoningParam> zoningParams = new ArrayList<NetworkZoningParam>();
for (Map.Entry<URI, List<URI>> entry : exportMaskToInitiators.entrySet()) {
ExportMask exportMask = dbClient.queryObject(ExportMask.class, entry.getKey());
if (exportMask == null || exportMask.getInactive()) {
throw WorkflowException.exceptions.workflowConstructionError("ExportMask is null: " + entry.getKey().toString());
}
NetworkZoningParam zoningParam = new NetworkZoningParam(exportGroup, exportMask, dbClient);
// Filter out entries in the zoning map not in the initiator list.
// This is done by retaining all the initiators in the exportMaskToInitiators value.
Set<String> retainedInitiators = StringSetUtil.uriListToSet(entry.getValue());
zoningParam.getZoningMap().keySet().retainAll(retainedInitiators);
// Add zoningParam to result
zoningParams.add(zoningParam);
}
return zoningParams;
}
use of com.emc.storageos.db.client.model.ExportMask 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));
}
}
Aggregations