Search in sources :

Example 96 with CIMInstance

use of javax.cim.CIMInstance in project coprhd-controller by CoprHD.

the class XIVSmisCommandHelper method getInitiatorsFromScsiProtocolController.

/**
 * Returns a map of normalized port name to port path for the masking.
 *
 * @param storage
 *            [in] - StorageSystem that the masking belongs to
 * @param controllerPath
 *            [in] - CIMObjectPath of IBMTSDS_SCSIProtocolController, holding a representation
 *            of an array masking container.
 * @return - a map of port name to port path for the container.
 */
public Map<String, CIMObjectPath> getInitiatorsFromScsiProtocolController(StorageSystem storage, CIMObjectPath controllerPath) {
    Map<String, CIMObjectPath> initiatorPortPaths = new HashMap<String, CIMObjectPath>();
    CloseableIterator<CIMInstance> iterator = null;
    try {
        WBEMClient client = getConnection(storage).getCimClient();
        iterator = client.associatorInstances(controllerPath, CP_SHWID_TO_SPC, CP_STORAGE_HARDWARE_ID, null, null, false, PS_STORAGE_ID);
        while (iterator.hasNext()) {
            CIMInstance cimInstance = iterator.next();
            String initiator = CIMPropertyFactory.getPropertyValue(cimInstance, CP_STORAGE_ID);
            initiatorPortPaths.put(Initiator.normalizePort(initiator), cimInstance.getObjectPath());
        }
    } catch (WBEMException we) {
        _log.error("Caught an error while attempting to get initiator list from " + "masking instance", we);
    } finally {
        if (iterator != null) {
            iterator.close();
        }
    }
    return initiatorPortPaths;
}
Also used : ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) CIMObjectPath(javax.cim.CIMObjectPath) WBEMClient(javax.wbem.client.WBEMClient) WBEMException(javax.wbem.WBEMException) CIMInstance(javax.cim.CIMInstance)

Example 97 with CIMInstance

use of javax.cim.CIMInstance in project coprhd-controller by CoprHD.

the class XIVSmisCommandHelper method getCGMembers.

/*
     * Returns null if CG doesn't exist, or members of the CG
     */
public Set<String> getCGMembers(StorageSystem storage, CIMObjectPath cgPath) throws Exception {
    Set<String> members = new HashSet<String>();
    CIMInstance cgPathInstance = checkExists(storage, cgPath, false, false);
    if (cgPathInstance == null) {
        return null;
    }
    CloseableIterator<CIMObjectPath> assocVolNamesIter = null;
    try {
        assocVolNamesIter = getAssociatorNames(storage, cgPath, null, IBMSmisConstants.CIM_STORAGE_VOLUME, null, null);
        while (assocVolNamesIter.hasNext()) {
            CIMObjectPath assocVolPath = assocVolNamesIter.next();
            String deviceId = assocVolPath.getKeyValue(IBMSmisConstants.CP_DEVICE_ID).toString();
            // may have a timing issue, sometimes vol is returned, but is gone from CG
            members.add(deviceId);
        }
    } finally {
        if (assocVolNamesIter != null) {
            assocVolNamesIter.close();
        }
    }
    return members;
}
Also used : CIMObjectPath(javax.cim.CIMObjectPath) CIMInstance(javax.cim.CIMInstance) HashSet(java.util.HashSet)

Example 98 with CIMInstance

use of javax.cim.CIMInstance in project coprhd-controller by CoprHD.

the class XIVSmisCommandHelper method checkExists.

/**
 * This method is a wrapper for the getInstance. If the object is not found,
 * it returns a null value instead of throwing an exception.
 *
 * @param storage
 *            [required] - StorageSystem object to which an SMI-S connection
 *            would be made
 * @param objectPath
 *            [required]
 * @param propagated
 *            [required]
 * @param includeClassOrigin
 *            [required]
 * @return CIMInstance object that represents the existing object
 * @throws Exception
 */
