Search in sources :

Example 6 with StoragePolicy

use of com.epam.pipeline.entity.datastorage.StoragePolicy in project cloud-pipeline by epam.

the class DataStorageDaoTest method setUp.

@Before
public void setUp() {
    testFolder = buildFolder(null);
    awsRegion = new AwsRegion();
    awsRegion.setName("Default");
    awsRegion.setDefault(true);
    awsRegion.setAwsRegionName("us-east-1");
    awsRegionDao.create(awsRegion);
    s3Bucket = new S3bucketDataStorage(null, TEST_STORAGE_NAME, TEST_STORAGE_PATH);
    s3Bucket.setDescription("testDescription");
    s3Bucket.setParentFolderId(testFolder.getId());
    s3Bucket.setRegionId(awsRegion.getId());
    s3Bucket.setOwner(TEST_OWNER);
    s3Bucket.setMountPoint("testMountPoint");
    s3Bucket.setMountOptions("testMountOptions");
    s3Bucket.setShared(true);
    s3Bucket.setAllowedCidrs(Arrays.asList("test1", "test2"));
    policy = new StoragePolicy();
    policy.setBackupDuration(BACKUP_DURATION);
    policy.setLongTermStorageDuration(LTS_DURATION);
    policy.setShortTermStorageDuration(STS_DURATION);
    policy.setVersioningEnabled(true);
    s3Bucket.setStoragePolicy(policy);
    nfsStorage = new NFSDataStorage(null, "NFS_STORAGE", "nfs_path");
    nfsStorage.setOwner(TEST_OWNER);
    nfsStorage.setDescription("NFS");
    nfsStorage.setParentFolderId(testFolder.getId());
    nfsStorage.setMountOptions("-s");
    nfsStorage.setMountPoint("nfs");
}
Also used : AwsRegion(com.epam.pipeline.entity.region.AwsRegion) NFSDataStorage(com.epam.pipeline.entity.datastorage.nfs.NFSDataStorage) S3bucketDataStorage(com.epam.pipeline.entity.datastorage.aws.S3bucketDataStorage) StoragePolicy(com.epam.pipeline.entity.datastorage.StoragePolicy) Before(org.junit.Before)

Example 7 with StoragePolicy

use of com.epam.pipeline.entity.datastorage.StoragePolicy in project cloud-pipeline by epam.

the class ObjectCreatorUtils method constructDataStorageVO.

public static DataStorageVO constructDataStorageVO(String name, String description, DataStorageType storageType, String path, Integer stsDuration, Integer ltsDuration, Long parentFolderId, String mountPoint, String mountOptions) {
    DataStorageVO storageVO = constructDataStorageVO(name, description, storageType, path, parentFolderId, mountPoint, mountOptions);
    StoragePolicy policy = new StoragePolicy();
    if (stsDuration != null) {
        policy.setShortTermStorageDuration(stsDuration);
    }
    if (ltsDuration != null) {
        policy.setLongTermStorageDuration(ltsDuration);
    }
    storageVO.setStoragePolicy(policy);
    return storageVO;
}
Also used : DataStorageVO(com.epam.pipeline.controller.vo.DataStorageVO) StoragePolicy(com.epam.pipeline.entity.datastorage.StoragePolicy)

Example 8 with StoragePolicy

use of com.epam.pipeline.entity.datastorage.StoragePolicy in project cloud-pipeline by epam.

the class DataStorageManagerTest method compareDataStorage.

private void compareDataStorage(AbstractDataStorage saved, AbstractDataStorage loaded) {
    Assert.assertNotNull(loaded);
    Assert.assertEquals(saved.getName(), loaded.getName());
    Assert.assertEquals(saved.getDescription(), loaded.getDescription());
    StoragePolicy savedStoragePolicy = saved.getStoragePolicy();
    StoragePolicy loadedStoragePolicy = loaded.getStoragePolicy();
    Assert.assertEquals(savedStoragePolicy.getShortTermStorageDuration(), loadedStoragePolicy.getShortTermStorageDuration());
    Assert.assertEquals(savedStoragePolicy.getLongTermStorageDuration(), loadedStoragePolicy.getLongTermStorageDuration());
    Assert.assertEquals(saved.getType(), loaded.getType());
}
Also used : StoragePolicy(com.epam.pipeline.entity.datastorage.StoragePolicy)

