Search in sources :

Example 36 with RelatedResourceRep

use of com.emc.storageos.model.RelatedResourceRep in project coprhd-controller by CoprHD.

the class ComputeVirtualPools method getByVirtualArray.

/**
 * Gets the compute virtual pools that are associated with the given virtual array and specific tenant.
 *
 * @param varrayId
 *            the ID of the virtual array.
 * @param tenantId
 *            the ID of the tenant.
 * @param filter
 *            the resource filter to apply to the results as they are returned (optional).
 *
 * @return the list of compute virtual pools.
 */
public List<ComputeVirtualPoolRestRep> getByVirtualArray(URI varrayId, URI tenantId, ResourceFilter<ComputeVirtualPoolRestRep> filter) {
    List<ComputeVirtualPoolRestRep> allPools = null;
    if (tenantId == null) {
        allPools = getAll(filter);
    } else {
        allPools = getByTenant(tenantId, filter);
    }
    // filter by varray
    List<ComputeVirtualPoolRestRep> poolsByArray = new ArrayList();
    for (ComputeVirtualPoolRestRep poolRep : allPools) {
        for (RelatedResourceRep resourceRep : poolRep.getVirtualArrays()) {
            if (resourceRep.getId().toString().equals(varrayId.toString())) {
                poolsByArray.add(poolRep);
            }
        }
    }
    return poolsByArray;
}
Also used : RelatedResourceRep(com.emc.storageos.model.RelatedResourceRep) NamedRelatedResourceRep(com.emc.storageos.model.NamedRelatedResourceRep) ArrayList(java.util.ArrayList)

Example 37 with RelatedResourceRep

use of com.emc.storageos.model.RelatedResourceRep in project coprhd-controller by CoprHD.

the class HostService method findComputeElementsUsedInCluster.

private Map<URI, List<ComputeElement>> findComputeElementsUsedInCluster(URI clusterId) throws DatabaseException {
    Map<URI, List<ComputeElement>> computeSystemToComputeElementMap = new HashMap<URI, List<ComputeElement>>();
    HostList hostList = clusterService.getClusterHosts(clusterId);
    List<NamedRelatedResourceRep> list = hostList.getHosts();
    for (NamedRelatedResourceRep hostRep : list) {
        HostRestRep host = getHost(hostRep.getId());
        RelatedResourceRep computeElement = host.getComputeElement();
        if (computeElement == null) {
            // this can happen if cluster has hosts that were not provisioned by vipr
            continue;
        }
        ComputeElement ce = _dbClient.queryObject(ComputeElement.class, computeElement.getId());
        URI computeSystem = ce.getComputeSystem();
        List<ComputeElement> usedComputeElements;
        if (computeSystemToComputeElementMap.containsKey(computeSystem)) {
            usedComputeElements = computeSystemToComputeElementMap.get(computeSystem);
        } else {
            usedComputeElements = new ArrayList<ComputeElement>();
        }
        usedComputeElements.add(ce);
        computeSystemToComputeElementMap.put(computeSystem, usedComputeElements);
    }
    return computeSystemToComputeElementMap;
}
Also used : HostRestRep(com.emc.storageos.model.host.HostRestRep) NamedRelatedResourceRep(com.emc.storageos.model.NamedRelatedResourceRep) RelatedResourceRep(com.emc.storageos.model.RelatedResourceRep) LinkedHashMap(java.util.LinkedHashMap) HashMap(java.util.HashMap) ComputeElement(com.emc.storageos.db.client.model.ComputeElement) UnManagedExportMaskList(com.emc.storageos.model.block.UnManagedExportMaskList) UnManagedVolumeList(com.emc.storageos.model.block.UnManagedVolumeList) NamedElementQueryResultList(com.emc.storageos.db.client.constraint.NamedElementQueryResultList) InitiatorList(com.emc.storageos.model.host.InitiatorList) ArrayList(java.util.ArrayList) TaskList(com.emc.storageos.model.TaskList) MountInfoList(com.emc.storageos.model.file.MountInfoList) HostList(com.emc.storageos.model.host.HostList) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) List(java.util.List) BulkList(com.emc.storageos.api.service.impl.response.BulkList) LinkedList(java.util.LinkedList) IpInterfaceList(com.emc.storageos.model.host.IpInterfaceList) HostList(com.emc.storageos.model.host.HostList) NamedRelatedResourceRep(com.emc.storageos.model.NamedRelatedResourceRep) URI(java.net.URI)

