use of javax.cim.CIMObjectPath in project coprhd-controller by CoprHD.
the class HDSCommunicationInterface method getCIMClient.
/**
* Creates a new WEBClient for a given IP, based on AccessProfile
*
* @param accessProfile
* : AccessProfile for the providers
* @throws WBEMException
* : if WBEMException while creating the WBEMClient
* @throws SMIPluginException
* @return WBEMClient : initialized instance of WBEMClientCIMXML
*/
private WBEMClient getCIMClient(AccessProfile accessProfile) throws Exception {
String protocol = Boolean.valueOf(accessProfile.getSslEnable()) ? CimConstants.SECURE_PROTOCOL : CimConstants.DEFAULT_PROTOCOL;
CIMObjectPath path = CimObjectPathCreator.createInstance(protocol, accessProfile.getIpAddress(), Integer.toString(accessProfile.getPortNumber()), accessProfile.getInteropNamespace(), null, null);
try {
Subject subject = new Subject();
subject.getPrincipals().add(new UserPrincipal(accessProfile.getUserName()));
subject.getPrivateCredentials().add(new PasswordCredential(accessProfile.getPassword()));
wbemClient = WBEMClientFactory.getClient(CimConstants.CIM_CLIENT_PROTOCOL);
// Operations block by default, so a timeout must be set in case the
// CIM server becomes unreachable.
// Commenting out, as timeout had been moved to cimom.properties
// file
// _cimClient.setProperty(WBEMClientConstants.PROP_TIMEOUT,
// CimConstants.CIM_CLIENT_TIMEOUT);
wbemClient.initialize(path, subject, null);
} catch (Exception e) {
_logger.error("Could not establish connection for {}", accessProfile.getIpAddress(), e);
wbemClient.close();
throw e;
}
return wbemClient;
}
use of javax.cim.CIMObjectPath in project coprhd-controller by CoprHD.
the class AbstractCIMObjectPathFactory method getSyncObject.
/**
* Return a single CIM_StorageSynchronized instance referenced by the given BlockObject.
*
* @deprecated In cases where there may be more than one CIM_StorageSynchronized instance, we
* should favor using #getSyncObjects instead and inspect each instances'
* [System|Synced] Element property to ensure that we're operating on the correct
* one.
* @param storage
* @param subject
* @return
*/
public CIMObjectPath getSyncObject(StorageSystem storage, BlockObject subject) {
CloseableIterator<CIMObjectPath> syncReference = null;
CIMObjectPath syncObjectPath = NULL_CIM_OBJECT_PATH;
try {
syncReference = getSyncObjects(storage, subject);
if (syncReference != null) {
while (syncReference.hasNext()) {
syncObjectPath = syncReference.next();
if (syncObjectPath != null) {
break;
}
}
}
} finally {
if (syncReference != null) {
syncReference.close();
}
}
return syncObjectPath;
}
use of javax.cim.CIMObjectPath in project coprhd-controller by CoprHD.
the class AbstractCloneOperations method fractureSingleClone.
@Override
@SuppressWarnings("rawtypes")
public void fractureSingleClone(StorageSystem storageSystem, URI source, URI cloneVolume, TaskCompleter taskCompleter) {
_log.info("START fractureSingleClone operation");
Volume clone = null;
try {
callEMCRefreshIfRequired(_dbClient, _helper, storageSystem, Arrays.asList(cloneVolume));
clone = _dbClient.queryObject(Volume.class, cloneVolume);
URI sourceUri = clone.getAssociatedSourceVolume();
if (!NullColumnValueGetter.isNullURI(sourceUri)) {
BlockObject sourceObj = BlockObject.fetch(_dbClient, sourceUri);
if (sourceObj != null) {
StorageSystem sourceSystem = _dbClient.queryObject(StorageSystem.class, sourceObj.getStorageController());
CIMObjectPath syncObject = _cimPath.getStorageSynchronized(sourceSystem, sourceObj, storageSystem, clone);
CIMInstance instance = _helper.checkExists(storageSystem, syncObject, false, false);
if (instance != null) {
fractureReplica(storageSystem, syncObject);
} else {
String errorMsg = "The clone is already detached. fracture will not be performed.";
_log.info(errorMsg);
ServiceError error = DeviceControllerErrors.smis.methodFailed("fractureSingleClone", errorMsg);
taskCompleter.error(_dbClient, error);
}
} else {
String errorMsg = "The clone's source volume cannot be found in the database. Fractrure will not be performed.";
_log.info(errorMsg);
ServiceError error = DeviceControllerErrors.smis.methodFailed("fractureSingleClone", errorMsg);
taskCompleter.error(_dbClient, error);
}
} else {
String errorMsg = "The clone does not have a source volume. Fracture will not be performed.";
_log.info(errorMsg);
ServiceError error = DeviceControllerErrors.smis.methodFailed("fractureSingleClone", errorMsg);
taskCompleter.error(_dbClient, error);
}
clone.setReplicaState(ReplicationState.SYNCHRONIZED.name());
_dbClient.persistObject(clone);
taskCompleter.ready(_dbClient);
} catch (Exception e) {
String errorMsg = String.format(FRACTURE_ERROR_MSG_FORMAT, cloneVolume, clone.getAssociatedSourceVolume());
_log.error(errorMsg, e);
taskCompleter.error(_dbClient, DeviceControllerException.exceptions.fractureFullCopyFailed(e));
}
}
use of javax.cim.CIMObjectPath in project coprhd-controller by CoprHD.
the class AbstractCloneOperations method resyncSingleClone.
@Override
@SuppressWarnings("rawtypes")
public void resyncSingleClone(StorageSystem storageSystem, URI cloneVolume, TaskCompleter taskCompleter) {
_log.info("START resyncSingleClone operation");
Volume clone = null;
try {
callEMCRefreshIfRequired(_dbClient, _helper, storageSystem, Arrays.asList(cloneVolume));
clone = _dbClient.queryObject(Volume.class, cloneVolume);
URI sourceUri = clone.getAssociatedSourceVolume();
Volume sourceObj = _dbClient.queryObject(Volume.class, sourceUri);
StorageSystem sourceSystem = _dbClient.queryObject(StorageSystem.class, sourceObj.getStorageController());
CIMObjectPath syncObject = _cimPath.getStorageSynchronized(sourceSystem, sourceObj, storageSystem, clone);
CIMInstance instance = _helper.checkExists(storageSystem, syncObject, false, false);
if (instance != null) {
CIMArgument[] inArgs = _helper.getResyncReplicaInputArguments(syncObject);
CIMArgument[] outArgs = new CIMArgument[5];
_helper.callModifyReplica(storageSystem, inArgs, outArgs);
CIMObjectPath job = _cimPath.getCimObjectPathFromOutputArgs(outArgs, SmisConstants.JOB);
if (job != null) {
ControllerServiceImpl.enqueueJob(new QueueJob(new SmisCloneResyncJob(job, storageSystem.getId(), taskCompleter)));
}
} else {
String errorMsg = "The clone is already detached. resync will not be performed.";
_log.info(errorMsg);
ServiceError error = DeviceControllerErrors.smis.methodFailed("resyncSingleClone", errorMsg);
taskCompleter.error(_dbClient, error);
}
} catch (Exception e) {
String errorMsg = String.format(RESYNC_ERROR_MSG_FORMAT, cloneVolume);
_log.error(errorMsg, e);
taskCompleter.error(_dbClient, DeviceControllerException.exceptions.resynchronizeFullCopyFailed(e));
}
}
use of javax.cim.CIMObjectPath in project coprhd-controller by CoprHD.
the class AbstractCloneOperations method getReplicationSettingDataInstanceForThinProvisioningPolicy.
@SuppressWarnings("rawtypes")
private CIMInstance getReplicationSettingDataInstanceForThinProvisioningPolicy(final StorageSystem storageSystem, int desiredValue) {
CIMInstance modifiedInstance = null;
try {
CIMObjectPath replicationSettingCapabilities = _cimPath.getReplicationServiceCapabilitiesPath(storageSystem);
CIMArgument[] inArgs = _helper.getReplicationSettingDataInstance();
CIMArgument[] outArgs = new CIMArgument[5];
_helper.invokeMethod(storageSystem, replicationSettingCapabilities, GET_DEFAULT_REPLICATION_SETTING_DATA, inArgs, outArgs);
for (CIMArgument<?> outArg : outArgs) {
if (null == outArg) {
continue;
}
if (outArg.getName().equalsIgnoreCase(SmisConstants.DEFAULT_INSTANCE)) {
CIMInstance repInstance = (CIMInstance) outArg.getValue();
if (null != repInstance) {
CIMProperty<?> thinProvisioningPolicy = new CIMProperty<Object>(SmisConstants.THIN_PROVISIONING_POLICY, UINT16_T, new UnsignedInteger16(desiredValue));
CIMProperty<?> targetElementSupplier = new CIMProperty<Object>(TARGET_ELEMENT_SUPPLIER, UINT16_T, new UnsignedInteger16(CREATE_NEW_TARGET_VALUE));
CIMProperty<?>[] propArray = new CIMProperty<?>[] { thinProvisioningPolicy, targetElementSupplier };
modifiedInstance = repInstance.deriveInstance(propArray);
break;
}
}
}
} catch (Exception e) {
_log.error("Error retrieving Replication Setting Data Instance ", e);
}
return modifiedInstance;
}
Aggregations