use of com.emc.storageos.db.client.model.VcenterDataCenter in project coprhd-controller by CoprHD.
the class ActionableEventExecutor method hostVcenterChangeDetails.
/**
* Get details for the hostVcenterChange method
* NOTE: In order to maintain backwards compatibility, do not change the signature of this method.
*
* @param hostId the host that is moving vcenters
* @param clusterId the cluster the host is moving to
* @param datacenterId the datacenter the host is moving to
* @param isVcenter if true, vcenter api operations will be executed against the host to detach/unmount and attach/mount disks and
* datastores
* @return list of event details
*/
// Invoked using reflection for the event framework
@SuppressWarnings("unused")
public List<String> hostVcenterChangeDetails(URI hostId, URI clusterId, URI datacenterId, boolean isVcenter) {
List<String> result = Lists.newArrayList();
Host host = _dbClient.queryObject(Host.class, hostId);
VcenterDataCenter datacenter = _dbClient.queryObject(VcenterDataCenter.class, datacenterId);
if (host != null && datacenter != null) {
result.add(ComputeSystemDialogProperties.getMessage("ComputeSystem.hostVcenterChangeDetails", host.getLabel(), datacenter.getLabel()));
result.addAll(hostClusterChangeDetails(hostId, clusterId, datacenterId, isVcenter));
}
return result;
}
use of com.emc.storageos.db.client.model.VcenterDataCenter in project coprhd-controller by CoprHD.
the class ComputeSystemHelper method isDataCenterInUse.
/**
* Checks if an datacenter is in use by an export groups
*
* @param dbClient
* @param datacenterURI the datacenter URI
* @return true if the datacenter is in used by an export group.
*/
public static boolean isDataCenterInUse(DbClient dbClient, URI datacenterURI) {
VcenterDataCenter dataCenter = dbClient.queryObject(VcenterDataCenter.class, datacenterURI);
if (dataCenter != null && !dataCenter.getInactive()) {
List<NamedElementQueryResultList.NamedElement> hostUris = listChildren(dbClient, dataCenter.getId(), Host.class, "label", "vcenterDataCenter");
for (NamedElementQueryResultList.NamedElement hostUri : hostUris) {
Host host = dbClient.queryObject(Host.class, hostUri.getId());
// ignore provisioned hosts
if (host != null && !host.getInactive() && NullColumnValueGetter.isNullURI(host.getComputeElement()) && isHostInUse(dbClient, host.getId())) {
return true;
}
}
List<NamedElementQueryResultList.NamedElement> clustersUris = listChildren(dbClient, dataCenter.getId(), Cluster.class, "label", "vcenterDataCenter");
for (NamedElementQueryResultList.NamedElement clusterUri : clustersUris) {
Cluster cluster = dbClient.queryObject(Cluster.class, clusterUri.getId());
if (cluster != null && !cluster.getInactive() && isClusterInExport(dbClient, clusterUri.getId())) {
return true;
}
}
}
return false;
}
use of com.emc.storageos.db.client.model.VcenterDataCenter in project coprhd-controller by CoprHD.
the class ComputeSystemControllerImpl method rescanHostStorage.
/**
* Creates workflow steps for rescanning HBAs and host storage for a list of ESX hosts
*
* @param hostIds list of host ids
* @param virtualDataCenter the virtual datacenter id that the hosts belong to
* @param waitFor the step to wait on for this workflow step
* @param workflow the workflow
* @return the step id
*/
private String rescanHostStorage(List<URI> hostIds, URI virtualDataCenter, String waitFor, Workflow workflow) {
String newWaitFor = waitFor;
for (URI hostId : hostIds) {
Host esxHost = _dbClient.queryObject(Host.class, hostId);
if (esxHost != null) {
VcenterDataCenter vcenterDataCenter = _dbClient.queryObject(VcenterDataCenter.class, virtualDataCenter);
if (vcenterDataCenter != null) {
URI vCenterId = vcenterDataCenter.getVcenter();
newWaitFor = workflow.createStep(RESCAN_HOST_STORAGE_STEP, String.format("Refreshing HBAs for host %s", esxHost.forDisplay()), newWaitFor, esxHost.getId(), esxHost.getId().toString(), this.getClass(), rescanHostStorageMethod(esxHost.getId(), vCenterId, vcenterDataCenter.getId()), rollbackMethodNullMethod(), null);
}
}
}
return newWaitFor;
}
use of com.emc.storageos.db.client.model.VcenterDataCenter in project coprhd-controller by CoprHD.
the class ComputeSystemControllerImpl method unmountAndDetach.
/**
* Unmounts and detaches every datastore and disk associated with the volumes in the export group.
* For each volume in the export group, the backed datastore is unmounted and the associated disk is detached from
* the host.
*
* @param exportGroupId
* export group that contains volumes
* @param hostId
* host to attach and mount to
* @param vcenterId
* vcenter that the host belongs to
* @param vcenterDatacenter
* vcenter datacenter that the host belongs to
* @param stepId
* the id of the workflow step
*/
public void unmountAndDetach(URI exportGroupId, URI hostId, URI vCenterId, URI vcenterDatacenter, String stepId) {
WorkflowStepCompleter.stepExecuting(stepId);
try {
Host esxHost = _dbClient.queryObject(Host.class, hostId);
Vcenter vCenter = _dbClient.queryObject(Vcenter.class, vCenterId);
VcenterDataCenter vCenterDataCenter = _dbClient.queryObject(VcenterDataCenter.class, vcenterDatacenter);
ExportGroup exportGroup = _dbClient.queryObject(ExportGroup.class, exportGroupId);
VCenterAPI api = VcenterDiscoveryAdapter.createVCenterAPI(vCenter);
HostSystem hostSystem = api.findHostSystem(vCenterDataCenter.getLabel(), esxHost.getLabel());
if (hostSystem == null) {
_log.info("Not able to find host " + esxHost.getLabel() + " in vCenter. Unable to validate");
WorkflowStepCompleter.stepSucceded(stepId);
return;
}
HostStorageAPI storageAPI = new HostStorageAPI(hostSystem);
Map<String, Datastore> wwnDatastores = getWwnDatastoreMap(hostSystem);
if (exportGroup != null && exportGroup.getVolumes() != null) {
for (String volume : exportGroup.getVolumes().keySet()) {
BlockObject blockObject = BlockObject.fetch(_dbClient, URI.create(volume));
if (blockObject != null) {
Datastore datastore = getDatastoreByWwn(wwnDatastores, blockObject.getWWN());
if (datastore != null) {
if (VMwareUtils.isDatastoreMountedOnHost(datastore, hostSystem)) {
boolean storageIOControlEnabled = datastore.getIormConfiguration().isEnabled();
if (storageIOControlEnabled) {
setStorageIOControl(api, datastore, false);
}
_log.info("Unmount datastore " + datastore.getName() + " from host " + esxHost.getLabel());
storageAPI.unmountVmfsDatastore(datastore);
if (storageIOControlEnabled) {
setStorageIOControl(api, datastore, true);
}
} else {
_log.info("Datastore " + datastore.getName() + " is not mounted on host " + esxHost.getLabel() + ". Skipping unmounting of datastore.");
}
}
}
// VBDU TODO: COP-28459, If datastore doesn't match, why do we need to run DetachSCSILun() ?
// Test mechanism to invoke a failure. No-op on production systems.
InvokeTestFailure.internalOnlyInvokeTestFailure(InvokeTestFailure.ARTIFICIAL_FAILURE_030);
for (HostScsiDisk entry : storageAPI.listScsiDisks()) {
if (VolumeWWNUtils.wwnMatches(VMwareUtils.getDiskWwn(entry), blockObject.getWWN())) {
if (!VMwareUtils.isDiskOff(entry)) {
_log.info("Detach SCSI Lun " + entry.getCanonicalName() + " from host " + esxHost.getLabel());
storageAPI.detachScsiLun(entry);
} else {
_log.info("SCSI Lun " + entry.getCanonicalName() + " is not in a valid state to detach");
}
}
}
storageAPI.refreshStorage();
// Test mechanism to invoke a failure. No-op on production systems.
InvokeTestFailure.internalOnlyInvokeTestFailure(InvokeTestFailure.ARTIFICIAL_FAILURE_031);
}
}
WorkflowStepCompleter.stepSucceded(stepId);
} catch (Exception ex) {
_log.error(ex.getMessage(), ex);
WorkflowStepCompleter.stepFailed(stepId, DeviceControllerException.errors.jobFailed(ex));
}
}
use of com.emc.storageos.db.client.model.VcenterDataCenter in project coprhd-controller by CoprHD.
the class VcenterCompleter method complete.
@Override
protected void complete(DbClient dbClient, Status status, ServiceCoded coded) throws DeviceControllerException {
super.complete(dbClient, status, coded);
switch(status) {
case error:
dbClient.error(Vcenter.class, this.getId(), getOpId(), coded);
break;
default:
dbClient.ready(Vcenter.class, this.getId(), getOpId());
}
if (deactivateOnComplete && status.equals(Status.ready)) {
Vcenter vcenter = dbClient.queryObject(Vcenter.class, this.getId());
List<NamedElementQueryResultList.NamedElement> datacenterUris = ComputeSystemHelper.listChildren(dbClient, vcenter.getId(), VcenterDataCenter.class, "label", "vcenter");
for (NamedElementQueryResultList.NamedElement datacenterUri : datacenterUris) {
VcenterDataCenter dataCenter = dbClient.queryObject(VcenterDataCenter.class, datacenterUri.getId());
if (dataCenter != null && !dataCenter.getInactive()) {
ComputeSystemHelper.doDeactivateVcenterDataCenter(dbClient, dataCenter);
}
}
vcenter.setRegistrationStatus(RegistrationStatus.UNREGISTERED.toString());
dbClient.markForDeletion(vcenter);
_logger.info("Deactivating Vcenter: " + this.getId());
}
}
Aggregations