Example 38 with RelatedResourceRep

use of com.emc.storageos.model.RelatedResourceRep in project coprhd-controller by CoprHD.

the class ApiTest method updateAllVnxAndVmaxPorts.

/**
 * Update the discovered VNX/VMAX storage ports to set the transport zone.
 *
 * @param provider : Provider.
 */
private void updateAllVnxAndVmaxPorts(SMISProviderRestRep provider) {
    StorageSystemList systemList = rZAdmin.path("/vdc/storage-systems").get(StorageSystemList.class);
    for (RelatedResourceRep resRep : systemList.getStorageSystems()) {
        StorageSystemRestRep system = rZAdmin.path(String.format("/vdc/storage-systems/%s", resRep.getId()).toString()).get(StorageSystemRestRep.class);
        if (system.getSystemType().equals(Type.vnxblock.toString()) || system.getSystemType().equals(Type.vmax.toString())) {
            // Register all the discovered storage ports .
            StoragePortList vnxBlockPortList = rZAdmin.path(String.format("/vdc/storage-systems/%s/storage-ports", system.getId()).toString()).get(StoragePortList.class);
            List<NamedRelatedResourceRep> vnxBlockPortURIList = vnxBlockPortList.getPorts();
            for (RelatedResourceRep portURI : vnxBlockPortURIList) {
                updateStoragePortTZ(resRep.getId(), portURI);
            }
        }
    }
}
Also used : StorageSystemList(com.emc.storageos.model.systems.StorageSystemList) NamedRelatedResourceRep(com.emc.storageos.model.NamedRelatedResourceRep) RelatedResourceRep(com.emc.storageos.model.RelatedResourceRep) StorageSystemRestRep(com.emc.storageos.model.systems.StorageSystemRestRep) StoragePortList(com.emc.storageos.model.ports.StoragePortList) NamedRelatedResourceRep(com.emc.storageos.model.NamedRelatedResourceRep)

Example 39 with RelatedResourceRep

use of com.emc.storageos.model.RelatedResourceRep in project coprhd-controller by CoprHD.

the class HostMapper method map.

public static HostRestRep map(Host from) {
    if (from == null) {
        return null;
    }
    HostRestRep to = new HostRestRep();
    mapDiscoveredSystemObjectFields(from, to);
    to.setHostName(from.getHostName());
    to.setType(from.getType());
    to.setUsername(from.getUsername());
    to.setPortNumber(from.getPortNumber());
    to.setOsVersion(from.getOsVersion());
    to.setUseSsl(from.getUseSSL());
    to.setCluster(toRelatedResource(ResourceTypeEnum.CLUSTER, from.getCluster()));
    to.setProject(toRelatedResource(ResourceTypeEnum.PROJECT, from.getProject()));
    to.setComputeElement(toRelatedResource(ResourceTypeEnum.COMPUTE_ELEMENT, from.getComputeElement()));
    to.setvCenterDataCenter(toRelatedResource(ResourceTypeEnum.VCENTERDATACENTER, from.getVcenterDataCenter()));
    if ((from.getVolumeGroupIds() != null) && (!from.getVolumeGroupIds().isEmpty())) {
        List<RelatedResourceRep> volumeGroups = new ArrayList<RelatedResourceRep>();
        for (String volumeGroup : from.getVolumeGroupIds()) {
            volumeGroups.add(toRelatedResource(ResourceTypeEnum.VOLUME_GROUP, URI.create(volumeGroup)));
        }
        to.setVolumeGroups(volumeGroups);
    }
    StringMap pools = from.getPreferredPools();
    if (pools != null && !pools.isEmpty()) {
        for (Map.Entry<String, String> entry : pools.entrySet()) {
            RelatedResourceRep poolRep = toRelatedResource(ResourceTypeEnum.STORAGE_POOL, URI.create(entry.getKey()));
            PreferredPoolParam pool = new PreferredPoolParam(poolRep, entry.getValue());
            to.getPreferredPools().add(pool);
        }
    }
    to.setTenant(toRelatedResource(ResourceTypeEnum.TENANT, from.getTenant()));
    to.setDiscoverable(from.getDiscoverable());
    to.setBootVolume(toRelatedResource(ResourceTypeEnum.VOLUME, from.getBootVolumeId()));
    if (from.getDiscoverable() != null && from.getDiscoverable() == false) {
        to.setProvisioningJobStatus(from.getProvisioningStatus());
    }
    return to;
}
Also used : HostRestRep(com.emc.storageos.model.host.HostRestRep) StringMap(com.emc.storageos.db.client.model.StringMap) RelatedResourceRep(com.emc.storageos.model.RelatedResourceRep) ArrayList(java.util.ArrayList) Map(java.util.Map) StringMap(com.emc.storageos.db.client.model.StringMap) PreferredPoolParam(com.emc.storageos.model.host.PreferredPoolParam)

