use of com.emc.storageos.db.client.model.VirtualArray in project coprhd-controller by CoprHD.
the class ExternalDeviceExportOperations method addVolumes.
@Override
public void addVolumes(StorageSystem storage, URI exportMaskUri, VolumeURIHLU[] volumeURIHLUs, List<com.emc.storageos.db.client.model.Initiator> initiatorList, TaskCompleter taskCompleter) throws DeviceControllerException {
log.info("{} addVolumes START...", storage.getSerialNumber());
try {
log.info("addVolumes: Export mask id: {}", exportMaskUri);
log.info("addVolumes: New volumes to add: volume-HLU pairs: {}", Joiner.on(',').join(volumeURIHLUs));
if (initiatorList != null) {
log.info("addVolumes: initiators: {}", Joiner.on(',').join(initiatorList));
}
BlockStorageDriver driver = externalDevice.getDriver(storage.getSystemType());
ExportMask exportMask = (ExportMask) dbClient.queryObject(exportMaskUri);
StringSet maskInitiators = exportMask.getInitiators();
List<String> maskInitiatorList = new ArrayList<>();
for (String initiatorUri : maskInitiators) {
maskInitiatorList.add(initiatorUri);
}
log.info("Export mask existing initiators: {} ", Joiner.on(',').join(maskInitiatorList));
StringSet storagePorts = exportMask.getStoragePorts();
List<URI> portList = new ArrayList<>();
for (String portUri : storagePorts) {
portList.add(URI.create(portUri));
}
log.info("Export mask existing storage ports: {} ", Joiner.on(',').join(portList));
// Get export group uri from task completer
URI exportGroupUri = taskCompleter.getId();
ExportGroup exportGroup = (ExportGroup) dbClient.queryObject(exportGroupUri);
Set<URI> volumeUris = new HashSet<>();
for (VolumeURIHLU volumeURIHLU : volumeURIHLUs) {
URI volumeURI = volumeURIHLU.getVolumeURI();
volumeUris.add(volumeURI);
}
// Prepare volumes. We send to driver only new volumes for the export mask.
List<StorageVolume> driverVolumes = new ArrayList<>();
Map<String, String> driverVolumeToHLUMap = new HashMap<>();
Map<String, URI> volumeNativeIdToUriMap = new HashMap<>();
prepareVolumes(storage, volumeURIHLUs, driverVolumes, driverVolumeToHLUMap, volumeNativeIdToUriMap);
// Prepare initiators
Set<com.emc.storageos.db.client.model.Initiator> initiators = ExportMaskUtils.getInitiatorsForExportMask(dbClient, exportMask, null);
List<Initiator> driverInitiators = new ArrayList<>();
prepareInitiators(initiators, exportGroup.forCluster(), driverInitiators);
// Prepare target storage ports
List<StoragePort> recommendedPorts = new ArrayList<>();
List<StoragePort> availablePorts = new ArrayList<>();
List<StoragePort> selectedPorts = new ArrayList<>();
// Prepare ports for driver call. Populate lists of recommended and available ports.
Map<String, com.emc.storageos.db.client.model.StoragePort> nativeIdToAvailablePortMap = new HashMap<>();
// We use existing ports in the mask as recommended ports.
preparePorts(storage, exportMaskUri, portList, recommendedPorts, availablePorts, nativeIdToAvailablePortMap);
log.info("varray ports: {}", nativeIdToAvailablePortMap);
// For add volumes to existing export mask, we do not allow storage port change in the mask.
// Only ports in the mask are available for driver call.
availablePorts = recommendedPorts;
ExportPathParams pathParams = blockScheduler.calculateExportPathParamForVolumes(volumeUris, exportGroup.getNumPaths(), storage.getId(), exportGroupUri);
StorageCapabilities capabilities = new StorageCapabilities();
// Prepare num paths to send to driver
prepareCapabilities(pathParams, capabilities);
MutableBoolean usedRecommendedPorts = new MutableBoolean(true);
// Ready to call driver
DriverTask task = driver.exportVolumesToInitiators(driverInitiators, driverVolumes, driverVolumeToHLUMap, recommendedPorts, availablePorts, capabilities, usedRecommendedPorts, selectedPorts);
// todo: need to implement support for async case.
if (task.getStatus() == DriverTask.TaskStatus.READY) {
String msg = String.format("Created export for volumes: %s . Used recommended ports: %s .", task.getMessage(), usedRecommendedPorts);
log.info(msg);
log.info("Driver selected storage ports: {} ", Joiner.on(',').join(selectedPorts));
// auto san zoning is enabled, we will fail the request.
if (usedRecommendedPorts.isFalse() && !selectedPorts.containsAll(recommendedPorts)) {
// for auto san zoning enabled we can not support case when selected ports do not include ports which are already in the mask
VirtualArray varray = dbClient.queryObject(VirtualArray.class, exportGroup.getVirtualArray());
log.info("AutoSanZoning for varray {} is {} ", varray.getLabel(), varray.getAutoSanZoning());
if (varray.getAutoSanZoning()) {
String errorMsg = String.format("AutoSanZoning is enabled and driver selected ports do not contain ports from the export mask: %s .", task.getMessage());
log.error(errorMsg);
ServiceError serviceError = ExternalDeviceException.errors.addVolumesToExportMaskFailed("addVolumes", errorMsg);
taskCompleter.error(dbClient, serviceError);
} else {
// auto san zoning is disabled --- add new selected ports to the mask
// we do not care about zoning map in this case
List<com.emc.storageos.db.client.model.StoragePort> selectedPortsForMask = new ArrayList<>();
for (StoragePort driverPort : selectedPorts) {
log.info("Driver selected port: {}", driverPort);
com.emc.storageos.db.client.model.StoragePort port = nativeIdToAvailablePortMap.get(driverPort.getNativeId());
if (port != null) {
// add all ports, StringSet in the mask will ignore duplicates
log.info("System port: {}", port);
selectedPortsForMask.add(port);
}
}
for (com.emc.storageos.db.client.model.StoragePort port : selectedPortsForMask) {
exportMask.addTarget(port.getId());
}
dbClient.updateObject(exportMask);
taskCompleter.ready(dbClient);
}
} else {
// Update volumes Lun Ids in export mask based on driver selection
for (String volumeNativeId : driverVolumeToHLUMap.keySet()) {
String targetLunId = driverVolumeToHLUMap.get(volumeNativeId);
URI volumeUri = volumeNativeIdToUriMap.get(volumeNativeId);
exportMask.getVolumes().put(volumeUri.toString(), targetLunId);
}
dbClient.updateObject(exportMask);
taskCompleter.ready(dbClient);
}
} else {
String errorMsg = String.format("Failed to add volumes to export mask: %s .", task.getMessage());
log.error(errorMsg);
ServiceError serviceError = ExternalDeviceException.errors.addVolumesToExportMaskFailed("addVolumes", errorMsg);
taskCompleter.error(dbClient, serviceError);
}
} catch (Exception ex) {
log.error("Problem in addVolumes: ", ex);
String errorMsg = String.format("Failed to add volumes to export mask: %s .", ex.getMessage());
log.error(errorMsg);
ServiceError serviceError = ExternalDeviceException.errors.addVolumesToExportMaskFailed("addVolumes", errorMsg);
taskCompleter.error(dbClient, serviceError);
}
log.info("{} addVolumes END...", storage.getSerialNumber());
}
use of com.emc.storageos.db.client.model.VirtualArray in project coprhd-controller by CoprHD.
the class MetroPointVolumeInternalSiteNameMigrationTest method createRPVirtualPool.
private URI createRPVirtualPool(String protectionVarrayName, String vpoolName, boolean metroPoint) {
VirtualArray virtualArray = new VirtualArray();
URI virtualArrayURI = URIUtil.createId(VirtualArray.class);
virtualArray.setId(virtualArrayURI);
virtualArray.setLabel(protectionVarrayName);
_dbClient.createObject(virtualArray);
VpoolProtectionVarraySettings protectionSettings = new VpoolProtectionVarraySettings();
URI protectionSettingsURI = URIUtil.createId(VpoolProtectionVarraySettings.class);
protectionSettings.setId(protectionSettingsURI);
protectionSettings.setJournalSize("min");
_dbClient.createObject(protectionSettings);
VirtualPool virtualPool = new VirtualPool();
URI virtualPoolURI = URIUtil.createId(VirtualPool.class);
virtualPool.setId(virtualPoolURI);
virtualPool.setLabel(vpoolName);
StringMap protectionVarraySettings = new StringMap();
protectionVarraySettings.put(virtualArrayURI.toString(), protectionSettingsURI.toString());
virtualPool.setProtectionVarraySettings(protectionVarraySettings);
if (metroPoint) {
virtualPool.setHighAvailability(VirtualPool.HighAvailabilityType.vplex_distributed.name());
virtualPool.setMetroPoint(Boolean.TRUE);
}
_dbClient.createObject(virtualPool);
return virtualPool.getId();
}
use of com.emc.storageos.db.client.model.VirtualArray in project coprhd-controller by CoprHD.
the class NetworkConnectedVirtualArraysMigrationTest method prepareData.
@SuppressWarnings("deprecation")
@Override
protected void prepareData() throws Exception {
Network networkAllNull;
Network networkAssignedOnly;
Network networkConnectedOnly;
Network networkAssignedAndConnected;
connectedVarray = new VirtualArray();
connectedVarray.setId(URIUtil.createId(VirtualArray.class));
connectedVarray.setLabel("connectedVarray");
_dbClient.createObject(connectedVarray);
assignedVarray = new VirtualArray();
assignedVarray.setId(URIUtil.createId(VirtualArray.class));
assignedVarray.setLabel("assignedVarray");
_dbClient.createObject(assignedVarray);
connectedAndassignedVarray = new VirtualArray();
connectedAndassignedVarray.setId(URIUtil.createId(VirtualArray.class));
connectedAndassignedVarray.setLabel("connectedAndassignedVarray");
_dbClient.createObject(connectedAndassignedVarray);
networkAllNull = new Network();
networkAllNull.setId(URIUtil.createId(Network.class));
networkAllNull.setLabel("networkAllNull");
_dbClient.createObject(networkAllNull);
networkAssignedOnly = new Network();
networkAssignedOnly.setId(URIUtil.createId(Network.class));
networkAssignedOnly.setLabel("networkAssignedOnly");
networkAssignedOnly.addAssignedVirtualArrays(Collections.singletonList(assignedVarray.getId().toString()));
_dbClient.createObject(networkAssignedOnly);
networkConnectedOnly = new Network();
networkConnectedOnly.setId(URIUtil.createId(Network.class));
networkConnectedOnly.setLabel("networkConnectedOnly");
networkConnectedOnly.addConnectedVirtualArrays(Collections.singletonList(connectedVarray.getId().toString()));
_dbClient.createObject(networkConnectedOnly);
networkAssignedAndConnected = new Network();
networkAssignedAndConnected.setId(URIUtil.createId(Network.class));
networkAssignedAndConnected.setLabel("networkAssignedAndConnected");
networkAssignedAndConnected.addAssignedVirtualArrays(Collections.singletonList(assignedVarray.getId().toString()));
networkAssignedAndConnected.addAssignedVirtualArrays(Collections.singletonList(connectedAndassignedVarray.getId().toString()));
networkAssignedAndConnected.addConnectedVirtualArrays(Collections.singletonList(connectedVarray.getId().toString()));
networkAssignedAndConnected.addConnectedVirtualArrays(Collections.singletonList(connectedAndassignedVarray.getId().toString()));
_dbClient.createObject(networkAssignedAndConnected);
}
use of com.emc.storageos.db.client.model.VirtualArray in project coprhd-controller by CoprHD.
the class NetworkVarrayIndexMigrationTest method prepareData.
/*
* (non-Javadoc)
*
* @see com.emc.storageos.db.server.upgrade.DbSimpleMigrationTestBase#prepareData()
*/
@Override
protected void prepareData() throws Exception {
DbClient dbClient = getDbClient();
virtualArray1 = new VirtualArray();
virtualArray1.setId(URIUtil.createId(VirtualArray.class));
virtualArray1.setLabel("varray1");
dbClient.createObject(virtualArray1);
network = new Network();
network.setId(URIUtil.createId(Network.class));
network.setLabel("networkObj");
StringSet varrayStrSet1 = new StringSet();
varrayStrSet1.add(virtualArray1.getId().toString());
network.setAssignedVirtualArrays(varrayStrSet1);
virtualArray2 = new VirtualArray();
virtualArray2.setId(URIUtil.createId(VirtualArray.class));
virtualArray2.setLabel("varray2");
dbClient.createObject(virtualArray2);
StringSet varrayStrSet2 = new StringSet();
varrayStrSet2.add(virtualArray1.getId().toString());
varrayStrSet2.add(virtualArray2.getId().toString());
network.setConnectedVirtualArrays(varrayStrSet2);
dbClient.createObject(network);
// prove that we've reproduced the problem
List<Network> assignedNetworks = CustomQueryUtility.queryActiveResourcesByRelation(dbClient, virtualArray2.getId(), Network.class, "assignedVirtualArrays");
// should be false once the index is fixed
Assert.assertTrue(assignedNetworks.iterator().hasNext());
}
use of com.emc.storageos.db.client.model.VirtualArray in project coprhd-controller by CoprHD.
the class VplexVolumeFullCopyMigrationTest method prepareData.
@Override
protected void prepareData() throws Exception {
s_logger.info("Preparing data for VPLEX volume full copy migration test.");
// Create the virtual array for the source side.
VirtualArray srcVarray = new VirtualArray();
URI srcVarrayURI = URIUtil.createId(VirtualArray.class);
srcVarray.setId(srcVarrayURI);
_dbClient.createObject(srcVarray);
s_logger.info("Created source side virtual array.");
// Create the virtual array for the HA side.
VirtualArray haVarray = new VirtualArray();
URI haVarrayURI = URIUtil.createId(VirtualArray.class);
haVarray.setId(haVarrayURI);
_dbClient.createObject(haVarray);
s_logger.info("Created HA side virtual array.");
// Create a backend volume in the source varray.
Volume srcBackendVolume = new Volume();
URI srcBackendVolumeURI = URIUtil.createId(Volume.class);
srcBackendVolume.setId(srcBackendVolumeURI);
srcBackendVolume.setVirtualArray(srcVarrayURI);
_dbClient.createObject(srcBackendVolume);
s_logger.info("Created source backend volume for source VPLEX volume.");
// Create a backend volume in the HA varray.
Volume haBackendVolume = new Volume();
URI haBackendVolumeURI = URIUtil.createId(Volume.class);
haBackendVolume.setId(haBackendVolumeURI);
haBackendVolume.setVirtualArray(haVarrayURI);
_dbClient.createObject(haBackendVolume);
s_logger.info("Created HA backend volume for source VPLEX volume.");
// Create the VPLEX volume in the source varray using the
// source and HA backend volumes. This volume will be the
// source of a VPLEX full copy volume.
Volume srcVplexVolume = new Volume();
_srcVplexVolumeURI = URIUtil.createId(Volume.class);
srcVplexVolume.setId(_srcVplexVolumeURI);
srcVplexVolume.setVirtualArray(srcVarrayURI);
srcVplexVolume.setLabel(VPLEX_VOLUME_LABEL);
StringSet associatedVolumes = new StringSet();
associatedVolumes.add(srcBackendVolumeURI.toString());
associatedVolumes.add(haBackendVolumeURI.toString());
srcVplexVolume.setAssociatedVolumes(associatedVolumes);
_dbClient.createObject(srcVplexVolume);
s_logger.info("Created source VPLEX volume.");
// Create another backend volume in the source varray.
Volume srcBackendVolumeForCopy = new Volume();
URI srcBackendVolumeForCopyURI = URIUtil.createId(Volume.class);
srcBackendVolumeForCopy.setId(srcBackendVolumeForCopyURI);
srcBackendVolumeForCopy.setVirtualArray(srcVarrayURI);
_dbClient.createObject(srcBackendVolumeForCopy);
s_logger.info("Created source backend volume for full copy VPLEX volume.");
// Create another backend volume in the HA varray.
Volume haBackendVolumeForCopy = new Volume();
URI haBackendVolumeForCopyURI = URIUtil.createId(Volume.class);
haBackendVolumeForCopy.setId(haBackendVolumeForCopyURI);
haBackendVolumeForCopy.setVirtualArray(haVarrayURI);
_dbClient.createObject(haBackendVolumeForCopy);
s_logger.info("Created HA backend volume for full copy VPLEX volume.");
// Create another VPLEX volume in the source varray.
// This volume will be the VPLEX full copy volume.
Volume vplexVolumeFullCopy = new Volume();
_vplexVolumeFullCopyURI = URIUtil.createId(Volume.class);
vplexVolumeFullCopy.setId(_vplexVolumeFullCopyURI);
vplexVolumeFullCopy.setVirtualArray(srcVarrayURI);
vplexVolumeFullCopy.setLabel(VPLEX_FULL_COPY_VOLUME_LABEL);
associatedVolumes = new StringSet();
associatedVolumes.add(srcBackendVolumeForCopyURI.toString());
associatedVolumes.add(haBackendVolumeForCopyURI.toString());
vplexVolumeFullCopy.setAssociatedVolumes(associatedVolumes);
_dbClient.createObject(vplexVolumeFullCopy);
s_logger.info("Created full copy VPLEX volume.");
// Setup the full copy relationship between the source
// backend volumes of the VPLEX volume and VPLEX full copy
// volumes.
StringSet fullCopyVolumes = new StringSet();
fullCopyVolumes.add(srcBackendVolumeForCopyURI.toString());
srcBackendVolume.setFullCopies(fullCopyVolumes);
srcBackendVolumeForCopy.setAssociatedSourceVolume(srcBackendVolumeURI);
_dbClient.persistObject(srcBackendVolume);
_dbClient.persistObject(srcBackendVolumeForCopy);
s_logger.info("Establish full copy relationships betwen the backend source volumes.");
}
Aggregations