Search in sources :

Example 1 with PreferredPoolParam

use of com.emc.storageos.model.host.PreferredPoolParam 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)

Aggregations

StringMap (com.emc.storageos.db.client.model.StringMap)1 RelatedResourceRep (com.emc.storageos.model.RelatedResourceRep)1 HostRestRep (com.emc.storageos.model.host.HostRestRep)1 PreferredPoolParam (com.emc.storageos.model.host.PreferredPoolParam)1 ArrayList (java.util.ArrayList)1 Map (java.util.Map)1