use of com.emc.storageos.volumecontroller.impl.smis.CIMConnectionFactory in project coprhd-controller by CoprHD.
the class SMICommunicationInterfaceTest method setup.
@Before
public void setup() {
// _context = new ClassPathXmlApplicationContext("/plugin-context.xml");
try {
_dbClient = Cassandraforplugin.returnDBClient();
cimConnectionFactory = new CIMConnectionFactory();
cimConnectionFactory.setDbClient(_dbClient);
cimConnectionFactory.setConnectionManager(connectionManager);
cleanDB();
URI tenantURI = URIUtil.createId(TenantOrg.class);
URI projURI = URIUtil.createId(Project.class);
TenantOrg tenantorg = new TenantOrg();
tenantorg.setId(URIUtil.createId(TenantOrg.class));
tenantorg.setLabel("some tenant");
tenantorg.setParentTenant(new NamedURI(URIUtil.createId(TenantOrg.class), tenantorg.getLabel()));
_LOGGER.info("TenantOrg :" + tenantorg.getId());
_dbClient.createObject(tenantorg);
Project proj = new Project();
proj.setId(URIUtil.createId(Project.class));
proj.setLabel("some name");
proj.setTenantOrg(new NamedURI(tenantorg.getId(), proj.getLabel()));
_LOGGER.info("Project :" + proj.getId());
_LOGGER.info("TenantOrg-Proj :" + proj.getTenantOrg());
_dbClient.createObject(proj);
Volume vol = new Volume();
// 02751
vol.setId(URIUtil.createId(Volume.class));
vol.setLabel("some volume");
vol.setNativeGuid("SYMMETRIX+000187910031+VOLUME+00000");
vol.setVirtualPool(URIUtil.createId(VirtualPool.class));
vol.setProject(new NamedURI(proj.getId(), vol.getLabel()));
_dbClient.createObject(vol);
// StorageProvider provider = new StorageProvider();
// provider.setId(URIUtil.createId(StorageProvider.class));
// provider.setIPAddress(providerIP);
// provider.setPassword(providerPassword);
// provider.setUserName(providerUser);
// provider.setPortNumber(providerPort);
// provider.setUseSSL(isProviderSslEnabled);
// provider.setInterfaceType(StorageProvider.InterfaceType.smis.name());
// _dbClient.createObject(provider);
} catch (Exception e) {
_LOGGER.error(e.getMessage(), e);
}
// to be used for Mock
// System.setProperty("wbeminterface",
// "com.emc.srm.base.discovery.plugins.smi.MockWBEMClient");
}
use of com.emc.storageos.volumecontroller.impl.smis.CIMConnectionFactory in project coprhd-controller by CoprHD.
the class ConnectionManagerUtils method allowReaping.
public void allowReaping(Object profile, Object client) throws BaseCollectionException {
AccessProfile accessProfile = (AccessProfile) profile;
DbClient dbClient = (DbClient) client;
try {
final CIMConnectionFactory connectionFactory = (CIMConnectionFactory) accessProfile.getCimConnectionFactory();
StorageSystem storageSystem = dbClient.queryObject(StorageSystem.class, accessProfile.getSystemId());
connectionFactory.unsetKeepAliveForConnection(storageSystem);
} catch (final IllegalStateException ex) {
log.error("Not able to get CIMOM Client instance for ip {} due to ", accessProfile.getIpAddress(), ex);
throw new SMIPluginException(SMIPluginException.ERRORCODE_NO_WBEMCLIENT, ex.fillInStackTrace(), ex.getMessage());
}
}
use of com.emc.storageos.volumecontroller.impl.smis.CIMConnectionFactory in project coprhd-controller by CoprHD.
the class SmisBlockDeleteCGMirrorJob method updateStatus.
@Override
public void updateStatus(JobContext jobContext) throws Exception {
DbClient dbClient = jobContext.getDbClient();
JobStatus jobStatus = getJobStatus();
try {
if (jobStatus == JobStatus.IN_PROGRESS) {
return;
}
BlockMirrorDeleteCompleter completer = (BlockMirrorDeleteCompleter) getTaskCompleter();
List<BlockMirror> mirrors = dbClient.queryObject(BlockMirror.class, completer.getIds());
// If terminal state update storage pool capacity
if (jobStatus == JobStatus.SUCCESS || jobStatus == JobStatus.FAILED || jobStatus == JobStatus.FATAL_ERROR) {
CIMConnectionFactory cimConnectionFactory = jobContext.getCimConnectionFactory();
WBEMClient client = getWBEMClient(dbClient, cimConnectionFactory);
Set<URI> poolURIs = new HashSet<URI>();
for (BlockMirror mirror : mirrors) {
poolURIs.add(mirror.getPool());
}
for (URI poolURI : poolURIs) {
// Update capacity of storage pools.
SmisUtils.updateStoragePoolCapacity(dbClient, client, poolURI);
}
}
if (jobStatus == JobStatus.SUCCESS) {
_log.info("Group mirror delete success");
dbClient.markForDeletion(mirrors);
} else if (jobStatus == JobStatus.FATAL_ERROR || jobStatus == JobStatus.FAILED) {
String msg = String.format("Failed to delete group mirrors");
_log.error(msg);
getTaskCompleter().error(dbClient, DeviceControllerErrors.smis.jobFailed(msg));
}
} catch (Exception e) {
setFatalErrorStatus("Encountered an internal error during block delete group mirror job status processing: " + e.getMessage());
_log.error("Caught an exception while trying to updateStatus for SmisBlockDeleteCGMirrorJob", e);
getTaskCompleter().error(dbClient, DeviceControllerErrors.smis.jobFailed(e.getMessage()));
} finally {
super.updateStatus(jobContext);
}
}
use of com.emc.storageos.volumecontroller.impl.smis.CIMConnectionFactory in project coprhd-controller by CoprHD.
the class SmisBlockDeleteListReplicaJob method updateStatus.
@Override
public void updateStatus(JobContext jobContext) throws Exception {
DbClient dbClient = jobContext.getDbClient();
JobStatus jobStatus = getJobStatus();
try {
if (jobStatus == JobStatus.IN_PROGRESS) {
return;
}
List<? extends BlockObject> replicas = BlockObject.fetch(dbClient, getTaskCompleter().getIds());
// If terminal state update storage pool capacity
if (jobStatus == JobStatus.SUCCESS || jobStatus == JobStatus.FAILED || jobStatus == JobStatus.FATAL_ERROR) {
CIMConnectionFactory cimConnectionFactory = jobContext.getCimConnectionFactory();
WBEMClient client = getWBEMClient(dbClient, cimConnectionFactory);
Set<URI> poolURIs = new HashSet<URI>();
for (BlockObject replica : replicas) {
if (replica instanceof Volume)
poolURIs.add(((Volume) replica).getPool());
}
for (URI poolURI : poolURIs) {
// Update capacity of storage pools.
SmisUtils.updateStoragePoolCapacity(dbClient, client, poolURI);
}
}
if (jobStatus == JobStatus.SUCCESS) {
_log.info("List replica delete success");
dbClient.markForDeletion(replicas);
} else if (jobStatus == JobStatus.FATAL_ERROR || jobStatus == JobStatus.FAILED) {
String msg = String.format("Failed to delete list replica");
_log.error(msg);
getTaskCompleter().error(dbClient, DeviceControllerErrors.smis.jobFailed(msg));
}
} catch (Exception e) {
setFatalErrorStatus("Encountered an internal error during block delete replica replica job status processing: " + e.getMessage());
_log.error("Caught an exception while trying to updateStatus for SmisBlockDeleteListReplicaJob", e);
getTaskCompleter().error(dbClient, DeviceControllerErrors.smis.jobFailed(e.getMessage()));
} finally {
super.updateStatus(jobContext);
}
}
use of com.emc.storageos.volumecontroller.impl.smis.CIMConnectionFactory in project coprhd-controller by CoprHD.
the class SmisBlockDeleteSnapshotJob method updateStatus.
public void updateStatus(JobContext jobContext) throws Exception {
DbClient dbClient = jobContext.getDbClient();
JobStatus jobStatus = getJobStatus();
try {
BlockSnapshotDeleteCompleter completer = (BlockSnapshotDeleteCompleter) getTaskCompleter();
BlockSnapshot snapshot = dbClient.queryObject(BlockSnapshot.class, completer.getId());
if (jobStatus == JobStatus.IN_PROGRESS) {
return;
}
// If terminal state update storage pool capacity
if (jobStatus == JobStatus.SUCCESS || jobStatus == JobStatus.FAILED || jobStatus == JobStatus.FATAL_ERROR) {
CIMConnectionFactory cimConnectionFactory = jobContext.getCimConnectionFactory();
WBEMClient client = getWBEMClient(dbClient, cimConnectionFactory);
NamedURI volumeURI = snapshot.getParent();
Volume volume = dbClient.queryObject(Volume.class, volumeURI);
URI poolURI = volume.getPool();
// Update capacity of storage pools.
SmisUtils.updateStoragePoolCapacity(dbClient, client, poolURI);
}
if (jobStatus == JobStatus.SUCCESS) {
_log.info("Deleting snapshot job was successful.");
snapshot.setInactive(true);
dbClient.persistObject(snapshot);
} else if (jobStatus == JobStatus.FAILED || jobStatus == JobStatus.FATAL_ERROR) {
_log.info("Failed to delete snapshot: {}", getTaskCompleter().getId());
}
} catch (Exception e) {
setFatalErrorStatus(e.getMessage());
_log.error("Caught an exception while trying to updateStatus for SmisBlockDeleteSnapshotJob", e);
Operation updateOp = new Operation();
updateOp.setStatus("Encountered an internal error during block delete snapshot job status processing: " + e.getMessage());
dbClient.updateTaskOpStatus(BlockSnapshot.class, getTaskCompleter().getId(), getTaskCompleter().getOpId(), updateOp);
} finally {
super.updateStatus(jobContext);
}
}
Aggregations