Search in sources :

Example 16 with ClusterRestRep

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();
    }
}
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 17 with ClusterRestRep

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);
    }
}
Also used : ClusterRestRep(com.emc.storageos.model.host.cluster.ClusterRestRep) RelatedResourceRep(com.emc.storageos.model.RelatedResourceRep) VcenterRestRep(com.emc.storageos.model.host.vcenter.VcenterRestRep)

Example 18 with ClusterRestRep

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;
}
Also used : ClusterRestRep(com.emc.storageos.model.host.cluster.ClusterRestRep)

Example 19 with ClusterRestRep

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;
}
Also used : ClusterRestRep(com.emc.storageos.model.host.cluster.ClusterRestRep)

Example 20 with ClusterRestRep

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;
}
Also used : ClusterRestRep(com.emc.storageos.model.host.cluster.ClusterRestRep)

Aggregations

ClusterRestRep (com.emc.storageos.model.host.cluster.ClusterRestRep)23 HostRestRep (com.emc.storageos.model.host.HostRestRep)7 Asset (com.emc.sa.asset.annotation.Asset)6 AssetOption (com.emc.vipr.model.catalog.AssetOption)6 URI (java.net.URI)6 RelatedResourceRep (com.emc.storageos.model.RelatedResourceRep)5 VcenterDataCenterRestRep (com.emc.storageos.model.host.vcenter.VcenterDataCenterRestRep)4 VcenterRestRep (com.emc.storageos.model.host.vcenter.VcenterRestRep)4 DefaultResourceFilter (com.emc.vipr.client.core.filters.DefaultResourceFilter)3 ProjectRestRep (com.emc.storageos.model.project.ProjectRestRep)2 FlashException (controllers.util.FlashException)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 AssetDependencies (com.emc.sa.asset.annotation.AssetDependencies)1 Vcenter (com.emc.storageos.db.client.model.Vcenter)1 VcenterDataCenter (com.emc.storageos.db.client.model.VcenterDataCenter)1 NamedRelatedResourceRep (com.emc.storageos.model.NamedRelatedResourceRep)1 SnapshotList (com.emc.storageos.model.SnapshotList)1 VirtualArrayRelatedResourceRep (com.emc.storageos.model.VirtualArrayRelatedResourceRep)1 VolumeGroupList (com.emc.storageos.model.application.VolumeGroupList)1