Search in sources :

Example 16 with CIMConnectionFactory

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");
}
Also used : CIMConnectionFactory(com.emc.storageos.volumecontroller.impl.smis.CIMConnectionFactory) URI(java.net.URI) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException) Before(org.junit.Before)

Example 17 with CIMConnectionFactory

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());
    }
}
Also used : DbClient(com.emc.storageos.db.client.DbClient) CIMConnectionFactory(com.emc.storageos.volumecontroller.impl.smis.CIMConnectionFactory) SMIPluginException(com.emc.storageos.plugins.metering.smis.SMIPluginException) AccessProfile(com.emc.storageos.plugins.AccessProfile) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 18 with CIMConnectionFactory

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);
    }
}
Also used : BlockMirrorDeleteCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.BlockMirrorDeleteCompleter) DbClient(com.emc.storageos.db.client.DbClient) BlockMirror(com.emc.storageos.db.client.model.BlockMirror) CIMConnectionFactory(com.emc.storageos.volumecontroller.impl.smis.CIMConnectionFactory) WBEMClient(javax.wbem.client.WBEMClient) URI(java.net.URI) HashSet(java.util.HashSet)

Example 19 with CIMConnectionFactory

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);
    }
}
Also used : DbClient(com.emc.storageos.db.client.DbClient) CIMConnectionFactory(com.emc.storageos.volumecontroller.impl.smis.CIMConnectionFactory) Volume(com.emc.storageos.db.client.model.Volume) WBEMClient(javax.wbem.client.WBEMClient) URI(java.net.URI) BlockObject(com.emc.storageos.db.client.model.BlockObject) HashSet(java.util.HashSet)

Example 20 with CIMConnectionFactory

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);
    }
}
Also used : DbClient(com.emc.storageos.db.client.DbClient) CIMConnectionFactory(com.emc.storageos.volumecontroller.impl.smis.CIMConnectionFactory) NamedURI(com.emc.storageos.db.client.model.NamedURI) Volume(com.emc.storageos.db.client.model.Volume) BlockSnapshotDeleteCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.BlockSnapshotDeleteCompleter) BlockSnapshot(com.emc.storageos.db.client.model.BlockSnapshot) Operation(com.emc.storageos.db.client.model.Operation) WBEMClient(javax.wbem.client.WBEMClient) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI)

Aggregations

CIMConnectionFactory (com.emc.storageos.volumecontroller.impl.smis.CIMConnectionFactory)32 DbClient (com.emc.storageos.db.client.DbClient)28 WBEMClient (javax.wbem.client.WBEMClient)27 CIMObjectPath (javax.cim.CIMObjectPath)18 Volume (com.emc.storageos.db.client.model.Volume)14 CIMInstance (javax.cim.CIMInstance)14 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)13 URI (java.net.URI)11 BlockMirror (com.emc.storageos.db.client.model.BlockMirror)5 BlockObject (com.emc.storageos.db.client.model.BlockObject)5 BlockSnapshot (com.emc.storageos.db.client.model.BlockSnapshot)5 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)5 CIMProperty (javax.cim.CIMProperty)5 StoragePool (com.emc.storageos.db.client.model.StoragePool)4 StringMap (com.emc.storageos.db.client.model.StringMap)4 ArrayList (java.util.ArrayList)4 CimConnection (com.emc.storageos.cimadapter.connections.cim.CimConnection)3 BlockSnapshotSession (com.emc.storageos.db.client.model.BlockSnapshotSession)3 SMIPluginException (com.emc.storageos.plugins.metering.smis.SMIPluginException)3 TaskCompleter (com.emc.storageos.volumecontroller.TaskCompleter)3