use of com.emc.storageos.model.host.cluster.ClusterRestRep 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.host.cluster.ClusterRestRep in project coprhd-controller by CoprHD.
the class VMWareProvider method listVcentersForCluster.
protected List<VcenterRestRep> listVcentersForCluster(AssetOptionsContext context, URI clusterId) {
ClusterRestRep clusterRestRep = api(context).clusters().get(clusterId);
RelatedResourceRep vcenterDatacenter = clusterRestRep.getVcenterDataCenter();
if (vcenterDatacenter == null) {
// return all vcenters
return api(context).vcenters().getByTenant(context.getTenant(), REGISTERED.and(INCOMPATIBLE.not()));
} else {
// return the vcenter this vipr cluster is already associated with in vcenter
RelatedResourceRep vcenterRelatedRestRep = api(context).vcenterDataCenters().get(vcenterDatacenter.getId()).getVcenter();
VcenterRestRep vcenterRestRep = api(context).vcenters().get(vcenterRelatedRestRep.getId());
return Arrays.asList(vcenterRestRep);
}
}
use of com.emc.storageos.model.host.cluster.ClusterRestRep in project coprhd-controller by CoprHD.
the class ClusterUtils method getClustersExcludingVCenter.
/**
* @return All clusters that are not VCenter clusters
*/
public static List<ClusterRestRep> getClustersExcludingVCenter(String tenantId) {
List<ClusterRestRep> clusterResponses = getClusters(tenantId);
List<ClusterRestRep> clusters = Lists.newArrayList();
for (ClusterRestRep clusterResponse : clusterResponses) {
if (clusterResponse.getVcenterDataCenter() == null) {
clusters.add(clusterResponse);
}
}
return clusters;
}
use of com.emc.storageos.model.host.cluster.ClusterRestRep in project coprhd-controller by CoprHD.
the class ClusterUtils method getClusterOptions.
/**
* Adds a NO CLUSTER option to the list of clusters
*/
public static List<ClusterRestRep> getClusterOptions(String tenantId) {
List<ClusterRestRep> clusters = Lists.newArrayList();
ClusterRestRep clusterRestRep = new ClusterRestRep();
clusterRestRep.setName(MessagesUtils.get("ClusterUtils.defaultName"));
clusterRestRep.setId(uri("null"));
clusters.add(clusterRestRep);
clusters.addAll(getClustersExcludingVCenter(tenantId));
return clusters;
}
use of com.emc.storageos.model.host.cluster.ClusterRestRep in project coprhd-controller by CoprHD.
the class ResourceUtils method createHostExport.
private static HostExport createHostExport(HostRestRep host) {
HostExport hostMapping = new HostExport();
hostMapping.host = host;
if (host.getCluster() != null) {
ClusterRestRep cluster = getViprClient().clusters().get(host.getCluster().getId());
hostMapping.cluster = (cluster != null) ? cluster.getName() : null;
}
return hostMapping;
}
Aggregations