Example 9 with StoragePolicy

use of com.epam.pipeline.entity.datastorage.StoragePolicy in project cloud-pipeline by epam.

the class FolderManagerTest method shouldCloneFolderWithDataStorages.

@Test
@Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Exception.class)
public void shouldCloneFolderWithDataStorages() {
    Folder sourceFolder = new Folder();
    sourceFolder.setName(FOLDER_TO_CLONE);
    folderManager.create(sourceFolder);
    DataStorageVO dataStorageVO = constructDataStorageVO(TEST_NAME, TEST_DESCRIPTION, DataStorageType.S3, TEST_PATH, STS_DURATION, LTS_DURATION, sourceFolder.getId(), TEST_MOUNT_POINT, TEST_MOUNT_OPTIONS);
    StoragePolicy storagePolicy = dataStorageVO.getStoragePolicy();
    storagePolicy.setBackupDuration(BACKUP_DURATION);
    dataStorageVO.setStoragePolicy(storagePolicy);
    AbstractDataStorage expectedDataStorage = dataStorageManager.create(dataStorageVO, true, true, false);
    Folder childSourceFolder = new Folder();
    childSourceFolder.setName(CHILD_FOLDER_TO_CLONE);
    childSourceFolder.setParentId(sourceFolder.getId());
    folderManager.create(childSourceFolder);
    dataStorageVO.setParentFolderId(childSourceFolder.getId());
    dataStorageVO.setName(TEST_NAME_1);
    dataStorageVO.setPath(TEST_NAME_1);
    dataStorageManager.create(dataStorageVO, true, true, false);
    Folder destinationFolder = new Folder();
    destinationFolder.setName(TEST_NAME);
    folderManager.create(destinationFolder);
    folderManager.cloneFolder(sourceFolder.getId(), destinationFolder.getId(), TEST_CLONE_PREFIX);
    destinationFolder = folderManager.loadByNameOrId(TEST_NAME);
    destinationFolder = folderManager.load(destinationFolder.getId());
    Folder clonedFolder = destinationFolder.getChildFolders().get(0);
    AbstractDataStorage clonedDataStorage = clonedFolder.getStorages().get(0);
    clonedDataStorage = dataStorageManager.load(clonedDataStorage.getId());
    assertTrue(clonedDataStorage.getName().startsWith(TEST_CLONE_PREFIX + storageSuffix));
    assertTrue(clonedDataStorage.getPath().startsWith((TEST_CLONE_PREFIX + storageSuffix).toLowerCase()));
    assertDataStorages(expectedDataStorage, clonedDataStorage);
    Folder clonedChildFolder = clonedFolder.getChildFolders().get(0);
    clonedDataStorage = clonedChildFolder.getStorages().get(0);
    clonedDataStorage = dataStorageManager.load(clonedDataStorage.getId());
    assertTrue(clonedDataStorage.getName().startsWith(TEST_CLONE_PREFIX + storageSuffix));
    assertTrue(clonedDataStorage.getPath().startsWith((TEST_CLONE_PREFIX + storageSuffix).toLowerCase()));
    assertDataStorages(expectedDataStorage, clonedDataStorage);
}
Also used : AbstractDataStorage(com.epam.pipeline.entity.datastorage.AbstractDataStorage) DataStorageVO(com.epam.pipeline.controller.vo.DataStorageVO) ObjectCreatorUtils.constructDataStorageVO(com.epam.pipeline.manager.ObjectCreatorUtils.constructDataStorageVO) StoragePolicy(com.epam.pipeline.entity.datastorage.StoragePolicy) Folder(com.epam.pipeline.entity.pipeline.Folder) AbstractSpringTest(com.epam.pipeline.AbstractSpringTest) Test(org.junit.Test) Transactional(org.springframework.transaction.annotation.Transactional)

