Search in sources :

Example 71 with NamedRelatedResourceRep

use of com.emc.storageos.model.NamedRelatedResourceRep in project coprhd-controller by CoprHD.

the class FileProvider method getFileSystemPolicies.

@Asset("fileSystemPolicies")
@AssetDependencies("fileFilesystemWithPolicies")
public List<AssetOption> getFileSystemPolicies(AssetOptionsContext ctx, URI fsId) {
    List<AssetOption> options = Lists.newArrayList();
    List<FilePolicyRestRep> fileSystemPolicies = getAllFileSystemLevelPolicies(ctx);
    for (FilePolicyRestRep policyRestRep : fileSystemPolicies) {
        // workaround to display policy name in oder receipt: if fsId is null then list all the policy
        if (fsId == null) {
            options.add(new AssetOption(policyRestRep.getId(), policyRestRep.getName()));
        } else if (policyRestRep.getAssignedResources() != null && !policyRestRep.getAssignedResources().isEmpty()) {
            for (NamedRelatedResourceRep resource : policyRestRep.getAssignedResources()) {
                if (resource.getId().equals(fsId)) {
                    options.add(new AssetOption(policyRestRep.getId(), policyRestRep.getName()));
                }
            }
        }
    }
    AssetOptionsUtils.sortOptionsByLabel(options);
    return options;
}
Also used : AssetOption(com.emc.vipr.model.catalog.AssetOption) FilePolicyRestRep(com.emc.storageos.model.file.policy.FilePolicyRestRep) NamedRelatedResourceRep(com.emc.storageos.model.NamedRelatedResourceRep) AssetDependencies(com.emc.sa.asset.annotation.AssetDependencies) Asset(com.emc.sa.asset.annotation.Asset)

Example 72 with NamedRelatedResourceRep

use of com.emc.storageos.model.NamedRelatedResourceRep in project coprhd-controller by CoprHD.

the class FileProvider method getAllFileSystemLevelPolicies.

private List<FilePolicyRestRep> getAllFileSystemLevelPolicies(AssetOptionsContext ctx) {
    ViPRCoreClient client = api(ctx);
    List<FilePolicyRestRep> fileSystemPolicies = new ArrayList<FilePolicyRestRep>();
    FilePolicyListRestRep policies = client.fileProtectionPolicies().listFilePolicies();
    if (policies != null && !policies.getFilePolicies().isEmpty()) {
        for (NamedRelatedResourceRep policy : policies.getFilePolicies()) {
            FilePolicyRestRep policyRestRep = client.fileProtectionPolicies().get(policy.getId());
            if (policyRestRep != null && policyRestRep.getAppliedAt() != null && policyRestRep.getAppliedAt().equalsIgnoreCase("file_system")) {
                fileSystemPolicies.add(policyRestRep);
            }
        }
    }
    return fileSystemPolicies;
}
Also used : ViPRCoreClient(com.emc.vipr.client.ViPRCoreClient) FilePolicyRestRep(com.emc.storageos.model.file.policy.FilePolicyRestRep) ArrayList(java.util.ArrayList) NamedRelatedResourceRep(com.emc.storageos.model.NamedRelatedResourceRep) FilePolicyListRestRep(com.emc.storageos.model.file.policy.FilePolicyListRestRep)

Example 73 with NamedRelatedResourceRep

use of com.emc.storageos.model.NamedRelatedResourceRep in project coprhd-controller by CoprHD.

the class BlockStorageUtils method getReplicationGroupFullCopies.

public static Table<URI, String, VolumeRestRep> getReplicationGroupFullCopies(List<NamedRelatedResourceRep> volumeUris) {
    // Group volumes by storage system and replication group
    Table<URI, String, VolumeRestRep> storageRgToVolumes = HashBasedTable.create();
    List<URI> parentVolIds = Lists.newArrayList();
    for (NamedRelatedResourceRep volumeUri : volumeUris) {
        VolumeRestRep volume = execute(new GetBlockVolume(volumeUri.getId()));
        if (volume != null && volume.getProtection() != null && volume.getProtection().getFullCopyRep() != null && volume.getProtection().getFullCopyRep().getAssociatedSourceVolume() != null) {
            parentVolIds.add(volume.getProtection().getFullCopyRep().getAssociatedSourceVolume().getId());
        }
        List<VolumeRestRep> parentVolumes = execute(new GetBlockVolumes(parentVolIds));
        if (parentVolumes != null && !parentVolumes.isEmpty()) {
            for (VolumeRestRep parentVolume : parentVolumes) {
                String rgName = stripRPTargetFromReplicationGroup(parentVolume.getReplicationGroupInstance());
                URI storage = parentVolume.getStorageController();
                if (!storageRgToVolumes.contains(storage, rgName)) {
                    storageRgToVolumes.put(storage, rgName, volume);
                }
            }
        }
    }
    return storageRgToVolumes;
}
Also used : GetBlockVolume(com.emc.sa.service.vipr.block.tasks.GetBlockVolume) GetBlockVolumes(com.emc.sa.service.vipr.block.tasks.GetBlockVolumes) VolumeRestRep(com.emc.storageos.model.block.VolumeRestRep) NamedRelatedResourceRep(com.emc.storageos.model.NamedRelatedResourceRep) URI(java.net.URI)

Example 74 with NamedRelatedResourceRep

use of com.emc.storageos.model.NamedRelatedResourceRep in project coprhd-controller by CoprHD.

the class CallHomeServiceImpl method toTask.

