Search in sources :

Example 16 with VNXeFileSystem

use of com.emc.storageos.vnxe.models.VNXeFileSystem 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();
    }
}
Also used : VNXeApiClient(com.emc.storageos.vnxe.VNXeApiClient) VNXeFileSystem(com.emc.storageos.vnxe.models.VNXeFileSystem) UnManagedFileQuotaDirectory(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedFileQuotaDirectory) IOException(java.io.IOException) VNXUnityTreeQuota(com.emc.storageos.vnxe.models.VNXUnityTreeQuota) AlternateIdConstraint(com.emc.storageos.db.client.constraint.AlternateIdConstraint) ContainmentConstraint(com.emc.storageos.db.client.constraint.ContainmentConstraint) StorageSystem(com.emc.storageos.db.client.model.StorageSystem) VNXUnityQuotaConfig(com.emc.storageos.vnxe.models.VNXUnityQuotaConfig)

Example 17 with VNXeFileSystem

use of com.emc.storageos.vnxe.models.VNXeFileSystem in project coprhd-controller by CoprHD.

the class VNXeStorageDevice method doCheckFSExists.

@Override
public boolean doCheckFSExists(StorageSystem storage, FileDeviceInputOutput fileInOut) throws ControllerException {
    _logger.info("checking file system existence on array: ", fileInOut.getFsName());
    boolean isFSExists = true;
    try {
        String name = fileInOut.getFsName();
        VNXeApiClient apiClient = getVnxeClient(storage);
        VNXeFileSystem fs = apiClient.getFileSystemByFSName(name);
        if (fs != null && (fs.getName().equals(name))) {
            isFSExists = true;
        } else {
            isFSExists = false;
        }
    } catch (Exception e) {
        _logger.error("Querying File System failed with exception:", e);
    }
    return isFSExists;
}
Also used : VNXeApiClient(com.emc.storageos.vnxe.VNXeApiClient) VNXeFileSystem(com.emc.storageos.vnxe.models.VNXeFileSystem) VNXeException(com.emc.storageos.vnxe.VNXeException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) ControllerException(com.emc.storageos.volumecontroller.ControllerException)

Example 18 with VNXeFileSystem

use of com.emc.storageos.vnxe.models.VNXeFileSystem in project coprhd-controller by CoprHD.

the class VNXUnityFileStorageDevice method doCheckFSExists.

@Override
public boolean doCheckFSExists(StorageSystem storage, FileDeviceInputOutput fileInOut) throws ControllerException {
    _logger.info("checking file system existence on array: ", fileInOut.getFsName());
    boolean isFSExists = true;
    try {
        String fsId = fileInOut.getFsNativeId();
        VNXeApiClient apiClient = getVnxUnityClient(storage);
        VNXeFileSystem fs = apiClient.getFileSystemByFSId(fsId);
        if (fs != null && (fs.getId().equals(fsId))) {
            isFSExists = true;
        } else {
            isFSExists = false;
        }
    } catch (Exception e) {
        _logger.error("Querying File System failed with exception:", e);
    }
    return isFSExists;
}
Also used : VNXeApiClient(com.emc.storageos.vnxe.VNXeApiClient) VNXeFileSystem(com.emc.storageos.vnxe.models.VNXeFileSystem) VNXeException(com.emc.storageos.vnxe.VNXeException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) ControllerException(com.emc.storageos.volumecontroller.ControllerException)

Example 19 with VNXeFileSystem

use of com.emc.storageos.vnxe.models.VNXeFileSystem in project coprhd-controller by CoprHD.

the class VNXeApiClient method getStorageResourceId.

/**
 * get storage resource Id using file system Id
 *
 * @param fsId
 *            file system Id
 * @return storage resource Id
 */
private String getStorageResourceId(String fsId) throws VNXeException {
    FileSystemRequest fsRequest = new FileSystemRequest(_khClient, fsId);
    VNXeFileSystem fs = fsRequest.get();
    if (fs == null) {
        _logger.info("Could not find file system in the vxne");
        throw VNXeException.exceptions.vnxeCommandFailed("Could not find file system in the vnxe for: " + fsId);
    }
    return fs.getStorageResource().getId();
}
Also used : FileSystemRequest(com.emc.storageos.vnxe.requests.FileSystemRequest) VNXeFileSystem(com.emc.storageos.vnxe.models.VNXeFileSystem)