Example 10 with StoragePolicy

use of com.epam.pipeline.entity.datastorage.StoragePolicy in project cloud-pipeline by epam.

the class DataStorageMapper method map.

@Override
public XContentBuilder map(final EntityContainer<DataStorageDoc> doc) {
    try (XContentBuilder jsonBuilder = XContentFactory.jsonBuilder()) {
        AbstractDataStorage storage = doc.getEntity().getStorage();
        jsonBuilder.startObject().field(DOC_TYPE_FIELD, documentType.name()).field("id", storage.getId()).field("parentId", storage.getParentFolderId()).field("name", storage.getName()).field("path", storage.getPath()).field("createdDate", parseDataToString(storage.getCreatedDate())).field("description", storage.getDescription()).field("storageType", storage.getType()).field("awsRegion", doc.getEntity().getRegionName());
        StoragePolicy storagePolicy = storage.getStoragePolicy();
        if (storagePolicy != null) {
            jsonBuilder.field("storagePolicyBackupDuration", storagePolicy.getBackupDuration()).field("storagePolicyLongTermStorageDuration", storagePolicy.getLongTermStorageDuration()).field("storagePolicyShortTermStorageDuration", storagePolicy.getShortTermStorageDuration()).field("storagePolicyVersioningEnabled", storagePolicy.getVersioningEnabled());
        }
        buildUserContent(doc.getOwner(), jsonBuilder);
        buildMetadata(doc.getMetadata(), jsonBuilder);
        buildPermissions(doc.getPermissions(), jsonBuilder);
        jsonBuilder.endObject();
        return jsonBuilder;
    } catch (IOException e) {
        throw new IllegalArgumentException("An error occurred while creating document: ", e);
    }
}
Also used : AbstractDataStorage(com.epam.pipeline.entity.datastorage.AbstractDataStorage) StoragePolicy(com.epam.pipeline.entity.datastorage.StoragePolicy) IOException(java.io.IOException) XContentBuilder(org.elasticsearch.common.xcontent.XContentBuilder)

Aggregations

StoragePolicy (com.epam.pipeline.entity.datastorage.StoragePolicy)10 AbstractDataStorage (com.epam.pipeline.entity.datastorage.AbstractDataStorage)4 DataStorageVO (com.epam.pipeline.controller.vo.DataStorageVO)2 DataStorageDoc (com.epam.pipeline.elasticsearchagent.model.DataStorageDoc)2 S3bucketDataStorage (com.epam.pipeline.entity.datastorage.S3bucketDataStorage)2 XContentBuilder (org.elasticsearch.common.xcontent.XContentBuilder)2 Test (org.junit.jupiter.api.Test)2 AbstractSpringTest (com.epam.pipeline.AbstractSpringTest)1 TaskGraphVO (com.epam.pipeline.controller.vo.TaskGraphVO)1 EntityContainer (com.epam.pipeline.elasticsearchagent.model.EntityContainer)1 S3bucketDataStorage (com.epam.pipeline.entity.datastorage.aws.S3bucketDataStorage)1 NFSDataStorage (com.epam.pipeline.entity.datastorage.nfs.NFSDataStorage)1 DataStorageRule (com.epam.pipeline.entity.datastorage.rules.DataStorageRule)1 GitRepositoryEntry (com.epam.pipeline.entity.git.GitRepositoryEntry)1 TaskNode (com.epam.pipeline.entity.graph.TaskNode)1 Folder (com.epam.pipeline.entity.pipeline.Folder)1 Pipeline (com.epam.pipeline.entity.pipeline.Pipeline)1 Revision (com.epam.pipeline.entity.pipeline.Revision)1 Tool (com.epam.pipeline.entity.pipeline.Tool)1 AwsRegion (com.epam.pipeline.entity.region.AwsRegion)1