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);
}
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();
}
}
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);
}
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;
}
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;
}
Aggregations