use of com.emc.storageos.vnxe.models.VNXeBase in project coprhd-controller by CoprHD.
the class VNXeUnManagedObjectDiscoverer method getStoragePortPool.
private StoragePort getStoragePortPool(StorageSystem storageSystem, DbClient dbClient, VNXeApiClient apiClient, VNXeFileSystem fs) throws IOException {
StoragePort storagePort = null;
// Retrieve the list of data movers interfaces for the VNX File device.
List<VNXeFileInterface> interfaces = apiClient.getFileInterfaces();
VNXeBase fsNasserver = fs.getNasServer();
if (interfaces == null || interfaces.isEmpty()) {
log.info("No file interfaces found for the system: {} ", storageSystem.getId());
return storagePort;
}
log.info("Number file interfaces found: {}", interfaces.size());
// Create the list of storage ports.
for (VNXeFileInterface intf : interfaces) {
VNXeBase nasServer = intf.getNasServer();
if (nasServer == null || (!fsNasserver.getId().equalsIgnoreCase(nasServer.getId()))) {
continue;
}
// Check if storage port was already discovered
URIQueryResultList results = new URIQueryResultList();
String portNativeGuid = NativeGUIDGenerator.generateNativeGuid(storageSystem, intf.getIpAddress(), NativeGUIDGenerator.PORT);
dbClient.queryByConstraint(AlternateIdConstraint.Factory.getStoragePortByNativeGuidConstraint(portNativeGuid), results);
Iterator<URI> storagePortIter = results.iterator();
if (storagePortIter.hasNext()) {
URI storagePortURI = storagePortIter.next();
storagePort = dbClient.queryObject(StoragePort.class, storagePortURI);
if (storagePort.getStorageDevice().equals(storageSystem.getId()) && storagePort.getPortGroup().equals(nasServer.getId())) {
log.debug("found a port for storage system {} {}", storageSystem.getSerialNumber(), storagePort);
break;
}
}
}
return storagePort;
}
use of com.emc.storageos.vnxe.models.VNXeBase in project coprhd-controller by CoprHD.
the class VNXeCreateVolumesJob method updateStatus.
/**
* Called to update the job status when the volumes create job completes.
*
* @param jobContext The job context.
*/
@Override
public void updateStatus(JobContext jobContext) throws Exception {
DbClient dbClient = jobContext.getDbClient();
try {
if (_status == JobStatus.IN_PROGRESS) {
return;
}
String opId = getTaskCompleter().getOpId();
StringBuilder logMsgBuilder = new StringBuilder(String.format("Updating status of job %s to %s", opId, _status.name()));
VNXeApiClient vnxeApiClient = getVNXeClient(jobContext);
// If terminal state update storage pool capacity
if (_status == JobStatus.SUCCESS || _status == JobStatus.FAILED) {
List<URI> volUris = getTaskCompleter().getIds();
List<String> volsInPool = new ArrayList<String>();
for (URI voluri : volUris) {
volsInPool.add(voluri.toString());
}
VNXeJob.updateStoragePoolCapacity(dbClient, vnxeApiClient, storagePool, volsInPool);
}
Calendar now = Calendar.getInstance();
int volumeCount = 0;
if (_status == JobStatus.SUCCESS) {
if (!isConsistencyGroup) {
for (String jobId : getJobIds()) {
VNXeCommandJob vnxeJob = vnxeApiClient.getJob(jobId);
ParametersOut output = vnxeJob.getParametersOut();
String nativeId = null;
URI volumeId = getTaskCompleter().getId(volumeCount);
if (output != null) {
VNXeBase storageResource = output.getStorageResource();
if (storageResource != null) {
nativeId = storageResource.getId();
}
}
processVolume(vnxeApiClient, nativeId, volumeId, dbClient, logMsgBuilder, now);
volumeCount++;
}
} else {
List<URI> volIds = getTaskCompleter().getIds();
processVolumesinConsistencyGroup(vnxeApiClient, volIds, dbClient, logMsgBuilder, now);
}
} else if (_status == JobStatus.FAILED) {
List<URI> volIds = getTaskCompleter().getIds();
for (URI volId : volIds) {
Volume volume = dbClient.queryObject(Volume.class, volId);
volume.setInactive(true);
dbClient.updateObject(volume);
if (logMsgBuilder.length() != 0) {
logMsgBuilder.append("\n");
}
logMsgBuilder.append(String.format("Task %s failed to create volume: %s", opId, volId));
}
}
_logger.info(logMsgBuilder.toString());
} catch (Exception e) {
_logger.error("Caught an exception while trying to updateStatus for VNXeCreateVolumesJob", e);
setErrorStatus("Encountered an internal error during volume create job status processing : " + e.getMessage());
} finally {
super.updateStatus(jobContext);
}
}
use of com.emc.storageos.vnxe.models.VNXeBase in project coprhd-controller by CoprHD.
the class VNXeModifyExportJob method updateExportRules.
/**
* update FileShare after exported in VNXe
*
* @param fsOjb fileShare object in vipr
* @param dbClient DbClient
* @param vnxeApiClient VNXeApiClient
*/
private void updateExportRules(VNXeApiClient vnxeApiClient, DbClient dbClient, FileShare fileObj, VNXeNfsShare nfsShare) {
_logger.info("updating file export. ");
try {
// Modify Existing Exports
FileExportRule newRule = new FileExportRule();
URI snapshotId = null;
if (!isFile) {
snapshotId = getTaskCompleter().getId();
}
// Copy the properties to build the index id to query DB for existing Export Rule
copyPropertiesToSave(newRule, rule, fileObj, dbClient, snapshotId);
newRule = getAvailableExportRule(newRule, dbClient);
// it updates the existing one with new information and upon keeping/appending to old one.
if (newRule != null) {
newRule.setInactive(true);
_logger.info("Removing Existing DB Export Rule {}", rule);
dbClient.persistObject(newRule);
}
if (!isDeleteRule) {
newRule = new FileExportRule();
newRule.setId(URIUtil.createId(FileExportRule.class));
if (nfsShare != null) {
if (nfsShare.getReadOnlyHosts() != null) {
Set<String> hosts = new HashSet<String>();
for (VNXeBase hostId : nfsShare.getReadOnlyHosts()) {
hosts.add(vnxeApiClient.getHostById(hostId.getId()).getName());
}
rule.setReadOnlyHosts(hosts);
}
if (nfsShare.getReadWriteHosts() != null) {
Set<String> hosts = new HashSet<String>();
for (VNXeBase hostId : nfsShare.getReadWriteHosts()) {
hosts.add(vnxeApiClient.getHostById(hostId.getId()).getName());
}
rule.setReadWriteHosts(hosts);
}
if (nfsShare.getRootAccessHosts() != null) {
Set<String> hosts = new HashSet<String>();
for (VNXeBase hostId : nfsShare.getRootAccessHosts()) {
hosts.add(vnxeApiClient.getHostById(hostId.getId()).getName());
}
rule.setRootHosts(hosts);
}
}
// Now, Copy the properties again into the rule came out of DB, before updating.
copyPropertiesToSave(newRule, rule, fileObj, dbClient, snapshotId);
_logger.info("Storing New DB Export Rule {}", newRule);
dbClient.createObject(newRule);
}
} catch (Exception e) {
_logger.info("Error While executing CRUD Operations {}", e);
}
}
use of com.emc.storageos.vnxe.models.VNXeBase in project coprhd-controller by CoprHD.
the class VNXUnityArrayAffinityDiscoverer method getPreferredPoolMap.
/**
* Construct pool to pool type map for a host
*
* @param system
* @param hostId
* @param apiClient
* @param dbClient
* @return pool to pool type map
* @throws IOException
*/
private Map<String, String> getPreferredPoolMap(StorageSystem system, URI hostId, VNXeApiClient apiClient, DbClient dbClient) throws IOException {
Map<String, String> preferredPoolMap = new HashMap<String, String>();
Map<String, StoragePool> pools = getStoragePoolMap(system, dbClient);
List<Initiator> allInitiators = CustomQueryUtility.queryActiveResourcesByConstraint(dbClient, Initiator.class, ContainmentConstraint.Factory.getContainedObjectsConstraint(hostId, Initiator.class, Constants.HOST));
String vnxeHostId = null;
for (Initiator initiator : allInitiators) {
logger.info("Processing initiator {}", initiator.getLabel());
String initiatorId = initiator.getInitiatorPort();
if (Protocol.FC.name().equals(initiator.getProtocol())) {
initiatorId = initiator.getInitiatorNode() + ":" + initiatorId;
}
// query VNX Unity initiator
VNXeHostInitiator vnxeInitiator = apiClient.getInitiatorByWWN(initiatorId);
if (vnxeInitiator != null) {
VNXeBase parentHost = vnxeInitiator.getParentHost();
if (parentHost != null) {
vnxeHostId = parentHost.getId();
break;
}
}
}
if (vnxeHostId == null) {
logger.info("Host {} cannot be found on array", hostId);
return preferredPoolMap;
}
// Get vnxeHost from vnxeHostId
VNXeHost vnxeHost = apiClient.getHostById(vnxeHostId);
List<VNXeBase> hostLunIds = vnxeHost.getHostLUNs();
if (hostLunIds != null && !hostLunIds.isEmpty()) {
for (VNXeBase hostLunId : hostLunIds) {
HostLun hostLun = apiClient.getHostLun(hostLunId.getId());
// get lun from from hostLun
VNXeBase lunId = hostLun.getLun();
if (lunId != null) {
VNXeLun lun = apiClient.getLun(lunId.getId());
if (lun != null) {
String nativeGuid = NativeGUIDGenerator.generateNativeGuidForVolumeOrBlockSnapShot(system.getNativeGuid(), lun.getId());
if (DiscoveryUtils.checkStorageVolumeExistsInDB(dbClient, nativeGuid) != null) {
logger.info("Skipping volume {} as it is already managed by ViPR", nativeGuid);
continue;
}
StoragePool pool = getStoragePoolOfUnManagedObject(lun.getPool().getId(), system, pools);
if (pool != null) {
String exportType = isSharedLun(lun) ? ExportGroup.ExportGroupType.Cluster.name() : ExportGroup.ExportGroupType.Host.name();
ArrayAffinityDiscoveryUtils.addPoolToPreferredPoolMap(preferredPoolMap, pool.getId().toString(), exportType);
} else {
logger.error("Skipping volume {} as its storage pool doesn't exist in ViPR", lun.getId());
}
}
}
}
}
return preferredPoolMap;
}
use of com.emc.storageos.vnxe.models.VNXeBase in project coprhd-controller by CoprHD.
the class VNXUnityArrayAffinityDiscoverer method isSharedLun.
/**
* Check if a LUN is shared
* @param lun
* @return boolean true if the LUN is shared
*/
private boolean isSharedLun(VNXeLun lun) {
List<BlockHostAccess> accesses = lun.getHostAccess();
int hostCount = 0;
if (accesses != null && !accesses.isEmpty()) {
for (BlockHostAccess access : accesses) {
if (access != null) {
VNXeBase hostId = access.getHost();
if (hostId != null) {
hostCount++;
if (hostCount > 1) {
return true;
}
}
}
}
}
return false;
}
Aggregations