use of com.emc.storageos.db.client.model.Host in project coprhd-controller by CoprHD.
the class ComputeVirtualPoolService method updateHostToCVPRelation.
private void updateHostToCVPRelation(ComputeVirtualPool cvp) {
Collection<ComputeElement> computeElements = _dbClient.queryObject(ComputeElement.class, toUriList(cvp.getMatchedComputeElements()));
List<Host> updatedHosts = Lists.newArrayList();
for (ComputeElement computeElement : computeElements) {
List<Host> hosts = CustomQueryUtility.queryActiveResourcesByConstraint(_dbClient, Host.class, ContainmentConstraint.Factory.getContainedObjectsConstraint(computeElement.getId(), Host.class, "computeElement"));
for (Host host : hosts) {
if (NullColumnValueGetter.isNullURI(host.getComputeVirtualPoolId()) || !cvp.getId().equals(host.getComputeVirtualPoolId())) {
host.setComputeVirtualPoolId(cvp.getId());
updatedHosts.add(host);
}
}
}
if (CollectionUtils.isNotEmpty(updatedHosts)) {
_dbClient.updateObject(updatedHosts);
}
}
use of com.emc.storageos.db.client.model.Host in project coprhd-controller by CoprHD.
the class ComputeVirtualPoolService method getHostsProvisionedFromPool.
private List<Host> getHostsProvisionedFromPool(ComputeVirtualPool cvp) {
List<Host> hostList = new ArrayList<Host>();
URIQueryResultList hostURIs = new URIQueryResultList();
_dbClient.queryByConstraint(ContainmentConstraint.Factory.getVirtualComputePoolHostConstraint(cvp.getId()), hostURIs);
Iterator<URI> iter = hostURIs.iterator();
while (iter.hasNext()) {
URI hostURI = iter.next();
Host host = _dbClient.queryObject(Host.class, hostURI);
if (host != null && !host.getInactive()) {
hostList.add(host);
} else {
_log.error("Can't find host {} in the database " + "or the host is marked for deletion", hostURI);
}
}
return hostList;
}
use of com.emc.storageos.db.client.model.Host in project coprhd-controller by CoprHD.
the class ComputeSystemControllerImpl method addStepForUpdatingHostAndInitiatorClusterReferences.
public String addStepForUpdatingHostAndInitiatorClusterReferences(Workflow workflow, String waitFor, List<URI> hostIds, URI clusterId, URI vCenterDataCenterId, HostCompleter completer) {
for (URI hostId : hostIds) {
URI oldClusterId = NullColumnValueGetter.getNullURI();
URI oldvCenterDataCenterId = NullColumnValueGetter.getNullURI();
Host host = _dbClient.queryObject(Host.class, hostId);
if (host != null) {
if (!NullColumnValueGetter.isNullURI(host.getCluster())) {
oldClusterId = host.getCluster();
}
if (!NullColumnValueGetter.isNullURI(host.getVcenterDataCenter())) {
oldvCenterDataCenterId = host.getVcenterDataCenter();
}
}
if (completer != null) {
// Update the completer with the correct values to rollback
completer.addOldHostClusterAndVcenterDataCenter(hostId, oldClusterId, oldvCenterDataCenterId);
}
waitFor = workflow.createStep(UPDATE_HOST_AND_INITIATOR_CLUSTER_NAMES_STEP, String.format("Updating host and initiator cluster names for host %s to %s", hostId, clusterId), waitFor, hostId, hostId.toString(), this.getClass(), updateHostAndInitiatorClusterReferencesMethod(hostId, clusterId, vCenterDataCenterId), updateHostAndInitiatorClusterReferencesMethod(hostId, oldClusterId, oldvCenterDataCenterId), null);
}
return waitFor;
}
use of com.emc.storageos.db.client.model.Host in project coprhd-controller by CoprHD.
the class ComputeSystemControllerImpl method rollbackHostBootVolumeId.
public void rollbackHostBootVolumeId(URI hostId, URI volumeId, String stepId) throws ControllerException {
_log.info("rollbackHostBootVolumeId:" + hostId.toString());
Host host = null;
try {
WorkflowStepCompleter.stepExecuting(stepId);
host = _dbClient.queryObject(Host.class, hostId);
if (host == null) {
throw ComputeSystemControllerException.exceptions.hostNotFound(hostId.toString());
}
_log.info("Rolling back boot volume association for host");
host.setBootVolumeId(NullColumnValueGetter.getNullURI());
_dbClient.persistObject(host);
WorkflowStepCompleter.stepSucceded(stepId);
} catch (Exception e) {
_log.error("unexpected exception: " + e.getMessage(), e);
String hostString = hostId.toString();
if (host != null) {
hostString = host.getHostName();
}
ServiceCoded serviceCoded = ComputeSystemControllerException.exceptions.unableToRollbackBootVolume(hostString, e);
WorkflowStepCompleter.stepFailed(stepId, serviceCoded);
}
}
use of com.emc.storageos.db.client.model.Host in project coprhd-controller by CoprHD.
the class ComputeSystemControllerImpl method attachAndMountVolumes.
/**
* Creates workflow steps for attaching disks and mounting datastores
*
* @param vCenterHostExportMap
* the map of hosts and export groups to operate on
* @param waitFor
* the step to wait on for this workflow step
* @param workflow
* the workflow to create the step
* @return the step id
*/
private String attachAndMountVolumes(Map<URI, Collection<URI>> vCenterHostExportMap, String waitFor, Workflow workflow) {
if (vCenterHostExportMap == null) {
return waitFor;
}
for (URI hostId : vCenterHostExportMap.keySet()) {
Host esxHost = _dbClient.queryObject(Host.class, hostId);
if (esxHost != null) {
URI virtualDataCenter = esxHost.getVcenterDataCenter();
VcenterDataCenter vcenterDataCenter = _dbClient.queryObject(VcenterDataCenter.class, virtualDataCenter);
URI vCenterId = vcenterDataCenter.getVcenter();
for (URI export : vCenterHostExportMap.get(hostId)) {
waitFor = workflow.createStep(MOUNT_AND_ATTACH_STEP, String.format("Mounting and attaching volumes from export group %s", export), waitFor, export, export.toString(), this.getClass(), attachAndMountMethod(export, esxHost.getId(), vCenterId, vcenterDataCenter.getId()), rollbackMethodNullMethod(), null);
}
}
}
return waitFor;
}
Aggregations