Example 20 with VNXeFileSystem

use of com.emc.storageos.vnxe.models.VNXeFileSystem in project coprhd-controller by CoprHD.

the class VNXeApiClient method removeCifsShare.

/**
 * Delete cifsShare
 *
 * @param cifsShareId
 *            cifsShare Id
 * @param fsId
 *            file system Id
 * @return VNXeCommandJob
 */
public VNXeCommandJob removeCifsShare(String cifsShareId, String fsId) {
    VNXeCommandJob job = null;
    _logger.info("deleting cifs share" + cifsShareId);
    FileSystemRequest fsRequest = new FileSystemRequest(_khClient, fsId);
    VNXeFileSystem fs = fsRequest.get();
    if (fs == null) {
        _logger.info("Could not find file system in the vxne");
        throw VNXeException.exceptions.vnxeCommandFailed("Could not find file system in the vnxe for: " + fsId);
    }
    String resourceId = fs.getStorageResource().getId();
    ModifyFileSystemParam modifyFSParm = new ModifyFileSystemParam();
    // set cifsShare delete parm
    CifsShareDeleteParam deleteParam = new CifsShareDeleteParam();
    VNXeBase share = new VNXeBase();
    share.setId(cifsShareId);
    deleteParam.setCifsShare(share);
    List<CifsShareDeleteParam> deleteList = new ArrayList<CifsShareDeleteParam>();
    deleteList.add(deleteParam);
    modifyFSParm.setCifsShareDelete(deleteList);
    FileSystemActionRequest req = new FileSystemActionRequest(_khClient);
    job = req.modifyFileSystemAsync(modifyFSParm, resourceId);
    return job;
}
Also used : VNXeCommandJob(com.emc.storageos.vnxe.models.VNXeCommandJob) FileSystemRequest(com.emc.storageos.vnxe.requests.FileSystemRequest) VNXeBase(com.emc.storageos.vnxe.models.VNXeBase) CifsShareDeleteParam(com.emc.storageos.vnxe.models.CifsShareDeleteParam) VNXeFileSystem(com.emc.storageos.vnxe.models.VNXeFileSystem) ArrayList(java.util.ArrayList) ModifyFileSystemParam(com.emc.storageos.vnxe.models.ModifyFileSystemParam) FileSystemActionRequest(com.emc.storageos.vnxe.requests.FileSystemActionRequest)

Aggregations

VNXeFileSystem (com.emc.storageos.vnxe.models.VNXeFileSystem)24 VNXeApiClient (com.emc.storageos.vnxe.VNXeApiClient)9 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)7 FileSystemRequest (com.emc.storageos.vnxe.requests.FileSystemRequest)7 StoragePort (com.emc.storageos.db.client.model.StoragePort)6 UnManagedFileSystem (com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedFileSystem)6 VNXeBase (com.emc.storageos.vnxe.models.VNXeBase)6 IOException (java.io.IOException)6 ArrayList (java.util.ArrayList)6 ModifyFileSystemParam (com.emc.storageos.vnxe.models.ModifyFileSystemParam)5 FileSystemActionRequest (com.emc.storageos.vnxe.requests.FileSystemActionRequest)5 VNXeNfsShare (com.emc.storageos.vnxe.models.VNXeNfsShare)4 VNXeCifsShare (com.emc.storageos.vnxe.models.VNXeCifsShare)3 VNXeCommandJob (com.emc.storageos.vnxe.models.VNXeCommandJob)3 AlternateIdConstraint (com.emc.storageos.db.client.constraint.AlternateIdConstraint)2 StoragePool (com.emc.storageos.db.client.model.StoragePool)2 UnManagedCifsShareACL (com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedCifsShareACL)2 UnManagedFileExportRule (com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedFileExportRule)2 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)2 VNXeException (com.emc.storageos.vnxe.VNXeException)2