use of com.emc.storageos.db.client.model.Host in project coprhd-controller by CoprHD.
the class UcsComputeDevice method persistServiceProfileForHost.
private UCSServiceProfile persistServiceProfileForHost(LsServer lsServer, ComputeSystem cs, URI hostId) {
Host host = _dbClient.queryObject(Host.class, hostId);
if (host == null) {
LOGGER.error("Host not found for URI:" + hostId.toString());
throw ComputeSystemControllerException.exceptions.hostNotFound(hostId.toString());
}
UCSServiceProfile serviceProfile = new UCSServiceProfile();
URI uri = URIUtil.createId(UCSServiceProfile.class);
serviceProfile.setComputeSystem(cs.getId());
serviceProfile.setInactive(false);
serviceProfile.setId(uri);
serviceProfile.setSystemType(cs.getSystemType());
serviceProfile.setCreationTime(Calendar.getInstance());
serviceProfile.setDn(lsServer.getDn());
serviceProfile.setLabel(lsServer.getName());
serviceProfile.setUuid(lsServer.getUuid());
serviceProfile.setNativeGuid(NativeGUIDGenerator.generateNativeGuid(cs, serviceProfile));
serviceProfile.setHost(hostId);
_dbClient.createObject(serviceProfile);
host.setServiceProfile(serviceProfile.getId());
_dbClient.updateObject(host);
return serviceProfile;
}
use of com.emc.storageos.db.client.model.Host in project coprhd-controller by CoprHD.
the class UcsComputeDevice method getHBAToStoragePorts.
private Map<String, Map<String, Integer>> getHBAToStoragePorts(URI volumeId, URI hostId) {
Host host = _dbClient.queryObject(Host.class, hostId);
Map<String, String> initiatorToHBAMapping = getInitiatorToHBAMapping(host.getComputeElement());
Volume volume = _dbClient.queryObject(Volume.class, volumeId);
List<Initiator> initiators = CustomQueryUtility.queryActiveResourcesByRelation(_dbClient, hostId, Initiator.class, "host");
Map<ExportMask, ExportGroup> exportMasks = ExportUtils.getExportMasks(volume, _dbClient);
Map<String, Map<String, Integer>> hbaToStoragePortMapForBoot = new HashMap<String, Map<String, Integer>>();
for (Initiator initiator : initiators) {
for (ExportMask exportMask : exportMasks.keySet()) {
List<URI> storagePorts = ExportUtils.getInitiatorPortsInMask(exportMask, initiator, _dbClient);
if (storagePorts != null && !storagePorts.isEmpty()) {
Integer volumeHLU = Integer.valueOf(exportMask.getVolumes().get(volumeId.toString()));
for (URI storagePortUri : storagePorts) {
StoragePort port = _dbClient.queryObject(StoragePort.class, storagePortUri);
String hbaName = initiatorToHBAMapping.get(initiator.getInitiatorPort());
if (hbaName != null) {
if (hbaToStoragePortMapForBoot.get(hbaName) == null) {
hbaToStoragePortMapForBoot.put(hbaName, new HashMap<String, Integer>());
}
hbaToStoragePortMapForBoot.get(hbaName).put(port.getPortNetworkId(), volumeHLU);
}
}
}
}
}
return hbaToStoragePortMapForBoot;
}
use of com.emc.storageos.db.client.model.Host in project coprhd-controller by CoprHD.
the class UcsComputeDevice method validateNewServiceProfile.
private void validateNewServiceProfile(ComputeSystem cs, UCSServiceProfile serviceProfile, Host newHost) {
Collection<URI> allHostUris = _dbClient.queryByType(Host.class, true);
Collection<Host> hosts = _dbClient.queryObjectFields(Host.class, Arrays.asList("uuid", "label", "computeElement", "registrationStatus", "inactive"), ControllerUtils.getFullyImplementedCollection(allHostUris));
for (Host host : hosts) {
if (host.getUuid() != null && host.getUuid().equals(serviceProfile.getUuid()) && !host.getId().equals(newHost.getId()) && (host.getInactive() != true)) {
LOGGER.error("Newly created service profile :" + serviceProfile.getLabel() + " shares same uuid " + serviceProfile.getUuid() + " as existing active host: " + host.getLabel());
throw ComputeSystemControllerException.exceptions.newServiceProfileDuplicateUuid(serviceProfile.getLabel(), serviceProfile.getUuid(), host.getLabel());
}
}
}
use of com.emc.storageos.db.client.model.Host in project coprhd-controller by CoprHD.
the class VolumeGroupService method getHosts.
/**
* Get application hosts
*
* @param id Application Id
* @brief List hosts for an application
* @return HostList
*/
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}/hosts")
public HostList getHosts(@PathParam("id") URI id) {
ArgValidator.checkFieldUriType(id, VolumeGroup.class, "id");
VolumeGroup volumeGroup = _dbClient.queryObject(VolumeGroup.class, id);
HostList result = new HostList();
List<Host> hosts = getVolumeGroupHosts(_dbClient, volumeGroup);
for (Host host : hosts) {
result.getHosts().add(toNamedRelatedResource(host));
}
return result;
}
use of com.emc.storageos.db.client.model.Host in project coprhd-controller by CoprHD.
the class VplexExportGroupServiceApiImpl method validateVarrayStoragePorts.
/**
* Validate varray ports during Export Group Create. If varray
* contains ports from both Vplex Cluster 1 and Cluster 2 thats an invalid
* network configuration. It could be one or more network within a varray.
* If initiators of a host are in two networks then vplex storage ports from
* both networks are taken into account to check if ports belong to both
* Vplex Cluster 1 and Cluster 2.
*
* @param storageSystemURIs vplex storageSystem URIs
* @param varray source VirtualArray
* @param allHosts
* @throws InternalException
*/
@Override
public void validateVarrayStoragePorts(Set<URI> storageSystemURIs, VirtualArray varray, List<URI> allHosts) throws InternalException {
try {
// Get VirtualArray Storage ports by Network.
Map<Network, Set<StoragePort>> networkToPortsMap = getVirtualArrayTaggedPortsByNework(varray.getId());
Map<URI, Set<URI>> vplexCluster1ports = new HashMap<URI, Set<URI>>();
Map<URI, Set<URI>> vplexCluster2ports = new HashMap<URI, Set<URI>>();
Map<URI, StorageSystem> storageSystems = new HashMap<URI, StorageSystem>();
// Separate cluster1 and cluster 2 ports of the provided vplex storageSystemURIs
for (URI uri : storageSystemURIs) {
StorageSystem storageSystem = _dbClient.queryObject(StorageSystem.class, uri);
URIQueryResultList storagePortURIs = new URIQueryResultList();
_dbClient.queryByConstraint(ContainmentConstraint.Factory.getStorageDeviceStoragePortConstraint(storageSystem.getId()), storagePortURIs);
final String cluster1 = "1";
final String cluster2 = "2";
Set<URI> cluster1StoragePorts = new HashSet<URI>();
Set<URI> cluster2StoragePorts = new HashSet<URI>();
Iterator<URI> storagePortsIter = storagePortURIs.iterator();
while (storagePortsIter.hasNext()) {
URI storagePortURI = storagePortsIter.next();
StoragePort storagePort = _dbClient.queryObject(StoragePort.class, storagePortURI);
if (storagePort != null && !storagePort.getInactive() && storagePort.getRegistrationStatus().equals(DiscoveredDataObject.RegistrationStatus.REGISTERED.name()) && !storagePort.getDiscoveryStatus().equalsIgnoreCase(DiscoveryStatus.NOTVISIBLE.name())) {
// after director- in this string determines vplex cluster
if (storagePort.getPortGroup() != null) {
String[] tokens = storagePort.getPortGroup().split("-");
if (cluster1.equals(tokens[1])) {
cluster1StoragePorts.add(storagePort.getId());
} else if (cluster2.equals(tokens[1])) {
cluster2StoragePorts.add(storagePort.getId());
} else {
_log.warn("Could not determine cluster for storageport:" + storagePort.getPortNetworkId() + " " + storagePort.getId() + " Port group is:" + storagePort.getPortGroup());
}
} else {
_log.warn("Could not determine cluster for storageport:" + storagePort.getPortNetworkId() + " " + storagePort.getId());
}
}
}
vplexCluster1ports.put(uri, cluster1StoragePorts);
vplexCluster2ports.put(uri, cluster2StoragePorts);
storageSystems.put(uri, storageSystem);
}
for (URI hostUri : allHosts) {
Map<URI, StoragePort> networkStoragePortsForHost = getNetworkTaggedPortsForHost(hostUri, networkToPortsMap);
// clusters of the vplex.
for (URI uri : storageSystemURIs) {
Set<URI> intersection1 = new HashSet<URI>(networkStoragePortsForHost.keySet());
Set<URI> intersection2 = new HashSet<URI>(networkStoragePortsForHost.keySet());
intersection1.retainAll(vplexCluster1ports.get(uri));
intersection2.retainAll(vplexCluster2ports.get(uri));
// if we have ports in both then its a mix ports from cluster 1 and cluster 2
if (!intersection1.isEmpty() && !intersection2.isEmpty()) {
Map<URI, String> cluster1Ports = new HashMap<URI, String>();
Map<URI, String> cluster2Ports = new HashMap<URI, String>();
// which belong in the same varray
for (URI uriIntersection1 : intersection1) {
if (networkStoragePortsForHost.get(uriIntersection1) != null) {
cluster1Ports.put(uriIntersection1, networkStoragePortsForHost.get(uriIntersection1).getPortNetworkId());
}
}
for (URI uriIntersection2 : intersection2) {
if (networkStoragePortsForHost.get(uriIntersection2) != null) {
cluster2Ports.put(uriIntersection2, networkStoragePortsForHost.get(uriIntersection2).getPortNetworkId());
}
}
Host host = _dbClient.queryObject(Host.class, hostUri);
_log.error("Varray " + varray.getLabel() + " has storageports from Cluster 1 and Cluster 2 of the Vplex " + storageSystems.get(uri).getLabel() + " " + storageSystems.get(uri).getId().toString() + ". This is detected for the host " + host.getHostName() + "\n Cluster 1 storageports in varray are" + cluster1Ports + "\n Cluster 2 storageports in varray are" + cluster2Ports);
throw APIException.badRequests.invalidVarrayNetworkConfiguration(varray.getLabel(), storageSystems.get(uri).getLabel());
}
}
}
_log.info("Done validating vplex cluster 1 and 2 ports for the Varray:" + varray.getLabel());
} catch (InternalException ex) {
_log.error(ex.getLocalizedMessage());
throw (ex);
}
}
Aggregations