public CIMInstance checkExists(StorageSystem storage, Volume volume, boolean propagated, boolean includeClassOrigin) throws Exception {
    CIMInstance instance = null;
    CIMObjectPath objectPath = _cimPath.getBlockObjectPath(storage, volume);
    try {
        if (objectPath != null) {
            _log.debug(String.format("checkExists(storage=%s, objectPath=%s, propagated=%s, includeClassOrigin=%s)", storage.getSerialNumber(), objectPath.toString(), String.valueOf(propagated), String.valueOf(includeClassOrigin)));
            instance = getInstance(storage, objectPath, propagated, includeClassOrigin, null);
        }
    } catch (WBEMException e) {
        // it's okay, we want to return null for this method
        if (e.getID() != WBEMException.CIM_ERR_NOT_FOUND) {
            throw e;
        }
    } catch (Exception e) {
        _log.error("checkExists call encountered an exception", e);
        throw e;
    }
    return instance;
}
Also used : CIMObjectPath(javax.cim.CIMObjectPath) WBEMException(javax.wbem.WBEMException) CIMInstance(javax.cim.CIMInstance) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) WBEMException(javax.wbem.WBEMException) SmisException(com.emc.storageos.volumecontroller.impl.smis.SmisException)

Example 99 with CIMInstance

use of javax.cim.CIMInstance in project coprhd-controller by CoprHD.

the class XIVSmisStorageDevice method doRemoveFromConsistencyGroup.

@Override
public void doRemoveFromConsistencyGroup(final StorageSystem storage, final URI consistencyGroupId, final List<URI> blockObjects, final TaskCompleter taskCompleter) throws DeviceControllerException {
    BlockConsistencyGroup consistencyGroup = _dbClient.queryObject(BlockConsistencyGroup.class, consistencyGroupId);
    try {
        // check if the consistency group already exists
        String groupName = _helper.getConsistencyGroupName(consistencyGroup, storage);
        CIMObjectPath cgPath = _cimPath.getConsistencyGroupPath(storage, groupName);
        CIMInstance cgPathInstance = _helper.checkExists(storage, cgPath, false, false);
        if (cgPathInstance != null) {
            String[] blockObjectIds = _helper.getBlockObjectNativeIds(blockObjects);
            removeVolumesFromCG(storage, consistencyGroup, cgPath, blockObjectIds);
        }
        // remove any references to the consistency group
        List<BlockObject> objectsToSave = new ArrayList<BlockObject>();
        for (URI blockObjectURI : blockObjects) {
            BlockObject blockObject = BlockObject.fetch(_dbClient, blockObjectURI);
            if (blockObject != null) {
                if (blockObject.getConsistencyGroup() != null) {
                    blockObject.setConsistencyGroup(NullColumnValueGetter.getNullURI());
                }
            }
            objectsToSave.add(blockObject);
        }
        _dbClient.persistObject(objectsToSave);
        taskCompleter.ready(_dbClient);
    } catch (DeviceControllerException e) {
        taskCompleter.error(_dbClient, e);
    } catch (Exception e) {
        taskCompleter.error(_dbClient, DeviceControllerException.exceptions.failedToRemoveMembersToConsistencyGroup(consistencyGroup.getLabel(), consistencyGroup.getCgNameOnStorageSystem(storage.getId()), e.getMessage()));
    }
}
Also used : CIMObjectPath(javax.cim.CIMObjectPath) ArrayList(java.util.ArrayList) URI(java.net.URI) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) CIMInstance(javax.cim.CIMInstance) BlockObject(com.emc.storageos.db.client.model.BlockObject) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) WBEMException(javax.wbem.WBEMException) BlockConsistencyGroup(com.emc.storageos.db.client.model.BlockConsistencyGroup)

Example 100 with CIMInstance

use of javax.cim.CIMInstance in project coprhd-controller by CoprHD.

the class XIVSmisStorageDevice method doFindHostHLUs.

/**
 * {@inheritDoc}
 */
