use of com.emc.storageos.model.host.HostRestRep in project coprhd-controller by CoprHD.
the class ResourceUtils method getHostExports.
public static List<HostExport> getHostExports(Collection<ITLRestRep> itls) {
Map<URI, HostExport> hostExports = Maps.newLinkedHashMap();
Map<ITLRestRep, ExportGroupRestRep> exportMap = getExportMap(itls);
for (Map.Entry<ITLRestRep, ExportGroupRestRep> entry : exportMap.entrySet()) {
HostRestRep host = getHost(entry.getKey(), entry.getValue());
if (host == null) {
continue;
}
HostExport hostExport = hostExports.get(host.getId());
if (hostExport == null) {
hostExport = createHostExport(host);
hostExports.put(host.getId(), hostExport);
}
hostExport.exportMap.put(entry.getKey(), entry.getValue());
}
return Lists.newArrayList(hostExports.values());
}
use of com.emc.storageos.model.host.HostRestRep 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.HostRestRep in project coprhd-controller by CoprHD.
the class BaseHostProvider method createHostOptions.
protected List<AssetOption> createHostOptions(AssetOptionsContext ctx, Collection<HostRestRep> hosts, Map<URI, String> clusters) {
List<AssetOption> options = Lists.newArrayList();
for (HostRestRep value : hosts) {
options.add(createHostOption(ctx, value, clusters));
}
AssetOptionsUtils.sortOptionsByLabel(options);
return options;
}
use of com.emc.storageos.model.host.HostRestRep in project coprhd-controller by CoprHD.
the class ComputeUtils method getHostURIsByCluster.
public static List<URI> getHostURIsByCluster(ViPRCoreClient client, URI clusterId) {
List<HostRestRep> resp = client.hosts().getByCluster(clusterId);
List<URI> hostURIs = Lists.newArrayList();
for (HostRestRep r : resp) {
hostURIs.add(r.getId());
}
return hostURIs;
}
use of com.emc.storageos.model.host.HostRestRep in project coprhd-controller by CoprHD.
the class ComputeUtils method findHostNamesInCluster.
/**
* Returns list of hostNames already in this cluster
* @param Cluster
* @return list of hostNames
*/
public static List<String> findHostNamesInCluster(Cluster cluster) {
if (cluster == null) {
return Collections.emptyList();
}
List<HostRestRep> hostRestReps = execute(new FindHostsInCluster(cluster.getId(), cluster.getLabel()));
List<String> hostNames = Lists.newArrayList();
if (hostRestReps != null) {
for (HostRestRep hostRestRep : hostRestReps) {
hostNames.add(hostRestRep.getHostName());
}
}
return hostNames;
}
Aggregations