Search in sources :

Example 11 with VolumeGroupRestRep

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

the class CreateApplicationService method execute.

@Override
public void execute() throws Exception {
    VolumeGroupRestRep application = execute(new CreateApplication(name, description));
    addAffectedResource(application);
}
Also used : CreateApplication(com.emc.sa.service.vipr.application.tasks.CreateApplication) VolumeGroupRestRep(com.emc.storageos.model.application.VolumeGroupRestRep)

Example 12 with VolumeGroupRestRep

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

the class BlockProvider method getAddMobilityGroupResources.

@Asset("addMobilityGroupResource")
@AssetDependencies("mobilityGroup")
public List<AssetOption> getAddMobilityGroupResources(AssetOptionsContext ctx, final URI mobilityGroupId) {
    final ViPRCoreClient client = api(ctx);
    VolumeGroupRestRep mobilityGroup = client.application().get(mobilityGroupId);
    if (mobilityGroup.getMigrationGroupBy().equals(VolumeGroup.MigrationGroupBy.VOLUMES.name())) {
        // VPLEX volumes that don't have reference to this mobility group
        List<URI> volumeIds = client.blockVolumes().listBulkIds();
        final ResourceFilter<VolumeRestRep> vplexFilter = new VplexVolumeFilter();
        List<VolumeRestRep> volumes = client.blockVolumes().getByIds(volumeIds, new ResourceFilter<VolumeRestRep>() {

            @Override
            public boolean acceptId(URI id) {
                return true;
            }

            @Override
            public boolean accept(VolumeRestRep item) {
                boolean accept = (item.getVolumeGroups() == null || !contains(item, mobilityGroupId)) && vplexFilter.accept(item);
                if (accept) {
                    boolean rpProtection = (item.getProtection() != null && item.getProtection().getRpRep() != null && item.getProtection().getRpRep().getPersonality() != null);
                    if (rpProtection) {
                        // If RP+VPLEX protection specified, only allow RP SOURCE volumes to be listed
                        // as candidates for mobility groups. Exclude TARGETs and JOURNALs.
                        String personality = item.getProtection().getRpRep().getPersonality();
                        if (Volume.PersonalityTypes.TARGET.name().equals(personality) || Volume.PersonalityTypes.METADATA.name().equals(personality)) {
                            accept = false;
                        }
                    }
                }
                return accept;
            }

            private boolean contains(VolumeRestRep item, URI mobilityGroup) {
                for (RelatedResourceRep vg : item.getVolumeGroups()) {
                    if (vg.getId().equals(mobilityGroup)) {
                        return true;
                    }
                }
                return false;
            }
        });
        return createBaseResourceOptions(volumes);
    } else if (mobilityGroup.getMigrationGroupBy().equals(VolumeGroup.MigrationGroupBy.HOSTS.name())) {
        List<URI> hostIds = client.hosts().listBulkIds();
        List<HostRestRep> hosts = client.hosts().getByIds(hostIds, new ResourceFilter<HostRestRep>() {

            @Override
            public boolean acceptId(URI id) {
                return true;
            }

            @Override
            public boolean accept(HostRestRep item) {
                return item.getVolumeGroups() == null || !contains(item, mobilityGroupId);
            }

            private boolean contains(HostRestRep item, URI mobilityGroup) {
                for (RelatedResourceRep vg : item.getVolumeGroups()) {
                    if (vg.getId().equals(mobilityGroup)) {
                        return true;
                    }
                }
                return false;
            }
        });
        return createBaseResourceOptions(hosts);
    } else if (mobilityGroup.getMigrationGroupBy().equals(VolumeGroup.MigrationGroupBy.CLUSTERS.name())) {
        List<URI> clusterIds = client.clusters().listBulkIds();
        List<ClusterRestRep> clusters = client.clusters().getByIds(clusterIds, new ResourceFilter<ClusterRestRep>() {

            @Override
            public boolean acceptId(URI id) {
                return true;
            }

            @Override
            public boolean accept(ClusterRestRep item) {
                return item.getVolumeGroups() == null || !contains(item, mobilityGroupId);
            }

            private boolean contains(ClusterRestRep item, URI mobilityGroup) {
                for (RelatedResourceRep vg : item.getVolumeGroups()) {
                    if (vg.getId().equals(mobilityGroup)) {
                        return true;
                    }
                }
                return false;
            }
        });
        return createBaseResourceOptions(clusters);
    } else {
        return Lists.newArrayList();
    }
}
Also used : ClusterRestRep(com.emc.storageos.model.host.cluster.ClusterRestRep) ViPRCoreClient(com.emc.vipr.client.ViPRCoreClient) NamedRelatedResourceRep(com.emc.storageos.model.NamedRelatedResourceRep) RelatedResourceRep(com.emc.storageos.model.RelatedResourceRep) VirtualArrayRelatedResourceRep(com.emc.storageos.model.VirtualArrayRelatedResourceRep) URI(java.net.URI) VplexVolumeFilter(com.emc.vipr.client.core.filters.VplexVolumeFilter) DefaultResourceFilter(com.emc.vipr.client.core.filters.DefaultResourceFilter) ResourceFilter(com.emc.vipr.client.core.filters.ResourceFilter) HostRestRep(com.emc.storageos.model.host.HostRestRep) VolumeGroupRestRep(com.emc.storageos.model.application.VolumeGroupRestRep) StoragePortGroupRestRepList(com.emc.storageos.model.portgroup.StoragePortGroupRestRepList) BlockSnapshotSessionList(com.emc.storageos.model.block.BlockSnapshotSessionList) StoragePortList(com.emc.storageos.model.ports.StoragePortList) ArrayList(java.util.ArrayList) VolumeGroupList(com.emc.storageos.model.application.VolumeGroupList) List(java.util.List) NamedVolumesList(com.emc.storageos.model.block.NamedVolumesList) SnapshotList(com.emc.storageos.model.SnapshotList) VolumeRestRep(com.emc.storageos.model.block.VolumeRestRep) AssetDependencies(com.emc.sa.asset.annotation.AssetDependencies) Asset(com.emc.sa.asset.annotation.Asset)

