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;
}
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;
}
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;
}
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));
}
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));
}
Aggregations