Search in sources :

Example 6 with VolumeGroupRestRep

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

the class BlockProvider method getRemoveMobilityGroupResources.

@Asset("removeMobilityGroupResource")
@AssetDependencies("mobilityGroup")
public List<AssetOption> getRemoveMobilityGroupResources(AssetOptionsContext ctx, URI mobilityGroupId) {
    final ViPRCoreClient client = api(ctx);
    VolumeGroupRestRep mobilityGroup = client.application().get(mobilityGroupId);
    if (mobilityGroup.getMigrationGroupBy().equals(VolumeGroup.MigrationGroupBy.VOLUMES.name())) {
        return createNamedResourceOptions(client.application().listVolumes(mobilityGroupId));
    } else if (mobilityGroup.getMigrationGroupBy().equals(VolumeGroup.MigrationGroupBy.HOSTS.name())) {
        return createNamedResourceOptions(client.application().getHosts(mobilityGroupId));
    } else if (mobilityGroup.getMigrationGroupBy().equals(VolumeGroup.MigrationGroupBy.CLUSTERS.name())) {
        return createNamedResourceOptions(client.application().getClusters(mobilityGroupId));
    } else {
        return Lists.newArrayList();
    }
}
Also used : ViPRCoreClient(com.emc.vipr.client.ViPRCoreClient) VolumeGroupRestRep(com.emc.storageos.model.application.VolumeGroupRestRep) AssetDependencies(com.emc.sa.asset.annotation.AssetDependencies) Asset(com.emc.sa.asset.annotation.Asset)

Example 7 with VolumeGroupRestRep

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

the class BlockProvider method getApplications.

@Asset("application")
public List<AssetOption> getApplications(AssetOptionsContext ctx) {
    final ViPRCoreClient client = api(ctx);
    List<VolumeGroupRestRep> volumeGroups = client.application().getApplications(new DefaultResourceFilter<VolumeGroupRestRep>() {

        @Override
        public boolean accept(VolumeGroupRestRep volumeGroup) {
            if (volumeGroup.getRoles() != null && volumeGroup.getRoles().contains(VolumeGroup.VolumeGroupRole.COPY.name())) {
                return true;
            } else {
                return false;
            }
        }
    });
    return createBaseResourceOptions(volumeGroups);
}
Also used : ViPRCoreClient(com.emc.vipr.client.ViPRCoreClient) VolumeGroupRestRep(com.emc.storageos.model.application.VolumeGroupRestRep) Asset(com.emc.sa.asset.annotation.Asset)

Example 8 with VolumeGroupRestRep

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

the class BlockProvider method getApplicationSourceVolumes.

@Asset("sourceBlockVolumeForAddToApplication")
@AssetDependencies({ "consistencyGroupAll" })
public List<AssetOption> getApplicationSourceVolumes(AssetOptionsContext ctx, URI cg) {
    final ViPRCoreClient client = api(ctx);
    VolumeGroupList applications = client.application().getApplications();
    List<URI> applicationIds = new ArrayList<URI>();
    for (NamedRelatedResourceRep volumeGroup : applications.getVolumeGroups()) {
        VolumeGroupRestRep vg = client.application().getApplication(volumeGroup.getId());
        if (vg.getRoles().contains("COPY")) {
            applicationIds.add(volumeGroup.getId());
        }
    }
    ResourceFilter<VolumeRestRep> cgFilter = new BlockVolumeConsistencyGroupFilter(cg, false);
    List<ProjectRestRep> projects = api(ctx).projects().getByTenant(ctx.getTenant());
    List<VolumeRestRep> volumes = new ArrayList<VolumeRestRep>();
    for (ProjectRestRep project : projects) {
        volumes.addAll(listSourceVolumes(api(ctx), project.getId(), cgFilter));
    }
    List<VolumeRestRep> volumesNotInApplication = new ArrayList<VolumeRestRep>();
    for (VolumeRestRep volume : volumes) {
        if (volume.getVolumeGroups() != null && !volume.getVolumeGroups().isEmpty()) {
            boolean volumeIsInApplication = false;
            for (RelatedResourceRep rep : volume.getVolumeGroups()) {
                if (applicationIds.contains(rep.getId())) {
                    volumeIsInApplication = true;
                    break;
                }
            }
            if (!volumeIsInApplication) {
                volumesNotInApplication.add(volume);
            }
        } else {
            volumesNotInApplication.add(volume);
        }
    }
    return createVolumeOptions(null, volumesNotInApplication);
}
Also used : ViPRCoreClient(com.emc.vipr.client.ViPRCoreClient) NamedRelatedResourceRep(com.emc.storageos.model.NamedRelatedResourceRep) RelatedResourceRep(com.emc.storageos.model.RelatedResourceRep) VirtualArrayRelatedResourceRep(com.emc.storageos.model.VirtualArrayRelatedResourceRep) ArrayList(java.util.ArrayList) NamedRelatedResourceRep(com.emc.storageos.model.NamedRelatedResourceRep) ProjectRestRep(com.emc.storageos.model.project.ProjectRestRep) URI(java.net.URI) BlockVolumeConsistencyGroupFilter(com.emc.vipr.client.core.filters.BlockVolumeConsistencyGroupFilter) VolumeGroupList(com.emc.storageos.model.application.VolumeGroupList) VolumeGroupRestRep(com.emc.storageos.model.application.VolumeGroupRestRep) VolumeRestRep(com.emc.storageos.model.block.VolumeRestRep) AssetDependencies(com.emc.sa.asset.annotation.AssetDependencies) Asset(com.emc.sa.asset.annotation.Asset)