private TaskResourceRep toTask(Task task) {
    TaskResourceRep taskResourceRep = new TaskResourceRep();
    taskResourceRep.setId(task.getId());
    NamedURI resource = task.getResource();
    NamedRelatedResourceRep namedRelatedResourceRep = new NamedRelatedResourceRep(resource.getURI(), new RestLinkRep("self", URI.create("/" + resource.getURI())), resource.getName());
    taskResourceRep.setResource(namedRelatedResourceRep);
    if (!StringUtils.isBlank(task.getRequestId())) {
        taskResourceRep.setOpId(task.getRequestId());
    }
    // Operation
    taskResourceRep.setState(task.getStatus());
    if (task.getServiceCode() != null) {
        taskResourceRep.setServiceError(toServiceErrorRestRep(toServiceCode(task.getServiceCode()), task.getMessage()));
    } else {
        taskResourceRep.setMessage(task.getMessage());
    }
    taskResourceRep.setDescription(task.getDescription());
    taskResourceRep.setStartTime(task.getStartTime());
    taskResourceRep.setEndTime(task.getEndTime());
    taskResourceRep.setProgress(task.getProgress() != null ? task.getProgress() : 0);
    taskResourceRep.setQueuedStartTime(task.getQueuedStartTime());
    taskResourceRep.setQueueName(task.getQueueName());
    return taskResourceRep;
}
Also used : NamedURI(com.emc.storageos.db.client.model.NamedURI) RestLinkRep(com.emc.storageos.model.RestLinkRep) TaskResourceRep(com.emc.storageos.model.TaskResourceRep) NamedRelatedResourceRep(com.emc.storageos.model.NamedRelatedResourceRep)

Example 75 with NamedRelatedResourceRep

use of com.emc.storageos.model.NamedRelatedResourceRep in project coprhd-controller by CoprHD.

the class GeoMode method setupGeoTenantModeBase.

@BeforeClass
public static void setupGeoTenantModeBase() throws Exception {
    VirtualDataCenters vdcs = superUserClient.vdcs();
    List<NamedRelatedResourceRep> list = vdcs.list();
    for (NamedRelatedResourceRep vdc : list) {
        VirtualDataCenterRestRep restRep = superUserClient.vdcs().get(vdc.getId());
        vdcList.add(restRep);
    }
    if (vdcList.size() < 2) {
        String errorMsg = "env check fail, only one VDC, Geo test need at least 2 vdcs";
        logger.error(errorMsg);
        throw new Exception(errorMsg);
    }
    logger.info("grant " + superUser + " security admin in both VDCs");
    ViPRCoreClient vdc1RootClient = new ViPRCoreClient(getVdcEndpointByIndex(0), true).withLogin("root", rootPassword);
    ViPRClientHelper vdc1Helper = new ViPRClientHelper(vdc1RootClient);
    vdc1Helper.addRoleAssignment(null, superUser, RoleOrAcl.SecurityAdmin.toString());
    vdc1Helper.addRoleAssignment(null, superUser, RoleOrAcl.SystemAdmin.toString());
    vdc1Helper.addRoleAssignment(null, superUser, RoleOrAcl.SystemMonitor.toString());
    vdc1RootClient.auth().logout();
    ViPRCoreClient vdc2RootClient = new ViPRCoreClient(getVdcEndpointByIndex(1), true).withLogin("root", rootPassword);
    ViPRClientHelper vdc2Helper = new ViPRClientHelper(vdc2RootClient);
    vdc2Helper.addRoleAssignment(null, superUser, RoleOrAcl.SecurityAdmin.toString());
    vdc2Helper.addRoleAssignment(null, superUser, RoleOrAcl.SystemAdmin.toString());
    vdc2Helper.addRoleAssignment(null, superUser, RoleOrAcl.SystemMonitor.toString());
    vdc2RootClient.auth().logout();
}
Also used : VirtualDataCenters(com.emc.vipr.client.core.VirtualDataCenters) ViPRCoreClient(com.emc.vipr.client.ViPRCoreClient) VirtualDataCenterRestRep(com.emc.storageos.model.vdc.VirtualDataCenterRestRep) NamedRelatedResourceRep(com.emc.storageos.model.NamedRelatedResourceRep) ViPRClientHelper(com.emc.storageos.usermanagement.util.ViPRClientHelper) BeforeClass(org.junit.BeforeClass)

Aggregations

NamedRelatedResourceRep (com.emc.storageos.model.NamedRelatedResourceRep)111 URI (java.net.URI)47 ArrayList (java.util.ArrayList)28 ViPRCoreClient (com.emc.vipr.client.ViPRCoreClient)22 VolumeRestRep (com.emc.storageos.model.block.VolumeRestRep)18 Asset (com.emc.sa.asset.annotation.Asset)11 AssetDependencies (com.emc.sa.asset.annotation.AssetDependencies)11 AssetOption (com.emc.vipr.model.catalog.AssetOption)9 HashMap (java.util.HashMap)8 GET (javax.ws.rs.GET)8 Produces (javax.ws.rs.Produces)8 NamedVolumesList (com.emc.storageos.model.block.NamedVolumesList)7 Path (javax.ws.rs.Path)7 RelatedResourceRep (com.emc.storageos.model.RelatedResourceRep)6 NamedURI (com.emc.storageos.db.client.model.NamedURI)5 SnapshotList (com.emc.storageos.model.SnapshotList)5 TaskResourceRep (com.emc.storageos.model.TaskResourceRep)5 StorageSystemRestRep (com.emc.storageos.model.systems.StorageSystemRestRep)5 HashSet (java.util.HashSet)5 List (java.util.List)5