use of com.emc.storageos.vnxe.models.VNXeBase in project coprhd-controller by CoprHD.
the class VNXeCommunicationInterface method discoverFileStoragePorts.
/**
* Discover file interfaces for specified VNXe Storage Array
*
* @param system
* storage system.
* @param client
* VNXe service client
* @param nasServerIdSet
* all valid NAS Server ids
* @return Map of New and Existing Storage Ports
* @throws VNXeException
*/
private HashMap<String, List<StoragePort>> discoverFileStoragePorts(StorageSystem system, VNXeApiClient client, Map<String, URI> nasServerIdMap) throws VNXeException {
HashMap<String, List<StoragePort>> storagePorts = new HashMap<String, List<StoragePort>>();
List<StoragePort> newStoragePorts = new ArrayList<StoragePort>();
List<StoragePort> existingStoragePorts = new ArrayList<StoragePort>();
_logger.info("Start storage port discovery for storage system {}", system.getId());
// Retrieve the list of data movers interfaces for the VNX File device.
List<VNXeFileInterface> interfaces = client.getFileInterfaces();
if (interfaces == null || interfaces.isEmpty()) {
_logger.info("No file interfaces found for the system: {} ", system.getId());
return storagePorts;
}
_logger.info("Number file interfaces found: {}", interfaces.size());
// Create the list of storage ports.
for (VNXeFileInterface intf : interfaces) {
StoragePort port = null;
// Check for valid nasServer
VNXeBase nasServer = intf.getNasServer();
if (nasServer == null) {
continue;
}
String nasServerId = nasServer.getId();
URI haDomainUri = nasServerIdMap.get(nasServerId);
if (haDomainUri == null) {
continue;
}
// Check if storage port was already discovered
String portNativeGuid = NativeGUIDGenerator.generateNativeGuid(system, intf.getIpAddress(), NativeGUIDGenerator.PORT);
URIQueryResultList results = new URIQueryResultList();
_dbClient.queryByConstraint(AlternateIdConstraint.Factory.getStoragePortByNativeGuidConstraint(portNativeGuid), results);
if (results.iterator().hasNext()) {
_logger.info("cross verifying for duplicate port");
StoragePort tmpPort = _dbClient.queryObject(StoragePort.class, results.iterator().next());
_logger.info(String.format("StorageDevice found for port %s - Actual StorageDevice %s : PortGroup found for port %s - Actual PortGroup %s", tmpPort.getStorageDevice(), system.getId(), tmpPort.getPortGroup(), nasServerId));
if (tmpPort.getStorageDevice().equals(system.getId()) && tmpPort.getPortGroup().equals(nasServerId)) {
port = tmpPort;
_logger.info("found duplicate dm intf {}", intf.getName());
}
}
// storage port
if (port == null) {
port = new StoragePort();
port.setId(URIUtil.createId(StoragePort.class));
port.setLabel(portNativeGuid);
port.setTransportType("IP");
port.setNativeGuid(portNativeGuid);
port.setStorageDevice(system.getId());
port.setRegistrationStatus(RegistrationStatus.REGISTERED.toString());
port.setPortName(intf.getName());
port.setPortNetworkId(intf.getIpAddress());
port.setPortGroup(nasServerId);
port.setStorageHADomain(haDomainUri);
_logger.info("Creating new storage port using NativeGuid : {}, IP : {}", portNativeGuid, intf.getIpAddress());
newStoragePorts.add(port);
} else {
existingStoragePorts.add(port);
}
port.setDiscoveryStatus(DiscoveryStatus.VISIBLE.name());
port.setCompatibilityStatus(DiscoveredDataObject.CompatibilityStatus.COMPATIBLE.name());
}
_logger.info("Storage port discovery for storage system {} complete", system.getId());
storagePorts.put(NEW, newStoragePorts);
storagePorts.put(EXISTING, existingStoragePorts);
return storagePorts;
}
use of com.emc.storageos.vnxe.models.VNXeBase in project coprhd-controller by CoprHD.
the class VNXeExportOperations method addVolumes.
@Override
public void addVolumes(StorageSystem storage, URI exportMaskUri, VolumeURIHLU[] volumeURIHLUs, List<Initiator> initiatorList, TaskCompleter taskCompleter) throws DeviceControllerException {
_logger.info("{} addVolume START...", storage.getSerialNumber());
List<URI> mappedVolumes = new ArrayList<URI>();
ExportMask exportMask = null;
try {
_logger.info("addVolumes: Export mask id: {}", exportMaskUri);
_logger.info("addVolumes: volume-HLU pairs: {}", Joiner.on(',').join(volumeURIHLUs));
if (initiatorList != null) {
_logger.info("addVolumes: initiators impacted: {}", Joiner.on(',').join(initiatorList));
}
ExportOperationContext context = new VNXeExportOperationContext();
taskCompleter.updateWorkflowStepContext(context);
VNXeApiClient apiClient = getVnxeClient(storage);
exportMask = _dbClient.queryObject(ExportMask.class, exportMaskUri);
if (exportMask == null || exportMask.getInactive()) {
throw new DeviceControllerException("Invalid ExportMask URI: " + exportMaskUri);
}
List<Initiator> initiators = ExportUtils.getExportMaskInitiators(exportMask, _dbClient);
Collection<VNXeHostInitiator> vnxeInitiators = prepareInitiators(initiators).values();
VNXeBase host = apiClient.prepareHostsForExport(vnxeInitiators);
String opId = taskCompleter.getOpId();
Set<String> processedCGs = new HashSet<String>();
for (VolumeURIHLU volURIHLU : volumeURIHLUs) {
URI volUri = volURIHLU.getVolumeURI();
String hlu = volURIHLU.getHLU();
_logger.info(String.format("hlu %s", hlu));
BlockObject blockObject = BlockObject.fetch(_dbClient, volUri);
VNXeExportResult result = null;
Integer newhlu = -1;
if (hlu != null && !hlu.isEmpty() && !hlu.equals(ExportGroup.LUN_UNASSIGNED_STR)) {
newhlu = Integer.valueOf(hlu);
}
// COP-25254 this method could be called when create vplex volumes from snapshot. in this case
// the volume passed in is an internal volume, representing the snapshot. we need to find the snapshot
// with the same nativeGUID, then export the snapshot.
BlockObject snapshot = findSnapshotByInternalVolume(blockObject);
boolean isVplexVolumeFromSnap = false;
URI vplexBackendVol = null;
if (snapshot != null) {
blockObject = snapshot;
exportMask.addVolume(volUri, newhlu);
isVplexVolumeFromSnap = true;
vplexBackendVol = volUri;
volUri = blockObject.getId();
}
String cgName = VNXeUtils.getBlockObjectCGName(blockObject, _dbClient);
if (cgName != null && !processedCGs.contains(cgName)) {
processedCGs.add(cgName);
VNXeUtils.getCGLock(workflowService, storage, cgName, opId);
}
String nativeId = blockObject.getNativeId();
if (URIUtil.isType(volUri, Volume.class)) {
result = apiClient.exportLun(host, nativeId, newhlu);
exportMask.addVolume(volUri, result.getHlu());
if (result.isNewAccess()) {
mappedVolumes.add(volUri);
}
} else if (URIUtil.isType(volUri, BlockSnapshot.class)) {
result = apiClient.exportSnap(host, nativeId, newhlu);
exportMask.addVolume(volUri, result.getHlu());
if (result.isNewAccess()) {
mappedVolumes.add(volUri);
}
String snapWWN = setSnapWWN(apiClient, blockObject, nativeId);
if (isVplexVolumeFromSnap) {
Volume backendVol = _dbClient.queryObject(Volume.class, vplexBackendVol);
backendVol.setWWN(snapWWN);
_dbClient.updateObject(backendVol);
}
}
}
ExportOperationContext.insertContextOperation(taskCompleter, VNXeExportOperationContext.OPERATION_ADD_VOLUMES_TO_HOST_EXPORT, mappedVolumes);
_dbClient.updateObject(exportMask);
// Test mechanism to invoke a failure. No-op on production systems.
InvokeTestFailure.internalOnlyInvokeTestFailure(InvokeTestFailure.ARTIFICIAL_FAILURE_002);
taskCompleter.ready(_dbClient);
} catch (Exception e) {
_logger.error("Add volumes error: ", e);
ServiceError error = DeviceControllerErrors.vnxe.jobFailed("addVolume", e.getMessage());
taskCompleter.error(_dbClient, error);
}
_logger.info("{} addVolumes END...", storage.getSerialNumber());
}
use of com.emc.storageos.vnxe.models.VNXeBase in project coprhd-controller by CoprHD.
the class VNXeExportOperations method addInitiators.
@Override
public void addInitiators(StorageSystem storage, URI exportMaskUri, List<URI> volumeURIs, List<Initiator> initiatorList, List<URI> targets, TaskCompleter taskCompleter) throws DeviceControllerException {
_logger.info("{} addInitiator START...", storage.getSerialNumber());
List<Initiator> createdInitiators = new ArrayList<Initiator>();
ExportMask exportMask = null;
try {
ExportOperationContext context = new VNXeExportOperationContext();
taskCompleter.updateWorkflowStepContext(context);
exportMask = _dbClient.queryObject(ExportMask.class, exportMaskUri);
if (exportMask == null || exportMask.getInactive()) {
throw new DeviceControllerException("Invalid ExportMask URI: " + exportMaskUri);
}
VNXeApiClient apiClient = getVnxeClient(storage);
List<Initiator> initiators = ExportUtils.getExportMaskInitiators(exportMask, _dbClient);
// Finding existing host from the array
Collection<VNXeHostInitiator> vnxeInitiators = prepareInitiators(initiators).values();
String hostId = null;
for (VNXeHostInitiator init : vnxeInitiators) {
VNXeHostInitiator foundInit = apiClient.getInitiatorByWWN(init.getInitiatorId());
if (foundInit != null) {
VNXeBase host = foundInit.getParentHost();
if (host != null) {
hostId = host.getId();
break;
}
}
}
if (hostId == null) {
String msg = String.format("No existing host found in the array for the existing exportMask %s", exportMask.getMaskName());
_logger.error(msg);
ServiceError error = DeviceControllerErrors.vnxe.jobFailed("addiniator", msg);
taskCompleter.error(_dbClient, error);
return;
}
validateInitiators(_dbClient, initiatorList, apiClient, hostId);
Map<Initiator, VNXeHostInitiator> initiatorMap = prepareInitiators(initiatorList);
for (Entry<Initiator, VNXeHostInitiator> entry : initiatorMap.entrySet()) {
VNXeHostInitiator newInit = entry.getValue();
VNXeHostInitiator init = apiClient.getInitiatorByWWN(newInit.getInitiatorId());
// COP-27752 - fresh deleted initiator may not be deleted completely
int retry = 0;
while (retry <= MAX_REMOVE_INITIATOR_RETRIES && init != null && init.getParentHost() == null) {
try {
Thread.sleep(WAIT_FOR_RETRY);
} catch (InterruptedException e1) {
Thread.currentThread().interrupt();
}
init = apiClient.getInitiatorByWWN(newInit.getInitiatorId());
}
if (init != null) {
// found it
VNXeBase host = init.getParentHost();
if (host != null && host.getId().equals(hostId)) {
// do nothing. it is already in the array
_logger.info("The initiator exist in the host in the array");
} else if (host == null) {
// initiator without parent host, add parent host
apiClient.setInitiatorHost(init.getId(), hostId);
} else {
String msg = String.format("Initiator %s belongs to %s, but other initiator belongs to %s. Please move initiator to the correct host", init.getInitiatorId(), host.getId(), hostId);
_logger.error(msg);
if (!createdInitiators.isEmpty()) {
for (Initiator initiator : createdInitiators) {
exportMask.getInitiators().add(initiator.getId().toString());
}
_dbClient.updateObject(exportMask);
ExportOperationContext.insertContextOperation(taskCompleter, VNXeExportOperationContext.OPERATION_ADD_INITIATORS_TO_HOST, createdInitiators);
}
ServiceError error = DeviceControllerErrors.vnxe.jobFailed("addiniator", msg);
taskCompleter.error(_dbClient, error);
return;
}
} else {
apiClient.createInitiator(newInit, hostId);
createdInitiators.add(entry.getKey());
}
}
for (Initiator initiator : initiatorList) {
exportMask.getInitiators().add(initiator.getId().toString());
}
_dbClient.updateObject(exportMask);
ExportOperationContext.insertContextOperation(taskCompleter, VNXeExportOperationContext.OPERATION_ADD_INITIATORS_TO_HOST, createdInitiators);
// Test mechanism to invoke a failure. No-op on production systems.
InvokeTestFailure.internalOnlyInvokeTestFailure(InvokeTestFailure.ARTIFICIAL_FAILURE_003);
taskCompleter.ready(_dbClient);
} catch (Exception e) {
_logger.error("Add initiators error: ", e);
ServiceError error = DeviceControllerErrors.vnxe.jobFailed("addInitiator", e.getMessage());
taskCompleter.error(_dbClient, error);
}
}
use of com.emc.storageos.vnxe.models.VNXeBase in project coprhd-controller by CoprHD.
the class VNXeStorageDevice method extraExportRuleFromArray.
/**
* Get the export rule which are present in array but not in CoprHD Database.
*
* @param storage
* @param args
* @return map with security flavor and export rule
*/
private Map<String, ExportRule> extraExportRuleFromArray(StorageSystem storage, FileDeviceInputOutput args) {
// map to store the export rule grouped by sec flavor
Map<String, ExportRule> exportRuleMap = new HashMap<>();
List<VNXeNfsShare> exportsList = new ArrayList<VNXeNfsShare>();
Set<String> arrayReadOnlyHost = new HashSet<>();
Set<String> arrayReadWriteHost = new HashSet<>();
Set<String> arrayRootHost = new HashSet<>();
Set<String> dbReadOnlyHost = new HashSet<>();
Set<String> dbReadWriteHost = new HashSet<>();
Set<String> dbRootHost = new HashSet<>();
// get all export rule from CoprHD data base
List<ExportRule> existingDBExportRules = args.getExistingDBExportRules();
// get the all the export from the storage system.
VNXeApiClient apiClient = getVnxeClient(storage);
for (ExportRule exportRule : existingDBExportRules) {
if (exportRule.getReadOnlyHosts() != null) {
dbReadOnlyHost.addAll(exportRule.getReadOnlyHosts());
}
if (exportRule.getReadWriteHosts() != null) {
dbReadWriteHost.addAll(exportRule.getReadWriteHosts());
}
if (exportRule.getRootHosts() != null) {
dbRootHost.addAll(exportRule.getRootHosts());
}
String vnxeExportId = exportRule.getDeviceExportId();
if (vnxeExportId != null) {
List<VNXeNfsShare> vnxeExports = null;
vnxeExports = apiClient.getNfsSharesForFileSystem(args.getFs().getNativeId());
exportsList.addAll(vnxeExports);
for (VNXeNfsShare vnXeNfsShare : vnxeExports) {
List<VNXeBase> hostIdReadOnly = vnXeNfsShare.getReadOnlyHosts();
for (VNXeBase vnXeBase : hostIdReadOnly) {
VNXeHost host = apiClient.getHostById(vnXeBase.getId());
arrayReadOnlyHost.add(host.getName());
}
List<VNXeBase> hostIdReadWrite = vnXeNfsShare.getReadWriteHosts();
for (VNXeBase vnXeBase : hostIdReadWrite) {
VNXeHost host = apiClient.getHostById(vnXeBase.getId());
arrayReadWriteHost.add(host.getName());
}
List<VNXeBase> hostIdRootHost = vnXeNfsShare.getRootAccessHosts();
for (VNXeBase vnXeBase : hostIdRootHost) {
VNXeHost host = apiClient.getHostById(vnXeBase.getId());
arrayRootHost.add(host.getName());
}
}
}
// find out the change between array and CoprHD database.
Set<String> arrayExtraReadOnlyHost = Sets.difference(arrayReadOnlyHost, dbReadOnlyHost);
Set<String> arrayExtraReadWriteHost = Sets.difference(arrayReadWriteHost, dbReadWriteHost);
Set<String> arrayExtraRootHost = Sets.difference(arrayRootHost, dbRootHost);
// if change found update the exportRuleMap
if (!arrayExtraReadOnlyHost.isEmpty() || !arrayExtraReadWriteHost.isEmpty() || !arrayExtraRootHost.isEmpty()) {
ExportRule extraRuleFromArray = new ExportRule();
extraRuleFromArray.setDeviceExportId(exportRule.getDeviceExportId());
extraRuleFromArray.setAnon(exportRule.getAnon());
extraRuleFromArray.setSecFlavor(exportRule.getSecFlavor());
extraRuleFromArray.setExportPath(exportRule.getExportPath());
extraRuleFromArray.setReadOnlyHosts(arrayExtraReadOnlyHost);
extraRuleFromArray.setReadWriteHosts(arrayExtraReadWriteHost);
extraRuleFromArray.setRootHosts(arrayExtraRootHost);
exportRuleMap.put(exportRule.getSecFlavor(), extraRuleFromArray);
}
}
return exportRuleMap;
}
use of com.emc.storageos.vnxe.models.VNXeBase in project coprhd-controller by CoprHD.
the class VNXeUnManagedObjectDiscoverer method createExportRules.
private UnManagedFileExportRule createExportRules(URI umfsId, VNXeApiClient apiClient, VNXeNfsShare export, UnManagedFileExportRule unManagedExpRule, String mountPath, String mountPoint, String nfsShareId, String storagePort) {
StringSet roHosts = new StringSet();
if (export.getReadOnlyHosts() != null && !export.getReadOnlyHosts().isEmpty()) {
for (VNXeBase roHost : export.getReadOnlyHosts()) {
roHosts.add(apiClient.getHostById(roHost.getId()).getName());
}
unManagedExpRule.setReadOnlyHosts(roHosts);
}
StringSet rwHosts = new StringSet();
if (export.getReadWriteHosts() != null && !export.getReadWriteHosts().isEmpty()) {
for (VNXeBase rwHost : export.getReadWriteHosts()) {
rwHosts.add(apiClient.getHostById(rwHost.getId()).getName());
}
unManagedExpRule.setReadWriteHosts(rwHosts);
}
StringSet rootHosts = new StringSet();
if (export.getRootAccessHosts() != null && !export.getRootAccessHosts().isEmpty()) {
for (VNXeBase rootHost : export.getRootAccessHosts()) {
rootHosts.add(apiClient.getHostById(rootHost.getId()).getName());
}
unManagedExpRule.setRootHosts(rootHosts);
}
unManagedExpRule.setAnon(ROOT_USER_ACCESS);
unManagedExpRule.setExportPath(export.getPath());
unManagedExpRule.setFileSystemId(umfsId);
unManagedExpRule.setSecFlavor(SECURITY_FLAVOR);
unManagedExpRule.setMountPoint(mountPoint);
unManagedExpRule.setExportPath(mountPath);
unManagedExpRule.setDeviceExportId(nfsShareId);
unManagedExpRule.setLabel(export.getName());
return unManagedExpRule;
}
Aggregations