use of com.emc.storageos.vnxe.VNXeApiClient in project coprhd-controller by CoprHD.
the class VNXUnityUnManagedObjectDiscoverer method discoverUnManagedFileSystems.
public void discoverUnManagedFileSystems(AccessProfile accessProfile, DbClient dbClient, CoordinatorClient coordinator, PartitionManager partitionManager) throws Exception {
log.info("Started discovery of UnManagedFilesystems for system {}", accessProfile.getSystemId());
StorageSystem storageSystem = dbClient.queryObject(StorageSystem.class, accessProfile.getSystemId());
VNXeApiClient apiClient = getVnxUnityClient(accessProfile);
unManagedFilesystemsInsert = new ArrayList<UnManagedFileSystem>();
unManagedFilesystemsUpdate = new ArrayList<UnManagedFileSystem>();
List<VNXeFileSystem> filesystems = apiClient.getAllFileSystems();
if (filesystems != null && !filesystems.isEmpty()) {
Map<String, StoragePool> pools = getStoragePoolMap(storageSystem, dbClient);
for (VNXeFileSystem fs : filesystems) {
StoragePort storagePort = getStoragePortPool(storageSystem, dbClient, apiClient, fs);
String fsNativeGuid = NativeGUIDGenerator.generateNativeGuid(storageSystem.getSystemType(), storageSystem.getSerialNumber(), fs.getId());
StoragePool pool = getStoragePoolOfUnManagedObject(fs.getPool().getId(), storageSystem, pools);
if (null == pool) {
log.error("Skipping unmanaged volume discovery as the file system {} storage pool doesn't exist in ViPR", fs.getId());
continue;
}
if (checkStorageFileSystemExistsInDB(fsNativeGuid, dbClient)) {
log.info("Skipping file system {} as it is already managed by ViPR", fsNativeGuid);
continue;
}
// Create UnManaged FS
String fsUnManagedFsNativeGuid = NativeGUIDGenerator.generateNativeGuidForPreExistingFileSystem(storageSystem.getSystemType(), storageSystem.getSerialNumber().toUpperCase(), fs.getId());
UnManagedFileSystem unManagedFs = checkUnManagedFileSystemExistsInDB(dbClient, fsUnManagedFsNativeGuid);
unManagedFs = createUnManagedFileSystem(unManagedFs, fsUnManagedFsNativeGuid, storageSystem, pool, storagePort, fs, dbClient);
unManagedFilesystemsReturnedFromProvider.add(unManagedFs.getId());
}
if (!unManagedFilesystemsInsert.isEmpty()) {
// Add UnManagedFileSystem
partitionManager.insertInBatches(unManagedFilesystemsInsert, Constants.DEFAULT_PARTITION_SIZE, dbClient, UNMANAGED_FILESYSTEM);
}
if (!unManagedFilesystemsUpdate.isEmpty()) {
// Update UnManagedFilesystem
partitionManager.updateAndReIndexInBatches(unManagedFilesystemsUpdate, Constants.DEFAULT_PARTITION_SIZE, dbClient, UNMANAGED_FILESYSTEM);
}
// Process those active unmanaged fs objects available in database but not in newly discovered items, to
// mark them inactive.
performStorageUnManagedFSBookKeeping(storageSystem, dbClient, partitionManager);
} else {
log.info("There are no file systems found on the system: {}", storageSystem.getId());
}
}
use of com.emc.storageos.vnxe.VNXeApiClient in project coprhd-controller by CoprHD.
the class VNXUnityUnManagedObjectDiscoverer method discoverAllTreeQuotas.
public void discoverAllTreeQuotas(AccessProfile accessProfile, DbClient dbClient, PartitionManager partitionManager) {
StorageSystem storageSystem = dbClient.queryObject(StorageSystem.class, accessProfile.getSystemId());
VNXeApiClient apiClient = getVnxUnityClient(accessProfile);
log.info("discoverAllTreeQuotas for storage system {} - start", storageSystem.getId());
unManagedTreeQuotaInsert = new ArrayList<UnManagedFileQuotaDirectory>();
unManagedTreeQuotaUpdate = new ArrayList<UnManagedFileQuotaDirectory>();
List<VNXUnityTreeQuota> treeQuotas = apiClient.getAllTreeQuotas();
for (VNXUnityTreeQuota quota : treeQuotas) {
log.info("Discovered fS tree quota {}", quota.toString());
VNXeFileSystem fs = null;
if (quota.getFilesystem() != null) {
fs = apiClient.getFileSystemByFSId(quota.getFilesystem().getId());
String fsNativeGUID = NativeGUIDGenerator.generateNativeGuid(storageSystem.getSystemType(), storageSystem.getSerialNumber(), fs.getId());
try {
if (checkStorageFileSystemExistsInDB(fsNativeGUID, dbClient)) {
log.info("Skipping file system {} as it is already managed by ViPR", fsNativeGUID);
continue;
}
String nativeUnmanagedGUID = NativeGUIDGenerator.generateNativeGuidForPreExistingQuotaDirectory(storageSystem.getSystemType(), storageSystem.getSerialNumber(), quota.getId());
VNXUnityQuotaConfig qc = apiClient.getQuotaConfigById(quota.getQuotaConfigId());
UnManagedFileQuotaDirectory unManagedFileQuotaDirectory = getExistingUnManagedQuotaDirectory(dbClient, nativeUnmanagedGUID);
boolean existingUnManagedQD = true;
if (unManagedFileQuotaDirectory == null) {
unManagedFileQuotaDirectory = new UnManagedFileQuotaDirectory();
existingUnManagedQD = false;
unManagedFileQuotaDirectory.setId(URIUtil.createId(UnManagedFileQuotaDirectory.class));
}
unManagedFileQuotaDirectory.setLabel(quota.getPath().substring(1));
unManagedFileQuotaDirectory.setNativeGuid(nativeUnmanagedGUID);
unManagedFileQuotaDirectory.setParentFSNativeGuid(fsNativeGUID);
unManagedFileQuotaDirectory.setSize(quota.getHardLimit());
Long size = quota.getHardLimit() > 0 ? quota.getHardLimit() : fs.getSizeAllocated();
Long softLimit = 0L;
if (quota.getSoftLimit() > 0) {
softLimit = quota.getSoftLimit() * 100 / size;
int softGrace = qc.getGracePeriod() / (24 * 60 * 60);
unManagedFileQuotaDirectory.setSoftGrace(softGrace);
}
unManagedFileQuotaDirectory.setSoftLimit(softLimit.intValue());
unManagedFileQuotaDirectory.setNotificationLimit(0);
unManagedFileQuotaDirectory.setNativeId(quota.getId());
if (!existingUnManagedQD) {
unManagedTreeQuotaInsert.add(unManagedFileQuotaDirectory);
} else {
unManagedTreeQuotaUpdate.add(unManagedFileQuotaDirectory);
}
} catch (IOException e) {
log.error("IOException occured in discoverAllTreeQuotas()", e);
}
}
}
if (!unManagedTreeQuotaInsert.isEmpty()) {
// Add UnManagedFileSystem
partitionManager.insertInBatches(unManagedTreeQuotaInsert, Constants.DEFAULT_PARTITION_SIZE, dbClient, UNMANAGED_FILEQUOTADIR);
unManagedTreeQuotaInsert.clear();
}
if (!unManagedTreeQuotaUpdate.isEmpty()) {
// Update UnManagedFilesystem
partitionManager.updateInBatches(unManagedTreeQuotaUpdate, Constants.DEFAULT_PARTITION_SIZE, dbClient, UNMANAGED_FILEQUOTADIR);
unManagedTreeQuotaUpdate.clear();
}
}
use of com.emc.storageos.vnxe.VNXeApiClient in project coprhd-controller by CoprHD.
the class VNXUnitySnapshotOperations method restoreGroupSnapshots.
@Override
public void restoreGroupSnapshots(StorageSystem storage, URI volume, URI snapshot, TaskCompleter taskCompleter) throws DeviceControllerException {
try {
BlockSnapshot snapshotObj = _dbClient.queryObject(BlockSnapshot.class, snapshot);
VNXeApiClient apiClient = getVnxeClient(storage);
Snap groupSnap = apiClient.getSnapshot(snapshotObj.getReplicationGroupInstance());
Snap snap = apiClient.getSnapshot(snapshotObj.getNativeId());
// Error out if the snapshot is attached
if (snap.isAttached()) {
log.error("Snapshot {})is exported and cannot be used for restore", snapshotObj.getLabel());
ServiceError error = DeviceControllerErrors.vnxe.cannotRestoreAttachedSnapshot(snapshotObj.getLabel());
taskCompleter.error(_dbClient, error);
}
VNXeCommandJob job = apiClient.restoreSnap(groupSnap.getId());
if (job != null) {
ControllerServiceImpl.enqueueJob(new QueueJob(new VNXUnityRestoreSnapshotJob(job.getId(), storage.getId(), taskCompleter)));
}
} catch (Exception ex) {
log.error("Restore group snapshot got the exception", ex);
ServiceError error = DeviceControllerErrors.vnxe.jobFailed("RestoreSnapshotJob", ex.getMessage());
taskCompleter.error(_dbClient, error);
}
}
use of com.emc.storageos.vnxe.VNXeApiClient in project coprhd-controller by CoprHD.
the class VNXUnitySnapshotOperations method createSingleVolumeSnapshot.
@Override
public void createSingleVolumeSnapshot(StorageSystem storage, URI snapshot, Boolean createInactive, Boolean readOnly, TaskCompleter taskCompleter) throws DeviceControllerException {
try {
BlockSnapshot snapshotObj = _dbClient.queryObject(BlockSnapshot.class, snapshot);
if (readOnly) {
snapshotObj.setIsReadOnly(readOnly);
_dbClient.updateObject(snapshotObj);
}
Volume volume = _dbClient.queryObject(Volume.class, snapshotObj.getParent());
TenantOrg tenant = _dbClient.queryObject(TenantOrg.class, volume.getTenant().getURI());
String tenantName = tenant.getLabel();
String snapLabelToUse = _nameGenerator.generate(tenantName, snapshotObj.getLabel(), snapshot.toString(), '-', SmisConstants.MAX_SNAPSHOT_NAME_LENGTH);
VNXeApiClient apiClient = getVnxeClient(storage);
VNXeCommandJob job = apiClient.createSnap(volume.getNativeId(), snapLabelToUse, readOnly);
if (job != null) {
ControllerServiceImpl.enqueueJob(new QueueJob(new VNXeBlockSnapshotCreateJob(job.getId(), storage.getId(), !createInactive, taskCompleter)));
}
} catch (Exception ex) {
log.error("Create volume snapshot got the exception", ex);
ServiceError error = DeviceControllerErrors.vnxe.jobFailed("CreateVolumeSnapshot", ex.getMessage());
taskCompleter.error(_dbClient, error);
}
}
use of com.emc.storageos.vnxe.VNXeApiClient in project coprhd-controller by CoprHD.
the class VNXUnitySnapshotOperations method createGroupSnapshots.
@Override
public void createGroupSnapshots(StorageSystem storage, List<URI> snapshotList, Boolean createInactive, Boolean readOnly, TaskCompleter taskCompleter) throws DeviceControllerException {
try {
URI snapshot = snapshotList.get(0);
BlockSnapshot snapshotObj = _dbClient.queryObject(BlockSnapshot.class, snapshot);
Volume volume = _dbClient.queryObject(Volume.class, snapshotObj.getParent());
boolean inApplication = false;
if (volume.getApplication(_dbClient) != null) {
inApplication = true;
} else if (volume.checkInternalFlags(Flag.INTERNAL_OBJECT)) {
// Check if it is VPLEX backend volume and if the vplex volume is in an application
final List<Volume> vplexVolumes = CustomQueryUtility.queryActiveResourcesByConstraint(_dbClient, Volume.class, getVolumesByAssociatedId(volume.getId().toString()));
for (Volume vplexVolume : vplexVolumes) {
if (vplexVolume.getApplication(_dbClient) != null) {
inApplication = true;
break;
}
}
}
String groupName = volume.getReplicationGroupInstance();
String snapLabelToUse = null;
if (NullColumnValueGetter.isNotNullValue(groupName)) {
String snapsetLabel = snapshotObj.getSnapsetLabel();
if (inApplication) {
// When in application, it could have more than one CGs in the same application, when creating
// snapshot on the application, the snapset label would be the same for all volumes in the application.
// if we use the same name to create snapshot for multiple CGs, it would fail.
snapLabelToUse = String.format("%s-%s", snapsetLabel, groupName);
} else {
snapLabelToUse = snapsetLabel;
}
VNXeApiClient apiClient = getVnxeClient(storage);
String cgId = apiClient.getConsistencyGroupIdByName(groupName);
VNXeCommandJob job = apiClient.createSnap(cgId, snapLabelToUse, readOnly);
if (job != null) {
ControllerServiceImpl.enqueueJob(new QueueJob(new VNXUnityCreateCGSnapshotJob(job.getId(), storage.getId(), readOnly, taskCompleter)));
}
} else {
String errorMsg = "Unable to find consistency group id when creating snapshot";
log.error(errorMsg);
ServiceError error = DeviceControllerErrors.vnxe.jobFailed("CreateCGSnapshot", errorMsg);
taskCompleter.error(_dbClient, error);
}
} catch (Exception ex) {
log.error("Create volume snapshot got the exception", ex);
ServiceError error = DeviceControllerErrors.vnxe.jobFailed("CreateCGSnapshot", ex.getMessage());
taskCompleter.error(_dbClient, error);
}
}
Aggregations