use of com.emc.storageos.db.client.model.Initiator in project coprhd-controller by CoprHD.
the class ExportGroupService method validatePortAssignmentOnStorageSystems.
/**
* Validate that we can assign the required number of ports for the varray(s)
* required to complete the export. Multiple varrays could be used if VPLEX.
*
* @param storageSystemURIs
* @param exportGroup
* @param initiatorURIs
* @param volumes
* @param pathParam optional ExportPathParameter block to override validation check
*/
private void validatePortAssignmentOnStorageSystems(Collection<URI> storageSystemURIs, ExportGroup exportGroup, List<URI> initiatorURIs, Collection<URI> volumes, ExportPathParameters pathParam) {
// Do not validate ExportGroup Initiator type exports
if (exportGroup.forInitiator()) {
return;
}
for (URI storageSystemURI : storageSystemURIs) {
StorageSystem storageSystem = _dbClient.queryObject(StorageSystem.class, storageSystemURI);
// Validate the initiators in their respective varrays.
if (storageSystem.getSystemType().equals(DiscoveredDataObject.Type.vplex.name())) {
List<URI> varrays = new ArrayList<URI>();
Map<URI, Set<URI>> varrayToVolumes = VPlexUtil.mapBlockObjectsToVarrays(_dbClient, volumes, storageSystemURI, exportGroup);
varrays.addAll(varrayToVolumes.keySet());
Map<URI, List<URI>> varrayToInitiatorsMap = VPlexUtil.partitionInitiatorsByVarray(_dbClient, initiatorURIs, varrays, storageSystem);
int nValidations = 0;
for (URI varrayKey : varrays) {
if (varrayToInitiatorsMap.get(varrayKey) == null || varrayToInitiatorsMap.get(varrayKey).isEmpty()) {
continue;
}
List<Initiator> initiators = _dbClient.queryObject(Initiator.class, varrayToInitiatorsMap.get(varrayKey));
if (varrayToVolumes.get(varrayKey) != null) {
nValidations++;
Collection<String> initiatorAddresses = Collections2.transform(initiators, CommonTransformerFunctions.fctnInitiatorToPortName());
_log.info(String.format("Validating port assignments varray %s initiators %s", varrayKey.toString(), initiatorAddresses));
validatePortAssignment(storageSystem, varrayKey, _blockStorageScheduler, initiators, varrayToVolumes.get(varrayKey), exportGroup.getId(), pathParam);
}
}
if (nValidations == 0) {
_log.info("No validations made for VPlex port assignment");
}
} else {
List<Initiator> initiators = _dbClient.queryObject(Initiator.class, initiatorURIs);
URI varray = exportGroup.getVirtualArray();
Collection<String> initiatorAddresses = Collections2.transform(initiators, CommonTransformerFunctions.fctnInitiatorToPortName());
_log.info(String.format("Validating port assignments varray %s initiators %s", varray.toString(), initiatorAddresses));
validatePortAssignment(storageSystem, varray, _blockStorageScheduler, initiators, volumes, exportGroup.getId(), pathParam);
}
}
}
use of com.emc.storageos.db.client.model.Initiator in project coprhd-controller by CoprHD.
the class ExportGroupService method validateNoConflictingExports.
/**
* Throw an error if we cannot override the Vpool path parameters because there is already
* an existing export from the indicated host(s) to storage array(s).
*
* @param exportGroup
* @param arrayURIs
* @param pathParam -- New ExportPathParams to be used
*/
private void validateNoConflictingExports(ExportGroup exportGroup, Set<URI> arrayURIs, ExportPathParams pathParam) {
_log.info("Requested path parameters: " + pathParam.toString());
Map<String, String> conflictingMasks = new HashMap<String, String>();
StringSet initiators = exportGroup.getInitiators();
if (initiators == null) {
// No initiators currently in export, nothing to do
return;
}
for (String initiatorId : initiators) {
Initiator initiator = _dbClient.queryObject(Initiator.class, URI.create(initiatorId));
if (initiator == null || initiator.getInactive()) {
continue;
}
// Look up all the Export Masks for this Initiator
List<ExportMask> exportMasks = ExportUtils.getInitiatorExportMasks(initiator, _dbClient);
for (ExportMask exportMask : exportMasks) {
// If this mask is for the same Host and Storage combination, we cannot override
if (arrayURIs.contains(exportMask.getStorageDevice())) {
ExportPathParams maskParam = BlockStorageScheduler.calculateExportPathParamForExportMask(_dbClient, exportMask);
_log.info(String.format("Existing mask %s (%s) parameters: %s", exportMask.getMaskName(), exportMask.getId(), maskParam));
// i.e. maskParams.ppi = pathParms.ppi and pathParams.minPath <= maskParams.maxpath <= pathParams.maxPath
if (pathParam.getPathsPerInitiator() == maskParam.getPathsPerInitiator() && (pathParam.getMinPaths() <= maskParam.getMaxPaths() && maskParam.getMaxPaths() <= pathParam.getMaxPaths())) {
_log.info(String.format("Export mask %s is compatible with the requested parameters", exportMask.getMaskName()));
} else {
StorageSystem system = _dbClient.queryObject(StorageSystem.class, exportMask.getStorageDevice());
String hostName = (initiator.getHostName() != null) ? initiator.getHostName() : initiatorId;
String systemName = (system != null) ? system.getLabel() : exportMask.getStorageDevice().toString();
if (!conflictingMasks.containsKey(hostName)) {
String msg = String.format("Export Mask %s for Host %s and Array %s has %d paths and paths_per_initiator %d", exportMask.getMaskName(), hostName, systemName, maskParam.getMaxPaths(), maskParam.getPathsPerInitiator());
conflictingMasks.put(hostName, msg);
}
}
}
}
}
if (!conflictingMasks.isEmpty()) {
StringBuilder builder = new StringBuilder();
for (Entry<String, String> entry : conflictingMasks.entrySet()) {
if (builder.length() != 0) {
builder.append("; ");
}
builder.append(entry.getValue());
}
throw APIException.badRequests.cannotOverrideVpoolPathsBecauseExistingExports(builder.toString());
}
}
use of com.emc.storageos.db.client.model.Initiator in project coprhd-controller by CoprHD.
the class ExportGroupService method validateInitiatorHostOS.
/**
* Validate that all the initiators to be added to the export group belong to the same host type
*
* @param initiators the list of initiators to validate
*/
private void validateInitiatorHostOS(Set<URI> initiators) {
Set<String> hostTypes = new HashSet<String>();
List<URI> hostList = new ArrayList<URI>();
// Dummy URI used in case we encounter null values
URI fillerHostURI = NullColumnValueGetter.getNullURI();
if (initiators != null && !initiators.isEmpty()) {
for (URI initiatorUri : initiators) {
Initiator ini = queryObject(Initiator.class, initiatorUri, true);
// If ini.getHost() returns a null value, set hostURI to fillerHostURI
URI hostURI = (ini.getHost() == null) ? fillerHostURI : ini.getHost();
// no need to go to the DB again..
if (!hostList.isEmpty() && hostList.contains(hostURI)) {
continue;
} else {
// add the hostURI to the hostList so that it can
// help in the next iteration.
hostList.add(hostURI);
}
if (hostURI == fillerHostURI) {
hostTypes.add(String.valueOf(fillerHostURI));
} else {
Host host = queryObject(Host.class, hostURI, true);
hostTypes.add(host.getType());
}
}
if (hostTypes.size() != 1) {
throw APIException.badRequests.initiatorHostsInSameOS();
}
}
}
use of com.emc.storageos.db.client.model.Initiator in project coprhd-controller by CoprHD.
the class ExportGroupService method getInitiatorExportGroupHost.
/**
* For Initiator type export groups, find the host to which the initiators belong.
*
* @param exportGroup the export group
* @return the URI of the initiators host
*/
private URI getInitiatorExportGroupHost(ExportGroup exportGroup) {
URI hostUri = null;
StringSet exportGroupInitiators = exportGroup.getInitiators();
if (exportGroup.forInitiator() && exportGroupInitiators != null) {
for (String uri : exportGroupInitiators) {
Initiator initiator = queryObject(Initiator.class, URI.create(uri), false);
hostUri = initiator.getHost();
break;
}
}
return hostUri;
}
use of com.emc.storageos.db.client.model.Initiator in project coprhd-controller by CoprHD.
the class ExportGroupService method removeClusterData.
/**
* Updates the lists of hosts and initiator when a cluster is removed.
*
* @param cluster the cluster being removed
* @param newHosts the list of hosts to update
* @param newInitiators the list of initiators to update
*/
private void removeClusterData(URI cluster, List<URI> newHosts, List<URI> newInitiators) {
List<URI> hostUris = ComputeSystemHelper.getChildrenUris(_dbClient, cluster, Host.class, "cluster");
for (URI hosturi : hostUris) {
newHosts.remove(hosturi);
newInitiators.removeAll(ComputeSystemHelper.getChildrenUris(_dbClient, hosturi, Initiator.class, "host"));
}
}
Aggregations