use of com.emc.storageos.svcs.errorhandling.model.ServiceCoded in project coprhd-controller by CoprHD.
the class AbstractCloneOperations method createSingleClone.
@Override
@SuppressWarnings("rawtypes")
public void createSingleClone(StorageSystem storageSystem, URI sourceVolume, URI cloneVolume, Boolean createInactive, TaskCompleter taskCompleter) {
_log.info("START createSingleClone operation");
try {
BlockObject sourceObj = BlockObject.fetch(_dbClient, sourceVolume);
URI tenantUri = null;
Volume baseVolume = null;
boolean isSourceSnap = false;
if (sourceObj instanceof BlockSnapshot) {
// In case of snapshot, get the tenant from its parent volume
NamedURI parentVolUri = ((BlockSnapshot) sourceObj).getParent();
Volume parentVolume = _dbClient.queryObject(Volume.class, parentVolUri);
tenantUri = parentVolume.getTenant().getURI();
baseVolume = parentVolume;
isSourceSnap = true;
} else {
// This is a default flow
tenantUri = ((Volume) sourceObj).getTenant().getURI();
baseVolume = (Volume) sourceObj;
}
// CTRL-1992: Need to resync any existing snapshot restore sessions, if applicable
if (_helper.arraySupportsResync(storageSystem)) {
CloseableIterator<CIMObjectPath> syncObjectIter = _cimPath.getSyncObjects(storageSystem, sourceObj);
CIMObjectPath path = null;
while (syncObjectIter.hasNext()) {
path = syncObjectIter.next();
CIMInstance instance = _helper.getInstance(storageSystem, path, false, false, SmisConstants.PS_COPY_STATE_AND_DESC_SYNCTYPE);
String copyState = instance.getPropertyValue(SmisConstants.CP_COPY_STATE).toString();
String copyStateDesc = instance.getPropertyValue(SmisConstants.EMC_COPY_STATE_DESC).toString();
String syncType = instance.getPropertyValue(SmisConstants.CP_SYNC_TYPE).toString();
_log.info(String.format("Sync %s has copyState %s (%s) syncType %s", path.toString(), copyState, copyStateDesc, syncType));
if (copyState.equals(COPY_STATE_RESTORED_INT_VALUE) && syncType.equals(Integer.toString(SmisConstants.SNAPSHOT_VALUE))) {
// This snapshot is in the 'Restored' state, need to
// resync it, before we can create a full copy
_log.info("Sync {} is in restored state, need to resync", path);
SmisBlockResyncSnapshotJob job = new SmisBlockResyncSnapshotJob(null, storageSystem.getId(), new TaskCompleter() {
@Override
protected void complete(DbClient dbClient, Operation.Status status, ServiceCoded coded) throws DeviceControllerException {
}
});
CIMArgument[] result = new CIMArgument[5];
_helper.invokeMethodSynchronously(storageSystem, _cimPath.getControllerReplicationSvcPath(storageSystem), SmisConstants.MODIFY_REPLICA_SYNCHRONIZATION, _helper.getResyncSnapshotInputArguments(path), result, job);
if (job.isSuccess()) {
_log.info("{} was successfully resynchronized", path.toString());
} else {
_log.error("Encountered a failure while trying to resynchronize a restored snapshot");
ServiceError error = DeviceControllerErrors.smis.resyncActiveRestoreSessionFailure(sourceObj.getLabel());
taskCompleter.error(_dbClient, error);
return;
}
}
}
}
Volume cloneObj = _dbClient.queryObject(Volume.class, cloneVolume);
StoragePool targetPool = _dbClient.queryObject(StoragePool.class, cloneObj.getPool());
TenantOrg tenantOrg = _dbClient.queryObject(TenantOrg.class, tenantUri);
String cloneLabel = generateLabel(tenantOrg, cloneObj);
CIMObjectPath volumeGroupPath = _helper.getVolumeGroupPath(storageSystem, storageSystem, baseVolume, targetPool);
CIMObjectPath sourceVolumePath = _cimPath.getBlockObjectPath(storageSystem, sourceObj);
CIMObjectPath replicationSvcPath = _cimPath.getControllerReplicationSvcPath(storageSystem);
CIMArgument[] inArgs = null;
CIMInstance repSettingData = null;
if (storageSystem.deviceIsType(Type.vmax)) {
if (createInactive && storageSystem.getUsingSmis80()) {
repSettingData = _helper.getReplicationSettingDataInstanceForDesiredCopyMethod(storageSystem, COPY_BEFORE_ACTIVATE, true);
} else if (storageSystem.checkIfVmax3() && ControllerUtils.isVmaxUsing81SMIS(storageSystem, _dbClient)) {
/**
* VMAX3 using SMI 8.1 provider needs to send DesiredCopyMethodology=32770
* to create TimeFinder differential clone.
*/
repSettingData = _helper.getReplicationSettingDataInstanceForDesiredCopyMethod(storageSystem, SMIS810_TF_DIFFERENTIAL_CLONE_VALUE, true);
} else {
repSettingData = _helper.getReplicationSettingDataInstanceForDesiredCopyMethod(storageSystem, DIFFERENTIAL_CLONE_VALUE, true);
}
inArgs = _helper.getCloneInputArguments(cloneLabel, sourceVolumePath, volumeGroupPath, storageSystem, targetPool, createInactive, repSettingData);
} else if (storageSystem.deviceIsType(Type.vnxblock)) {
if (!isSourceSnap) {
repSettingData = getReplicationSettingDataInstanceForThinProvisioningPolicy(storageSystem, PROVISIONING_TARGET_SAME_AS_SOURCE);
// don't supply target pool when using thinlyProvisioningPolicy=PROVISIONING_TARGET_SAME_AS_SOURCE
inArgs = _helper.getCreateElementReplicaMirrorInputArgumentsWithReplicationSettingData(storageSystem, sourceObj, null, false, repSettingData, cloneLabel);
cloneObj.setPool(baseVolume.getPool());
_dbClient.persistObject(cloneObj);
} else {
// when source is snapshot, create clone instead of mirror, since creating mirror from a snap is not supported.
inArgs = _helper.getCloneInputArguments(cloneLabel, sourceVolumePath, volumeGroupPath, storageSystem, targetPool, createInactive, null);
}
}
CIMArgument[] outArgs = new CIMArgument[5];
_helper.invokeMethod(storageSystem, replicationSvcPath, SmisConstants.CREATE_ELEMENT_REPLICA, inArgs, outArgs);
CIMObjectPath job = _cimPath.getCimObjectPathFromOutputArgs(outArgs, SmisConstants.JOB);
if (job != null) {
ControllerServiceImpl.enqueueJob(new QueueJob(new SmisCloneVolumeJob(job, storageSystem.getId(), taskCompleter)));
}
} catch (Exception e) {
Volume clone = _dbClient.queryObject(Volume.class, cloneVolume);
if (clone != null) {
clone.setInactive(true);
_dbClient.persistObject(clone);
}
String errorMsg = String.format(CREATE_ERROR_MSG_FORMAT, sourceVolume, cloneVolume);
_log.error(errorMsg, e);
SmisException serviceCode = DeviceControllerExceptions.smis.createFullCopyFailure(errorMsg, e);
taskCompleter.error(_dbClient, serviceCode);
throw serviceCode;
}
}
use of com.emc.storageos.svcs.errorhandling.model.ServiceCoded in project coprhd-controller by CoprHD.
the class ComputeDeviceControllerImpl method removeVcenterCluster.
/**
* Remove cluster from vCenter.
*
* @param clusterId
* @param datacenterId
* @param stepId
*/
public void removeVcenterCluster(URI clusterId, URI datacenterId, String stepId) {
log.info("removeVcenterCluster {} {}", clusterId, datacenterId);
Cluster cluster = null;
try {
WorkflowStepCompleter.stepExecuting(stepId);
cluster = _dbClient.queryObject(Cluster.class, clusterId);
vcenterController.removeVcenterCluster(datacenterId, clusterId);
log.info("Remove vCenter cluster success");
WorkflowStepCompleter.stepSucceded(stepId);
} catch (VcenterControllerException e) {
log.warn("VcenterControllerException when trying to removeVcenterCluster: " + e.getMessage(), e);
if (e.getCause() instanceof VcenterObjectNotFoundException) {
log.info("did not find the datacenter or cluster, considering success");
WorkflowStepCompleter.stepSucceded(stepId);
} else {
log.error("failure " + e);
WorkflowStepCompleter.stepFailed(stepId, e);
}
} catch (InternalException e) {
log.error("InternalException when trying to removeVcenterCluster: " + e.getMessage(), e);
WorkflowStepCompleter.stepFailed(stepId, e);
} catch (Exception e) {
log.error("unexpected exception " + e);
ServiceCoded serviceCoded = ComputeSystemControllerException.exceptions.unableToRemoveVcenterCluster(cluster != null ? cluster.getLabel() : clusterId.toString(), e);
WorkflowStepCompleter.stepFailed(stepId, serviceCoded);
}
}
use of com.emc.storageos.svcs.errorhandling.model.ServiceCoded in project coprhd-controller by CoprHD.
the class ComputeDeviceControllerImpl method removeHostFromVcenterCluster.
/**
* This will attempt to remove host from vCenter cluster.
*
* @param hostId
* @param stepId
*/
public void removeHostFromVcenterCluster(URI hostId, String stepId) {
log.info("removeHostFromVcenterCluster {}", hostId);
Host host = null;
try {
WorkflowStepCompleter.stepExecuting(stepId);
host = _dbClient.queryObject(Host.class, hostId);
if (NullColumnValueGetter.isNullURI(host.getVcenterDataCenter())) {
log.info("datacenter is null, nothing to do");
WorkflowStepCompleter.stepSucceded(stepId);
return;
}
if (NullColumnValueGetter.isNullURI(host.getCluster())) {
log.warn("cluster is null, nothing to do");
WorkflowStepCompleter.stepSucceded(stepId);
return;
}
// Test mechanism to invoke a failure. No-op on production systems.
InvokeTestFailure.internalOnlyInvokeTestFailure(InvokeTestFailure.ARTIFICIAL_FAILURE_068);
String taskId = stepId;
Operation op = new Operation();
op.setResourceType(ResourceOperationTypeEnum.UPDATE_VCENTER_CLUSTER);
_dbClient.createTaskOpStatus(VcenterDataCenter.class, host.getVcenterDataCenter(), taskId, op);
AsyncTask task = new AsyncTask(VcenterDataCenter.class, host.getVcenterDataCenter(), taskId);
final String workflowKey = "updateVcenterCluster";
if (!WorkflowService.getInstance().hasWorkflowBeenCreated(taskId, workflowKey)) {
vcenterController.updateVcenterCluster(task, host.getCluster(), null, new URI[] { host.getId() }, null);
// Mark this workflow as created/executed so we don't do it
// again on retry/resume
WorkflowService.getInstance().markWorkflowBeenCreated(taskId, workflowKey);
}
} catch (VcenterControllerException e) {
log.warn("VcenterControllerException when trying to removeHostFromVcenterCluster: " + e.getMessage(), e);
if (e.getCause() instanceof VcenterObjectNotFoundException) {
log.info("did not find the host, considering success");
WorkflowStepCompleter.stepSucceded(stepId);
} else if (e.getCause() instanceof VcenterObjectConnectionException) {
log.info("host is not connected, considering success");
WorkflowStepCompleter.stepSucceded(stepId);
} else {
log.error("failure " + e);
WorkflowStepCompleter.stepFailed(stepId, e);
}
} catch (InternalException e) {
log.error("InternalException when trying to removeHostFromVcenterCluster: " + e.getMessage(), e);
WorkflowStepCompleter.stepFailed(stepId, e);
} catch (Exception e) {
log.error("unexpected exception: " + e.getMessage(), e);
ServiceCoded serviceCoded = ComputeSystemControllerException.exceptions.unableToRemoveHostVcenterCluster(host != null ? host.getHostName() : hostId.toString(), e);
WorkflowStepCompleter.stepFailed(stepId, serviceCoded);
}
}
use of com.emc.storageos.svcs.errorhandling.model.ServiceCoded in project coprhd-controller by CoprHD.
the class ComputeDeviceControllerImpl method putHostInMaintenanceMode.
/**
* This will attempt to put host into maintenance mode on a Vcenter.
*
* @param hostId
* @param stepId
*/
public void putHostInMaintenanceMode(URI hostId, String stepId) {
log.info("putHostInMaintenanceMode {}", hostId);
Host host = null;
try {
WorkflowStepCompleter.stepExecuting(stepId);
host = _dbClient.queryObject(Host.class, hostId);
if (NullColumnValueGetter.isNullURI(host.getVcenterDataCenter())) {
log.info("datacenter is null, nothing to do");
WorkflowStepCompleter.stepSucceded(stepId);
return;
}
if (NullColumnValueGetter.isNullURI(host.getCluster())) {
log.warn("cluster is null, nothing to do");
WorkflowStepCompleter.stepSucceded(stepId);
return;
}
vcenterController.enterMaintenanceMode(host.getVcenterDataCenter(), host.getCluster(), host.getId());
WorkflowStepCompleter.stepSucceded(stepId);
} catch (VcenterControllerException e) {
log.warn("VcenterControllerException when trying to putHostInMaintenanceMode: " + e.getMessage(), e);
if (e.getCause() instanceof VcenterObjectNotFoundException) {
if (checkPreviouslyFailedDecommission(host)) {
log.info("did not find the host, considering success based on previous delete host operation");
WorkflowStepCompleter.stepSucceded(stepId);
} else {
log.info("did not find the host, considering failure as no previous delete host operation found");
WorkflowStepCompleter.stepFailed(stepId, e);
}
} else if (e.getCause() instanceof VcenterObjectConnectionException) {
if (checkPreviouslyFailedDecommission(host)) {
log.info("host is not connected, considering success based on previous delete host operation");
WorkflowStepCompleter.stepSucceded(stepId);
} else {
log.info("host is not connected, considering failure as no previous delete host operation found");
WorkflowStepCompleter.stepFailed(stepId, e);
}
} else {
log.error("failure " + e);
WorkflowStepCompleter.stepFailed(stepId, e);
}
} catch (InternalException e) {
log.error("InternalException when trying to putHostInMaintenanceMode: " + e.getMessage(), e);
WorkflowStepCompleter.stepFailed(stepId, e);
} catch (Exception e) {
log.error("unexpected exception" + e.getMessage(), e);
ServiceCoded serviceCoded = ComputeSystemControllerException.exceptions.unableToPutHostInMaintenanceMode(host != null ? host.getHostName() : hostId.toString(), e);
WorkflowStepCompleter.stepFailed(stepId, serviceCoded);
}
}
use of com.emc.storageos.svcs.errorhandling.model.ServiceCoded in project coprhd-controller by CoprHD.
the class ComputeDeviceControllerImpl method prepareOsInstallNetworkStep.
/**
* Method or step responsible for setting up the required OS install network
*
* @param computeSystemId
* {@link URI} compute system URI
* @param computeElementId
* {@link URI} compute element URI
* @param stepId
* {@link String} step id
*/
public void prepareOsInstallNetworkStep(URI computeSystemId, URI computeElementId, String stepId) {
log.info("prepareOsInstallNetworkStep");
ComputeSystem computeSystem = null;
try {
WorkflowStepCompleter.stepExecuting(stepId);
computeSystem = _dbClient.queryObject(ComputeSystem.class, computeSystemId);
// Test mechanism to invoke a failure. No-op on production systems.
InvokeTestFailure.internalOnlyInvokeTestFailure(InvokeTestFailure.ARTIFICIAL_FAILURE_071);
Map<String, Boolean> vlanMap = prepareOsInstallNetwork(computeSystemId, computeElementId);
_workflowService.storeStepData(stepId, vlanMap);
WorkflowStepCompleter.stepSucceded(stepId);
} catch (InternalException e) {
String opName = ResourceOperationTypeEnum.INSTALL_OPERATING_SYSTEM.getName();
ServiceCoded sce = ImageServerControllerException.exceptions.unexpectedException(opName, e);
if (computeSystem != null) {
sce = ComputeSystemControllerException.exceptions.unableToSetOsInstallNetwork(computeSystem.getOsInstallNetwork(), computeElementId.toString(), e);
}
log.error("Exception prepareOsInstallNetworkStep: " + e.getMessage(), e);
WorkflowStepCompleter.stepFailed(stepId, sce);
} catch (Exception e) {
String opName = ResourceOperationTypeEnum.INSTALL_OPERATING_SYSTEM.getName();
ImageServerControllerException controllerException = ImageServerControllerException.exceptions.unexpectedException(opName, e);
log.error("Unexpected exception prepareOsInstallNetworkStep: " + e.getMessage(), e);
WorkflowStepCompleter.stepFailed(stepId, controllerException);
}
}
Aggregations