@Override
public Map<URI, List<Integer>> doFindHostHLUs(StorageSystem storage, Collection<URI> initiatorURIs) throws DeviceControllerException {
    Map<URI, List<Integer>> initiatorToHLUMap = new HashMap<URI, List<Integer>>();
    for (URI initiatorURI : initiatorURIs) {
        List<Integer> initiatorHLUs = new ArrayList<Integer>();
        initiatorToHLUMap.put(initiatorURI, initiatorHLUs);
        Initiator initiator = _dbClient.queryObject(Initiator.class, initiatorURI);
        final String normalizedPortName = Initiator.normalizePort(initiator.getInitiatorPort());
        CloseableIterator<CIMInstance> scsiPCInstances = null;
        CloseableIterator<CIMInstance> pcforseunitInstances = null;
        try {
            String query = String.format("Select * From %s Where ElementName=\"%s\"", IBMSmisConstants.CP_STORAGE_HARDWARE_ID, normalizedPortName);
            CIMObjectPath pcHwdIDPath = CimObjectPathCreator.createInstance(IBMSmisConstants.CP_STORAGE_HARDWARE_ID, Constants.IBM_NAMESPACE, null);
            List<CIMInstance> hwidInstances = _helper.executeQuery(storage, pcHwdIDPath, query, "WQL");
            if (null != hwidInstances && !hwidInstances.isEmpty()) {
                CIMObjectPath hwidObjectPath = hwidInstances.get(0).getObjectPath();
                scsiPCInstances = _helper.getAssociatorInstances(storage, hwidObjectPath, null, IBMSmisConstants.CP_SCSI_PROTOCOL_CONTROLLER, IBMSmisConstants.CP_COLLECTION, IBMSmisConstants.CP_MEMBER, SmisConstants.PS_ELEMENT_NAME);
                while (null != scsiPCInstances && scsiPCInstances.hasNext()) {
                    CIMInstance scsiPCInstance = scsiPCInstances.next();
                    CIMObjectPath scsiPCObjectPath = scsiPCInstance.getObjectPath();
                    pcforseunitInstances = _helper.getReferenceInstances(storage, scsiPCObjectPath, IBMSmisConstants.CP_PROTOCOLCONTROLLER_FOR_SEUNIT, null, new String[] { IBMSmisConstants.DEVICE_NUMBER });
                    while (null != pcforseunitInstances && pcforseunitInstances.hasNext()) {
                        CIMInstance instance = pcforseunitInstances.next();
                        final String deviceNumber = CIMPropertyFactory.getPropertyValue(instance, IBMSmisConstants.DEVICE_NUMBER);
                        if (null != deviceNumber && !deviceNumber.isEmpty()) {
                            initiatorHLUs.add(Integer.parseInt(deviceNumber));
                        }
                    }
                    _log.info("HLU list for Initiator Port {} : {}", normalizedPortName, initiatorHLUs);
                }
            }
        } catch (WBEMException e) {
            DeviceControllerException.exceptions.smis.hluRetrievalFailed("Error occured during retrieval of HLUs for a Host", e);
        } finally {
            if (scsiPCInstances != null) {
                scsiPCInstances.close();
            }
            if (pcforseunitInstances != null) {
                pcforseunitInstances.close();
            }
        }
    }
    return initiatorToHLUMap;
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) CIMObjectPath(javax.cim.CIMObjectPath) WBEMException(javax.wbem.WBEMException) URI(java.net.URI) CIMInstance(javax.cim.CIMInstance) Initiator(com.emc.storageos.db.client.model.Initiator) List(java.util.List) ArrayList(java.util.ArrayList)

Aggregations

CIMInstance (javax.cim.CIMInstance)370 CIMObjectPath (javax.cim.CIMObjectPath)254 WBEMException (javax.wbem.WBEMException)139 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)104 ArrayList (java.util.ArrayList)98 BaseCollectionException (com.emc.storageos.plugins.BaseCollectionException)79 URI (java.net.URI)79 CIMArgument (javax.cim.CIMArgument)71 WBEMClient (javax.wbem.client.WBEMClient)69 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)62 Volume (com.emc.storageos.db.client.model.Volume)62 HashSet (java.util.HashSet)60 IOException (java.io.IOException)53 HashMap (java.util.HashMap)52 Iterator (java.util.Iterator)50 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)48 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)48 CIMProperty (javax.cim.CIMProperty)37 StringSet (com.emc.storageos.db.client.model.StringSet)31 SmisException (com.emc.storageos.volumecontroller.impl.smis.SmisException)29