Example 13 with VolumeGroupRestRep

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

the class BlockApplications method getAssociatedSnapshots.

public static void getAssociatedSnapshots(String id, String snapSet) {
    renderArgs.put("dataTable", new ApplicationSnapshotDataTable());
    VolumeGroupRestRep application = AppSupportUtil.getApplication(id);
    String snapLabel = id + "~~~" + snapSet;
    render(application, snapLabel, snapSet);
}
Also used : ApplicationSnapshotDataTable(models.datatable.ApplicationSnapshotDataTable) VolumeGroupRestRep(com.emc.storageos.model.application.VolumeGroupRestRep)

Example 14 with VolumeGroupRestRep

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

the class VolumeGroupService method getVolumeGroup.

/**
 * List a volume group
 *
 * @param id volume group Id
 * @brief Show details for a volume group
 * @return ApplicationRestRep
 */
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}")
public VolumeGroupRestRep getVolumeGroup(@PathParam("id") URI id) {
    ArgValidator.checkFieldUriType(id, VolumeGroup.class, "id");
    VolumeGroup volumeGroup = (VolumeGroup) queryResource(id);
    StorageOSUser user = getUserFromContext();
    if (!_permissionsHelper.userHasGivenRole(user, null, Role.SYSTEM_MONITOR, Role.TENANT_ADMIN, Role.SECURITY_ADMIN)) {
        // Check if the application tenant is the same as the user tenant
        List<Volume> volumes = ControllerUtils.getVolumeGroupVolumes(_dbClient, volumeGroup);
        if (volumes != null && !volumes.isEmpty()) {
            URI tenant = URI.create(user.getTenantId());
            Volume firstVol = volumes.get(0);
            URI volTenant = firstVol.getTenant().getURI();
            if (!volTenant.equals(tenant)) {
                APIException.forbidden.insufficientPermissionsForUser(user.getName());
            }
        }
    }
    VolumeGroupRestRep resp = DbObjectMapper.map(volumeGroup);
    resp.setReplicationGroupNames(CopyVolumeGroupUtils.getReplicationGroupNames(volumeGroup, _dbClient));
    resp.setVirtualArrays(CopyVolumeGroupUtils.getVirtualArrays(volumeGroup, _dbClient));
    return resp;
}
Also used : Volume(com.emc.storageos.db.client.model.Volume) VolumeGroup(com.emc.storageos.db.client.model.VolumeGroup) StorageOSUser(com.emc.storageos.security.authentication.StorageOSUser) VolumeGroupRestRep(com.emc.storageos.model.application.VolumeGroupRestRep) URI(java.net.URI) NullColumnValueGetter.isNullURI(com.emc.storageos.db.client.util.NullColumnValueGetter.isNullURI) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 15 with VolumeGroupRestRep

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

the class DbObjectMapper method map.

/**
 * Map an VolumeGroup to VolumeGroupRestRep
 *
 * @param from VolumeGroup
 * @return VolumeGroupRestRep
 */
public static VolumeGroupRestRep map(VolumeGroup from) {
    if (from == null) {
        return null;
    }
    VolumeGroupRestRep rep = new VolumeGroupRestRep();
    mapDataObjectFields(from, rep);
    rep.setDescription(from.getDescription());
    rep.setRoles(from.getRoles());
    rep.setParent(toRelatedResource(ResourceTypeEnum.VOLUME_GROUP, from.getParent()));
    rep.setMigrationGroupBy(from.getMigrationGroupBy());
    rep.setMigrationType(from.getMigrationType());
    return rep;
}
Also used : VolumeGroupRestRep(com.emc.storageos.model.application.VolumeGroupRestRep)

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