Search in sources :

Example 31 with HostRestRep

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());
}
Also used : HostRestRep(com.emc.storageos.model.host.HostRestRep) ExportGroupRestRep(com.emc.storageos.model.block.export.ExportGroupRestRep) ITLRestRep(com.emc.storageos.model.block.export.ITLRestRep) URI(java.net.URI) Map(java.util.Map)

Example 32 with HostRestRep

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();
    }
}
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 33 with HostRestRep

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;
}
Also used : HostRestRep(com.emc.storageos.model.host.HostRestRep) AssetOption(com.emc.vipr.model.catalog.AssetOption)

Example 34 with HostRestRep

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;
}
Also used : HostRestRep(com.emc.storageos.model.host.HostRestRep) URI(java.net.URI)

Example 35 with HostRestRep

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;
}
Also used : HostRestRep(com.emc.storageos.model.host.HostRestRep) FindHostsInCluster(com.emc.sa.service.vipr.compute.tasks.FindHostsInCluster)

Aggregations

HostRestRep (com.emc.storageos.model.host.HostRestRep)46 URI (java.net.URI)17 ArrayList (java.util.ArrayList)10 ExecutionException (com.emc.sa.engine.ExecutionException)7 Host (com.emc.storageos.db.client.model.Host)6 ClusterRestRep (com.emc.storageos.model.host.cluster.ClusterRestRep)6 DeactivateHost (com.emc.sa.service.vipr.compute.tasks.DeactivateHost)5 DiscoverHost (com.emc.sa.service.vipr.compute.tasks.DiscoverHost)5 GetHost (com.emc.sa.service.vipr.tasks.GetHost)5 ExportGroupRestRep (com.emc.storageos.model.block.export.ExportGroupRestRep)5 TimeoutException (com.emc.vipr.client.exceptions.TimeoutException)5 ViPRException (com.emc.vipr.client.exceptions.ViPRException)5 HashMap (java.util.HashMap)5 HostUpdateParam (com.emc.storageos.model.host.HostUpdateParam)4 InitiatorRestRep (com.emc.storageos.model.host.InitiatorRestRep)4 Asset (com.emc.sa.asset.annotation.Asset)3 RelatedResourceRep (com.emc.storageos.model.RelatedResourceRep)3 BlockObjectRestRep (com.emc.storageos.model.block.BlockObjectRestRep)3 VcenterDataCenterRestRep (com.emc.storageos.model.host.vcenter.VcenterDataCenterRestRep)3 Task (com.emc.vipr.client.Task)3