Example 9 with VolumeGroupRestRep

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

the class BlockProviderUtils method getApplicationReplicationGroupNames.

/**
 * returns the list of application sub groups for an application
 *
 * @param viprClient
 * @param applicationId
 * @return
 */
public static Set<String> getApplicationReplicationGroupNames(ViPRCoreClient viprClient, URI applicationId) {
    VolumeGroupRestRep application = viprClient.application().getApplication(applicationId);
    Set<String> visibleGroups = new HashSet<String>();
    Set<String> groupNames = application.getReplicationGroupNames();
    for (String grp : groupNames) {
        if (!isRPTargetReplicationGroup(grp)) {
            visibleGroups.add(grp);
        }
    }
    return visibleGroups;
}
Also used : VolumeGroupRestRep(com.emc.storageos.model.application.VolumeGroupRestRep) HashSet(java.util.HashSet)

Example 10 with VolumeGroupRestRep

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

the class BlockProvider method getMobilityGroups.

@Asset("mobilityGroup")
public List<AssetOption> getMobilityGroups(AssetOptionsContext ctx) {
    final ViPRCoreClient client = api(ctx);
    List<VolumeGroupRestRep> volumeGroups = client.application().getApplications(new DefaultResourceFilter<VolumeGroupRestRep>() {

        @Override
        public boolean accept(VolumeGroupRestRep volumeGroup) {
            if (volumeGroup.getRoles() != null && volumeGroup.getRoles().contains(VolumeGroup.VolumeGroupRole.MOBILITY.name())) {
                return true;
            } else {
                return false;
            }
        }
    });
    return createBaseResourceOptions(volumeGroups);
}
Also used : ViPRCoreClient(com.emc.vipr.client.ViPRCoreClient) VolumeGroupRestRep(com.emc.storageos.model.application.VolumeGroupRestRep) Asset(com.emc.sa.asset.annotation.Asset)

Aggregations

VolumeGroupRestRep (com.emc.storageos.model.application.VolumeGroupRestRep)15 Asset (com.emc.sa.asset.annotation.Asset)5 ViPRCoreClient (com.emc.vipr.client.ViPRCoreClient)5 URI (java.net.URI)4 AssetDependencies (com.emc.sa.asset.annotation.AssetDependencies)3 NamedRelatedResourceRep (com.emc.storageos.model.NamedRelatedResourceRep)3 RelatedResourceRep (com.emc.storageos.model.RelatedResourceRep)2 VirtualArrayRelatedResourceRep (com.emc.storageos.model.VirtualArrayRelatedResourceRep)2 VolumeGroupList (com.emc.storageos.model.application.VolumeGroupList)2 VolumeRestRep (com.emc.storageos.model.block.VolumeRestRep)2 ArrayList (java.util.ArrayList)2 CreateApplication (com.emc.sa.service.vipr.application.tasks.CreateApplication)1 Volume (com.emc.storageos.db.client.model.Volume)1 VolumeGroup (com.emc.storageos.db.client.model.VolumeGroup)1 NullColumnValueGetter.isNullURI (com.emc.storageos.db.client.util.NullColumnValueGetter.isNullURI)1 SnapshotList (com.emc.storageos.model.SnapshotList)1 BlockSnapshotSessionList (com.emc.storageos.model.block.BlockSnapshotSessionList)1 NamedVolumesList (com.emc.storageos.model.block.NamedVolumesList)1 HostRestRep (com.emc.storageos.model.host.HostRestRep)1 ClusterRestRep (com.emc.storageos.model.host.cluster.ClusterRestRep)1