use of com.emc.storageos.db.client.model.ExportMask in project coprhd-controller by CoprHD.
the class ExportGroupService method getVolumes.
// This was originally in the ExportGroupRestRep
private Map<String, Integer> getVolumes(ExportGroup exportGroup) {
Map<String, Integer> volumesMap = new HashMap<String, Integer>();
StringMap volumes = exportGroup.getVolumes();
for (ExportMask exportMask : ExportMaskUtils.getExportMasks(_dbClient, exportGroup)) {
try {
if (exportMask != null && exportMask.getVolumes() != null) {
for (Map.Entry<String, String> entry : exportMask.getVolumes().entrySet()) {
if (!volumesMap.containsKey(entry.getKey()) && (entry.getValue() != null)) {
// ensure that this volume is referenced by this export group
if (volumes != null && volumes.containsKey(entry.getKey())) {
volumesMap.put(entry.getKey(), Integer.valueOf(entry.getValue()));
}
}
}
}
} catch (Exception e) {
_log.error("Error getting volumes for export group {}", exportGroup.getId(), e);
}
}
/*
* Now include any volumes that might be a part of the Export Group
* but not of the Export Mask.
*/
if (volumes != null) {
for (Map.Entry<String, String> entry : volumes.entrySet()) {
if (!volumesMap.containsKey(entry.getKey()) && (entry.getValue() != null)) {
volumesMap.put(entry.getKey(), Integer.valueOf(entry.getValue()));
}
}
}
return volumesMap;
}
use of com.emc.storageos.db.client.model.ExportMask 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.ExportMask in project coprhd-controller by CoprHD.
the class ExportUtilsTests method populateDb.
/**
* Populate the database with ITL components
*/
public void populateDb() {
String[] vmaxFE = { "50:FE:FE:FE:FE:FE:FE:00", "50:FE:FE:FE:FE:FE:FE:01", "50:FE:FE:FE:FE:FE:FE:02", "50:FE:FE:FE:FE:FE:FE:03" };
// Create a Network
Network network = ExportUtilsTestUtils.createNetwork(_dbClient, vmaxFE, "VSANFE", "FC+BROCADE+FE", null);
// Create a Virtual Array
VirtualArray varray = ExportUtilsTestUtils.createVirtualArray(_dbClient, "varray1");
// Create a storage system
StorageSystem storageSystem = ExportUtilsTestUtils.createStorageSystem(_dbClient, "vmax", "vmax1");
// Create two front-end storage ports VMAX
List<StoragePort> vmaxPorts = new ArrayList<StoragePort>();
for (int i = 0; i < vmaxFE.length; i++) {
vmaxPorts.add(ExportUtilsTestUtils.createStoragePort(_dbClient, storageSystem, network, vmaxFE[i], varray, StoragePort.PortType.frontend.name(), "portGroupvmax" + i, "C0+FC0" + i));
}
// Create initiators
List<Initiator> initiators = new ArrayList<Initiator>();
for (int i = 0; i < NUM_INITIATORS; i++) {
initiators.add(ExportUtilsTestUtils.createInitiator(_dbClient, network, i));
}
// Create Volumes
List<Volume> volumes = new ArrayList<Volume>();
for (int i = 0; i < NUM_VOLUMES; i++) {
Volume volume = ExportUtilsTestUtils.createVolume(_dbClient, varray, i);
volumes.add(volume);
_volumeIds.add(volume.getId());
}
// Create export groups
List<ExportGroup> egs = new ArrayList<ExportGroup>();
for (int i = 0; i < NUM_EXPORT_GROUPS; i++) {
egs.add(ExportUtilsTestUtils.createExportGroup(_dbClient, initiators, volumes, varray, i));
}
// Create export masks
List<ExportMask> ems = new ArrayList<ExportMask>();
for (int i = 0; i < NUM_EXPORT_MASKS; i++) {
ems.add(ExportUtilsTestUtils.createExportMask(_dbClient, egs, initiators, volumes, vmaxPorts, i));
}
}
use of com.emc.storageos.db.client.model.ExportMask in project coprhd-controller by CoprHD.
the class UcsComputeDevice method getHBAToStoragePorts.
private Map<String, Map<String, Integer>> getHBAToStoragePorts(URI volumeId, URI hostId) {
Host host = _dbClient.queryObject(Host.class, hostId);
Map<String, String> initiatorToHBAMapping = getInitiatorToHBAMapping(host.getComputeElement());
Volume volume = _dbClient.queryObject(Volume.class, volumeId);
List<Initiator> initiators = CustomQueryUtility.queryActiveResourcesByRelation(_dbClient, hostId, Initiator.class, "host");
Map<ExportMask, ExportGroup> exportMasks = ExportUtils.getExportMasks(volume, _dbClient);
Map<String, Map<String, Integer>> hbaToStoragePortMapForBoot = new HashMap<String, Map<String, Integer>>();
for (Initiator initiator : initiators) {
for (ExportMask exportMask : exportMasks.keySet()) {
List<URI> storagePorts = ExportUtils.getInitiatorPortsInMask(exportMask, initiator, _dbClient);
if (storagePorts != null && !storagePorts.isEmpty()) {
Integer volumeHLU = Integer.valueOf(exportMask.getVolumes().get(volumeId.toString()));
for (URI storagePortUri : storagePorts) {
StoragePort port = _dbClient.queryObject(StoragePort.class, storagePortUri);
String hbaName = initiatorToHBAMapping.get(initiator.getInitiatorPort());
if (hbaName != null) {
if (hbaToStoragePortMapForBoot.get(hbaName) == null) {
hbaToStoragePortMapForBoot.put(hbaName, new HashMap<String, Integer>());
}
hbaToStoragePortMapForBoot.get(hbaName).put(port.getPortNetworkId(), volumeHLU);
}
}
}
}
}
return hbaToStoragePortMapForBoot;
}
use of com.emc.storageos.db.client.model.ExportMask in project coprhd-controller by CoprHD.
the class MaskPerHostIngestOrchestrator method getExportMaskAlreadyIngested.
/**
* maskPerHost Mode guaranteed to have initiators in only 1 export mask
* always.
*/
@Override
protected ExportMask getExportMaskAlreadyIngested(UnManagedExportMask mask, DbClient dbClient) {
ExportMask eMask = null;
boolean maskFound = false;
List<URI> initiatorUris = new ArrayList<URI>(Collections2.transform(mask.getKnownInitiatorUris(), CommonTransformerFunctions.FCTN_STRING_TO_URI));
for (URI ini : initiatorUris) {
List<URI> exportMaskUris = _dbClient.queryByConstraint(AlternateIdConstraint.Factory.getExportMaskInitiatorConstraint(ini.toString()));
if (null == exportMaskUris) {
return eMask;
}
for (URI eMaskUri : exportMaskUris) {
ExportMask potentialMask = _dbClient.queryObject(ExportMask.class, eMaskUri);
if (potentialMask.getStorageDevice() != null && potentialMask.getStorageDevice().equals(mask.getStorageSystemUri())) {
_logger.info("Found Mask {} with matching initiator and matching Storage System", eMaskUri);
eMask = potentialMask;
maskFound = true;
break;
} else {
_logger.info("Found Mask {} with matching initiator and unmatched Storage System. Skipping mask", eMaskUri);
}
}
if (maskFound) {
break;
}
}
return eMask;
}
Aggregations