Search in sources :

Example 26 with HostRestRep

use of com.emc.storageos.model.host.HostRestRep 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 27 with HostRestRep

use of com.emc.storageos.model.host.HostRestRep 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 28 with HostRestRep

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

the class HostMapper method map.

public static HostRestRep map(Host host, ComputeElement computeElement, UCSServiceProfile serviceProfile, ComputeSystem computeSystem) {
    HostRestRep to = map(host);
    if (computeElement != null) {
        StringBuffer buffer = new StringBuffer();
        if (computeSystem != null) {
            buffer.append(computeSystem.getLabel() + " : ");
        }
        buffer.append(computeElement.getLabel());
        to.setComputeElementName(buffer.toString());
    }
    if (serviceProfile != null) {
        StringBuffer buffer = new StringBuffer();
        if (computeSystem != null) {
            buffer.append(computeSystem.getLabel() + " : ");
        }
        buffer.append(serviceProfile.getLabel());
        to.setServiceProfileName(buffer.toString());
    }
    return to;
}
Also used : HostRestRep(com.emc.storageos.model.host.HostRestRep)

Example 29 with HostRestRep

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

the class Networks method endpointsJson.

/**
 * Creates and renders JSON datatable source for endpoints for the given network.
 *
 * @param networkId
 *            the network ID.
 */
public static void endpointsJson(String networkId) {
    NetworkRestRep network = NetworkUtils.getNetwork(networkId);
    if (network == null) {
        error(MessagesUtils.get(UNKNOWN, networkId));
    }
    List<EndpointInfo> items = Lists.newArrayList();
    // All known endpoints, remove endpoints from storage systems and hosts to get manual endpoints
    Set<String> endpoints = Sets.newTreeSet(new Comparator<String>() {

        @Override
        public int compare(String s1, String s2) {
            return s1.compareToIgnoreCase(s2);
        }
    });
    endpoints.addAll(network.getEndpoints());
    // Add ports from storage systems
    CachedResources<StorageSystemRestRep> storageSystems = StorageSystemUtils.createCache();
    for (StoragePortRestRep storagePort : StoragePortUtils.getStoragePortsByNetwork(network.getId())) {
        items.add(new EndpointInfo(storagePort, storageSystems));
        for (String endpoint : NetworkUtils.getEndPoints(storagePort)) {
            endpoints.remove(endpoint);
        }
    }
    // Add ports from hosts
    CachedResources<HostRestRep> hosts = HostUtils.createCache();
    for (InitiatorRestRep initiator : NetworkUtils.getInitiators(network.getId())) {
        if (initiator.getHost() != null) {
            items.add(new EndpointInfo(initiator, hosts));
            endpoints.remove(NetworkUtils.getEndPoint(initiator));
        }
    }
    for (IpInterfaceRestRep ipInterface : NetworkUtils.getIpInterfaces(network.getId())) {
        if (ipInterface.getHost() != null) {
            items.add(new EndpointInfo(ipInterface, hosts));
            endpoints.remove(NetworkUtils.getEndPoint(ipInterface));
        }
    }
    // Add any remaining endpoints as 'manual'
    for (String endpoint : endpoints) {
        items.add(new EndpointInfo(endpoint));
    }
    setEndpointAttrs(network, items);
    renderJSON(DataTablesSupport.createJSON(items, params));
}
Also used : StorageSystemRestRep(com.emc.storageos.model.systems.StorageSystemRestRep) StoragePortRestRep(com.emc.storageos.model.ports.StoragePortRestRep) InitiatorRestRep(com.emc.storageos.model.host.InitiatorRestRep) IpInterfaceRestRep(com.emc.storageos.model.host.IpInterfaceRestRep) EndpointInfo(models.datatable.NetworkEndpointDataTable.EndpointInfo) HostRestRep(com.emc.storageos.model.host.HostRestRep) NetworkRestRep(com.emc.storageos.model.varray.NetworkRestRep)

Example 30 with HostRestRep

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

the class BlockExportGroups method availableInitiatorsJson.

public static void availableInitiatorsJson(String id) {
    CachedResources<HostRestRep> hosts = HostUtils.createCache();
    List<EndpointInfo> items = Lists.newArrayList();
    for (InitiatorRestRep initiator : getEligibleInitiators(uri(id))) {
        items.add(new EndpointInfo(initiator, hosts));
    }
    renderJSON(DataTablesSupport.createJSON(items, params));
}
Also used : EndpointInfo(models.datatable.NetworkEndpointDataTable.EndpointInfo) HostRestRep(com.emc.storageos.model.host.HostRestRep) InitiatorRestRep(com.emc.storageos.model.host.InitiatorRestRep)

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