Example 40 with RelatedResourceRep

use of com.emc.storageos.model.RelatedResourceRep in project coprhd-controller by CoprHD.

the class HostMapper method map.

public static ClusterRestRep map(Cluster from) {
    if (from == null) {
        return null;
    }
    ClusterRestRep to = new ClusterRestRep();
    mapTenantResource(from, to);
    to.setProject(toRelatedResource(ResourceTypeEnum.PROJECT, from.getProject()));
    to.setVcenterDataCenter(toRelatedResource(ResourceTypeEnum.VCENTERDATACENTER, from.getVcenterDataCenter()));
    to.setAutoExportEnabled(from.getAutoExportEnabled());
    if ((from.getVolumeGroupIds() != null) && (!from.getVolumeGroupIds().isEmpty())) {
        List<RelatedResourceRep> volumeGroups = new ArrayList<RelatedResourceRep>();
        for (String volumeGroup : from.getVolumeGroupIds()) {
            volumeGroups.add(toRelatedResource(ResourceTypeEnum.VOLUME_GROUP, URI.create(volumeGroup)));
        }
        to.setVolumeGroups(volumeGroups);
    }
    return to;
}
Also used : ClusterRestRep(com.emc.storageos.model.host.cluster.ClusterRestRep) RelatedResourceRep(com.emc.storageos.model.RelatedResourceRep) ArrayList(java.util.ArrayList)

Aggregations

RelatedResourceRep (com.emc.storageos.model.RelatedResourceRep)41 NamedRelatedResourceRep (com.emc.storageos.model.NamedRelatedResourceRep)25 ArrayList (java.util.ArrayList)19 VirtualArrayRelatedResourceRep (com.emc.storageos.model.VirtualArrayRelatedResourceRep)14 URI (java.net.URI)12 Asset (com.emc.sa.asset.annotation.Asset)8 ViPRCoreClient (com.emc.vipr.client.ViPRCoreClient)8 AssetDependencies (com.emc.sa.asset.annotation.AssetDependencies)7 VolumeRestRep (com.emc.storageos.model.block.VolumeRestRep)7 BlockSnapshotRestRep (com.emc.storageos.model.block.BlockSnapshotRestRep)5 BlockSnapshotSessionRestRep (com.emc.storageos.model.block.BlockSnapshotSessionRestRep)5 ClusterRestRep (com.emc.storageos.model.host.cluster.ClusterRestRep)5 BlockSnapshotSessionList (com.emc.storageos.model.block.BlockSnapshotSessionList)4 StoragePortList (com.emc.storageos.model.ports.StoragePortList)4 VirtualArrayRestRep (com.emc.storageos.model.varray.VirtualArrayRestRep)4 AssetOption (com.emc.vipr.model.catalog.AssetOption)4 HashMap (java.util.HashMap)4 HashSet (java.util.HashSet)4 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)3 VolumeGroupList (com.emc.storageos.model.application.VolumeGroupList)3